Differential D14144 Diff 34181 src/applications/drydock/blueprint/DrydockWorkingCopyBlueprintImplementation.php
Changeset View
Changeset View
Standalone View
Standalone View
src/applications/drydock/blueprint/DrydockWorkingCopyBlueprintImplementation.php
Show First 20 Lines • Show All 120 Lines • ▼ Show 20 Lines | $interface->execx( | ||||
$path); | $path); | ||||
$resource | $resource | ||||
->setAttribute('workingcopy.root', $root) | ->setAttribute('workingcopy.root', $root) | ||||
->setAttribute('workingcopy.path', $path) | ->setAttribute('workingcopy.path', $path) | ||||
->activateResource(); | ->activateResource(); | ||||
} | } | ||||
public function destroyResource( | |||||
DrydockBlueprint $blueprint, | |||||
DrydockResource $resource) { | |||||
$lease = $this->loadHostLease($resource); | |||||
// Destroy the lease on the host. | |||||
$lease->releaseOnDestruction(); | |||||
// Destroy the working copy on disk. | |||||
$command_type = DrydockCommandInterface::INTERFACE_TYPE; | |||||
$interface = $lease->getInterface($command_type); | |||||
$root_key = 'workingcopy.root'; | |||||
$root = $resource->getAttribute($root_key); | |||||
if (strlen($root)) { | |||||
$interface->execx('rm -rf -- %s', $root); | |||||
} | |||||
} | |||||
public function activateLease( | public function activateLease( | ||||
DrydockBlueprint $blueprint, | DrydockBlueprint $blueprint, | ||||
DrydockResource $resource, | DrydockResource $resource, | ||||
DrydockLease $lease) { | DrydockLease $lease) { | ||||
$command_type = DrydockCommandInterface::INTERFACE_TYPE; | $command_type = DrydockCommandInterface::INTERFACE_TYPE; | ||||
$interface = $lease->getInterface($command_type); | $interface = $lease->getInterface($command_type); | ||||
Show All 20 Lines | public function activateLease( | ||||
$result = call_user_func_array( | $result = call_user_func_array( | ||||
array($interface, 'execx'), | array($interface, 'execx'), | ||||
$argv); | $argv); | ||||
$lease->activateOnResource($resource); | $lease->activateOnResource($resource); | ||||
} | } | ||||
public function didReleaseLease( | |||||
DrydockBlueprint $blueprint, | |||||
DrydockResource $resource, | |||||
DrydockLease $lease) { | |||||
// We leave working copies around even if there are no leases on them, | |||||
// since the cost to maintain them is nearly zero but rebuilding them is | |||||
// moderately expensive and it's likely that they'll be reused. | |||||
return; | |||||
} | |||||
public function destroyLease( | |||||
DrydockBlueprint $blueprint, | |||||
DrydockResource $resource, | |||||
DrydockLease $lease) { | |||||
// When we activate a lease we just reset the working copy state and do | |||||
// not create any new state, so we don't need to do anything special when | |||||
// destroying a lease. | |||||
return; | |||||
} | |||||
public function getType() { | public function getType() { | ||||
return 'working-copy'; | return 'working-copy'; | ||||
} | } | ||||
public function getInterface( | public function getInterface( | ||||
DrydockBlueprint $blueprint, | DrydockBlueprint $blueprint, | ||||
DrydockResource $resource, | DrydockResource $resource, | ||||
DrydockLease $lease, | DrydockLease $lease, | ||||
▲ Show 20 Lines • Show All 57 Lines • Show Last 20 Lines |