public function getInterface(DrydockResource $resource, DrydockLease $lease, $type) { switch ($type) { case 'command': return $this->loadLease($resource->getAttribute('lease.host'))->getInterface($type); } throw new Exception("No interface of type '{$type}'."); }
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)); }
public function getInterface(DrydockBlueprint $blueprint, DrydockResource $resource, DrydockLease $lease, $type) { $viewer = PhabricatorUser::getOmnipotentUser(); switch ($type) { case DrydockCommandInterface::INTERFACE_TYPE: $credential_phid = $blueprint->getFieldValue('credentialPHID'); $binding_phid = $resource->getAttribute('almanacBindingPHID'); $binding = id(new AlmanacBindingQuery())->setViewer($viewer)->withPHIDs(array($binding_phid))->executeOne(); if (!$binding) { // TODO: This is probably a permanent failure, destroy this resource? throw new Exception(pht('Unable to load binding "%s" to create command interface.', $binding_phid)); } $interface = $binding->getInterface(); return id(new DrydockSSHCommandInterface())->setConfig('credentialPHID', $credential_phid)->setConfig('host', $interface->getAddress())->setConfig('port', $interface->getPort()); } }
private function loadHostLease(DrydockResource $resource) { $viewer = PhabricatorUser::getOmnipotentUser(); $lease_phid = $resource->getAttribute('host.leasePHID'); $lease = id(new DrydockLeaseQuery())->setViewer($viewer)->withPHIDs(array($lease_phid))->executeOne(); if (!$lease) { throw new Exception(pht('Unable to load lease ("%s").', $lease_phid)); } return $lease; }
public function getInterface(DrydockResource $resource, DrydockLease $lease, $type) { switch ($type) { case 'webroot': $iface = new DrydockApacheWebrootInterface(); $iface->setConfiguration(array('uri' => $lease->getAttribute('uri'))); return $iface; case 'command': $host_lease_id = $resource->getAttribute('lease.host'); $host_lease = id(new DrydockLease())->load($host_lease_id); $host_lease->attachResource($host_lease->loadResource()); return $host_lease->getInterface($type); } throw new Exception("No interface of type '{$type}'."); }
public function getInterface(DrydockResource $resource, DrydockLease $lease, $type) { switch ($type) { case 'command': $ssh = new DrydockSSHCommandInterface(); $ssh->setConfiguration(array('host' => $resource->getAttribute('host'), 'user' => $resource->getAttribute('user'), 'ssh-keyfile' => $resource->getAttribute('ssh-keyfile'))); return $ssh; } throw new Exception("No interface of type '{$type}'."); }