1
0
Fork 0
mirror of https://we.phorge.it/source/phorge.git synced 2025-01-31 08:58:20 +01:00

Allow timeouts to be specified on Drydock SSH connections

Summary: This allows timeouts to be specified on SSH connections that Drydock makes.  Used in the EC2 allocator to poll for the SSH server starting.

Test Plan: Used in EC2 allocator diff.

Reviewers: epriestley, #blessed_reviewers

Reviewed By: epriestley, #blessed_reviewers

Subscribers: epriestley, Korvin

Differential Revision: https://secure.phabricator.com/D10225
This commit is contained in:
James Rhodes 2014-08-12 09:14:47 +10:00
parent e48aaa563a
commit d2111214f2

View file

@ -3,6 +3,7 @@
final class DrydockSSHCommandInterface extends DrydockCommandInterface {
private $passphraseSSHKey;
private $connectTimeout;
private function openCredentialsIfNotOpen() {
if ($this->passphraseSSHKey !== null) {
@ -25,6 +26,11 @@ final class DrydockSSHCommandInterface extends DrydockCommandInterface {
PhabricatorUser::getOmnipotentUser());
}
public function setConnectTimeout($timeout) {
$this->connectTimeout = $timeout;
return $this;
}
public function getExecFuture($command) {
$this->openCredentialsIfNotOpen();
@ -44,8 +50,19 @@ final class DrydockSSHCommandInterface extends DrydockCommandInterface {
$full_command = 'C:\\Windows\\system32\\cmd.exe /C '.$full_command;
}
$command_timeout = '';
if ($this->connectTimeout !== null) {
$command_timeout = csprintf(
'-o %s',
'ConnectTimeout='.$this->connectTimeout);
}
return new ExecFuture(
'ssh -o StrictHostKeyChecking=no -p %s -i %P %P@%s -- %s',
'ssh '.
'-o StrictHostKeyChecking=no '.
'-o BatchMode=yes '.
'%C -p %s -i %P %P@%s -- %s',
$command_timeout,
$this->getConfig('port'),
$this->passphraseSSHKey->getKeyfileEnvelope(),
$this->passphraseSSHKey->getUsernameEnvelope(),