Esempio n. 1
0
 def test_image_coercion(self):
     image = Image.coerce('redock:test')
     self.assertEqual(image.repository, 'redock')
     self.assertEqual(image.tag, 'test')
     self.assertEqual(image.key, ('redock', 'test'))
     self.assertEqual(image.name, 'redock:test')
     self.assertEqual(image.unique_name, 'redock:test')
Esempio n. 2
0
         usage()
         return
     supported_actions = ('start', 'commit', 'kill', 'delete')
     action = arguments.pop(0)
     if action not in supported_actions:
         msg = "Action not supported: %r (supported actions are: %s)"
         raise Exception, msg % (action, ', '.join(supported_actions))
 except Exception, e:
     logger.error("Failed to parse command line arguments!")
     logger.exception(e)
     usage()
     sys.exit(1)
 # Start the container and connect to it over SSH.
 try:
     for image_name in arguments:
         container = Container(image=Image.coerce(image_name),
                               hostname=hostname)
         if action == 'start':
             container.start()
             if len(arguments) == 1 and all(os.isatty(n) for n in range(3)):
                 ssh_timer = Timer()
                 logger.info("Detected interactive terminal, connecting to container ..")
                 ssh_client = subprocess.Popen(['ssh', container.ssh_alias])
                 ssh_client.wait()
                 if ssh_client.returncode == 0:
                     logger.info("SSH client exited after %s.", ssh_timer)
                 else:
                     logger.warn("SSH client exited with status %i after %s.",
                                 ssh_client.returncode, ssh_timer)
         elif action == 'commit':
             container.commit(message=message)