summaryrefslogtreecommitdiffstats
path: root/python-dockering/dockering/config_building.py
diff options
context:
space:
mode:
authorMichael Hwang <mhwang@research.att.com>2017-09-14 10:56:07 -0400
committerMichael Hwang <mhwang@research.att.com>2017-09-14 10:57:30 -0400
commit66613f4112b0e68f30430944b7d94e6ca14b1f62 (patch)
tree98316d7a0663e3a2e69d7128bbcc8997b60052ad /python-dockering/dockering/config_building.py
parent0c209c0c2b6e4bbadf413c048d9c535d3c2d1a0b (diff)
Fix issue where container ports is not list
Container ports was being returned as dict keys for python3 Change-Id: I434049c465094265d8e0ec8c8d6310b682866da8 Issue-Id: DCAEGEN2-91 Signed-off-by: Michael Hwang <mhwang@research.att.com>
Diffstat (limited to 'python-dockering/dockering/config_building.py')
-rw-r--r--python-dockering/dockering/config_building.py14
1 files changed, 9 insertions, 5 deletions
diff --git a/python-dockering/dockering/config_building.py b/python-dockering/dockering/config_building.py
index d8e3c84..564e5de 100644
--- a/python-dockering/dockering/config_building.py
+++ b/python-dockering/dockering/config_building.py
@@ -20,6 +20,7 @@
"""
Abstraction in Docker container configuration
"""
+import six
from dockering import utils
from dockering.exceptions import DockerConstructionError
@@ -234,6 +235,13 @@ def add_host_config_params_dns(docker_host, host_config_params=None):
return host_config_params
+def _get_container_ports(host_config_params):
+ """Grab list of container ports from host config params"""
+ if "port_bindings" in host_config_params:
+ return list(six.iterkeys(host_config_params["port_bindings"]))
+ else:
+ return None
+
def create_container_config(client, image, envs, host_config_params, tty=False):
"""Create docker container config
@@ -252,11 +260,7 @@ def create_container_config(client, image, envs, host_config_params, tty=False):
host_config = client.create_host_config(**host_config_params)
- if "port_bindings" in host_config_params:
- # TODO: Use six for creating the list of ports - six.iterkeys
- ports = host_config_params["port_bindings"].keys()
- else:
- ports = None
+ ports = _get_container_ports(host_config_params)
command = "" # This is required...
config = client.create_container_config(image, command, detach=True, tty=tty,