Page Menu
Home
c4science
Search
Configure Global Search
Log In
Files
F99309142
DrydockManagementLeaseWorkflow.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, Jan 23, 08:15
Size
1 KB
Mime Type
text/x-php
Expires
Sat, Jan 25, 08:15 (2 d)
Engine
blob
Format
Raw Data
Handle
23773911
Attached To
rPH Phabricator
DrydockManagementLeaseWorkflow.php
View Options
<?php
final
class
DrydockManagementLeaseWorkflow
extends
DrydockManagementWorkflow
{
public
function
didConstruct
()
{
$this
->
setName
(
'lease'
)
->
setSynopsis
(
'Lease a resource.'
)
->
setArguments
(
array
(
array
(
'name'
=>
'type'
,
'param'
=>
'resource_type'
,
'help'
=>
'Resource type.'
,
),
array
(
'name'
=>
'attributes'
,
'param'
=>
'name=value,...'
,
'help'
=>
'Resource specficiation.'
,
),
));
}
public
function
execute
(
PhutilArgumentParser
$args
)
{
$console
=
PhutilConsole
::
getConsole
();
$resource_type
=
$args
->
getArg
(
'type'
);
if
(!
$resource_type
)
{
throw
new
PhutilArgumentUsageException
(
"Specify a resource type with `--type`."
);
}
$attributes
=
$args
->
getArg
(
'attributes'
);
if
(
$attributes
)
{
$options
=
new
PhutilSimpleOptions
();
$options
->
setCaseSensitive
(
true
);
$attributes
=
$options
->
parse
(
$attributes
);
}
PhabricatorWorker
::
setRunAllTasksInProcess
(
true
);
$lease
=
id
(
new
DrydockLease
())
->
setResourceType
(
$resource_type
);
if
(
$attributes
)
{
$lease
->
setAttributes
(
$attributes
);
}
$lease
->
queueForActivation
()
->
waitUntilActive
();
$console
->
writeOut
(
"Acquired Lease %s
\n
"
,
$lease
->
getID
());
return
0
;
}
}
Event Timeline
Log In to Comment