Page Menu
Home
c4science
Search
Configure Global Search
Log In
Files
F91482948
DrydockManagementCommandWorkflow.php
No One
Temporary
Actions
Download File
Edit File
Delete File
View Transforms
Subscribe
Mute Notifications
Award Token
Subscribers
None
File Metadata
Details
File Info
Storage
Attached
Created
Mon, Nov 11, 13:50
Size
1 KB
Mime Type
text/x-php
Expires
Wed, Nov 13, 13:50 (2 d)
Engine
blob
Format
Raw Data
Handle
22269377
Attached To
rPH Phabricator
DrydockManagementCommandWorkflow.php
View Options
<?php
final
class
DrydockManagementCommandWorkflow
extends
DrydockManagementWorkflow
{
protected
function
didConstruct
()
{
$this
->
setName
(
'command'
)
->
setSynopsis
(
pht
(
'Run a command on a leased resource.'
))
->
setArguments
(
array
(
array
(
'name'
=>
'lease'
,
'param'
=>
'id'
,
'help'
=>
pht
(
'Lease ID.'
),
),
array
(
'name'
=>
'argv'
,
'wildcard'
=>
true
,
'help'
=>
pht
(
'Command to execute.'
),
),
));
}
public
function
execute
(
PhutilArgumentParser
$args
)
{
$lease_id
=
$args
->
getArg
(
'lease'
);
if
(!
$lease_id
)
{
throw
new
PhutilArgumentUsageException
(
pht
(
'Use %s to specify a lease.'
,
'--lease'
));
}
$argv
=
$args
->
getArg
(
'argv'
);
if
(!
$argv
)
{
throw
new
PhutilArgumentUsageException
(
pht
(
'Specify a command to run.'
));
}
$lease
=
id
(
new
DrydockLeaseQuery
())
->
setViewer
(
$this
->
getViewer
())
->
withIDs
(
array
(
$lease_id
))
->
executeOne
();
if
(!
$lease
)
{
throw
new
Exception
(
pht
(
'Unable to load lease with ID "%s"!'
,
$lease_id
));
}
// TODO: Check lease state, etc.
$interface
=
$lease
->
getInterface
(
DrydockCommandInterface
::
INTERFACE_TYPE
);
list
(
$stdout
,
$stderr
)
=
call_user_func_array
(
array
(
$interface
,
'execx'
),
array
(
'%Ls'
,
$argv
));
fprintf
(
STDOUT
,
$stdout
);
fprintf
(
STDERR
,
$stderr
);
return
0
;
}
}
Event Timeline
Log In to Comment