Octavia Scenario to create loadbalancer resources
spawns jump host and a given number of clients It also creates a load balancer, listener, pool and adds those clients to the pool Change-Id: Id0d4f3e12167b00619fc71f57bf467c670a93098
This commit is contained in:
parent
7003ea8c4a
commit
6aca8b9bd9
@ -41,6 +41,7 @@ rally:
|
||||
- glance: rally/rally-plugins/glance
|
||||
- neutron: rally/rally-plugins/neutron
|
||||
- netcreate-boot: rally/rally-plugins/netcreate-boot
|
||||
- octavia: rally/rally-plugins/octavia
|
||||
- cinder: rally/rally-plugins/cinder
|
||||
- workloads: rally/rally-plugins/workloads
|
||||
shaker:
|
||||
@ -414,6 +415,17 @@ workloads:
|
||||
image_name: centos7
|
||||
flavor_name: m1.small
|
||||
file: rally/rally-plugins/cinder/boot_vm_attach_volume_list.yml
|
||||
- name: octavia-create-loadbalancer-resources
|
||||
enabled: true
|
||||
image_name: cirros
|
||||
flavor_name: m1.xtiny
|
||||
user: cirros
|
||||
ext_net_id:
|
||||
protocol: HTTP
|
||||
lb_algorithm: ROUND_ROBIN
|
||||
protocol_port: 80
|
||||
num_clients: 1
|
||||
file: rally/rally-plugins/octavia/octavia-create-loadabalancer-resources.yml
|
||||
|
||||
- name: plugin-workloads
|
||||
enabled: false
|
||||
|
@ -0,0 +1,191 @@
|
||||
# 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.
|
||||
|
||||
import logging
|
||||
import time
|
||||
|
||||
from rally.common import sshutils
|
||||
from rally_openstack import consts
|
||||
from rally_openstack.scenarios.vm import utils as vm_utils
|
||||
from rally_openstack.scenarios.neutron import utils as neutron_utils
|
||||
from rally_openstack.scenarios.octavia import utils as octavia_utils
|
||||
from rally.task import atomic
|
||||
from rally.task import scenario
|
||||
from rally.task import types
|
||||
from rally.task import validation
|
||||
|
||||
|
||||
LOG = logging.getLogger(__name__)
|
||||
|
||||
|
||||
@types.convert(image={"type": "glance_image"}, flavor={"type": "nova_flavor"})
|
||||
@validation.add("image_valid_on_flavor", flavor_param="flavor", image_param="image")
|
||||
@validation.add("required_services", services=[consts.Service.NEUTRON,
|
||||
consts.Service.NOVA,
|
||||
consts.Service.OCTAVIA])
|
||||
@validation.add("required_platform", platform="openstack", users=True)
|
||||
@validation.add("required_contexts", contexts=["network"])
|
||||
@scenario.configure(context={"cleanup@openstack": ["octavia", "neutron", "nova"],
|
||||
"keypair@openstack": {}, "allow_ssh@openstack": None},
|
||||
name="BrowbeatPlugin.OctaviaCreateLoadbalancerResources", platform="openstack")
|
||||
class OctaviaCreateLoadbalancerResources(vm_utils.VMScenario, neutron_utils.NeutronScenario,
|
||||
octavia_utils.OctaviaBase):
|
||||
|
||||
@atomic.action_timer("neutron.create_router")
|
||||
def _create_router(self, router_create_args):
|
||||
"""Create neutron router.
|
||||
:param router_create_args: POST /v2.0/routers request options
|
||||
:returns: neutron router dict
|
||||
"""
|
||||
return self.admin_clients("neutron").create_router({"router": router_create_args})
|
||||
|
||||
def build_jump_host(self, ext_net_name, image, flavor, user, password=None, **kwargs):
|
||||
keyname = self.context["user"]["keypair"]["name"]
|
||||
LOG.info("Building Jump Host with key : {}".format(keyname))
|
||||
jump_host, jump_host_ip = self._boot_server_with_fip(image,
|
||||
flavor,
|
||||
True,
|
||||
floating_network=ext_net_name,
|
||||
key_name=keyname,
|
||||
**kwargs)
|
||||
# wait for ping
|
||||
self._wait_for_ping(jump_host_ip["ip"])
|
||||
|
||||
# open ssh connection
|
||||
jump_ssh = sshutils.SSH(user, jump_host_ip["ip"], 22, self.context[
|
||||
"user"]["keypair"]["private"], password)
|
||||
|
||||
# check for connectivity
|
||||
self._wait_for_ssh(jump_ssh)
|
||||
|
||||
# write id_rsa(private key) to get to guests
|
||||
self._run_command_over_ssh(jump_ssh, {"remote_path": "rm -rf ~/.ssh"})
|
||||
self._run_command_over_ssh(jump_ssh, {"remote_path": "mkdir ~/.ssh"})
|
||||
jump_ssh.run(
|
||||
"cat > ~/.ssh/id_rsa",
|
||||
stdin=self.context["user"]["keypair"]["private"])
|
||||
jump_ssh.execute("chmod 0600 ~/.ssh/id_rsa")
|
||||
return jump_ssh, jump_host_ip, jump_host
|
||||
|
||||
def create_clients(self, jump_ssh, num_clients, image, flavor, user, **kwargs):
|
||||
_clients = []
|
||||
for i in range(num_clients):
|
||||
LOG.info("Launching Client : {}".format(i))
|
||||
server = self._boot_server(
|
||||
image,
|
||||
flavor,
|
||||
key_name=self.context["user"]["keypair"]["name"],
|
||||
**kwargs)
|
||||
for net in server.addresses:
|
||||
network_name = net
|
||||
break
|
||||
if network_name is None:
|
||||
return False
|
||||
# IP Address
|
||||
_clients.append(
|
||||
str(server.addresses[network_name][0]["addr"]))
|
||||
LOG.info(_clients)
|
||||
return _clients
|
||||
|
||||
def run(self, image, flavor, user, lb_algorithm, protocol, protocol_port,
|
||||
ext_net_id, router_create_args=None, network_create_args=None,
|
||||
subnet_create_args=None, description=None, admin_state=None,
|
||||
listeners=None, flavor_id=None, provider=None, num_clients=2,
|
||||
vip_qos_policy_id=None, password="", **kwargs):
|
||||
ext_net_name = None
|
||||
if ext_net_id:
|
||||
ext_net_name = self.clients("neutron").show_network(
|
||||
ext_net_id)["network"]["name"]
|
||||
router_create_args["name"] = self.generate_random_name()
|
||||
router_create_args["tenant_id"] = self.context["tenant"]["id"]
|
||||
router_create_args.setdefault("external_gateway_info",
|
||||
{"network_id": ext_net_id, "enable_snat": True})
|
||||
router = self._create_router(router_create_args)
|
||||
|
||||
project_id = self.context["tenant"]["id"]
|
||||
network = self._create_network(network_create_args or {})
|
||||
subnet = self._create_subnet(network, subnet_create_args or {})
|
||||
self._add_interface_router(subnet['subnet'], router['router'])
|
||||
kwargs["nics"] = [{"net-id": network['network']['id']}]
|
||||
subnet_id = subnet['subnet']['id']
|
||||
loadbalancers = []
|
||||
|
||||
LOG.info("Creating a load balancer")
|
||||
# create a loadbalancer, listener, pool and add members to the pool
|
||||
|
||||
lb = self.octavia.load_balancer_create(
|
||||
subnet_id=subnet_id,
|
||||
admin_state=True,
|
||||
project_id=project_id)
|
||||
loadbalancers.append(lb)
|
||||
LOG.info(loadbalancers)
|
||||
LOG.info("Waiting for the load balancer to be active")
|
||||
for loadbalancer in loadbalancers:
|
||||
self.octavia.wait_for_loadbalancer_prov_status(loadbalancer)
|
||||
LOG.info("Loadbalancer")
|
||||
LOG.info(loadbalancer)
|
||||
time.sleep(90)
|
||||
lb_id = lb["id"]
|
||||
listener_args = {
|
||||
"name": self.generate_random_name(),
|
||||
"loadbalancer_id": lb_id,
|
||||
"protocol": protocol,
|
||||
"protocol_port": protocol_port,
|
||||
"connection_limit": -1,
|
||||
"admin_state_up": True,
|
||||
"default_tls_container_ref": None,
|
||||
"description": None,
|
||||
"insert_headers": None,
|
||||
"l7policies": [],
|
||||
"sni_container_refs": [],
|
||||
"timeout_client_data": 50000,
|
||||
"timeout_member_connect": 5000,
|
||||
"timeout_member_data": 50000,
|
||||
"timeout_tcp_inspect": 0,
|
||||
}
|
||||
LOG.info("Creating a listener")
|
||||
listener = self.octavia.listener_create(json={"listener": listener_args})
|
||||
LOG.info(listener)
|
||||
time.sleep(30)
|
||||
|
||||
LOG.info("Creating a pool")
|
||||
pool = self.octavia.pool_create(
|
||||
lb_id=lb["id"],
|
||||
protocol=protocol,
|
||||
lb_algorithm=lb_algorithm,
|
||||
listener_id=listener["listener"]["id"],
|
||||
admin_state_up=True)
|
||||
|
||||
jump_ssh, jump_host_ip, jump_host = self.build_jump_host(
|
||||
ext_net_name, image, flavor, user, **kwargs)
|
||||
_clients = self.create_clients(
|
||||
jump_ssh, num_clients, image, flavor, user, **kwargs)
|
||||
|
||||
# member_create(pool_id, args), subnet_id, address, protocol_port, pool_id
|
||||
time.sleep(60)
|
||||
for client_ip in _clients:
|
||||
member_args = {
|
||||
"address": client_ip,
|
||||
"protocol_port": protocol_port,
|
||||
"subnet_id": subnet_id,
|
||||
"admin_state_up": True,
|
||||
"weight": 1,
|
||||
"monitor_port": None,
|
||||
"monitor_address": None,
|
||||
"name": self.generate_random_name(),
|
||||
"backup": False,
|
||||
}
|
||||
LOG.info("Adding member : {} to the pool".format(client_ip))
|
||||
self.octavia.member_create(
|
||||
pool["id"],
|
||||
json={"member": member_args})
|
||||
time.sleep(30)
|
@ -0,0 +1,54 @@
|
||||
{% set image_name = image_name or 'centos7' %}
|
||||
{% set flavor_name = flavor_name or 'm1.small' %}
|
||||
{% set num_clients = num_clients or 2 %}
|
||||
{% set password = password or 'None' %}
|
||||
{% set protocol = protocol or 'HTTP' %}
|
||||
{% set lb_algorithm = lb_algorithm or 'ROUND_ROBIN' %}
|
||||
{% set protocol_port = protocol_port or 80 %}
|
||||
{% 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.OctaviaCreateLoadbalancerResources:
|
||||
-
|
||||
args:
|
||||
image:
|
||||
name: '{{image_name}}'
|
||||
flavor:
|
||||
name: '{{flavor_name}}'
|
||||
network_create_args: {}
|
||||
router_create_args: {}
|
||||
subnet_create_args: {}
|
||||
user: '{{user}}'
|
||||
password: '{{password}}'
|
||||
num_clients: {{num_clients}}
|
||||
protocol: '{{protocol}}'
|
||||
lb_algorithm: '{{lb_algorithm}}'
|
||||
protocol_port: '{{protocol_port}}'
|
||||
ext_net_id: '{{ext_net_id}}'
|
||||
runner:
|
||||
concurrency: {{concurrency}}
|
||||
times: {{times}}
|
||||
type: "constant"
|
||||
context:
|
||||
users:
|
||||
tenants: 2
|
||||
users_per_tenant: 2
|
||||
network: {}
|
||||
quotas:
|
||||
neutron:
|
||||
network: -1
|
||||
port: -1
|
||||
router: -1
|
||||
subnet: -1
|
||||
floatingip: -1
|
||||
nova:
|
||||
instances: -1
|
||||
cores: -1
|
||||
ram: -1
|
||||
sla:
|
||||
max_avg_duration: {{sla_max_avg_duration}}
|
||||
max_seconds_per_iteration: {{sla_max_seconds}}
|
||||
failure_rate:
|
||||
max: {{sla_max_failure}}
|
||||
|
Loading…
x
Reference in New Issue
Block a user