1
0
Fork 0
mirror of https://we.phorge.it/source/phorge.git synced 2024-12-19 12:00:55 +01:00

Remove localhost Drydock allocator

Summary: This has never been enabled by default, and isn't safe.  Remove it since people can use preallocated or EC2 hosts.

Test Plan: Removed it; didn't see it appear on the "Create Blueprint" page.

Reviewers: epriestley, #blessed_reviewers

Reviewed By: epriestley, #blessed_reviewers

Subscribers: epriestley, Korvin

Differential Revision: https://secure.phabricator.com/D10287
This commit is contained in:
James Rhodes 2014-08-20 08:29:32 +10:00
parent 0057cf17e9
commit df7fb09845
2 changed files with 0 additions and 99 deletions

View file

@ -605,7 +605,6 @@ phutil_register_library_map(array(
'DrydockLeaseStatus' => 'applications/drydock/constants/DrydockLeaseStatus.php',
'DrydockLeaseViewController' => 'applications/drydock/controller/DrydockLeaseViewController.php',
'DrydockLocalCommandInterface' => 'applications/drydock/interface/command/DrydockLocalCommandInterface.php',
'DrydockLocalHostBlueprintImplementation' => 'applications/drydock/blueprint/DrydockLocalHostBlueprintImplementation.php',
'DrydockLog' => 'applications/drydock/storage/DrydockLog.php',
'DrydockLogController' => 'applications/drydock/controller/DrydockLogController.php',
'DrydockLogListController' => 'applications/drydock/controller/DrydockLogListController.php',
@ -3357,7 +3356,6 @@ phutil_register_library_map(array(
'DrydockLeaseStatus' => 'DrydockConstants',
'DrydockLeaseViewController' => 'DrydockLeaseController',
'DrydockLocalCommandInterface' => 'DrydockCommandInterface',
'DrydockLocalHostBlueprintImplementation' => 'DrydockBlueprintImplementation',
'DrydockLog' => array(
'DrydockDAO',
'PhabricatorPolicyInterface',

View file

@ -1,97 +0,0 @@
<?php
final class DrydockLocalHostBlueprintImplementation
extends DrydockBlueprintImplementation {
public function isEnabled() {
return false;
}
public function getBlueprintName() {
return pht('Local Host');
}
public function getDescription() {
return pht(
'Allows Drydock to run on the local host.');
}
public function canAllocateMoreResources(array $pool) {
assert_instances_of($pool, 'DrydockResource');
// The localhost can be allocated only once.
foreach ($pool as $resource) {
if ($resource->getBlueprintClass() == $this->getBlueprintClass()) {
return false;
}
}
return true;
}
protected function executeAllocateResource(DrydockLease $lease) {
// TODO: Don't hard-code this.
$path = '/var/drydock/';
if (!Filesystem::pathExists($path)) {
throw new Exception(
"Path '{$path}' does not exist!");
}
Filesystem::assertIsDirectory($path);
Filesystem::assertWritable($path);
$resource = $this->newResourceTemplate('Host (localhost)');
$resource->setStatus(DrydockResourceStatus::STATUS_OPEN);
$resource->setAttribute('path', $path);
$resource->setAttribute('remote', 'false');
$resource->setAttribute('preallocated', 'false');
$resource->save();
return $resource;
}
protected function canAllocateLease(
DrydockResource $resource,
DrydockLease $lease) {
return false;
}
protected function shouldAllocateLease(
DrydockResource $resource,
DrydockLease $lease,
array $other_leases) {
return true;
}
protected function executeAcquireLease(
DrydockResource $resource,
DrydockLease $lease) {
$lease_id = $lease->getID();
$full_path = $resource->getAttribute('path').$lease_id.'/';
$cmd = $lease->getInterface('command');
$cmd->execx('mkdir %s', $full_path);
$lease->setAttribute('path', $full_path);
}
public function getType() {
return 'host';
}
public function getInterface(
DrydockResource $resource,
DrydockLease $lease,
$type) {
switch ($type) {
case 'command':
return new DrydockLocalCommandInterface();
}
throw new Exception("No interface of type '{$type}'.");
}
}