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