import paramiko
import dns.resolver
from jinja2 import Environment, FileSystemLoader
+from snaps.config.flavor import FlavorConfig
+from snaps.config.image import ImageConfig
+from snaps.config.network import NetworkConfig, PortConfig, SubnetConfig
+from snaps.config.router import RouterConfig
+from snaps.config.security_group import (
+ Direction, Protocol, SecurityGroupConfig, SecurityGroupRuleConfig)
+from snaps.config.vm_inst import FloatingIpConfig, VmInstanceConfig
+from snaps.openstack.create_flavor import OpenStackFlavor
+from snaps.openstack.create_instance import OpenStackVmInstance
+from snaps.openstack.create_network import OpenStackNetwork
+from snaps.openstack.create_router import OpenStackRouter
+from snaps.openstack.create_security_group import OpenStackSecurityGroup
+from xtesting.energy import energy
-
-from functest.energy import energy
from functest.opnfv_tests.openstack.snaps import snaps_utils
-import functest.opnfv_tests.vnf.ims.cloudify_ims as cloudify_ims
-from functest.utils.constants import CONST
-
-from snaps.openstack.create_network import (NetworkSettings, SubnetSettings,
- OpenStackNetwork, PortSettings)
-from snaps.openstack.create_security_group import (SecurityGroupSettings,
- SecurityGroupRuleSettings,
- Direction, Protocol,
- OpenStackSecurityGroup)
-from snaps.openstack.create_router import RouterSettings, OpenStackRouter
-from snaps.openstack.create_instance import (VmInstanceSettings,
- FloatingIpSettings,
- OpenStackVmInstance)
-from snaps.openstack.create_flavor import FlavorSettings, OpenStackFlavor
-from snaps.openstack.create_image import ImageSettings
-
-from ixia.utils.IxChassisUtils import ChassisRestAPI
-import ixia.utils.IxLoadUtils as IxLoadUtils
-import ixia.utils.IxRestUtils as IxRestUtils
+from functest.opnfv_tests.vnf.ims import cloudify_ims
+from functest.opnfv_tests.vnf.ims.ixia.utils import IxChassisUtils
+from functest.opnfv_tests.vnf.ims.ixia.utils import IxLoadUtils
+from functest.opnfv_tests.vnf.ims.ixia.utils import IxRestUtils
+from functest.utils import config
+from functest.utils import env
__author__ = "Valentin Boucher <valentin.boucher@orange.com>"
# Retrieve the configuration
try:
- self.config = CONST.__getattribute__(
- 'vnf_{}_config'.format(self.case_name))
+ self.config = getattr(
+ config.CONF, 'vnf_{}_config'.format(self.case_name))
except Exception:
raise Exception("VNF config file not found")
ellis_ip = outputs['ellis_ip']
self.__logger.info("Creating full IXIA network ...")
- subnet_settings = SubnetSettings(name='ixia_management_subnet',
- cidr='10.10.10.0/24')
- network_settings = NetworkSettings(name='ixia_management_network',
- subnet_settings=[subnet_settings])
+ subnet_settings = SubnetConfig(name='ixia_management_subnet',
+ cidr='10.10.10.0/24',
+ dns_nameservers=[env.get('NAMESERVER')])
+ network_settings = NetworkConfig(name='ixia_management_network',
+ subnet_settings=[subnet_settings])
network_creator = OpenStackNetwork(self.snaps_creds, network_settings)
network_creator.create()
self.created_object.append(network_creator)
ext_net_name = snaps_utils.get_ext_net_name(self.snaps_creds)
router_creator = OpenStackRouter(
self.snaps_creds,
- RouterSettings(
+ RouterConfig(
name='ixia_management_router',
external_gateway=ext_net_name,
internal_subnets=[subnet_settings.name]))
self.__logger.info("Creating security groups for IXIA VMs")
sg_rules = list()
sg_rules.append(
- SecurityGroupRuleSettings(sec_grp_name="ixia_management",
- direction=Direction.ingress,
- protocol=Protocol.tcp, port_range_min=1,
- port_range_max=65535))
+ SecurityGroupRuleConfig(sec_grp_name="ixia_management",
+ direction=Direction.ingress,
+ protocol=Protocol.tcp, port_range_min=1,
+ port_range_max=65535))
sg_rules.append(
- SecurityGroupRuleSettings(sec_grp_name="ixia_management",
- direction=Direction.ingress,
- protocol=Protocol.udp, port_range_min=1,
- port_range_max=65535))
+ SecurityGroupRuleConfig(sec_grp_name="ixia_management",
+ direction=Direction.ingress,
+ protocol=Protocol.udp, port_range_min=1,
+ port_range_max=65535))
sg_rules.append(
- SecurityGroupRuleSettings(sec_grp_name="ixia_management",
- direction=Direction.ingress,
- protocol=Protocol.icmp))
+ SecurityGroupRuleConfig(sec_grp_name="ixia_management",
+ direction=Direction.ingress,
+ protocol=Protocol.icmp))
- ixia_managment_sg_settings = SecurityGroupSettings(
- name="ixia_management",
- rule_settings=sg_rules)
+ ixia_managment_sg_settings = SecurityGroupConfig(
+ name="ixia_management", rule_settings=sg_rules)
securit_group_creator = OpenStackSecurityGroup(
self.snaps_creds,
ixia_managment_sg_settings)
sg_rules = list()
sg_rules.append(
- SecurityGroupRuleSettings(sec_grp_name="ixia_ssh_http",
- direction=Direction.ingress,
- protocol=Protocol.tcp, port_range_min=1,
- port_range_max=65535))
-
- ixia_ssh_http_sg_settings = SecurityGroupSettings(
- name="ixia_ssh_http",
- rule_settings=sg_rules)
+ SecurityGroupRuleConfig(sec_grp_name="ixia_ssh_http",
+ direction=Direction.ingress,
+ protocol=Protocol.tcp, port_range_min=1,
+ port_range_max=65535))
+
+ ixia_ssh_http_sg_settings = SecurityGroupConfig(
+ name="ixia_ssh_http", rule_settings=sg_rules)
securit_group_creator = OpenStackSecurityGroup(
self.snaps_creds,
ixia_ssh_http_sg_settings)
securit_group_creator.create()
self.created_object.append(securit_group_creator)
- chassis_flavor_settings = FlavorSettings(
+ chassis_flavor_settings = FlavorConfig(
name="ixia_vChassis",
ram=4096,
disk=40,
flavor_creator.create()
self.created_object.append(flavor_creator)
- card_flavor_settings = FlavorSettings(
+ card_flavor_settings = FlavorConfig(
name="ixia_vCard",
ram=4096,
disk=4,
flavor_creator.create()
self.created_object.append(flavor_creator)
- load_flavor_settings = FlavorSettings(
+ load_flavor_settings = FlavorConfig(
name="ixia_vLoad",
ram=8192,
disk=100,
flavor_creator.create()
self.created_object.append(flavor_creator)
- chassis_image_settings = ImageSettings(
+ chassis_image_settings = ImageConfig(
name=self.test['requirements']['chassis']['image'],
image_user='admin',
exists=True)
- card_image_settings = ImageSettings(
+ card_image_settings = ImageConfig(
name=self.test['requirements']['card']['image'],
image_user='admin',
exists=True)
- load_image_settings = ImageSettings(
+ load_image_settings = ImageConfig(
name=self.test['requirements']['load']['image'],
image_user='admin',
exists=True)
- chassis_port_settings = PortSettings(
- name='ixia_chassis_port',
- network_name=network_settings.name)
+ chassis_port_settings = PortConfig(
+ name='ixia_chassis_port', network_name=network_settings.name)
- card1_port1_settings = PortSettings(
- name='ixia_card1_port1',
- network_name=network_settings.name)
+ card1_port1_settings = PortConfig(
+ name='ixia_card1_port1', network_name=network_settings.name)
- card2_port1_settings = PortSettings(
- name='ixia_card2_port1',
- network_name=network_settings.name)
+ card2_port1_settings = PortConfig(
+ name='ixia_card2_port1', network_name=network_settings.name)
- card1_port2_settings = PortSettings(
- name='ixia_card1_port2',
- network_name="cloudify_ims_network")
+ card1_port2_settings = PortConfig(
+ name='ixia_card1_port2', network_name="cloudify_ims_network")
- card2_port2_settings = PortSettings(
- name='ixia_card2_port2',
- network_name="cloudify_ims_network")
+ card2_port2_settings = PortConfig(
+ name='ixia_card2_port2', network_name="cloudify_ims_network")
- load_port_settings = PortSettings(
- name='ixia_load_port',
- network_name=network_settings.name)
+ load_port_settings = PortConfig(
+ name='ixia_load_port', network_name=network_settings.name)
- chassis_settings = VmInstanceSettings(
+ chassis_settings = VmInstanceConfig(
name='ixia_vChassis',
flavor=chassis_flavor_settings.name,
port_settings=[chassis_port_settings],
security_group_names=[ixia_ssh_http_sg_settings.name,
ixia_managment_sg_settings.name],
- floating_ip_settings=[FloatingIpSettings(
+ floating_ip_settings=[FloatingIpConfig(
name='ixia_vChassis_fip',
port_name=chassis_port_settings.name,
router_name=router_creator.router_settings.name)])
fip_chassis = vm_creator.get_floating_ip().ip
self.created_object.append(vm_creator)
- card1_settings = VmInstanceSettings(
+ card1_settings = VmInstanceConfig(
name='ixia_vCard1',
flavor=card_flavor_settings.name,
port_settings=[card1_port1_settings, card1_port2_settings],
vcard_ips_p2.append(vm_creator.get_port_ip('ixia_card1_port2'))
self.created_object.append(vm_creator)
- card2_settings = VmInstanceSettings(
+ card2_settings = VmInstanceConfig(
name='ixia_vCard2',
flavor=card_flavor_settings.name,
port_settings=[card2_port1_settings, card2_port2_settings],
vcard_ips_p2.append(vm_creator.get_port_ip('ixia_card2_port2'))
self.created_object.append(vm_creator)
- load_settings = VmInstanceSettings(
+ load_settings = VmInstanceConfig(
name='ixia_vLoad',
flavor=load_flavor_settings.name,
port_settings=[load_port_settings],
security_group_names=[ixia_ssh_http_sg_settings.name,
ixia_managment_sg_settings.name],
- floating_ip_settings=[FloatingIpSettings(
+ floating_ip_settings=[FloatingIpConfig(
name='ixia_vLoad_fip',
port_name=load_port_settings.name,
router_name=router_creator.router_settings.name)])
"password": "admin",
"rememberMe": "false"})
api_key = json.loads((
- ChassisRestAPI.postWithPayload(login_url, payload)))["apiKey"]
+ IxChassisUtils.ChassisRestAPI.postWithPayload(
+ login_url, payload)))["apiKey"]
self.__logger.info("Adding 2 card back inside the ixia chassis...")
for ip in vcard_ips:
payload = {"ipAddress": str(ip)}
- response = json.loads(ChassisRestAPI.postOperation(cards_url,
- api_key,
- payload))
+ response = json.loads(IxChassisUtils.ChassisRestAPI.postOperation(
+ cards_url, api_key, payload))
count = 0
while (int(
- ChassisRestAPI.getWithHeaders(response['url'],
- api_key)['progress']) != 100):
+ IxChassisUtils.ChassisRestAPI.getWithHeaders(
+ response['url'], api_key)['progress']) != 100):
self.__logger.debug("Operation did not finish yet. \
Waiting for 1 more second..")
time.sleep(1)
i = 0
for rdata in result:
i = i + 1
- print rdata.address
+ print(rdata.address)
iplistims += str(rdata.address)
if i != len(result):
iplistims += ';'
j2_env = Environment(loader=FileSystemLoader(files_dir),
trim_blocks=True)
self.test['inputs'].update(dict(
- ipchassis=fip_chassis,
- ipcard1=vcard_ips_p2[0],
- ipcard2=vcard_ips_p2[1],
- iplistims=iplistims
+ ipchassis=fip_chassis, ipcard1=vcard_ips_p2[0],
+ ipcard2=vcard_ips_p2[1], iplistims=iplistims
))
target_file.write(
self.__logger.info("Starting the test...")
IxLoadUtils.runTest(connection, sessionUrl)
- self.__logger.info("Polling values for stats %s..." % (
- kStatsToDisplayDict))
+ self.__logger.info(
+ "Polling values for stats %s..." % (kStatsToDisplayDict))
result = IxLoadUtils.pollStats(connection, sessionUrl,
kStatsToDisplayDict)
self.__logger.info("Test finished.")
result=result,
duration=duration)
if testRunError:
- self.__logger.info("The test exited with following error: %s" % (
- testRunError))
+ self.__logger.info(
+ "The test exited with following error: %s" % (testRunError))
self.details['test_vnf'].update(status='FAIL', duration=duration)
return False
else: