Пример #1
0
def check_finish_install(address):
    attempt = 0
    while True:
        attempt += 1
        try:
            out = execute("ssh ubuntu@%s status cloud-config" % (address),
                          timeout=30).strip()
            if out == 'cloud-config stop/waiting':
                logger.debug('cloud-config finished')
                break
            else:
                logger.debug(out.strip())
        except CommandTimeout:
            logger.debug("ssh to %s timed out.", address)
        except CommandFailure, e:
            logger.debug("Command failed with exit code %d.", e.return_code)
            for i in e.output.split('\n'):
                logger.debug("    stdout: %s", i)
        time.sleep(5)
Пример #2
0
 def execute(self, context, timeout, private_context=None):
     cmd = self.format_command(context, private_context)
     return commands.execute(cmd, timeout)
Пример #3
0
 def execute(self, context, timeout, private_context=None):
     cmd = self.format_command(context, private_context)
     return commands.execute(cmd, timeout)
Пример #4
0
 def test_execute_failure(self):
     with self.assertRaises(commands.CommandFailure):
         # Non-existant command
         out = commands.execute("xxxps auwwwx", 10)
Пример #5
0
 def test_execute_success(self):
     out = commands.execute("echo test", 10)
     self.assertEqual(out, "test\n")
Пример #6
0
 def test_execute_timeout(self):
     with self.assertRaises(commands.CommandTimeout):
         out = commands.execute("sleep 2", 1)
Пример #7
0
 def test_execute_failure(self):
     with self.assertRaises(commands.CommandFailure):
         # Non-existant command
         commands.execute('xxxps auwwwx', 10)
Пример #8
0
 def test_execute_success(self):
     out = commands.execute('echo test', 10)
     self.assertEqual(out, 'test\n')
Пример #9
0
 def test_execute_timeout(self):
     with self.assertRaises(commands.CommandTimeout):
         commands.execute('sleep 2', 1)