mirror of
https://we.phorge.it/source/phorge.git
synced 2025-01-03 19:31:02 +01:00
Remove DrydockPreallocatedHostBlueprintImplementation
Summary: Ref T9253. This comes from a time before Almanac. Now that we have Almanac, it makes much more sense to put this logic there than to try to put it in Drydock itself. Remove the preallocated host blueprint, a relic of a bygone time. Test Plan: Grepped for callsites. Reviewers: hach-que, chad Reviewed By: hach-que, chad Maniphest Tasks: T9253 Differential Revision: https://secure.phabricator.com/D14110
This commit is contained in:
parent
d6514321b1
commit
c44f9d80de
2 changed files with 0 additions and 118 deletions
|
@ -849,7 +849,6 @@ phutil_register_library_map(array(
|
||||||
'DrydockManagementLeaseWorkflow' => 'applications/drydock/management/DrydockManagementLeaseWorkflow.php',
|
'DrydockManagementLeaseWorkflow' => 'applications/drydock/management/DrydockManagementLeaseWorkflow.php',
|
||||||
'DrydockManagementReleaseWorkflow' => 'applications/drydock/management/DrydockManagementReleaseWorkflow.php',
|
'DrydockManagementReleaseWorkflow' => 'applications/drydock/management/DrydockManagementReleaseWorkflow.php',
|
||||||
'DrydockManagementWorkflow' => 'applications/drydock/management/DrydockManagementWorkflow.php',
|
'DrydockManagementWorkflow' => 'applications/drydock/management/DrydockManagementWorkflow.php',
|
||||||
'DrydockPreallocatedHostBlueprintImplementation' => 'applications/drydock/blueprint/DrydockPreallocatedHostBlueprintImplementation.php',
|
|
||||||
'DrydockQuery' => 'applications/drydock/query/DrydockQuery.php',
|
'DrydockQuery' => 'applications/drydock/query/DrydockQuery.php',
|
||||||
'DrydockResource' => 'applications/drydock/storage/DrydockResource.php',
|
'DrydockResource' => 'applications/drydock/storage/DrydockResource.php',
|
||||||
'DrydockResourceCloseController' => 'applications/drydock/controller/DrydockResourceCloseController.php',
|
'DrydockResourceCloseController' => 'applications/drydock/controller/DrydockResourceCloseController.php',
|
||||||
|
@ -4567,7 +4566,6 @@ phutil_register_library_map(array(
|
||||||
'DrydockManagementLeaseWorkflow' => 'DrydockManagementWorkflow',
|
'DrydockManagementLeaseWorkflow' => 'DrydockManagementWorkflow',
|
||||||
'DrydockManagementReleaseWorkflow' => 'DrydockManagementWorkflow',
|
'DrydockManagementReleaseWorkflow' => 'DrydockManagementWorkflow',
|
||||||
'DrydockManagementWorkflow' => 'PhabricatorManagementWorkflow',
|
'DrydockManagementWorkflow' => 'PhabricatorManagementWorkflow',
|
||||||
'DrydockPreallocatedHostBlueprintImplementation' => 'DrydockBlueprintImplementation',
|
|
||||||
'DrydockQuery' => 'PhabricatorCursorPagedPolicyAwareQuery',
|
'DrydockQuery' => 'PhabricatorCursorPagedPolicyAwareQuery',
|
||||||
'DrydockResource' => array(
|
'DrydockResource' => array(
|
||||||
'DrydockDAO',
|
'DrydockDAO',
|
||||||
|
|
|
@ -1,116 +0,0 @@
|
||||||
<?php
|
|
||||||
|
|
||||||
final class DrydockPreallocatedHostBlueprintImplementation
|
|
||||||
extends DrydockBlueprintImplementation {
|
|
||||||
|
|
||||||
public function isEnabled() {
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
|
|
||||||
public function getBlueprintName() {
|
|
||||||
return pht('Preallocated Remote Hosts');
|
|
||||||
}
|
|
||||||
|
|
||||||
public function getDescription() {
|
|
||||||
return pht('Allows Drydock to run on specific remote hosts you configure.');
|
|
||||||
}
|
|
||||||
|
|
||||||
public function canAllocateMoreResources(array $pool) {
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
|
|
||||||
protected function executeAllocateResource(DrydockLease $lease) {
|
|
||||||
throw new Exception(
|
|
||||||
pht("Preallocated hosts can't be dynamically allocated."));
|
|
||||||
}
|
|
||||||
|
|
||||||
protected function canAllocateLease(
|
|
||||||
DrydockResource $resource,
|
|
||||||
DrydockLease $lease) {
|
|
||||||
return
|
|
||||||
$lease->getAttribute('platform') === $resource->getAttribute('platform');
|
|
||||||
}
|
|
||||||
|
|
||||||
protected function shouldAllocateLease(
|
|
||||||
DrydockResource $resource,
|
|
||||||
DrydockLease $lease,
|
|
||||||
array $other_leases) {
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
|
|
||||||
protected function executeAcquireLease(
|
|
||||||
DrydockResource $resource,
|
|
||||||
DrydockLease $lease) {
|
|
||||||
|
|
||||||
// Because preallocated resources are manually created, we should verify
|
|
||||||
// we have all the information we need.
|
|
||||||
PhutilTypeSpec::checkMap(
|
|
||||||
$resource->getAttributesForTypeSpec(
|
|
||||||
array('platform', 'host', 'port', 'credential', 'path')),
|
|
||||||
array(
|
|
||||||
'platform' => 'string',
|
|
||||||
'host' => 'string',
|
|
||||||
'port' => 'string', // Value is a string from the command line
|
|
||||||
'credential' => 'string',
|
|
||||||
'path' => 'string',
|
|
||||||
));
|
|
||||||
$v_platform = $resource->getAttribute('platform');
|
|
||||||
$v_path = $resource->getAttribute('path');
|
|
||||||
|
|
||||||
// Similar to DrydockLocalHostBlueprint, we create a folder
|
|
||||||
// on the remote host that the lease can use.
|
|
||||||
|
|
||||||
$lease_id = $lease->getID();
|
|
||||||
|
|
||||||
// Can't use DIRECTORY_SEPERATOR here because that is relevant to
|
|
||||||
// the platform we're currently running on, not the platform we are
|
|
||||||
// remoting to.
|
|
||||||
$separator = '/';
|
|
||||||
if ($v_platform === 'windows') {
|
|
||||||
$separator = '\\';
|
|
||||||
}
|
|
||||||
|
|
||||||
// Clean up the directory path a little.
|
|
||||||
$base_path = rtrim($v_path, '/');
|
|
||||||
$base_path = rtrim($base_path, '\\');
|
|
||||||
$full_path = $base_path.$separator.$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 id(new DrydockSSHCommandInterface())
|
|
||||||
->setConfiguration(array(
|
|
||||||
'host' => $resource->getAttribute('host'),
|
|
||||||
'port' => $resource->getAttribute('port'),
|
|
||||||
'credential' => $resource->getAttribute('credential'),
|
|
||||||
'platform' => $resource->getAttribute('platform'),
|
|
||||||
))
|
|
||||||
->setWorkingDirectory($lease->getAttribute('path'));
|
|
||||||
case 'filesystem':
|
|
||||||
return id(new DrydockSFTPFilesystemInterface())
|
|
||||||
->setConfiguration(array(
|
|
||||||
'host' => $resource->getAttribute('host'),
|
|
||||||
'port' => $resource->getAttribute('port'),
|
|
||||||
'credential' => $resource->getAttribute('credential'),
|
|
||||||
));
|
|
||||||
}
|
|
||||||
|
|
||||||
throw new Exception(pht("No interface of type '%s'.", $type));
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
Loading…
Reference in a new issue