Created
February 26, 2015 17:01
-
-
Save jimi-c/b489a515e0a7b3c64f3c to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
diff --git a/cloud/docker/docker.py b/cloud/docker/docker.py | |
index ba0828d..1417da0 100644 | |
--- a/cloud/docker/docker.py | |
+++ b/cloud/docker/docker.py | |
@@ -781,7 +781,7 @@ class DockerManager(object): | |
return containers | |
- def restart_named_container(self, existing_container): | |
+ def should_restart_named_container(self, existing_container): | |
if existing_container: | |
return (self.image_changed(existing_container) or | |
self.env_changed(existing_container) or | |
@@ -800,8 +800,8 @@ class DockerManager(object): | |
# loop through each ansible config try to find a matchig docker config | |
# return False if unable to match | |
for port in ports: | |
- num_colons = port.count(":") | |
- parts = port.split(":") | |
+ num_colons = str(port).count(":") | |
+ parts = str(port).split(":") | |
host_ip, host_port, remote_port = "", None, None | |
@@ -812,7 +812,7 @@ class DockerManager(object): | |
host_ip, host_port, remote_port = parts[0], parts[1], parts[2] | |
# default to tcp if not specified, default docker behavior | |
- if "/" not in remote_port: | |
+ if remote_port and "/" not in remote_port: | |
remote_port = remote_port + "/tcp" | |
found = False | |
@@ -852,10 +852,10 @@ class DockerManager(object): | |
def env_changed(self, existing_container): | |
container_config = existing_container.get('Config', dict()) | |
- container_env = container_config.get('Env') | |
+ container_env = container_config.get('Env', []) | |
# convert from list to dict | |
- container_env = dict(env_var.split('=') for env_var in container_env) | |
+ container_env = dict(env_var.split('=', 1) for env_var in container_env) | |
# ignore PATH | |
if 'PATH' in container_env: | |
@@ -864,8 +864,8 @@ class DockerManager(object): | |
return self.key_val_changed(self.module.params.get('env') or {}, container_env) | |
def key_val_changed(self, input_env, container_env): | |
- if len(input_env) != len(container_env): | |
- return True | |
+ #if len(input_env) != len(container_env): | |
+ # return True | |
for key, value in input_env.iteritems(): | |
if container_env.get(key): | |
@@ -1007,7 +1007,7 @@ def main(): | |
# the named container is running, but with a | |
# different image, tag or env vars, so we stop it first | |
- if manager.restart_named_container(existing_container): | |
+ if manager.should_restart_named_container(existing_container): | |
manager.stop_containers([existing_container]) | |
manager.remove_containers([existing_container]) | |
running_containers = manager.get_running_containers() |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment