Skip to content

Commit a3981f8

Browse files
committed
Add docker network IPAM options parameter
Signed-off-by: Walker Lee <[email protected]>
1 parent c7dabbf commit a3981f8

File tree

4 files changed

+11
-4
lines changed

4 files changed

+11
-4
lines changed

docker/utils/utils.py

+6-2
Original file line numberDiff line numberDiff line change
@@ -47,10 +47,14 @@ def create_ipam_pool(subnet=None, iprange=None, gateway=None,
4747
}
4848

4949

50-
def create_ipam_config(driver='default', pool_configs=None):
50+
def create_ipam_config(driver='default', pool_configs=None, options=None):
51+
if options is not None and not isinstance(options, dict):
52+
raise TypeError('IPAM options must be a dictionary')
53+
5154
return {
5255
'Driver': driver,
53-
'Config': pool_configs or []
56+
'Config': pool_configs or [],
57+
'Options': options
5458
}
5559

5660

docs/networks.md

+1
Original file line numberDiff line numberDiff line change
@@ -137,6 +137,7 @@ Create an IPAM (IP Address Management) config dictionary to be used with
137137
* driver (str): The IPAM driver to use. Defaults to `'default'`.
138138
* pool_configs (list): A list of pool configuration dictionaries as created
139139
by `docker.utils.create_ipam_pool`. Defaults to empty list.
140+
* options (dict): Driver options as a key-value dictionary. Defaults to `None`.
140141

141142
**Returns** An IPAM config dictionary
142143

tests/unit/network_test.py

+2-1
Original file line numberDiff line numberDiff line change
@@ -100,7 +100,8 @@ def test_create_network(self):
100100
"Gateway": "192.168.52.254",
101101
"Subnet": "192.168.52.0/24",
102102
"AuxiliaryAddresses": None,
103-
}]
103+
}],
104+
"Options": None
104105
}
105106
})
106107

tests/unit/utils_test.py

+2-1
Original file line numberDiff line numberDiff line change
@@ -691,7 +691,8 @@ def test_create_ipam_config(self):
691691
'Gateway': '192.168.52.254',
692692
'AuxiliaryAddresses': None,
693693
'IPRange': None,
694-
}]
694+
}],
695+
'Options': None
695696
})
696697

697698

0 commit comments

Comments
 (0)