Page Menu
Home
c4science
Search
Configure Global Search
Log In
Files
F102067956
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
Sun, Feb 16, 19:01
Size
1 KB
Mime Type
text/x-php
Expires
Tue, Feb 18, 19:01 (1 d, 23 h)
Engine
blob
Format
Raw Data
Handle
24274514
Attached To
rPH Phabricator
DrydockManagementLeaseWorkflow.php
View Options
<?php
final
class
DrydockManagementLeaseWorkflow
extends
DrydockManagementWorkflow
{
protected
function
didConstruct
()
{
$this
->
setName
(
'lease'
)
->
setSynopsis
(
pht
(
'Lease a resource.'
))
->
setArguments
(
array
(
array
(
'name'
=>
'type'
,
'param'
=>
'resource_type'
,
'help'
=>
pht
(
'Resource type.'
),
),
array
(
'name'
=>
'attributes'
,
'param'
=>
'name=value,...'
,
'help'
=>
pht
(
'Resource specficiation.'
),
),
));
}
public
function
execute
(
PhutilArgumentParser
$args
)
{
$console
=
PhutilConsole
::
getConsole
();
$resource_type
=
$args
->
getArg
(
'type'
);
if
(!
$resource_type
)
{
throw
new
PhutilArgumentUsageException
(
pht
(
'Specify a resource type with `%s`.'
,
'--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
(
"%s
\n
"
,
pht
(
'Acquired Lease %s'
,
$lease
->
getID
()));
return
0
;
}
}
Event Timeline
Log In to Comment