Only pass ipam parameter to create_network() if needed. (#48735)

This commit is contained in:
Felix Fontein 2018-11-16 07:20:32 +01:00 committed by ansibot
parent 6745ee7cc8
commit ce3a9cfae5

View file

@ -424,6 +424,11 @@ class DockerNetworkManager(object):
else: else:
ipam_pools.append(utils.create_ipam_pool(**ipam_pool)) ipam_pools.append(utils.create_ipam_pool(**ipam_pool))
if self.parameters.ipam_driver or ipam_pools:
# Only add ipam parameter if a driver was specified or if IPAM parameters
# were specified. Leaving this parameter away can significantly speed up
# creation; on my machine creation with this option needs ~15 seconds,
# and without just a few seconds.
if HAS_DOCKER_PY_2 or HAS_DOCKER_PY_3: if HAS_DOCKER_PY_2 or HAS_DOCKER_PY_3:
params['ipam'] = IPAMConfig(driver=self.parameters.ipam_driver, params['ipam'] = IPAMConfig(driver=self.parameters.ipam_driver,
pool_configs=ipam_pools) pool_configs=ipam_pools)