Page Menu
Home
Phorge
Search
Configure Global Search
Log In
Files
F972703
DrydockManagementCommandWorkflow.php
No One
Temporary
Actions
Download File
Edit File
Delete File
View Transforms
Subscribe
Flag For Later
Award Token
Size
1 KB
Referenced Files
None
Subscribers
None
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 "--lease" to specify a 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
));
fwrite
(
STDOUT
,
$stdout
);
fwrite
(
STDERR
,
$stderr
);
return
0
;
}
}
File Metadata
Details
Attached
Mime Type
text/x-php
Expires
Wed, Jun 18, 6:22 AM (2 d)
Storage Engine
blob
Storage Format
Raw Data
Storage Handle
224265
Default Alt Text
DrydockManagementCommandWorkflow.php (1 KB)
Attached To
Mode
rP Phorge
Attached
Detach File
Event Timeline
Log In to Comment