Merge pull request #460 from dnephin/fix_tests_for_docker_1.1
Fix test failures on docker 1.1.2
This commit is contained in:
commit
ec5c864cc7
5 changed files with 51 additions and 32 deletions
|
|
@ -67,7 +67,7 @@ class Container(object):
|
|||
@property
|
||||
def ports(self):
|
||||
self.inspect_if_not_inspected()
|
||||
return self.dictionary['NetworkSettings']['Ports'] or {}
|
||||
return self.get('NetworkSettings.Ports') or {}
|
||||
|
||||
@property
|
||||
def human_readable_ports(self):
|
||||
|
|
@ -82,33 +82,35 @@ class Container(object):
|
|||
|
||||
@property
|
||||
def human_readable_state(self):
|
||||
self.inspect_if_not_inspected()
|
||||
if self.dictionary['State']['Running']:
|
||||
if self.dictionary['State'].get('Ghost'):
|
||||
return 'Ghost'
|
||||
else:
|
||||
return 'Up'
|
||||
if self.is_running:
|
||||
return 'Ghost' if self.get('State.Ghost') else 'Up'
|
||||
else:
|
||||
return 'Exit %s' % self.dictionary['State']['ExitCode']
|
||||
return 'Exit %s' % self.get('State.ExitCode')
|
||||
|
||||
@property
|
||||
def human_readable_command(self):
|
||||
self.inspect_if_not_inspected()
|
||||
if self.dictionary['Config']['Cmd']:
|
||||
return ' '.join(self.dictionary['Config']['Cmd'])
|
||||
else:
|
||||
return ''
|
||||
return ' '.join(self.get('Config.Cmd') or '')
|
||||
|
||||
@property
|
||||
def environment(self):
|
||||
self.inspect_if_not_inspected()
|
||||
return dict(var.split("=", 1)
|
||||
for var in self.dictionary.get('Config', {}).get('Env', []))
|
||||
return dict(var.split("=", 1) for var in self.get('Config.Env') or [])
|
||||
|
||||
@property
|
||||
def is_running(self):
|
||||
return self.get('State.Running')
|
||||
|
||||
def get(self, key):
|
||||
"""Return a value from the container or None if the value is not set.
|
||||
|
||||
:param key: a string using dotted notation for nested dictionary
|
||||
lookups
|
||||
"""
|
||||
self.inspect_if_not_inspected()
|
||||
return self.dictionary['State']['Running']
|
||||
|
||||
def get_value(dictionary, key):
|
||||
return (dictionary or {}).get(key)
|
||||
|
||||
return reduce(get_value, key.split('.'), self.dictionary)
|
||||
|
||||
def get_local_port(self, port, protocol='tcp'):
|
||||
port = self.ports.get("%s/%s" % (port, protocol))
|
||||
|
|
|
|||
|
|
@ -205,6 +205,10 @@ class Service(object):
|
|||
return tuples
|
||||
|
||||
def recreate_container(self, container, **override_options):
|
||||
"""Recreate a container. An intermediate container is created so that
|
||||
the new container has the same name, while still supporting
|
||||
`volumes-from` the original container.
|
||||
"""
|
||||
try:
|
||||
container.stop()
|
||||
except APIError as e:
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue