aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorManuel Buil <mbuil@suse.com>2017-12-14 12:13:19 +0100
committerManuel Buil <mbuil@suse.com>2017-12-21 17:28:32 +0100
commitdeca6d35cd4ba0c6444b92d15b07ade1169d0ef3 (patch)
tree36abacae739f5c6bb494c2502b6ad3e37446d676
parent163aacce943bf07a5603587b9ae681ff9bf4605b (diff)
Migrate to SNAPs openstack library
Functest is deprecating its openstack library which we were using extensively We need then to move to an alternative and the best appears to be SNAPs Change-Id: Icaa0b9f1ec580545b9d0faa88be2080a310deaf7 Signed-off-by: Manuel Buil<mbuil@suse.com>
-rw-r--r--requirements.txt1
-rw-r--r--sfc/lib/cleanup.py92
-rw-r--r--sfc/lib/config.py10
-rw-r--r--sfc/lib/openstack_utils.py363
-rw-r--r--sfc/lib/topology_shuffler.py5
-rw-r--r--sfc/tests/functest/config.yaml3
-rw-r--r--sfc/tests/functest/run_sfc_tests.py22
-rw-r--r--sfc/tests/functest/setup_scripts/delete.sh23
-rw-r--r--sfc/tests/functest/sfc_one_chain_two_service_functions.py94
-rw-r--r--sfc/tests/functest/sfc_symmetric_chain.py104
-rw-r--r--sfc/tests/functest/sfc_two_chains_SSH_and_HTTP.py92
11 files changed, 376 insertions, 433 deletions
diff --git a/requirements.txt b/requirements.txt
index 239c0b1b..dce5e2e0 100644
--- a/requirements.txt
+++ b/requirements.txt
@@ -11,3 +11,4 @@ python-novaclient>=9.0.0 # Apache-2.0
python-tackerclient>=0.8.0 # Apache-2.0
PyYAML>=3.10.0 # MIT
opnfv
+snaps
diff --git a/sfc/lib/cleanup.py b/sfc/lib/cleanup.py
index 9c7b5484..32835fa8 100644
--- a/sfc/lib/cleanup.py
+++ b/sfc/lib/cleanup.py
@@ -1,97 +1,85 @@
import sys
import time
import logging
-import functest.utils.openstack_utils as os_utils
-import sfc.lib.openstack_tacker as os_tacker
-import sfc.lib.utils as utils
+import sfc.lib.openstack_utils as os_sfc_utils
+import sfc.lib.odl_utils as odl_utils
logger = logging.getLogger(__name__)
def delete_odl_resources(odl_ip, odl_port, resource):
- rsrc_list = utils.get_odl_resource_list(odl_ip, odl_port, resource)
- elem_names = utils.odl_resource_list_names(resource, rsrc_list)
+ rsrc_list = odl_utils.get_odl_resource_list(odl_ip, odl_port, resource)
+ elem_names = odl_utils.odl_resource_list_names(resource, rsrc_list)
for elem in elem_names:
logger.info("Removing ODL resource: {0}/{1}".format(resource, elem))
- utils.delete_odl_resource_elem(odl_ip, odl_port, resource, elem)
+ odl_utils.delete_odl_resource_elem(odl_ip, odl_port, resource, elem)
def delete_odl_ietf_access_lists(odl_ip, odl_port):
- acl_list = utils.get_odl_acl_list(odl_ip, odl_port)
- acl_types_names = utils.odl_acl_types_names(acl_list)
+ acl_list = odl_utils.get_odl_acl_list(odl_ip, odl_port)
+ acl_types_names = odl_utils.odl_acl_types_names(acl_list)
for acl_type, acl_name in acl_types_names:
- utils.delete_odl_acl(odl_ip, odl_port, acl_type, acl_name)
+ odl_utils.delete_odl_acl(odl_ip, odl_port, acl_type, acl_name)
def delete_vnfds():
- t = os_tacker.get_tacker_client()
- vnfds = os_tacker.list_vnfds(t)
+ t = os_sfc_utils.get_tacker_client()
+ vnfds = os_sfc_utils.list_vnfds(t)
if vnfds is None:
return
for vnfd in vnfds:
logger.info("Removing vnfd: {0}".format(vnfd))
- os_tacker.delete_vnfd(t, vnfd_id=vnfd)
+ os_sfc_utils.delete_vnfd(t, vnfd_id=vnfd)
def delete_vnfs():
- t = os_tacker.get_tacker_client()
- vnfs = os_tacker.list_vnfs(t)
+ t = os_sfc_utils.get_tacker_client()
+ vnfs = os_sfc_utils.list_vnfs(t)
if vnfs is None:
return
for vnf in vnfs:
logger.info("Removing vnf: {0}".format(vnf))
- os_tacker.delete_vnf(t, vnf_id=vnf)
+ os_sfc_utils.delete_vnf(t, vnf_id=vnf)
def delete_vnffgs():
- t = os_tacker.get_tacker_client()
- vnffgs = os_tacker.list_vnffgs(t)
+ t = os_sfc_utils.get_tacker_client()
+ vnffgs = os_sfc_utils.list_vnffgs(t)
if vnffgs is None:
return
for vnffg in reversed(vnffgs):
logger.info("Removing vnffg: {0}".format(vnffg))
- os_tacker.delete_vnffg(t, vnffg_id=vnffg)
+ os_sfc_utils.delete_vnffg(t, vnffg_id=vnffg)
def delete_vnffgds():
- t = os_tacker.get_tacker_client()
- vnffgds = os_tacker.list_vnffgds(t)
+ t = os_sfc_utils.get_tacker_client()
+ vnffgds = os_sfc_utils.list_vnffgds(t)
if vnffgds is None:
return
for vnffgd in vnffgds:
logger.info("Removing vnffgd: {0}".format(vnffgd))
- os_tacker.delete_vnffgd(t, vnffgd_id=vnffgd)
+ os_sfc_utils.delete_vnffgd(t, vnffgd_id=vnffgd)
def delete_vims():
- t = os_tacker.get_tacker_client()
- vims = os_tacker.list_vims(t)
+ t = os_sfc_utils.get_tacker_client()
+ vims = os_sfc_utils.list_vims(t)
if vims is None:
return
for vim in vims:
logger.info("Removing vim: {0}".format(vim))
- os_tacker.delete_vim(t, vim_id=vim)
+ os_sfc_utils.delete_vim(t, vim_id=vim)
-def delete_floating_ips():
- n = os_utils.get_nova_client()
- fips = os_utils.get_floating_ips(n)
- if fips is None:
- return
- for fip in fips:
- logger.info("Removing floating ip: {0}".format(fip.ip))
- os_utils.delete_floating_ip(n, fip.id)
-
-
-def delete_instances():
- n = os_utils.get_nova_client()
- instances = os_utils.get_instances(n)
- if instances is None:
- return
- for inst in instances:
- logger.info("Removing instance: {0}".format(inst.id))
- os_utils.delete_instance(n, inst.id)
+# Creators is a list full of SNAPs objects
+def delete_openstack_objects(creators):
+ for creator in reversed(creators):
+ try:
+ creator.clean()
+ except Exception as e:
+ logger.error('Unexpected error cleaning - %s', e)
def cleanup_odl(odl_ip, odl_port):
@@ -102,21 +90,29 @@ def cleanup_odl(odl_ip, odl_port):
delete_odl_ietf_access_lists(odl_ip, odl_port)
-def cleanup(odl_ip=None, odl_port=None):
+def cleanup(creators, odl_ip=None, odl_port=None):
+ delete_vnffgs()
+ delete_vnffgds()
+ delete_vnfs()
+ time.sleep(20)
+ delete_vnfds()
+ delete_vims()
+ delete_openstack_objects(creators)
+ if odl_ip is not None and odl_port is not None:
+ cleanup_odl(odl_ip, odl_port)
+
+
+def cleanup_from_bash(odl_ip=None, odl_port=None):
delete_vnffgs()
delete_vnffgds()
delete_vnfs()
time.sleep(20)
delete_vnfds()
delete_vims()
- delete_floating_ips()
- delete_instances()
if odl_ip is not None and odl_port is not None:
cleanup_odl(odl_ip, odl_port)
if __name__ == '__main__':
if len(sys.argv) > 2:
- cleanup(sys.argv[1], sys.argv[2])
- else:
- cleanup()
+ cleanup_from_bash(sys.argv[1], sys.argv[2])
diff --git a/sfc/lib/config.py b/sfc/lib/config.py
index fe95e983..bc955d8b 100644
--- a/sfc/lib/config.py
+++ b/sfc/lib/config.py
@@ -13,7 +13,7 @@ import yaml
import sfc
import functest
-import sfc.lib.utils as test_utils
+import sfc.lib.test_utils as test_utils
from functest.utils.constants import CONST
import logging
import functest.utils.functest_utils as ft_utils
@@ -83,16 +83,12 @@ class CommonConfig(object):
"defaults.vcpu_count", self.config_file)
self.image_name = ft_utils.get_parameter_from_yaml(
"defaults.image_name", self.config_file)
- self.image_file_name = ft_utils.get_parameter_from_yaml(
- "defaults.image_file_name", self.config_file)
self.image_format = ft_utils.get_parameter_from_yaml(
"defaults.image_format", self.config_file)
- self.url = ft_utils.get_parameter_from_yaml(
- "defaults.url", self.config_file)
+ self.image_url = ft_utils.get_parameter_from_yaml(
+ "defaults.image_url", self.config_file)
self.dir_functest_data = ft_utils.get_functest_config(
"general.dir.functest_data")
- self.image_path = os.path.join(
- self.dir_functest_data, self.image_file_name)
class TestcaseConfig(object):
diff --git a/sfc/lib/openstack_utils.py b/sfc/lib/openstack_utils.py
index 2d4ecff3..f55f62e8 100644
--- a/sfc/lib/openstack_utils.py
+++ b/sfc/lib/openstack_utils.py
@@ -3,200 +3,207 @@ import os
import time
import json
import yaml
-import functest.utils.openstack_utils as os_utils
from tackerclient.tacker import client as tackerclient
from functest.utils.constants import CONST
+from snaps.openstack.tests import openstack_tests
-logger = logging.getLogger(__name__)
-DEFAULT_TACKER_API_VERSION = '1.0'
+from snaps.openstack.create_image import OpenStackImage
+from snaps.config.image import ImageConfig
+from snaps.config.flavor import FlavorConfig
+from snaps.openstack.create_flavor import OpenStackFlavor
-def get_av_zones():
- '''
- Return the availability zone each host belongs to
- '''
- nova_client = os_utils.get_nova_client()
- hosts = os_utils.get_hypervisors(nova_client)
- return ['nova::{0}'.format(host) for host in hosts]
+from snaps.config.network import NetworkConfig, SubnetConfig, PortConfig
+from snaps.openstack.create_network import OpenStackNetwork
+from snaps.config.router import RouterConfig
+from snaps.openstack.create_router import OpenStackRouter
-def get_compute_client():
- '''
- Return the compute where the client sits
- '''
- nova_client = os_utils.get_nova_client()
- hosts = os_utils.get_hypervisors(nova_client)
- for compute in hosts:
- vms = nova_client.servers.list(search_opts={'host': compute})
- for vm in vms:
- if "client" in vm.name:
- return compute
- return False
-
-
-def setup_neutron(neutron_client, net, subnet, router, subnet_cidr):
- n_dict = os_utils.create_network_full(neutron_client,
- net,
- subnet,
- router,
- subnet_cidr)
- if not n_dict:
- logger.error("failed to create neutron network")
- return False
-
- return n_dict["net_id"]
-
-
-def create_secgroup_rule(neutron_client, sg_id, direction, protocol,
- port_range_min=None, port_range_max=None):
- # We create a security group in 2 steps
- # 1 - we check the format and set the json body accordingly
- # 2 - we call neturon client to create the security group
-
- # Format check
- json_body = {'security_group_rule': {'direction': direction,
- 'security_group_id': sg_id,
- 'protocol': protocol}}
- # parameters may be
- # - both None => we do nothing
- # - both Not None => we add them to the json description
- # but one cannot be None is the other is not None
- if (port_range_min is not None and port_range_max is not None):
- # add port_range in json description
- json_body['security_group_rule']['port_range_min'] = port_range_min
- json_body['security_group_rule']['port_range_max'] = port_range_max
- logger.debug("Security_group format set (port range included)")
- else:
- # either both port range are set to None => do nothing
- # or one is set but not the other => log it and return False
- if port_range_min is None and port_range_max is None:
- logger.debug("Security_group format set (no port range mentioned)")
- else:
- logger.error("Bad security group format."
- "One of the port range is not properly set:"
- "range min: {},"
- "range max: {}".format(port_range_min,
- port_range_max))
- return False
-
- # Create security group using neutron client
- try:
- neutron_client.create_security_group_rule(json_body)
- return True
- except:
- return False
-
-
-def setup_ingress_egress_secgroup(neutron_client, protocol,
- min_port=None, max_port=None):
- secgroups = os_utils.get_security_groups(neutron_client)
- for sg in secgroups:
- # TODO: the version of the create_secgroup_rule function in
- # functest swallows the exception thrown when a secgroup rule
- # already exists and prints a ton of noise in the test output.
- # Instead of making changes in functest code this late in the
- # release cycle, we keep our own version without the exception
- # logging. We must find a way to properly cleanup sec group
- # rules using "functest openstack clean" or pretty printing the
- # specific exception in the next release
- create_secgroup_rule(neutron_client, sg['id'],
- 'ingress', protocol,
- port_range_min=min_port,
- port_range_max=max_port)
- create_secgroup_rule(neutron_client, sg['id'],
- 'egress', protocol,
- port_range_min=min_port,
- port_range_max=max_port)
-
-
-def create_security_groups(neutron_client, secgroup_name, secgroup_descr):
- sg_id = os_utils.create_security_group_full(neutron_client,
- secgroup_name, secgroup_descr)
- setup_ingress_egress_secgroup(neutron_client, "icmp")
- setup_ingress_egress_secgroup(neutron_client, "tcp", 22, 22)
- setup_ingress_egress_secgroup(neutron_client, "tcp", 80, 80)
- setup_ingress_egress_secgroup(neutron_client, "udp", 67, 68)
- return sg_id
-
-
-def create_instance(nova_client, name, flavor, image_id, network_id, sg_id,
- secgroup_name=None, fixed_ip=None,
- av_zone='', userdata=None, files=None):
- logger.info("Creating instance '%s'..." % name)
- logger.debug(
- "Configuration:\n name=%s \n flavor=%s \n image=%s \n"
- " network=%s\n secgroup=%s \n hypervisor=%s \n"
- " fixed_ip=%s\n files=%s\n userdata=\n%s\n"
- % (name, flavor, image_id, network_id, sg_id,
- av_zone, fixed_ip, files, userdata))
- instance = os_utils.create_instance_and_wait_for_active(
- flavor,
- image_id,
- network_id,
- name,
- config_drive=True,
- userdata=userdata,
- av_zone=av_zone,
- fixed_ip=fixed_ip,
- files=files)
-
- if instance is None:
- logger.error("Error while booting instance.")
- return None
+from snaps.config.security_group import (
+ Protocol, SecurityGroupRuleConfig, Direction, SecurityGroupConfig)
- if secgroup_name:
- logger.debug("Adding '%s' to security group '%s'..."
- % (name, secgroup_name))
- else:
- logger.debug("Adding '%s' to security group '%s'..."
- % (name, sg_id))
- os_utils.add_secgroup_to_instance(nova_client, instance.id, sg_id)
+from snaps.openstack.create_security_group import OpenStackSecurityGroup
- return instance
+import snaps.openstack.create_instance as cr_inst
+from snaps.config.vm_inst import VmInstanceConfig, FloatingIpConfig
+from snaps.openstack.utils import (
+ nova_utils, neutron_utils, glance_utils, heat_utils, keystone_utils)
-def assign_floating_ip(nova_client, neutron_client, instance_id):
- instance = nova_client.servers.get(instance_id)
- floating_ip = os_utils.create_floating_ip(neutron_client)['fip_addr']
- instance.add_floating_ip(floating_ip)
- logger.info("Assigned floating ip [%s] to instance [%s]"
- % (floating_ip, instance.name))
+logger = logging.getLogger(__name__)
+DEFAULT_TACKER_API_VERSION = '1.0'
- return floating_ip
+class OpenStackSFC:
-def get_nova_id(tacker_client, resource, vnf_id=None, vnf_name=None):
- vnf = get_vnf(tacker_client, vnf_id, vnf_name)
- try:
- if vnf is None:
- raise Exception("VNF not found")
- heat = os_utils.get_heat_client()
- resource = heat.resources.get(vnf['instance_id'], resource)
- return resource.attributes['id']
- except:
- logger.error("Cannot get nova ID for VNF (id='%s', name='%s')"
- % (vnf_id, vnf_name))
- return None
+ def __init__(self):
+ self.os_creds = openstack_tests.get_credentials(
+ os_env_file=CONST.__getattribute__('openstack_creds'))
+ self.creators = []
+ self.nova = nova_utils.nova_client(self.os_creds)
+ self.neutron = neutron_utils.neutron_client(self.os_creds)
+ self.glance = glance_utils.glance_client(self.os_creds)
+ self.heat = heat_utils.heat_client(self.os_creds)
+ def register_glance_image(self, name, url, img_format, public):
+ image_settings = ImageConfig(name=name, img_format=img_format, url=url,
+ public=public, image_user='admin')
-def get_neutron_interfaces(vm):
- '''
- Get the interfaces of an instance
- '''
- nova_client = os_utils.get_nova_client()
- interfaces = nova_client.servers.interface_list(vm.id)
- return interfaces
+ # TODO Remove this when tacker is part of SNAPS
+ self.image_settings = image_settings
+ image_creator = OpenStackImage(self.os_creds, image_settings)
+ image_creator.create()
-def get_client_port_id(vm):
- '''
- Get the neutron port id of the client
- '''
- interfaces = get_neutron_interfaces(vm)
- if len(interfaces) > 1:
- raise Exception("Client has more than one interface. Not expected!")
- return interfaces[0].id
+ self.creators.append(image_creator)
+ return image_creator
+
+ def create_flavor(self, name, ram, disk, vcpus):
+ flavor_settings = FlavorConfig(name=name, ram=ram, disk=disk,
+ vcpus=vcpus)
+ flavor_creator = OpenStackFlavor(self.os_creds, flavor_settings)
+ flavor = flavor_creator.create()
+
+ self.creators.append(flavor_creator)
+ return flavor
+
+ def create_network_infrastructure(self, net_name, subnet_name, subnet_cidr,
+ router_name):
+ # Network and subnet
+ subnet_settings = SubnetConfig(name=subnet_name, cidr=subnet_cidr)
+ network_settings = NetworkConfig(name=net_name,
+ subnet_settings=[subnet_settings])
+ network_creator = OpenStackNetwork(self.os_creds, network_settings)
+ network = network_creator.create()
+
+ self.creators.append(network_creator)
+
+ # Router
+ ext_network_name = CONST.__getattribute__('EXTERNAL_NETWORK')
+
+ router_settings = RouterConfig(name=router_name,
+ external_gateway=ext_network_name,
+ internal_subnets=[subnet_name])
+
+ router_creator = OpenStackRouter(self.os_creds, router_settings)
+ router = router_creator.create()
+
+ self.creators.append(router_creator)
+
+ return network, router
+
+ def create_security_group(self, sec_grp_name):
+ rule_ping = SecurityGroupRuleConfig(sec_grp_name=sec_grp_name,
+ direction=Direction.ingress,
+ protocol=Protocol.icmp)
+
+ rule_ssh = SecurityGroupRuleConfig(sec_grp_name=sec_grp_name,
+ direction=Direction.ingress,
+ protocol=Protocol.tcp,
+ port_range_min=22,
+ port_range_max=22)
+
+ rule_http = SecurityGroupRuleConfig(sec_grp_name=sec_grp_name,
+ direction=Direction.ingress,
+ protocol=Protocol.tcp,
+ port_range_min=80,
+ port_range_max=80)
+
+ rules = [rule_ping, rule_ssh, rule_http]
+
+ secgroup_settings = SecurityGroupConfig(name=sec_grp_name,
+ rule_settings=rules)
+
+ sec_group_creator = OpenStackSecurityGroup(self.os_creds,
+ secgroup_settings)
+ sec_group = sec_group_creator.create()
+
+ self.creators.append(sec_group_creator)
+
+ return sec_group
+
+ def create_instance(self, vm_name, flavor_name, image_creator, network,
+ secgrp, av_zone):
+
+ port_settings = PortConfig(name=vm_name + '-port',
+ network_name=network.name)
+
+ instance_settings = VmInstanceConfig(
+ name=vm_name, flavor=flavor_name,
+ security_group_names=str(secgrp.name),
+ port_settings=[port_settings],
+ availability_zone=av_zone)
+
+ instance_creator = cr_inst.OpenStackVmInstance(
+ self.os_creds,
+ instance_settings,
+ image_creator.image_settings)
+
+ instance = instance_creator.create()
+
+ self.creators.append(instance_creator)
+ return instance, instance_creator
+
+ def get_av_zones(self):
+ '''
+ Return the availability zone each host belongs to
+ '''
+ hosts = nova_utils.get_hypervisor_hosts(self.nova)
+ return ['nova::{0}'.format(host) for host in hosts]
+
+ def get_compute_client(self):
+ '''
+ Return the compute where the client sits
+ '''
+ compute = nova_utils.get_server(self.nova, server_name='client')
+ return compute
+
+ def assign_floating_ip(self, router, vm, vm_creator):
+ '''
+ Assign a floating ips to all the VMs
+ '''
+ name = vm.name + "-float"
+ port_name = vm.ports[0].name
+ float_ip = FloatingIpConfig(name=name,
+ port_name=port_name,
+ router_name=router.name)
+ ip = vm_creator.add_floating_ip(float_ip)
+
+ return ip.ip
+
+ # We need this function because tacker VMs cannot be created through SNAPs
+ def assign_floating_ip_vnfs(self, router):
+ '''
+ Assign a floating ips to all the SFs
+ '''
+ stacks = self.heat.stacks.list()
+ fips = []
+ for stack in stacks:
+ servers = heat_utils.get_stack_servers(self.heat,
+ self.nova,
+ self.neutron,
+ stack)
+ sf_creator = cr_inst.generate_creator(self.os_creds,
+ servers[0],
+ self.image_settings)
+ port_name = servers[0].ports[0].name
+ name = servers[0].name + "-float"
+ float_ip = FloatingIpConfig(name=name,
+ port_name=port_name,
+ router_name=router.name)
+ ip = sf_creator.add_floating_ip(float_ip)
+ fips.append(ip.ip)
+
+ return fips
+
+ def get_client_port_id(self, vm):
+ '''
+ Get the neutron port id of the client
+ '''
+ port_id = neutron_utils.get_port(self.neutron,
+ port_name=vm.name + "-port")
+ return port_id
# TACKER SECTION #
@@ -210,7 +217,11 @@ def get_tacker_client_version():
def get_tacker_client(other_creds={}):
- sess = os_utils.get_session(other_creds)
+ creds_override = None
+ os_creds = openstack_tests.get_credentials(
+ os_env_file=CONST.__getattribute__('openstack_creds'),
+ overrides=creds_override)
+ sess = keystone_utils.keystone_session(os_creds)
return tackerclient.Client(get_tacker_client_version(), session=sess)
diff --git a/sfc/lib/topology_shuffler.py b/sfc/lib/topology_shuffler.py
index 24c8f875..f678137a 100644
--- a/sfc/lib/topology_shuffler.py
+++ b/sfc/lib/topology_shuffler.py
@@ -1,7 +1,6 @@
import datetime
import random
import logging
-import sfc.lib.utils as sfc_utils
logger = logging.getLogger(__name__)
@@ -78,7 +77,7 @@ def get_seed():
return seed
-def topology(vnf_names, av_zones=None, seed=None):
+def topology(vnf_names, os_sfc_util, av_zones=None, seed=None):
'''
Get the topology for client, server and vnfs.
The topology is returned as a dict in the form
@@ -93,7 +92,7 @@ def topology(vnf_names, av_zones=None, seed=None):
'''
if av_zones is None:
- av_zones = sfc_utils.get_av_zones()
+ av_zones = os_sfc_util.get_av_zones()
if len(av_zones) < 2 or seed is None:
# fall back to nova availability zone
diff --git a/sfc/tests/functest/config.yaml b/sfc/tests/functest/config.yaml
index 294ba7c7..be37e626 100644
--- a/sfc/tests/functest/config.yaml
+++ b/sfc/tests/functest/config.yaml
@@ -6,7 +6,6 @@ defaults:
disk_size_in_gb: 10
vcpu_count: 1
image_name: sfc_nsh_euphrates
- image_file_name: sfc_nsh_euphrates.qcow2
installer:
fuel:
user: root
@@ -19,7 +18,7 @@ defaults:
user: root
pkey_file: "/root/.ssh/id_rsa"
image_format: qcow2
- url: "http://artifacts.opnfv.org/sfc/images"
+ image_url: "http://artifacts.opnfv.org/sfc/images/sfc_nsh_euphrates.qcow2"
vnfd-dir: "vnfd-templates"
vnfd-default-params-file: "test-vnfd-default-params.yaml"
diff --git a/sfc/tests/functest/run_sfc_tests.py b/sfc/tests/functest/run_sfc_tests.py
index 49bf6c20..a1e73040 100644
--- a/sfc/tests/functest/run_sfc_tests.py
+++ b/sfc/tests/functest/run_sfc_tests.py
@@ -14,13 +14,12 @@ import time
import sys
import yaml
-from functest.utils import openstack_utils as os_utils
from functest.core import testcase
from opnfv.utils import ovs_logger as ovs_log
from opnfv.deployment.factory import Factory as DeploymentFactory
from sfc.lib import cleanup as sfc_cleanup
from sfc.lib import config as sfc_config
-from sfc.lib import utils as sfc_utils
+from sfc.lib import odl_utils as odl_utils
from collections import OrderedDict
import logging
@@ -127,20 +126,7 @@ class SfcFunctest(testcase.TestCase):
self.__disable_heat_resource_finder_cache(nodes,
COMMON_CONFIG.installer_type)
- if COMMON_CONFIG.installer_type == 'fuel':
- a_controller = [node for node in nodes
- if node.is_controller()][0]
-
- rc_file = self.__fetch_tackerc_file(a_controller)
- os_utils.source_credentials(rc_file)
-
- logger.info("Updating env with {0}".format(rc_file))
- logger.info("OS credentials:")
- for var, value in os.environ.items():
- if var.startswith("OS_"):
- logger.info("\t{0}={1}".format(var, value))
-
- odl_ip, odl_port = sfc_utils.get_odl_ip_port(nodes)
+ odl_ip, odl_port = odl_utils.get_odl_ip_port(nodes)
ovs_logger = ovs_log.OVSLogger(
os.path.join(COMMON_CONFIG.sfc_test_dir, 'ovs-logs'),
@@ -168,7 +154,7 @@ class SfcFunctest(testcase.TestCase):
package=None)
start_time = time.time()
try:
- result = t.main()
+ result, creators = t.main()
except Exception as e:
logger.error("Exception when executing: %s" % test_name)
logger.error(e)
@@ -190,7 +176,7 @@ class SfcFunctest(testcase.TestCase):
dic = {"duration": duration, "status": status}
self.details.update({test_name: dic})
- sfc_cleanup.cleanup(odl_ip=odl_ip, odl_port=odl_port)
+ sfc_cleanup.cleanup(creators, odl_ip=odl_ip, odl_port=odl_port)
self.stop_time = time.time()
diff --git a/sfc/tests/functest/setup_scripts/delete.sh b/sfc/tests/functest/setup_scripts/delete.sh
index 908d81fc..3333c52b 100644
--- a/sfc/tests/functest/setup_scripts/delete.sh
+++ b/sfc/tests/functest/setup_scripts/delete.sh
@@ -1,17 +1,8 @@
# Remember to source the env variables $creds before
-tacker sfc-classifier-delete red_http
-tacker sfc-classifier-delete blue_ssh
-tacker sfc-classifier-delete red_ssh
-tacker sfc-classifier-delete blue_http
-tacker sfc-delete red
-tacker sfc-delete blue
-tacker vnf-delete testVNF1
-tacker vnf-delete testVNF2
-tacker vnfd-delete test-vnfd1
-tacker vnfd-delete test-vnfd2
-openstack stack delete sfc --y
-openstack stack delete sfc_test1 --y
-openstack stack delete sfc_test2 --y
-nova delete client
-nova delete server
-for line in $(neutron floatingip-list | cut -d" " -f2);do neutron floatingip-delete $line;done
+FILE=$(readlink -f $0)
+FILE_PATH=$(dirname $FILE)
+cd $FILE_PATH
+python ../../../lib/cleanup.py $1 $2
+openstack server delete client
+openstack server delete server
+for line in $(openstack floating ip list);do openstack floating ip delete $line;done
diff --git a/sfc/tests/functest/sfc_one_chain_two_service_functions.py b/sfc/tests/functest/sfc_one_chain_two_service_functions.py
index 86fab534..043b5a6a 100644
--- a/sfc/tests/functest/sfc_one_chain_two_service_functions.py
+++ b/sfc/tests/functest/sfc_one_chain_two_service_functions.py
@@ -14,7 +14,6 @@ import logging
import sfc.lib.openstack_utils as os_sfc_utils
import sfc.lib.odl_utils as odl_utils
-import functest.utils.openstack_utils as os_utils
import opnfv.utils.ovs_logger as ovs_log
import sfc.lib.config as sfc_config
@@ -80,21 +79,17 @@ def main():
results.add_to_summary(2, "STATUS", "SUBTEST")
results.add_to_summary(0, "=")
- test_utils.download_image(COMMON_CONFIG.url,
- COMMON_CONFIG.image_path)
- _, custom_flv_id = os_utils.get_or_create_flavor(
+ openstack_sfc = os_sfc_utils.OpenStackSFC()
+
+ custom_flv = openstack_sfc.create_flavor(
COMMON_CONFIG.flavor,
COMMON_CONFIG.ram_size_in_mb,
COMMON_CONFIG.disk_size_in_gb,
- COMMON_CONFIG.vcpu_count,
- public=True)
- if not custom_flv_id:
+ COMMON_CONFIG.vcpu_count)
+ if not custom_flv:
logger.error("Failed to create custom flavor")
sys.exit(1)
- glance_client = os_utils.get_glance_client()
- neutron_client = os_utils.get_neutron_client()
- nova_client = os_utils.get_nova_client()
tacker_client = os_sfc_utils.get_tacker_client()
controller_clients = test_utils.get_ssh_clients(controller_nodes)
@@ -104,43 +99,39 @@ def main():
os.path.join(COMMON_CONFIG.sfc_test_dir, 'ovs-logs'),
COMMON_CONFIG.functest_results_dir)
- image_id = os_utils.create_glance_image(glance_client,
- COMMON_CONFIG.image_name,
- COMMON_CONFIG.image_path,
- COMMON_CONFIG.image_format,
- public='public')
+ image_creator = openstack_sfc.register_glance_image(
+ COMMON_CONFIG.image_name,
+ COMMON_CONFIG.image_url,
+ COMMON_CONFIG.image_format,
+ 'public')
- network_id = os_sfc_utils.setup_neutron(neutron_client,
- TESTCASE_CONFIG.net_name,
- TESTCASE_CONFIG.subnet_name,
- TESTCASE_CONFIG.router_name,
- TESTCASE_CONFIG.subnet_cidr)
+ network, router = openstack_sfc.create_network_infrastructure(
+ TESTCASE_CONFIG.net_name,
+ TESTCASE_CONFIG.subnet_name,
+ TESTCASE_CONFIG.subnet_cidr,
+ TESTCASE_CONFIG.router_name)
- sg_id = os_sfc_utils.create_security_groups(neutron_client,
- TESTCASE_CONFIG.secgroup_name,
- TESTCASE_CONFIG.secgroup_descr)
+ sg = openstack_sfc.create_security_group(TESTCASE_CONFIG.secgroup_name)
vnfs = ['testVNF1', 'testVNF2']
topo_seed = topo_shuffler.get_seed()
- testTopology = topo_shuffler.topology(vnfs, seed=topo_seed)
+ testTopology = topo_shuffler.topology(vnfs, openstack_sfc, seed=topo_seed)
logger.info('This test is run with the topology {0}'
.format(testTopology['id']))
logger.info('Topology description: {0}'
.format(testTopology['description']))
- client_instance = os_sfc_utils.create_instance(
- nova_client, CLIENT, COMMON_CONFIG.flavor, image_id,
- network_id, sg_id, av_zone=testTopology['client'])
+ client_instance, client_creator = openstack_sfc.create_instance(
+ CLIENT, COMMON_CONFIG.flavor, image_creator, network, sg,
+ av_zone=testTopology['client'])
- server_instance = os_sfc_utils.create_instance(
- nova_client, SERVER, COMMON_CONFIG.flavor, image_id,
- network_id, sg_id, av_zone=testTopology['server'])
+ server_instance, server_creator = openstack_sfc.create_instance(
+ SERVER, COMMON_CONFIG.flavor, image_creator, network, sg,
+ av_zone=testTopology['server'])
- client_ip = client_instance.networks.get(TESTCASE_CONFIG.net_name)[0]
- logger.info("Client instance received private ip [{}]".format(client_ip))
- server_ip = server_instance.networks.get(TESTCASE_CONFIG.net_name)[0]
+ server_ip = server_instance.ports[0].ips[0]['ip_address']
logger.info("Server instance received private ip [{}]".format(server_ip))
os_sfc_utils.register_vim(tacker_client, vim_file=COMMON_CONFIG.vim_file)
@@ -178,10 +169,6 @@ def main():
logger.error('ERROR while booting vnfs')
sys.exit(1)
- vnf1_instance_id = os_sfc_utils.get_nova_id(tacker_client, 'VDU1', vnf1_id)
-
- vnf2_instance_id = os_sfc_utils.get_nova_id(tacker_client, 'VDU1', vnf2_id)
-
tosca_file = os.path.join(COMMON_CONFIG.sfc_test_dir,
COMMON_CONFIG.vnffgd_dir,
TESTCASE_CONFIG.test_vnffgd_red)
@@ -190,11 +177,11 @@ def main():
tosca_file=tosca_file,
vnffgd_name='red')
- neutron_port = os_sfc_utils.get_client_port_id(client_instance)
+ neutron_port = openstack_sfc.get_client_port_id(client_instance)
os_sfc_utils.create_vnffg_with_param_file(tacker_client, 'red',
'red_http',
default_param_file,
- neutron_port)
+ neutron_port.id)
# Start measuring the time it takes to implement the classification rules
t1 = threading.Thread(target=odl_utils.wait_for_classification_rules,
@@ -205,19 +192,20 @@ def main():
logger.error("Unable to start the thread that counts time %s" % e)
logger.info("Assigning floating IPs to instances")
- server_floating_ip = os_sfc_utils.assign_floating_ip(
- nova_client, neutron_client, server_instance.id)
- client_floating_ip = os_sfc_utils.assign_floating_ip(
- nova_client, neutron_client, client_instance.id)
- sf1_floating_ip = os_sfc_utils.assign_floating_ip(
- nova_client, neutron_client, vnf1_instance_id)
- sf2_floating_ip = os_sfc_utils.assign_floating_ip(
- nova_client, neutron_client, vnf2_instance_id)
-
- for ip in (server_floating_ip,
- client_floating_ip,
- sf1_floating_ip,
- sf2_floating_ip):
+ client_floating_ip = openstack_sfc.assign_floating_ip(router,
+ client_instance,
+ client_creator)
+ server_floating_ip = openstack_sfc.assign_floating_ip(router,
+ server_instance,
+ server_creator)
+ fips_sfs = openstack_sfc.assign_floating_ip_vnfs(router)
+ sf1_floating_ip = fips_sfs[0]
+ sf2_floating_ip = fips_sfs[1]
+
+ fips = [client_floating_ip, server_floating_ip, sf1_floating_ip,
+ sf2_floating_ip]
+
+ for ip in fips:
logger.info("Checking connectivity towards floating IP [%s]" % ip)
if not test_utils.ping(ip, retries=50, retry_timeout=3):
logger.error("Cannot ping floating IP [%s]" % ip)
@@ -287,7 +275,7 @@ def main():
ovs_logger, controller_clients, compute_clients, error)
results.add_to_summary(2, "FAIL", "HTTP not blocked")
- return results.compile_summary()
+ return results.compile_summary(), openstack_sfc.creators
if __name__ == '__main__':
diff --git a/sfc/tests/functest/sfc_symmetric_chain.py b/sfc/tests/functest/sfc_symmetric_chain.py
index 75ea43f1..b8d35514 100644
--- a/sfc/tests/functest/sfc_symmetric_chain.py
+++ b/sfc/tests/functest/sfc_symmetric_chain.py
@@ -14,8 +14,8 @@ import sys
import threading
import logging
-import sfc.lib.openstack_utils as os_tacker
-import functest.utils.openstack_utils as os_utils
+import sfc.lib.openstack_utils as os_sfc_utils
+import sfc.lib.odl_utils as odl_utils
import opnfv.utils.ovs_logger as ovs_log
from opnfv.deployment.factory import Factory as DeploymentFactory
@@ -49,26 +49,23 @@ def main():
controller_nodes = [node for node in all_nodes if node.is_controller()]
compute_nodes = [node for node in all_nodes if node.is_compute()]
- odl_ip, odl_port = test_utils.get_odl_ip_port(all_nodes)
+ odl_ip, odl_port = odl_utils.get_odl_ip_port(all_nodes)
results = Results(COMMON_CONFIG.line_length)
results.add_to_summary(0, "=")
results.add_to_summary(2, "STATUS", "SUBTEST")
results.add_to_summary(0, "=")
- test_utils.download_image(COMMON_CONFIG.url, COMMON_CONFIG.image_path)
+ openstack_sfc = os_sfc_utils.OpenStackSFC()
- neutron_client = os_utils.get_neutron_client()
- nova_client = os_utils.get_nova_client()
- tacker_client = os_tacker.get_tacker_client()
+ tacker_client = os_sfc_utils.get_tacker_client()
- _, custom_flavor_id = os_utils.get_or_create_flavor(
+ _, custom_flavor = openstack_sfc.get_or_create_flavor(
COMMON_CONFIG.flavor,
COMMON_CONFIG.ram_size_in_mb,
COMMON_CONFIG.disk_size_in_gb,
- COMMON_CONFIG.vcpu_count,
- public=True)
- if custom_flavor_id is None:
+ COMMON_CONFIG.vcpu_count)
+ if custom_flavor is None:
logger.error("Failed to create custom flavor")
sys.exit(1)
@@ -79,52 +76,38 @@ def main():
os.path.join(COMMON_CONFIG.sfc_test_dir, 'ovs-logs'),
COMMON_CONFIG.functest_results_dir)
- image_id = os_utils.create_glance_image(
- os_utils.get_glance_client(),
+ image_creator = openstack_sfc.register_glance_image(
COMMON_CONFIG.image_name,
- COMMON_CONFIG.image_path,
+ COMMON_CONFIG.image_url,
COMMON_CONFIG.image_format,
- public='public')
+ 'public')
- network_id = test_utils.setup_neutron(
- neutron_client,
+ network, router = openstack_sfc.create_network_infrastructure(
TESTCASE_CONFIG.net_name,
TESTCASE_CONFIG.subnet_name,
- TESTCASE_CONFIG.router_name,
- TESTCASE_CONFIG.subnet_cidr)
+ TESTCASE_CONFIG.subnet_cidr,
+ TESTCASE_CONFIG.router_name)
- sg_id = test_utils.create_security_groups(
- neutron_client,
- TESTCASE_CONFIG.secgroup_name,
- TESTCASE_CONFIG.secgroup_descr)
+ sg = openstack_sfc.create_security_group(TESTCASE_CONFIG.secgroup_name)
vnf_name = 'testVNF1'
# Using seed=0 uses the baseline topology: everything in the same host
- testTopology = topo_shuffler.topology([vnf_name], seed=0)
+ testTopology = topo_shuffler.topology([vnf_name], openstack_sfc, seed=0)
logger.info('This test is run with the topology {0}'
.format(testTopology['id']))
logger.info('Topology description: {0}'
.format(testTopology['description']))
- client_instance = test_utils.create_instance(
- nova_client,
- CLIENT,
- COMMON_CONFIG.flavor,
- image_id,
- network_id,
- sg_id,
- av_zone=testTopology[CLIENT])
-
- server_instance = test_utils.create_instance(
- nova_client,
- SERVER,
- COMMON_CONFIG.flavor,
- image_id,
- network_id,
- sg_id,
- av_zone=testTopology[SERVER])
+ client_instance, client_creator = openstack_sfc.create_instance(
+ CLIENT, COMMON_CONFIG.flavor, image_creator, network, sg,
+ av_zone=testTopology['client'])
- server_ip = server_instance.networks.get(TESTCASE_CONFIG.net_name)[0]
+ server_instance, server_creator = openstack_sfc.create_instance(
+ SERVER, COMMON_CONFIG.flavor, image_creator, network, sg,
+ av_zone=testTopology['server'])
+
+ server_ip = server_instance.ports[0].ips[0]['ip_address']
+ logger.info("Server instance received private ip [{}]".format(server_ip))
tosca_file = os.path.join(
COMMON_CONFIG.sfc_test_dir,
@@ -136,7 +119,7 @@ def main():
COMMON_CONFIG.vnfd_dir,
COMMON_CONFIG.vnfd_default_params_file)
- os_tacker.create_vnfd(tacker_client, tosca_file=tosca_file)
+ os_sfc_utils.create_vnfd(tacker_client, tosca_file=tosca_file)
test_utils.create_vnf_in_av_zone(
tacker_client,
vnf_name,
@@ -144,21 +127,18 @@ def main():
default_param_file,
testTopology[vnf_name])
- vnf_id = os_tacker.wait_for_vnf(tacker_client, vnf_name=vnf_name)
+ vnf_id = os_sfc_utils.wait_for_vnf(tacker_client, vnf_name=vnf_name)
if vnf_id is None:
logger.error('ERROR while booting VNF')
sys.exit(1)
- vnf_instance_id = test_utils.get_nova_id(tacker_client, 'vdu1', vnf_id)
- os_utils.add_secgroup_to_instance(nova_client, vnf_instance_id, sg_id)
-
- os_tacker.create_sfc(
+ os_sfc_utils.create_sfc(
tacker_client,
sfc_name='red',
chain_vnf_names=[vnf_name],
symmetrical=True)
- os_tacker.create_sfc_classifier(
+ os_sfc_utils.create_sfc_classifier(
tacker_client, 'red_http', sfc_name='red',
match={
'source_port': 0,
@@ -169,7 +149,7 @@ def main():
# FIXME: JIRA SFC-86
# Tacker does not allow to specify the direction of the chain to be used,
# only references the SFP (which for symmetric chains results in two RSPs)
- os_tacker.create_sfc_classifier(
+ os_sfc_utils.create_sfc_classifier(
tacker_client, 'red_http_reverse', sfc_name='red',
match={
'source_port': 80,
@@ -181,7 +161,7 @@ def main():
logger.info(test_utils.run_cmd('tacker sfc-classifier-list'))
# Start measuring the time it takes to implement the classification rules
- t1 = threading.Thread(target=test_utils.wait_for_classification_rules,
+ t1 = threading.Thread(target=odl_utils.wait_for_classification_rules,
args=(ovs_logger, compute_nodes, odl_ip, odl_port,))
try:
@@ -190,14 +170,18 @@ def main():
logger.error("Unable to start the thread that counts time %s" % e)
logger.info("Assigning floating IPs to instances")
- server_floating_ip = test_utils.assign_floating_ip(
- nova_client, neutron_client, server_instance.id)
- client_floating_ip = test_utils.assign_floating_ip(
- nova_client, neutron_client, client_instance.id)
- sf_floating_ip = test_utils.assign_floating_ip(
- nova_client, neutron_client, vnf_instance_id)
-
- for ip in (server_floating_ip, client_floating_ip, sf_floating_ip):
+ client_floating_ip = openstack_sfc.assign_floating_ip(router,
+ client_instance,
+ client_creator)
+ server_floating_ip = openstack_sfc.assign_floating_ip(router,
+ server_instance,
+ server_creator)
+ fips_sfs = openstack_sfc.assign_floating_ip_vnfs(router)
+ sf_floating_ip = fips_sfs[0]
+
+ fips = [client_floating_ip, server_floating_ip, fips_sfs[0]]
+
+ for ip in fips:
logger.info("Checking connectivity towards floating IP [%s]" % ip)
if not test_utils.ping(ip, retries=50, retry_timeout=3):
logger.error("Cannot ping floating IP [%s]" % ip)
@@ -243,7 +227,7 @@ def main():
ovs_logger, controller_clients, compute_clients, error)
results.add_to_summary(2, "FAIL", "HTTP Blocked")
- return results.compile_summary()
+ return results.compile_summary(), openstack_sfc.creators
if __name__ == '__main__':
diff --git a/sfc/tests/functest/sfc_two_chains_SSH_and_HTTP.py b/sfc/tests/functest/sfc_two_chains_SSH_and_HTTP.py
index 5a5645df..d7eb2994 100644
--- a/sfc/tests/functest/sfc_two_chains_SSH_and_HTTP.py
+++ b/sfc/tests/functest/sfc_two_chains_SSH_and_HTTP.py
@@ -15,7 +15,6 @@ import logging
import sfc.lib.openstack_utils as os_sfc_utils
import sfc.lib.odl_utils as odl_utils
-import functest.utils.openstack_utils as os_utils
import opnfv.utils.ovs_logger as ovs_log
import sfc.lib.config as sfc_config
@@ -78,20 +77,17 @@ def main():
results.add_to_summary(2, "STATUS", "SUBTEST")
results.add_to_summary(0, "=")
- test_utils.download_image(COMMON_CONFIG.url,
- COMMON_CONFIG.image_path)
- _, custom_flv_id = os_utils.get_or_create_flavor(
+ openstack_sfc = os_sfc_utils.OpenStackSFC()
+
+ custom_flv = openstack_sfc.create_flavor(
COMMON_CONFIG.flavor,
COMMON_CONFIG.ram_size_in_mb,
COMMON_CONFIG.disk_size_in_gb,
- COMMON_CONFIG.vcpu_count, public=True)
- if not custom_flv_id:
+ COMMON_CONFIG.vcpu_count)
+ if not custom_flv:
logger.error("Failed to create custom flavor")
sys.exit(1)
- glance_client = os_utils.get_glance_client()
- neutron_client = os_utils.get_neutron_client()
- nova_client = os_utils.get_nova_client()
tacker_client = os_sfc_utils.get_tacker_client()
controller_clients = test_utils.get_ssh_clients(controller_nodes)
@@ -101,41 +97,40 @@ def main():
os.path.join(COMMON_CONFIG.sfc_test_dir, 'ovs-logs'),
COMMON_CONFIG.functest_results_dir)
- image_id = os_utils.create_glance_image(glance_client,
- COMMON_CONFIG.image_name,
- COMMON_CONFIG.image_path,
- COMMON_CONFIG.image_format,
- public='public')
+ image_creator = openstack_sfc.register_glance_image(
+ COMMON_CONFIG.image_name,
+ COMMON_CONFIG.image_url,
+ COMMON_CONFIG.image_format,
+ 'public')
- network_id = os_sfc_utils.setup_neutron(neutron_client,
- TESTCASE_CONFIG.net_name,
- TESTCASE_CONFIG.subnet_name,
- TESTCASE_CONFIG.router_name,
- TESTCASE_CONFIG.subnet_cidr)
+ network, router = openstack_sfc.create_network_infrastructure(
+ TESTCASE_CONFIG.net_name,
+ TESTCASE_CONFIG.subnet_name,
+ TESTCASE_CONFIG.subnet_cidr,
+ TESTCASE_CONFIG.router_name)
- sg_id = os_sfc_utils.create_security_groups(neutron_client,
- TESTCASE_CONFIG.secgroup_name,
- TESTCASE_CONFIG.secgroup_descr)
+ sg = openstack_sfc.create_security_group(TESTCASE_CONFIG.secgroup_name)
vnf_names = ['testVNF1', 'testVNF2']
topo_seed = topo_shuffler.get_seed() # change to None for nova av zone
- testTopology = topo_shuffler.topology(vnf_names, seed=topo_seed)
+ testTopology = topo_shuffler.topology(vnf_names, openstack_sfc,
+ seed=topo_seed)
logger.info('This test is run with the topology {0}'
.format(testTopology['id']))
logger.info('Topology description: {0}'
.format(testTopology['description']))
- client_instance = os_sfc_utils.create_instance(
- nova_client, CLIENT, COMMON_CONFIG.flavor, image_id,
- network_id, sg_id, av_zone=testTopology['client'])
+ client_instance, client_creator = openstack_sfc.create_instance(
+ CLIENT, COMMON_CONFIG.flavor, image_creator, network, sg,
+ av_zone=testTopology['client'])
- server_instance = os_sfc_utils.create_instance(
- nova_client, SERVER, COMMON_CONFIG.flavor, image_id,
- network_id, sg_id, av_zone=testTopology['server'])
+ server_instance, server_creator = openstack_sfc.create_instance(
+ SERVER, COMMON_CONFIG.flavor, image_creator, network, sg,
+ av_zone=testTopology['server'])
- server_ip = server_instance.networks.get(TESTCASE_CONFIG.net_name)[0]
+ server_ip = server_instance.ports[0].ips[0]['ip_address']
os_sfc_utils.register_vim(tacker_client, vim_file=COMMON_CONFIG.vim_file)
@@ -172,10 +167,6 @@ def main():
logger.error('ERROR while booting vnfs')
sys.exit(1)
- vnf1_instance_id = os_sfc_utils.get_nova_id(tacker_client, 'VDU1', vnf1_id)
-
- vnf2_instance_id = os_sfc_utils.get_nova_id(tacker_client, 'VDU1', vnf2_id)
-
tosca_file = os.path.join(COMMON_CONFIG.sfc_test_dir,
COMMON_CONFIG.vnffgd_dir,
TESTCASE_CONFIG.test_vnffgd_red)
@@ -184,11 +175,11 @@ def main():
tosca_file=tosca_file,
vnffgd_name='red')
- neutron_port = os_sfc_utils.get_client_port_id(client_instance)
+ neutron_port = openstack_sfc.get_client_port_id(client_instance)
os_sfc_utils.create_vnffg_with_param_file(tacker_client, 'red',
'red_http',
default_param_file,
- neutron_port)
+ neutron_port.id)
# Start measuring the time it takes to implement the classification rules
t1 = threading.Thread(target=odl_utils.wait_for_classification_rules,
@@ -200,19 +191,20 @@ def main():
logger.error("Unable to start the thread that counts time %s" % e)
logger.info("Assigning floating IPs to instances")
- server_floating_ip = os_sfc_utils.assign_floating_ip(
- nova_client, neutron_client, server_instance.id)
- client_floating_ip = os_sfc_utils.assign_floating_ip(
- nova_client, neutron_client, client_instance.id)
- sf1_floating_ip = os_sfc_utils.assign_floating_ip(
- nova_client, neutron_client, vnf1_instance_id)
- sf2_floating_ip = os_sfc_utils.assign_floating_ip(
- nova_client, neutron_client, vnf2_instance_id)
-
- for ip in (server_floating_ip,
- client_floating_ip,
- sf1_floating_ip,
- sf2_floating_ip):
+ client_floating_ip = openstack_sfc.assign_floating_ip(router,
+ client_instance,
+ client_creator)
+ server_floating_ip = openstack_sfc.assign_floating_ip(router,
+ server_instance,
+ server_creator)
+ fips_sfs = openstack_sfc.assign_floating_ip_vnfs(router)
+ sf1_floating_ip = fips_sfs[0]
+ sf2_floating_ip = fips_sfs[1]
+
+ fips = [client_floating_ip, server_floating_ip, sf1_floating_ip,
+ sf2_floating_ip]
+
+ for ip in fips:
logger.info("Checking connectivity towards floating IP [%s]" % ip)
if not test_utils.ping(ip, retries=50, retry_timeout=3):
logger.error("Cannot ping floating IP [%s]" % ip)
@@ -309,7 +301,7 @@ def main():
ovs_logger, controller_clients, compute_clients, error)
results.add_to_summary(2, "FAIL", "SSH works")
- return results.compile_summary()
+ return results.compile_summary(), openstack_sfc.creators
if __name__ == '__main__':