From a3981f891d9ca52b145ba875c4c0e6d72c36a716 Mon Sep 17 00:00:00 2001 From: Walker Lee Date: Thu, 27 Oct 2016 00:12:56 +0800 Subject: [PATCH] Add docker network IPAM options parameter Signed-off-by: Walker Lee --- docker/utils/utils.py | 8 ++++++-- docs/networks.md | 1 + tests/unit/network_test.py | 3 ++- tests/unit/utils_test.py | 3 ++- 4 files changed, 11 insertions(+), 4 deletions(-) diff --git a/docker/utils/utils.py b/docker/utils/utils.py index d89aecf3..13254b9e 100644 --- a/docker/utils/utils.py +++ b/docker/utils/utils.py @@ -47,10 +47,14 @@ def create_ipam_pool(subnet=None, iprange=None, gateway=None, } -def create_ipam_config(driver='default', pool_configs=None): +def create_ipam_config(driver='default', pool_configs=None, options=None): + if options is not None and not isinstance(options, dict): + raise TypeError('IPAM options must be a dictionary') + return { 'Driver': driver, - 'Config': pool_configs or [] + 'Config': pool_configs or [], + 'Options': options } diff --git a/docs/networks.md b/docs/networks.md index fb0e9f42..d9829909 100644 --- a/docs/networks.md +++ b/docs/networks.md @@ -137,6 +137,7 @@ Create an IPAM (IP Address Management) config dictionary to be used with * driver (str): The IPAM driver to use. Defaults to `'default'`. * pool_configs (list): A list of pool configuration dictionaries as created by `docker.utils.create_ipam_pool`. Defaults to empty list. +* options (dict): Driver options as a key-value dictionary. Defaults to `None`. **Returns** An IPAM config dictionary diff --git a/tests/unit/network_test.py b/tests/unit/network_test.py index 93f03da4..a79132ed 100644 --- a/tests/unit/network_test.py +++ b/tests/unit/network_test.py @@ -100,7 +100,8 @@ class NetworkTest(DockerClientTest): "Gateway": "192.168.52.254", "Subnet": "192.168.52.0/24", "AuxiliaryAddresses": None, - }] + }], + "Options": None } }) diff --git a/tests/unit/utils_test.py b/tests/unit/utils_test.py index 290874f4..a87293de 100644 --- a/tests/unit/utils_test.py +++ b/tests/unit/utils_test.py @@ -691,7 +691,8 @@ class UtilsTest(base.BaseTestCase): 'Gateway': '192.168.52.254', 'AuxiliaryAddresses': None, 'IPRange': None, - }] + }], + 'Options': None })