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)
def execute(self, context, timeout, private_context=None): cmd = self.format_command(context, private_context) return commands.execute(cmd, timeout)
def test_execute_failure(self): with self.assertRaises(commands.CommandFailure): # Non-existant command out = commands.execute("xxxps auwwwx", 10)
def test_execute_success(self): out = commands.execute("echo test", 10) self.assertEqual(out, "test\n")
def test_execute_timeout(self): with self.assertRaises(commands.CommandTimeout): out = commands.execute("sleep 2", 1)
def test_execute_failure(self): with self.assertRaises(commands.CommandFailure): # Non-existant command commands.execute('xxxps auwwwx', 10)
def test_execute_success(self): out = commands.execute('echo test', 10) self.assertEqual(out, 'test\n')
def test_execute_timeout(self): with self.assertRaises(commands.CommandTimeout): commands.execute('sleep 2', 1)