From df7fb098451cba78a5223c0c6bff9bb1dbf9c882 Mon Sep 17 00:00:00 2001 From: James Rhodes Date: Wed, 20 Aug 2014 08:29:32 +1000 Subject: [PATCH] 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 --- src/__phutil_library_map__.php | 2 - ...rydockLocalHostBlueprintImplementation.php | 97 ------------------- 2 files changed, 99 deletions(-) delete mode 100644 src/applications/drydock/blueprint/DrydockLocalHostBlueprintImplementation.php diff --git a/src/__phutil_library_map__.php b/src/__phutil_library_map__.php index 19d157b55f..bcd89290ae 100644 --- a/src/__phutil_library_map__.php +++ b/src/__phutil_library_map__.php @@ -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', diff --git a/src/applications/drydock/blueprint/DrydockLocalHostBlueprintImplementation.php b/src/applications/drydock/blueprint/DrydockLocalHostBlueprintImplementation.php deleted file mode 100644 index 43ee8bab62..0000000000 --- a/src/applications/drydock/blueprint/DrydockLocalHostBlueprintImplementation.php +++ /dev/null @@ -1,97 +0,0 @@ -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}'."); - } - -}