diff options
author | Walker Lee <walkerlee.tw@gmail.com> | 2016-10-27 00:12:56 +0800 |
---|---|---|
committer | Walker Lee <walkerlee.tw@gmail.com> | 2016-10-27 00:17:05 +0800 |
commit | a3981f891d9ca52b145ba875c4c0e6d72c36a716 (patch) | |
tree | 32e13e7e3cb7b527f2290083d8cff772b410313a | |
parent | c7dabbfa37e7251d018af4ef65e24e24764dbf80 (diff) | |
download | docker-py-a3981f891d9ca52b145ba875c4c0e6d72c36a716.tar.gz |
Add docker network IPAM options parameter
Signed-off-by: Walker Lee <walkerlee.tw@gmail.com>
-rw-r--r-- | docker/utils/utils.py | 8 | ||||
-rw-r--r-- | docs/networks.md | 1 | ||||
-rw-r--r-- | tests/unit/network_test.py | 3 | ||||
-rw-r--r-- | 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 d89aecf..13254b9 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 fb0e9f4..d982990 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 93f03da..a79132e 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 290874f..a87293d 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 }) |