Permalink
Browse files

port-create-associate

Creates port and associates it to a host

Change-Id: Ie94978ff42f91eb20f8a95964606260de603e3f2
  • Loading branch information...
jtaleric committed Oct 30, 2017
1 parent 70c2a22 commit db8096ca4898c6f13fe04cedb62dbff4c92d359c
View
@@ -249,6 +249,14 @@ rally:
image_location: /home/stack/cirros.qcow2
flavor_name: m1.xtiny
file: rally/rally-plugins/glance/glance_create_boot_delete.yml
- name: rally-port-create-associate
file: rally/rally-plugins/neutron/port_create_assoicate.yml
enabled: true
num_networks: 1
num_ports: 100
hypervisor: overcloud-compute-0.localdomain
browbeat_ssh_config: ansible/ssh-config
username: heat-admin
#shaker scenarios require atleast 2 compute nodes
shaker:
enabled: true
@@ -0,0 +1,78 @@
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
from rally.plugins.openstack.scenarios.neutron import utils as neutron_utils
from rally.task import scenario
from rally.task import validation
from rally import consts
import subprocess
import time
@validation.required_services(consts.Service.NEUTRON)
@validation.required_openstack(admin=True)
@scenario.configure(context={"cleanup": ["neutron"]},
name="BrowbeatPlugin.PortCreateAssoicate")
class PortCreateAssoicate(neutron_utils.NeutronScenario):
def run(self, hypervisor, num_ports=1, user='heat-admin', ssh_config=None, wait=360,
network_create_args=None, subnet_create_args=None, create_port_args=None, **kwargs):
neutron = self.admin_clients("neutron")
ports = []
neutron.list_agents()
if create_port_args is None:
create_port_args = {'binding:host_id': hypervisor}
else:
create_port_args['binding:host_id'] = hypervisor
network = self._create_network(network_create_args or {})
self._create_subnet(network, subnet_create_args or {})
for port in range(num_ports):
create_port_args['network_id'] = network['network']['id']
port = neutron.create_port({"port": create_port_args})
ports.append(port)
server = hypervisor.split('.')[0]
ssh_cmd = "ssh -F {} {}@{}".format(ssh_config, user, server)
port_num = 0
for port in ports:
cmd = "sudo ovs-vsctl -- --may-exist add-port br-int {}".format(
"port-{}".format(port_num))
cmd += " -- set Interface {} type=internal".format(
"port-{}".format(port_num))
cmd += " -- set Interface {} external-ids:iface-status=active".format(
"port-{}".format(port_num))
cmd += " -- set Interface {} external-ids:attached-mac={}".format(
"port-{}".format(port_num), port['port']['mac_address'])
cmd += " -- set Interface {} external-ids:iface-id={}".format(
"port-{}".format(port_num), port['port']['id'])
subprocess.call("{} {}".format(ssh_cmd, cmd), shell=True)
port_num = port_num + 1
for look in range(30):
if 'ACTIVE' in neutron.show_port(port["port"]["id"])["port"]["status"]:
break
else:
time.sleep(1)
time.sleep(wait)
# Cleanup
if len(ports) > 0 :
for num in range(len(ports)):
subprocess.call(
"{} sudo ovs-vsctl del-port port-{}".format(ssh_cmd, num), shell=True)
for port in ports :
neutron.port_delete(port["port"]["id"])
@@ -0,0 +1,33 @@
{% set num_networks = num_networks or 1 %}
{% set sla_max_avg_duration = sla_max_avg_duration or 60 %}
{% set sla_max_failure = sla_max_failure or 0 %}
{% set sla_max_seconds = sla_max_seconds or 60 %}
---
BrowbeatPlugin.PortCreateAssoicate:
-
args:
network_create_args: {}
num_networks: {{num_networks}}
num_ports: {{num_ports}}
ssh_config: {{browbeat_ssh_config}}
hypervisor: {{hypervisor}}
user: {{username}}
runner:
concurrency: {{concurrency}}
times: {{times}}
type: "constant"
context:
users:
tenants: 10
users_per_tenant: 10
quotas:
neutron:
network: -1
port: -1
router: -1
subnet: -1
sla:
max_avg_duration: {{sla_max_avg_duration}}
max_seconds_per_iteration: {{sla_max_seconds}}
failure_rate:
max: {{sla_max_failure}}

0 comments on commit db8096c

Please sign in to comment.