Page Menu
Home
Phorge
Search
Configure Global Search
Log In
Files
F2891151
DrydockManagementLeaseWorkflow.php
No One
Temporary
Actions
Download File
Edit File
Delete File
View Transforms
Subscribe
Award Token
Flag For Later
Advanced/Developer...
View Handle
View Hovercard
Size
2 KB
Referenced Files
None
Subscribers
None
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
)
;
}
$lease
=
new
DrydockLease
(
)
;
$lease
->
setResourceType
(
$resource_type
)
;
if
(
$attributes
)
{
$lease
->
setAttributes
(
$attributes
)
;
}
$lease
->
queueForActivation
(
)
;
$root
=
dirname
(
phutil_get_library_root
(
'phabricator'
)
)
;
$wait
=
new
ExecFuture
(
'php -f %s wait-for-lease --id %s'
,
$root
.
'/scripts/drydock/drydock_control.php'
,
$lease
->
getID
(
)
)
;
$cursor
=
0
;
foreach
(
Futures
(
array
(
$wait
)
)
->
setUpdateInterval
(
1
)
as
$key
=>
$future
)
{
if
(
$future
)
{
$future
->
resolvex
(
)
;
break
;
}
$logs
=
id
(
new
DrydockLogQuery
(
)
)
->
setViewer
(
PhabricatorUser
::
getOmnipotentUser
(
)
)
->
withLeaseIDs
(
array
(
$lease
->
getID
(
)
)
)
->
execute
(
)
;
if
(
$logs
)
{
foreach
(
$logs
as
$log
)
{
$console
->
writeErr
(
"%s\n"
,
$log
->
getMessage
(
)
)
;
}
$cursor
=
max
(
mpull
(
$logs
,
'getID'
)
)
;
}
}
$console
->
writeOut
(
"Acquired Lease %s\n"
,
$lease
->
getID
(
)
)
;
return
0
;
}
}
File Metadata
Details
Attached
Mime Type
text/x-php
Expires
Sun, Jan 19, 14:43 (3 w, 2 d ago)
Storage Engine
blob
Storage Format
Raw Data
Storage Handle
1125618
Default Alt Text
DrydockManagementLeaseWorkflow.php (2 KB)
Attached To
Mode
rP Phorge
Attached
Detach File
Event Timeline
Log In to Comment