mirror of
https://we.phorge.it/source/phorge.git
synced 2024-12-02 19:52:44 +01:00
daadf95537
Summary: Ref T6822. Test Plan: `grep`. This method is only called from within `PhutilArgumentWorkflow::__construct`. Reviewers: epriestley, #blessed_reviewers Reviewed By: epriestley, #blessed_reviewers Subscribers: Korvin, epriestley Maniphest Tasks: T6822 Differential Revision: https://secure.phabricator.com/D11415
52 lines
1.3 KiB
PHP
52 lines
1.3 KiB
PHP
<?php
|
|
|
|
final class DrydockManagementReleaseWorkflow
|
|
extends DrydockManagementWorkflow {
|
|
|
|
protected function didConstruct() {
|
|
$this
|
|
->setName('release')
|
|
->setSynopsis('Release a lease.')
|
|
->setArguments(
|
|
array(
|
|
array(
|
|
'name' => 'ids',
|
|
'wildcard' => true,
|
|
),
|
|
));
|
|
}
|
|
|
|
public function execute(PhutilArgumentParser $args) {
|
|
$console = PhutilConsole::getConsole();
|
|
|
|
$ids = $args->getArg('ids');
|
|
if (!$ids) {
|
|
throw new PhutilArgumentUsageException(
|
|
'Specify one or more lease IDs to release.');
|
|
}
|
|
|
|
$viewer = $this->getViewer();
|
|
|
|
$leases = id(new DrydockLeaseQuery())
|
|
->setViewer($viewer)
|
|
->withIDs($ids)
|
|
->execute();
|
|
|
|
foreach ($ids as $id) {
|
|
$lease = idx($leases, $id);
|
|
if (!$lease) {
|
|
$console->writeErr("Lease %d does not exist!\n", $id);
|
|
} else if ($lease->getStatus() != DrydockLeaseStatus::STATUS_ACTIVE) {
|
|
$console->writeErr("Lease %d is not 'active'!\n", $id);
|
|
} else {
|
|
$resource = $lease->getResource();
|
|
$blueprint = $resource->getBlueprint();
|
|
$blueprint->releaseLease($resource, $lease);
|
|
|
|
$console->writeErr("Released lease %d.\n", $id);
|
|
}
|
|
}
|
|
|
|
}
|
|
|
|
}
|