Changeset View
Changeset View
Standalone View
Standalone View
src/applications/drydock/worker/DrydockLeaseUpdateWorker.php
Show First 20 Lines • Show All 338 Lines • ▼ Show 20 Lines | if (!$allocated) { | ||||
$lease->getPHID()), | $lease->getPHID()), | ||||
$exceptions); | $exceptions); | ||||
} | } | ||||
} | } | ||||
} | } | ||||
/** | /** | ||||
* Get all the @{class:DrydockBlueprintImplementation}s which can possibly | |||||
* build a resource to satisfy a lease. | |||||
* | |||||
* This method returns blueprints which might, at some time, be able to | |||||
* build a resource which can satisfy the lease. They may not be able to | |||||
* build that resource right now. | |||||
* | |||||
* @param DrydockLease Requested lease. | |||||
* @return list<DrydockBlueprintImplementation> List of qualifying blueprint | |||||
* implementations. | |||||
* @task allocator | |||||
*/ | |||||
private function loadBlueprintImplementationsForAllocatingLease( | |||||
DrydockLease $lease) { | |||||
$impls = DrydockBlueprintImplementation::getAllBlueprintImplementations(); | |||||
$keep = array(); | |||||
foreach ($impls as $key => $impl) { | |||||
// Don't use disabled blueprint types. | |||||
if (!$impl->isEnabled()) { | |||||
continue; | |||||
} | |||||
// Don't use blueprint types which can't allocate the correct kind of | |||||
// resource. | |||||
if ($impl->getType() != $lease->getResourceType()) { | |||||
continue; | |||||
} | |||||
if (!$impl->canAnyBlueprintEverAllocateResourceForLease($lease)) { | |||||
continue; | |||||
} | |||||
$keep[$key] = $impl; | |||||
} | |||||
return $keep; | |||||
} | |||||
/** | |||||
* Get all the concrete @{class:DrydockBlueprint}s which can possibly | * Get all the concrete @{class:DrydockBlueprint}s which can possibly | ||||
* build a resource to satisfy a lease. | * build a resource to satisfy a lease. | ||||
* | * | ||||
* @param DrydockLease Requested lease. | * @param DrydockLease Requested lease. | ||||
* @return list<DrydockBlueprint> List of qualifying blueprints. | * @return list<DrydockBlueprint> List of qualifying blueprints. | ||||
* @task allocator | * @task allocator | ||||
*/ | */ | ||||
private function loadBlueprintsForAllocatingLease( | private function loadBlueprintsForAllocatingLease( | ||||
DrydockLease $lease) { | DrydockLease $lease) { | ||||
$viewer = $this->getViewer(); | $viewer = $this->getViewer(); | ||||
$impls = $this->loadBlueprintImplementationsForAllocatingLease($lease); | $impls = DrydockBlueprintImplementation::getAllForAllocatingLease($lease); | ||||
if (!$impls) { | if (!$impls) { | ||||
return array(); | return array(); | ||||
} | } | ||||
$blueprint_phids = $lease->getAllowedBlueprintPHIDs(); | $blueprint_phids = $lease->getAllowedBlueprintPHIDs(); | ||||
if (!$blueprint_phids) { | if (!$blueprint_phids) { | ||||
$lease->logEvent(DrydockLeaseNoBlueprintsLogType::LOGCONST); | $lease->logEvent(DrydockLeaseNoBlueprintsLogType::LOGCONST); | ||||
return array(); | return array(); | ||||
▲ Show 20 Lines • Show All 618 Lines • Show Last 20 Lines |