Fix hard code kuryr driver name bug

kuryr driver name is hard coded in zun, if user installed it by
docker plugin install kuryr/libnetwork2, the driver name maybe the
'kuryr/libnetwork2:latest', which will cause create docker fail.

Make the dirver name passed to docker as an conf options, which
default is 'kuryr' as the default driver is kuryr.

Change-Id: I9cc52585950bc44889a3e468476599e27007e8d0
Closes-Bug: #1703383
This commit is contained in:
ShunliZhou 2017-07-11 10:51:50 +08:00
parent 2f3629a91d
commit 8ce08d7012
2 changed files with 10 additions and 2 deletions

View File

@ -20,6 +20,10 @@ network_opts = [
cfg.StrOpt('driver',
default='kuryr',
help='Defines which driver to use for container network.'),
cfg.StrOpt('driver_name',
default='kuryr',
help=('The network plugin driver name, you can find it by'
' docker plugin list.')),
]
ALL_OPTS = (network_opts)

View File

@ -20,8 +20,12 @@ from oslo_utils import excutils
from zun.common import clients
from zun.common import exception
from zun.common.i18n import _
import zun.conf
from zun.network import network
CONF = zun.conf.CONF
LOG = logging.getLogger(__name__)
@ -54,7 +58,7 @@ class KuryrNetwork(network.Network):
"The Neutron network %s has no subnet") % neutron_net_id)
ipam_options = {
"Driver": "kuryr",
"Driver": CONF.network.driver_name,
"Options": {},
"Config": []
}
@ -84,7 +88,7 @@ class KuryrNetwork(network.Network):
"ipam_options %s, options %s", name, ipam_options, options)
docker_network = self.docker.create_network(
name=name,
driver='kuryr',
driver=CONF.network.driver_name,
enable_ipv6=True if v6_subnet else False,
options=options,
ipam=ipam_options)