Page Menu
Home
c4science
Search
Configure Global Search
Log In
Files
F110082133
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
Thu, Apr 24, 15:13
Size
1 KB
Mime Type
text/x-php
Expires
Sat, Apr 26, 15:13 (2 d)
Engine
blob
Format
Raw Data
Handle
25724439
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