示例#1
0
 def remote_executor(self, hostname, key_file=None, ignore_errors=False):
     key_files = []
     if self.ssh_settings.key_file is not None:
         key_files.append(self.ssh_settings.key_file)
     if key_file is not None:
         key_files.append(key_file)
     if key_files:
         utils.ensure_ssh_key_added(key_files)
     try:
         yield RemoteExecutor(self.ssh_settings, hostname, ignore_errors)
     finally:
         _close_connection(hostname)
示例#2
0
 def test_agent_is_not_run(self, test_local):
     test_local.side_effect = [
         create_attribute_string(
             'The agent has no identities', succeeded=True),
         create_attribute_string('Agent pid 1234\n/foo/bar',
                                 succeeded=True),
     ]
     utils.forward_agent(['test_key_1', 'test_key_2'])
     self.assertFalse(
         utils.ensure_ssh_key_added(['test_key_1', 'test_key_2']))
示例#3
0
 def test_agent_is_already_run_w_keys(self, test_local):
     test_local.side_effect = [
         create_attribute_string(
             '4096 de:3b:90:e1:3e:f7:3e:f5:4b:e3:ca:9f:1c:68:45:fb '
             'test_key_1 (RSA)\n'
             '2048 8a:f7:05:14:f7:3a:9b:28:70:d8:95:6e:df:e9:78:c7 '
             'test_key_2 (RSA)\n',
             succeeded=True),
     ]
     utils.forward_agent(['test_key_1', 'test_key_2'])
     self.assertTrue(
         utils.ensure_ssh_key_added(['test_key_1', 'test_key_2']))
示例#4
0
 def remote_executor(self, hostname, key_file=None, ignore_errors=False):
     # pylint: disable=no-member
     key_files = []
     settings = self.ssh_settings
     if settings.key_file is not None:
         key_files.append(settings.key_file)
     if key_file is not None:
         key_files.append(key_file)
     if key_files:
         utils.ensure_ssh_key_added(key_files)
     try:
         yield remote.RemoteExecutor(
             hostname, settings.username,
             sudo_password=settings.sudo_password,
             gateway=settings.gateway,
             connection_attempts=settings.connection_attempts,
             cipher=settings.cipher,
             key_file=settings.key_file,
             ignore_errors=ignore_errors)
     finally:
         remote.RemoteExecutor.close_connection(hostname)
示例#5
0
 def remote_executor(self, hostname, key_file=None, ignore_errors=False):
     # pylint: disable=no-member
     key_files = []
     settings = self.ssh_settings
     if settings.key_file is not None:
         key_files.append(settings.key_file)
     if key_file is not None:
         key_files.append(key_file)
     if key_files:
         utils.ensure_ssh_key_added(key_files)
     try:
         yield remote.RemoteExecutor(
             hostname,
             settings.username,
             sudo_password=settings.sudo_password,
             gateway=settings.gateway,
             connection_attempts=settings.connection_attempts,
             cipher=settings.cipher,
             key_file=settings.key_file,
             ignore_errors=ignore_errors)
     finally:
         remote.RemoteExecutor.close_connection(hostname)
示例#6
0
 def test_agent_is_already_run_w_another_key(self, test_local):
     test_local.return_value = local(
         "echo test_session_num test_fingerprint test_key test_type\n",
         capture=True
     )
     test_local.side_effect = [
         create_attribute_string(
             '4096 de:3b:90:e1:3e:f7:3e:f5:4b:e3:ca:9f:1c:68:45:fb '
             'test_key_1 (RSA)\n',
             succeeded=True),
         create_attribute_string('Agent pid 1234\n/foo/bar',
                                 succeeded=True),
     ]
     utils.forward_agent(['test_key_1', 'test_key_2'])
     self.assertFalse(
         utils.ensure_ssh_key_added(['test_key_1', 'test_key_2']))