summaryrefslogtreecommitdiffstats
path: root/python-dockering
diff options
context:
space:
mode:
Diffstat (limited to 'python-dockering')
-rw-r--r--python-dockering/ChangeLog.md5
-rw-r--r--python-dockering/dockering/config_building.py14
-rw-r--r--python-dockering/setup.py3
-rw-r--r--python-dockering/tests/test_config_building.py8
4 files changed, 24 insertions, 6 deletions
diff --git a/python-dockering/ChangeLog.md b/python-dockering/ChangeLog.md
index 67ae4f8..9c7781d 100644
--- a/python-dockering/ChangeLog.md
+++ b/python-dockering/ChangeLog.md
@@ -5,6 +5,11 @@ All notable changes to this project will be documented in this file.
The format is based on [Keep a Changelog](http://keepachangelog.com/)
and this project adheres to [Semantic Versioning](http://semver.org/).
+## [1.3.0]
+
+* Fix issue with returning container ports as dict keys when list was expected
+* Add in functionality to notify Docker containers for policy changes
+
## [1.2.0]
* Add the ability to force reauthentication for Docker login
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,
diff --git a/python-dockering/setup.py b/python-dockering/setup.py
index 418403e..9a0537e 100644
--- a/python-dockering/setup.py
+++ b/python-dockering/setup.py
@@ -29,6 +29,7 @@ setup(
packages=['dockering'],
zip_safe=False,
install_requires=[
- "docker-py>=1.0.0,<2.0.0"
+ "docker-py>=1.0.0,<2.0.0",
+ "six"
]
)
diff --git a/python-dockering/tests/test_config_building.py b/python-dockering/tests/test_config_building.py
index c9251e2..ff1b409 100644
--- a/python-dockering/tests/test_config_building.py
+++ b/python-dockering/tests/test_config_building.py
@@ -148,3 +148,11 @@ def test_parse_volumes_param():
assert actual == expected
assert None == doc._parse_volumes_param(None)
+
+
+def test_get_container_ports():
+ hcp = {'publish_all_ports': False, 'port_bindings': {'80': {'HostPort':
+ '80'}, '22': {'HostPort': '22'}}}
+ assert sorted(['80', '22']) == sorted(doc._get_container_ports(hcp))
+
+ assert None == doc._get_container_ports({})