Merge "container connect both bridge and kuryr network in Rally"
This commit is contained in:
@@ -70,9 +70,11 @@ class DockerNetworkContext(context.Context):
|
|||||||
driver="kuryr",
|
driver="kuryr",
|
||||||
ipam=ipam)
|
ipam=ipam)
|
||||||
self.context["netid"] = res.get("Id")
|
self.context["netid"] = res.get("Id")
|
||||||
|
self.context["netname"] = "kuryr_network"
|
||||||
else:
|
else:
|
||||||
res = docker_client.create_network(name="docker_network")
|
res = docker_client.create_network(name="docker_network")
|
||||||
self.context["netid"] = res.get("Id")
|
self.context["netid"] = res.get("Id")
|
||||||
|
self.context["netname"] = "docker_network"
|
||||||
LOG.debug("Container network id is '%s'" % self.context["netid"])
|
LOG.debug("Container network id is '%s'" % self.context["netid"])
|
||||||
except Exception as e:
|
except Exception as e:
|
||||||
msg = "Can't create docker network: %s" % e.message
|
msg = "Can't create docker network: %s" % e.message
|
||||||
|
@@ -24,7 +24,7 @@ class Kuryr(utils.KuryrScenario):
|
|||||||
def __init__(self, context=None, admin_clients=None, clients=None):
|
def __init__(self, context=None, admin_clients=None, clients=None):
|
||||||
super(Kuryr, self).__init__(context, admin_clients, clients)
|
super(Kuryr, self).__init__(context, admin_clients, clients)
|
||||||
|
|
||||||
@scenario.configure(context={"cleanup": ["kuryr"]})
|
@scenario.configure()
|
||||||
def list_networks(self, network_list_args=None):
|
def list_networks(self, network_list_args=None):
|
||||||
"""List the networks.
|
"""List the networks.
|
||||||
|
|
||||||
@@ -40,7 +40,7 @@ class Kuryr(utils.KuryrScenario):
|
|||||||
"""
|
"""
|
||||||
self._list_networks(network_list_args or {})
|
self._list_networks(network_list_args or {})
|
||||||
|
|
||||||
@scenario.configure(context={"cleanup": ["kuryr"]})
|
@scenario.configure()
|
||||||
def create_and_delete_networks_with_kuryr(self, network_create_args=None):
|
def create_and_delete_networks_with_kuryr(self, network_create_args=None):
|
||||||
"""Create and delete a network with kuryr.
|
"""Create and delete a network with kuryr.
|
||||||
|
|
||||||
@@ -53,7 +53,7 @@ class Kuryr(utils.KuryrScenario):
|
|||||||
network_create_args=network_create_args or {})
|
network_create_args=network_create_args or {})
|
||||||
self._delete_network(network)
|
self._delete_network(network)
|
||||||
|
|
||||||
@scenario.configure(context={"cleanup": ["kuryr"]})
|
@scenario.configure()
|
||||||
def create_and_delete_networks_without_kuryr(self,
|
def create_and_delete_networks_without_kuryr(self,
|
||||||
network_create_args=None):
|
network_create_args=None):
|
||||||
"""Create and delete a network without kuryr.
|
"""Create and delete a network without kuryr.
|
||||||
@@ -67,7 +67,7 @@ class Kuryr(utils.KuryrScenario):
|
|||||||
network_create_args=network_create_args or {})
|
network_create_args=network_create_args or {})
|
||||||
self._delete_network(network)
|
self._delete_network(network)
|
||||||
|
|
||||||
@scenario.configure(context={"cleanup": ["kuryr"]})
|
@scenario.configure()
|
||||||
def start_and_stop_containers(self, container_create_args=None):
|
def start_and_stop_containers(self, container_create_args=None):
|
||||||
"""Start and stop container on docker network.
|
"""Start and stop container on docker network.
|
||||||
|
|
||||||
|
@@ -79,14 +79,15 @@ class KuryrScenario(scenario.OpenStackScenario):
|
|||||||
@atomic.action_timer("kuryr.start_container")
|
@atomic.action_timer("kuryr.start_container")
|
||||||
def _start_container(self, container_create_args=None):
|
def _start_container(self, container_create_args=None):
|
||||||
"""Start Container on docker network."""
|
"""Start Container on docker network."""
|
||||||
|
network_config = self.docker_client.create_networking_config(
|
||||||
|
{self.context.get("netname"):
|
||||||
|
self.docker_client.create_endpoint_config()})
|
||||||
container = self.docker_client.create_container(
|
container = self.docker_client.create_container(
|
||||||
image='kuryr/busybox',
|
image='kuryr/busybox',
|
||||||
command='/bin/sleep 600')
|
command='/bin/sleep 600',
|
||||||
|
networking_config=network_config)
|
||||||
container_id = container.get('Id')
|
container_id = container.get('Id')
|
||||||
self.docker_client.start(container=container_id)
|
self.docker_client.start(container=container_id)
|
||||||
net_id = self.context.get("netid")
|
|
||||||
self.docker_client.connect_container_to_network(container_id,
|
|
||||||
net_id)
|
|
||||||
return container_id
|
return container_id
|
||||||
|
|
||||||
@atomic.action_timer("kuryr.stop_container")
|
@atomic.action_timer("kuryr.stop_container")
|
||||||
|
Reference in New Issue
Block a user