Page Menu
Home
c4science
Search
Configure Global Search
Log In
Files
F91482883
DrydockManagementReclaimWorkflow.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
Mon, Nov 11, 13:49
Size
1 KB
Mime Type
text/x-php
Expires
Wed, Nov 13, 13:49 (2 d)
Engine
blob
Format
Raw Data
Handle
22269363
Attached To
rPH Phabricator
DrydockManagementReclaimWorkflow.php
View Options
<?php
final
class
DrydockManagementReclaimWorkflow
extends
DrydockManagementWorkflow
{
protected
function
didConstruct
()
{
$this
->
setName
(
'reclaim'
)
->
setSynopsis
(
pht
(
'Reclaim unused resources.'
))
->
setArguments
(
array
());
}
public
function
execute
(
PhutilArgumentParser
$args
)
{
$viewer
=
$this
->
getViewer
();
$drydock_phid
=
id
(
new
PhabricatorDrydockApplication
())->
getPHID
();
PhabricatorWorker
::
setRunAllTasksInProcess
(
true
);
$resources
=
id
(
new
DrydockResourceQuery
())
->
setViewer
(
$viewer
)
->
withStatuses
(
array
(
DrydockResourceStatus
::
STATUS_ACTIVE
,
))
->
execute
();
foreach
(
$resources
as
$resource
)
{
$command
=
DrydockCommand
::
initializeNewCommand
(
$viewer
)
->
setTargetPHID
(
$resource
->
getPHID
())
->
setAuthorPHID
(
$drydock_phid
)
->
setCommand
(
DrydockCommand
::
COMMAND_RECLAIM
)
->
save
();
$resource
->
scheduleUpdate
();
$resource
=
$resource
->
reload
();
$name
=
pht
(
'Resource %d: %s'
,
$resource
->
getID
(),
$resource
->
getResourceName
());
switch
(
$resource
->
getStatus
())
{
case
DrydockResourceStatus
::
STATUS_RELEASED
:
case
DrydockResourceStatus
::
STATUS_DESTROYED
:
echo
tsprintf
(
"%s
\n
"
,
pht
(
'Resource "%s" was reclaimed.'
,
$name
));
break
;
default
:
echo
tsprintf
(
"%s
\n
"
,
pht
(
'Resource "%s" could not be reclaimed.'
,
$name
));
break
;
}
}
}
}
Event Timeline
Log In to Comment