diff options
Diffstat (limited to 'functest/opnfv_tests/vnf/ims')
-rw-r--r-- | functest/opnfv_tests/vnf/ims/clearwater.py | 2 | ||||
-rw-r--r-- | functest/opnfv_tests/vnf/ims/cloudify_ims.py | 246 | ||||
-rw-r--r-- | functest/opnfv_tests/vnf/ims/cloudify_ims.yaml | 39 | ||||
-rw-r--r-- | functest/opnfv_tests/vnf/ims/opera_ims.py | 475 | ||||
-rw-r--r-- | functest/opnfv_tests/vnf/ims/orchestra_ims.py | 465 | ||||
-rw-r--r-- | functest/opnfv_tests/vnf/ims/orchestra_ims.yaml | 7 | ||||
-rw-r--r-- | functest/opnfv_tests/vnf/ims/orchestrator_cloudify.py | 9 |
7 files changed, 943 insertions, 300 deletions
diff --git a/functest/opnfv_tests/vnf/ims/clearwater.py b/functest/opnfv_tests/vnf/ims/clearwater.py index eb0abacd..32c6dc5c 100644 --- a/functest/opnfv_tests/vnf/ims/clearwater.py +++ b/functest/opnfv_tests/vnf/ims/clearwater.py @@ -12,7 +12,7 @@ ######################################################################## -class Clearwater: +class Clearwater(object): def __init__(self, inputs={}, orchestrator=None, logger=None): self.config = inputs diff --git a/functest/opnfv_tests/vnf/ims/cloudify_ims.py b/functest/opnfv_tests/vnf/ims/cloudify_ims.py index 13a5af4f..c2c251ad 100644 --- a/functest/opnfv_tests/vnf/ims/cloudify_ims.py +++ b/functest/opnfv_tests/vnf/ims/cloudify_ims.py @@ -11,7 +11,9 @@ import json import os import requests import subprocess +import sys import time +import yaml import functest.core.vnf_base as vnf_base import functest.utils.functest_logger as ft_logger @@ -29,57 +31,127 @@ class ImsVnf(vnf_base.VnfOnBoardingBase): repo='', cmd=''): super(ImsVnf, self).__init__(project, case, repo, cmd) self.logger = ft_logger.Logger("vIMS").getLogger() - self.case_dir = os.path.join(CONST.functest_test, 'vnf/ims/') - self.data_dir = CONST.dir_vIMS_data + self.case_dir = os.path.join(CONST.dir_functest_test, 'vnf/ims/') + self.data_dir = CONST.dir_ims_data self.test_dir = CONST.dir_repo_vims_test + # Retrieve the configuration + try: + self.config = CONST.__getattribute__( + 'vnf_{}_config'.format(self.case_name)) + except: + raise Exception("VNF config file not found") + + config_file = self.case_dir + self.config self.orchestrator = dict( - requirements=CONST.cloudify_requirements, - blueprint=CONST.cloudify_blueprint, - inputs=CONST.cloudify_inputs + requirements=get_config("cloudify.requirements", config_file), + blueprint=get_config("cloudify.blueprint", config_file), + inputs=get_config("cloudify.inputs", config_file) ) - + self.logger.debug("Orchestrator configuration: %s" % self.orchestrator) self.vnf = dict( - blueprint=CONST.clearwater_blueprint, - deployment_name=CONST.clearwater_deployment_name, - inputs=CONST.clearwater_inputs, - requirements=CONST.clearwater_requirements + blueprint=get_config("clearwater.blueprint", config_file), + deployment_name=get_config("clearwater.deployment_name", + config_file), + inputs=get_config("clearwater.inputs", config_file), + requirements=get_config("clearwater.requirements", config_file) ) + self.logger.debug("VNF configuration: %s" % self.vnf) + + self.images = get_config("tenant_images", config_file) + self.logger.info("Images needed for vIMS: %s" % self.images) # vIMS Data directory creation if not os.path.exists(self.data_dir): os.makedirs(self.data_dir) def deploy_orchestrator(self, **kwargs): + + self.logger.info("Additional pre-configuration steps") + self.neutron_client = os_utils.get_neutron_client(self.admin_creds) + self.glance_client = os_utils.get_glance_client(self.admin_creds) + self.keystone_client = os_utils.get_keystone_client(self.admin_creds) + self.nova_client = os_utils.get_nova_client(self.admin_creds) + + # needs some images + self.logger.info("Upload some OS images if it doesn't exist") + temp_dir = os.path.join(self.data_dir, "tmp/") + for image_name, image_url in self.images.iteritems(): + self.logger.info("image: %s, url: %s" % (image_name, image_url)) + try: + image_id = os_utils.get_image_id(self.glance_client, + image_name) + self.logger.debug("image_id: %s" % image_id) + except: + self.logger.error("Unexpected error: %s" % sys.exc_info()[0]) + + if image_id == '': + self.logger.info("""%s image doesn't exist on glance repository. Try + downloading this image and upload on glance !""" % image_name) + image_id = download_and_add_image_on_glance(self.glance_client, + image_name, + image_url, + temp_dir) + if image_id == '': + self.step_failure( + "Failed to find or upload required OS " + "image for this deployment") + # Need to extend quota + self.logger.info("Update security group quota for this tenant") + tenant_id = os_utils.get_tenant_id(self.keystone_client, + self.tenant_name) + self.logger.debug("Tenant id found %s" % tenant_id) + if not os_utils.update_sg_quota(self.neutron_client, + tenant_id, 50, 100): + self.step_failure("Failed to update security group quota" + + " for tenant " + self.tenant_name) + self.logger.debug("group quota extended") + + # start the deployment of cloudify public_auth_url = os_utils.get_endpoint('identity') - cfy = Orchestrator(self.data_dir, self.orchestrator.inputs) - self.orchestrator.object = cfy + self.logger.debug("CFY inputs: %s" % self.orchestrator['inputs']) + cfy = Orchestrator(self.data_dir, self.orchestrator['inputs']) + self.orchestrator['object'] = cfy + self.logger.debug("Orchestrator object created") - if 'tenant_name' in self.creds.keys(): - tenant_name = self.creds['tenant_name'] - elif 'project_name' in self.creds.keys(): - tenant_name = self.creds['project_name'] + self.logger.debug("Tenant name: %s" % self.tenant_name) - cfy.set_credentials(username=self.creds['username'], - password=self.creds['password'], - tenant_name=tenant_name, + cfy.set_credentials(username=self.tenant_name, + password=self.tenant_name, + tenant_name=self.tenant_name, auth_url=public_auth_url) + self.logger.info("Credentials set in CFY") # orchestrator VM flavor - flavor_id = self.get_flavor("m1.large", self.orchestrator.requirements) + self.logger.info("Check Flavor is available, if not create one") + self.logger.debug("Flavor details %s " % + self.orchestrator['requirements']['ram_min']) + flavor_exist, flavor_id = os_utils.get_or_create_flavor( + "m1.large", + self.orchestrator['requirements']['ram_min'], + '50', + '2', + public=True) + self.logger.debug("Flavor id: %s" % flavor_id) + if not flavor_id: self.logger.info("Available flavors are: ") - self.pMsg(self.nova_client.flavor.list()) + self.logger.info(self.nova_client.flavor.list()) self.step_failure("Failed to find required flavor" "for this deployment") cfy.set_flavor_id(flavor_id) + self.logger.debug("Flavor OK") # orchestrator VM image - if 'os_image' in self.orchestrator.requirements.keys(): + self.logger.debug("Orchestrator image") + if 'os_image' in self.orchestrator['requirements'].keys(): image_id = os_utils.get_image_id( - self.glance_client, self.orchestrator.requirements['os_image']) + self.glance_client, + self.orchestrator['requirements']['os_image']) + self.logger.debug("Orchestrator image id: %s" % image_id) if image_id == '': + self.logger.error("CFY image not found") self.step_failure("Failed to find required OS image" " for cloudify manager") else: @@ -87,21 +159,22 @@ class ImsVnf(vnf_base.VnfOnBoardingBase): " for cloudify manager") cfy.set_image_id(image_id) + self.logger.debug("Orchestrator image set") + self.logger.debug("Get External network") ext_net = os_utils.get_external_net(self.neutron_client) + self.logger.debug("External network: %s" % ext_net) if not ext_net: self.step_failure("Failed to get external network") cfy.set_external_network_name(ext_net) + self.logger.debug("CFY External network set") + self.logger.debug("get resolvconf") ns = ft_utils.get_resolvconf_ns() if ns: cfy.set_nameservers(ns) - - if 'compute' in self.nova_client.client.services_url: - cfy.set_nova_url(self.nova_client.client.services_url['compute']) - if self.neutron_client.httpclient.endpoint_url is not None: - cfy.set_neutron_url(self.neutron_client.httpclient.endpoint_url) + self.logger.debug("Resolvconf set") self.logger.info("Prepare virtualenv for cloudify-cli") cmd = "chmod +x " + self.case_dir + "create_venv.sh" @@ -110,30 +183,42 @@ class ImsVnf(vnf_base.VnfOnBoardingBase): cmd = self.case_dir + "create_venv.sh " + self.data_dir ft_utils.execute_command(cmd) - cfy.download_manager_blueprint(self.orchestrator.blueprint['url'], - self.orchestrator.blueprint['branch']) + cfy.download_manager_blueprint( + self.orchestrator['blueprint']['url'], + self.orchestrator['blueprint']['branch']) - cfy.deploy_manager() - return {'status': 'PASS', 'result': ''} + error = cfy.deploy_manager() + if error: + self.logger.error(error) + return {'status': 'FAIL', 'result': error} + else: + return {'status': 'PASS', 'result': ''} def deploy_vnf(self): - cw = Clearwater(self.vnf.inputs, self.orchestrator.object, self.logger) - self.vnf.object = cw + cw = Clearwater(self.vnf['inputs'], self.orchestrator['object'], + self.logger) + self.vnf['object'] = cw self.logger.info("Collect flavor id for all clearwater vm") - flavor_id = self.get_flavor("m1.small", self.vnf.requirements) + flavor_exist, flavor_id = os_utils.get_or_create_flavor( + "m1.small", + self.vnf['requirements']['ram_min'], + '20', + '1', + public=True) + self.logger.debug("Flavor id: %s" % flavor_id) if not flavor_id: self.logger.info("Available flavors are: ") - self.pMsg(self.nova_client.flavor.list()) + self.logger.info(self.nova_client.flavor.list()) self.step_failure("Failed to find required flavor" " for this deployment") cw.set_flavor_id(flavor_id) # VMs image - if 'os_image' in self.vnf.requirements.keys(): + if 'os_image' in self.vnf['requirements'].keys(): image_id = os_utils.get_image_id( - self.glance_client, self.vnf.requirements['os_image']) + self.glance_client, self.vnf['requirements']['os_image']) if image_id == '': self.step_failure("Failed to find required OS image" " for clearwater VMs") @@ -149,8 +234,12 @@ class ImsVnf(vnf_base.VnfOnBoardingBase): cw.set_external_network_name(ext_net) - cw.deploy_vnf() - return {'status': 'PASS', 'result': ''} + error = cw.deploy_vnf() + if error: + self.logger.error(error) + return {'status': 'FAIL', 'result': error} + else: + return {'status': 'PASS', 'result': ''} def test_vnf(self): script = "source {0}venv_cloudify/bin/activate; " @@ -168,7 +257,7 @@ class ImsVnf(vnf_base.VnfOnBoardingBase): api_url = "http://" + mgr_ip + "/api/v2" dep_outputs = requests.get(api_url + "/deployments/" + - self.vnf.deployment_name + "/outputs") + self.vnf['deployment_name'] + "/outputs") dns_ip = dep_outputs.json()['outputs']['dns_ip'] ellis_ip = dep_outputs.json()['outputs']['ellis_ip'] @@ -252,27 +341,58 @@ class ImsVnf(vnf_base.VnfOnBoardingBase): return {'status': 'FAIL', 'result': ''} def clean(self): - self.vnf.object.undeploy_vnf() - self.orchestrator.object.undeploy_manager() + self.vnf['object'].undeploy_vnf() + self.orchestrator['object'].undeploy_manager() super(ImsVnf, self).clean() - def get_flavor(self, flavor_name, requirements): - try: - flavor_id = os_utils.get_flavor_id(self.nova_client, flavor_name) - if 'ram_min' in requirements.keys(): - flavor_id = os_utils.get_flavor_id_by_ram_range( - self.nova_client, requirements['ram_min'], 7500) - - if flavor_id == '': - self.logger.error( - "Failed to find %s flavor. " - "Try with ram range default requirement !" % flavor_name) - flavor_id = os_utils.get_flavor_id_by_ram_range( - self.nova_client, - 4000, 10000) - return flavor_id - except: - self.logger.error("Flavor '%s' not found." % self.flavor_name) - self.logger.info("Available flavors are: ") - self.pMsg(self.nova_client.flavor.list()) - return None + def main(self, **kwargs): + self.logger.info("Cloudify IMS VNF onboarding test starting") + self.execute() + self.logger.info("Cloudify IMS VNF onboarding test executed") + if self.criteria is "PASS": + return self.EX_OK + else: + return self.EX_RUN_ERROR + + def run(self): + kwargs = {} + return self.main(**kwargs) + + +# ---------------------------------------------------------- +# +# YAML UTILS +# +# ----------------------------------------------------------- +def get_config(parameter, file): + """ + Returns the value of a given parameter in file.yaml + parameter must be given in string format with dots + Example: general.openstack.image_name + """ + with open(file) as f: + file_yaml = yaml.safe_load(f) + f.close() + value = file_yaml + for element in parameter.split("."): + value = value.get(element) + if value is None: + raise ValueError("The parameter %s is not defined in" + " reporting.yaml" % parameter) + return value + + +def download_and_add_image_on_glance(glance, image_name, image_url, data_dir): + dest_path = data_dir + if not os.path.exists(dest_path): + os.makedirs(dest_path) + file_name = image_url.rsplit('/')[-1] + if not ft_utils.download_url(image_url, dest_path): + return False + + image = os_utils.create_glance_image( + glance, image_name, dest_path + file_name) + if not image: + return False + + return image diff --git a/functest/opnfv_tests/vnf/ims/cloudify_ims.yaml b/functest/opnfv_tests/vnf/ims/cloudify_ims.yaml new file mode 100644 index 00000000..775685fa --- /dev/null +++ b/functest/opnfv_tests/vnf/ims/cloudify_ims.yaml @@ -0,0 +1,39 @@ +tenant_images: + ubuntu_14.04: http://cloud-images.ubuntu.com/trusty/current/trusty-server-cloudimg-amd64-disk1.img + centos_7: http://cloud.centos.org/centos/7/images/CentOS-7-x86_64-GenericCloud-1510.qcow2 +cloudify: + blueprint: + url: https://github.com/boucherv-orange/cloudify-manager-blueprints.git + branch: '3.3.1-build' + requirements: + ram_min: 4000 + os_image: centos_7 + inputs: + keystone_username: "" + keystone_password: "" + keystone_tenant_name: "" + keystone_url: "" + manager_public_key_name: 'manager-kp' + agent_public_key_name: 'agent-kp' + image_id: "" + flavor_id: "3" + external_network_name: "" + ssh_user: centos + agents_user: ubuntu +clearwater: + blueprint: + file_name: openstack-blueprint.yaml + name: clearwater-opnfv + destination_folder: opnfv-cloudify-clearwater + url: https://github.com/Orange-OpenSource/opnfv-cloudify-clearwater.git + branch: stable + deployment_name: clearwater-opnfv + requirements: + ram_min: 2000 + os_image: ubuntu_14.04 + inputs: + image_id: '' + flavor_id: '' + agent_user: ubuntu + external_network_name: '' + public_domain: clearwaterfv diff --git a/functest/opnfv_tests/vnf/ims/opera_ims.py b/functest/opnfv_tests/vnf/ims/opera_ims.py index 073a56c3..7ead401f 100644 --- a/functest/opnfv_tests/vnf/ims/opera_ims.py +++ b/functest/opnfv_tests/vnf/ims/opera_ims.py @@ -8,148 +8,393 @@ # http://www.apache.org/licenses/LICENSE-2.0 import json -import os -import requests -import subprocess +import socket +import sys import time +import yaml import functest.core.vnf_base as vnf_base import functest.utils.functest_logger as ft_logger import functest.utils.functest_utils as ft_utils +import functest.utils.openstack_utils as os_utils +import os from functest.utils.constants import CONST +from org.openbaton.cli.agents.agents import MainAgent +from org.openbaton.cli.errors.errors import NfvoException + + +def servertest(host, port): + args = socket.getaddrinfo(host, port, socket.AF_INET, socket.SOCK_STREAM) + for family, socktype, proto, canonname, sockaddr in args: + s = socket.socket(family, socktype, proto) + try: + s.connect(sockaddr) + except socket.error: + return False + else: + s.close() + return True + +# ---------------------------------------------------------- +# +# UTILS +# +# ----------------------------------------------------------- + + +def get_config(parameter, file): + """ + Returns the value of a given parameter in file.yaml + parameter must be given in string format with dots + Example: general.openstack.image_name + """ + with open(file) as f: + file_yaml = yaml.safe_load(f) + f.close() + value = file_yaml + for element in parameter.split("."): + value = value.get(element) + if value is None: + raise ValueError("The parameter %s is not defined in" + " reporting.yaml" % parameter) + return value + + +def download_and_add_image_on_glance(glance, image_name, + image_url, data_dir): + dest_path = data_dir + if not os.path.exists(dest_path): + os.makedirs(dest_path) + file_name = image_url.rsplit('/')[-1] + if not ft_utils.download_url(image_url, dest_path): + return False + image = os_utils.create_glance_image( + glance, image_name, dest_path + file_name) + if not image: + return False + return image + class ImsVnf(vnf_base.VnfOnBoardingBase): - def __init__(self, project='functest', case='opera_ims', + def __init__(self, project='functest', case='orchestra_ims', repo='', cmd=''): super(ImsVnf, self).__init__(project, case, repo, cmd) - self.logger = ft_logger.Logger("vIMS").getLogger() - self.case_dir = os.path.join(CONST.functest_test, 'vnf/ims/') - self.data_dir = CONST.dir_vIMS_data + self.ob_password = "openbaton" + self.ob_username = "admin" + self.ob_https = False + self.ob_port = "8080" + self.ob_ip = "localhost" + self.ob_instance_id = "" + self.logger = ft_logger.Logger("orchestra_ims").getLogger() + self.case_dir = os.path.join(CONST.dir_functest_test, 'vnf/ims/') + self.data_dir = CONST.dir_ims_data self.test_dir = CONST.dir_repo_vims_test - + self.ob_projectid = "" + self.keystone_client = os_utils.get_keystone_client() + self.ob_nsr_id = "" + self.main_agent = None # vIMS Data directory creation if not os.path.exists(self.data_dir): os.makedirs(self.data_dir) + # Retrieve the configuration + try: + self.config = CONST.__getattribute__( + 'vnf_{}_config'.format(self.case_name)) + except: + raise Exception("Orchestra VNF config file not found") + config_file = self.case_dir + self.config + self.imagename = get_config("openbaton.imagename", config_file) + self.market_link = get_config("openbaton.marketplace_link", + config_file) + self.images = get_config("tenant_images", config_file) def deploy_orchestrator(self, **kwargs): - # TODO - # deploy open-O from Functest docker located on the Jumphost - # you have admin rights on OpenStack SUT - # you can cretae a VM, spawn docker on the jumphost - # spawn docker on a VM in the SUT, ..up to you - # - # note: this step can be ignored - # if Open-O is part of the installer + self.logger.info("Additional pre-configuration steps") + nova_client = os_utils.get_nova_client() + neutron_client = os_utils.get_neutron_client() + glance_client = os_utils.get_glance_client() + + # needs some images + self.logger.info("Upload some OS images if it doesn't exist") + temp_dir = os.path.join(self.data_dir, "tmp/") + for image_name, image_url in self.images.iteritems(): + self.logger.info("image: %s, url: %s" % (image_name, image_url)) + try: + image_id = os_utils.get_image_id(glance_client, + image_name) + self.logger.info("image_id: %s" % image_id) + except: + self.logger.error("Unexpected error: %s" % sys.exc_info()[0]) + + if image_id == '': + self.logger.info("""%s image doesn't exist on glance repository. Try + downloading this image and upload on glance !""" % image_name) + image_id = download_and_add_image_on_glance(glance_client, + image_name, + image_url, + temp_dir) + if image_id == '': + self.step_failure( + "Failed to find or upload required OS " + "image for this deployment") + network_dic = os_utils.create_network_full(neutron_client, + "openbaton_mgmt", + "openbaton_mgmt_subnet", + "openbaton_router", + "192.168.100.0/24") + + # orchestrator VM flavor + self.logger.info("Check medium Flavor is available, if not create one") + flavor_exist, flavor_id = os_utils.get_or_create_flavor( + "m1.medium", + "4096", + '1', + '2', + public=True) + self.logger.debug("Flavor id: %s" % flavor_id) + + if not network_dic: + self.logger.error("There has been a problem when creating the " + "neutron network") + + network_id = network_dic["net_id"] + + self.logger.info("Creating floating IP for VM in advance...") + floatip_dic = os_utils.create_floating_ip(neutron_client) + floatip = floatip_dic['fip_addr'] + + if floatip is None: + self.logger.error("Cannot create floating IP.") + + userdata = "#!/bin/bash\n" + userdata += "set -x\n" + userdata += "set -e\n" + userdata += "echo \"nameserver 8.8.8.8\" >> /etc/resolv.conf\n" + userdata += "apt-get install curl\n" + userdata += ("echo \"rabbitmq_broker_ip=%s\" > ./config_file\n" + % floatip) + userdata += "echo \"mysql=no\" >> ./config_file\n" + userdata += ("echo \"ssh-rsa AAAAB3NzaC1yc2EAAAADAQABAAABAQCuPXrV3" + "geeHc6QUdyUr/1Z+yQiqLcOskiEGBiXr4z76MK4abiFmDZ18OMQlc" + "fl0p3kS0WynVgyaOHwZkgy/DIoIplONVr2CKBKHtPK+Qcme2PVnCtv" + "EqItl/FcD+1h5XSQGoa+A1TSGgCod/DPo+pes0piLVXP8Ph6QS1k7S" + "ic7JDeRQ4oT1bXYpJ2eWBDMfxIWKZqcZRiGPgMIbJ1iEkxbpeaAd9O" + "4MiM9nGCPESmed+p54uYFjwEDlAJZShcAZziiZYAvMZhvAhe6USljc" + "7YAdalAnyD/jwCHuwIrUw/lxo7UdNCmaUxeobEYyyFA1YVXzpNFZya" + "XPGAAYIJwEq/ openbaton@opnfv\" >> /home/ubuntu/.ssh/aut" + "horized_keys\n") + userdata += "cat ./config_file\n" + userdata += ("curl -s http://get.openbaton.org/bootstrap " + "> ./bootstrap\n") + userdata += "export OPENBATON_COMPONENT_AUTOSTART=false\n" + bootstrap = "sh ./bootstrap release -configFile=./config_file" + userdata += bootstrap + "\n" + + userdata += ("echo \"nfvo.plugin.timeout=300000\" >> " + "/etc/openbaton/openbaton-nfvo.properties\n") + userdata += "service openbaton-nfvo restart\n" + userdata += "service openbaton-vnfm-generic restart\n" + + sg_id = os_utils.create_security_group_full(neutron_client, + "orchestra-sec-group", + "allowall") + + os_utils.create_secgroup_rule(neutron_client, sg_id, "ingress", + "icmp", 0, 255) + os_utils.create_secgroup_rule(neutron_client, sg_id, "egress", + "icmp", 0, 255) + os_utils.create_secgroup_rule(neutron_client, sg_id, "ingress", + "tcp", 1, 65535) + os_utils.create_secgroup_rule(neutron_client, sg_id, "ingress", + "udp", 1, 65535) + os_utils.create_secgroup_rule(neutron_client, sg_id, "egress", + "tcp", 1, 65535) + os_utils.create_secgroup_rule(neutron_client, sg_id, "egress", + "udp", 1, 65535) + + self.logger.info("Security group set") + + self.logger.info("Create instance....") + self.logger.info("flavor: m1.medium\n" + "image: %s\n" + "network_id: %s\n" + "userdata: %s\n" + % (self.imagename, network_id, userdata)) + + instance = os_utils.create_instance_and_wait_for_active( + "m1.medium", + os_utils.get_image_id(glance_client, self.imagename), + network_id, + "orchestra-openbaton", + config_drive=False, + userdata=userdata) + + self.ob_instance_id = instance.id + + self.logger.info("Adding sec group to orchestra instance") + os_utils.add_secgroup_to_instance(nova_client, + self.ob_instance_id, sg_id) + + self.logger.info("Associating floating ip: '%s' to VM '%s' " + % (floatip, "orchestra-openbaton")) + if not os_utils.add_floating_ip(nova_client, instance.id, floatip): + self.logger.error("Cannot associate floating IP to VM.") + self.step_failure("Cannot associate floating IP to VM.") + + self.logger.info("Waiting for nfvo to be up and running...") + x = 0 + while x < 100: + if servertest(floatip, "8080"): + break + else: + self.logger.debug("openbaton is not started yet") + time.sleep(5) + x += 1 + + if x == 100: + self.logger.error("Openbaton is not started correctly") + self.step_failure("Openbaton is not started correctly") + + self.ob_ip = floatip + self.ob_password = "openbaton" + self.ob_username = "admin" + self.ob_https = False + self.ob_port = "8080" + self.logger.info("Deploy orchestrator: OK") def deploy_vnf(self): - # TODO - self.logger.info("Deploy VNF: OK") + self.logger.info("vIMS Deployment") + + self.main_agent = MainAgent(nfvo_ip=self.ob_ip, + nfvo_port=self.ob_port, + https=self.ob_https, + version=1, + username=self.ob_username, + password=self.ob_password) + + project_agent = self.main_agent.get_agent("project", self.ob_projectid) + for p in json.loads(project_agent.find()): + if p.get("name") == "default": + self.ob_projectid = p.get("id") + break + + self.logger.debug("project id: %s" % self.ob_projectid) + if self.ob_projectid == "": + self.logger.error("Default project id was not found!") + self.step_failure("Default project id was not found!") + + vim_json = { + "name": "vim-instance", + "authUrl": os_utils.get_credentials().get("auth_url"), + "tenant": os_utils.get_credentials().get("tenant_name"), + "username": os_utils.get_credentials().get("username"), + "password": os_utils.get_credentials().get("password"), + # "keyPair": "opnfv", + # TODO change the keypair to correct value + # or upload a correct one or remove it + "securityGroups": [ + "default", + "orchestra-sec-group" + ], + "type": "openstack", + "location": { + "name": "opnfv", + "latitude": "52.525876", + "longitude": "13.314400" + } + } + + self.logger.debug("vim: %s" % vim_json) + + self.main_agent.get_agent( + "vim", + project_id=self.ob_projectid).create(entity=json.dumps(vim_json)) + + market_agent = self.main_agent.get_agent("market", + project_id=self.ob_projectid) + + nsd = {} + try: + self.logger.info("sending: %s" % self.market_link) + nsd = market_agent.create(entity=self.market_link) + self.logger.info("Onboarded nsd: " + nsd.get("name")) + except NfvoException as e: + self.step_failure(e.message) + + nsr_agent = self.main_agent.get_agent("nsr", + project_id=self.ob_projectid) + nsd_id = nsd.get('id') + if nsd_id is None: + self.step_failure("NSD not onboarded correctly") + + nsr = None + try: + nsr = nsr_agent.create(nsd_id) + except NfvoException as e: + self.step_failure(e.message) + + if nsr.get('code') is not None: + self.logger.error( + "vIMS cannot be deployed: %s -> %s" % + (nsr.get('code'), nsr.get('message'))) + self.step_failure("vIMS cannot be deployed") + + i = 0 + self.logger.info("waiting NSR to go to active...") + while nsr.get("status") != 'ACTIVE' and nsr.get("status") != 'ERROR': + i += 1 + if i == 100: + self.step_failure("After %s sec the nsr did not go to active.." + % 5 * 100) + time.sleep(5) + nsr = json.loads(nsr_agent.find(nsr.get('id'))) + + if nsr.get("status") == 'ACTIVE': + deploy_vnf = {'status': "PASS", 'result': nsr} + self.logger.info("Deploy VNF: OK") + else: + deploy_vnf = {'status': "FAIL", 'result': nsr} + self.logger.error("Deploy VNF: ERROR") + self.step_failure("Deploy vIMS failed") + self.ob_nsr_id = nsr.get("id") + return deploy_vnf def test_vnf(self): # Adaptations probably needed # code used for cloudify_ims # ruby client on jumphost calling the vIMS on the SUT - script = "source {0}venv_cloudify/bin/activate; " - script += "cd {0}; " - script += "cfy status | grep -Eo \"([0-9]{{1,3}}\.){{3}}[0-9]{{1,3}}\"" - cmd = "/bin/bash -c '" + script.format(self.data_dir) + "'" + return - try: - self.logger.debug("Trying to get clearwater manager IP ... ") - mgr_ip = os.popen(cmd).read() - mgr_ip = mgr_ip.splitlines()[0] - except: - self.step_failure("Unable to retrieve the IP of the " - "cloudify manager server !") - - api_url = "http://" + mgr_ip + "/api/v2" - dep_outputs = requests.get(api_url + "/deployments/" + - self.vnf.deployment_name + "/outputs") - dns_ip = dep_outputs.json()['outputs']['dns_ip'] - ellis_ip = dep_outputs.json()['outputs']['ellis_ip'] - - ellis_url = "http://" + ellis_ip + "/" - url = ellis_url + "accounts" - - params = {"password": "functest", - "full_name": "opnfv functest user", - "email": "functest@opnfv.fr", - "signup_code": "secret"} - - rq = requests.post(url, data=params) - i = 20 - while rq.status_code != 201 and i > 0: - rq = requests.post(url, data=params) - i = i - 1 - time.sleep(10) - - if rq.status_code == 201: - url = ellis_url + "session" - rq = requests.post(url, data=params) - cookies = rq.cookies - - url = ellis_url + "accounts/" + params['email'] + "/numbers" - if cookies != "": - rq = requests.post(url, cookies=cookies) - i = 24 - while rq.status_code != 200 and i > 0: - rq = requests.post(url, cookies=cookies) - i = i - 1 - time.sleep(25) - - if rq.status_code != 200: - self.step_failure("Unable to create a number: %s" - % rq.json()['reason']) - - nameservers = ft_utils.get_resolvconf_ns() - resolvconf = "" - for ns in nameservers: - resolvconf += "\nnameserver " + ns - - if dns_ip != "": - script = ('echo -e "nameserver ' + dns_ip + resolvconf + - '" > /etc/resolv.conf; ') - script += 'source /etc/profile.d/rvm.sh; ' - script += 'cd {0}; ' - script += ('rake test[{1}] SIGNUP_CODE="secret"') - - cmd = ("/bin/bash -c '" + - script.format(self.data_dir, self.inputs["public_domain"]) + - "'") - output_file = "output.txt" - f = open(output_file, 'w+') - subprocess.call(cmd, shell=True, stdout=f, - stderr=subprocess.STDOUT) - f.close() - - f = open(output_file, 'r') - result = f.read() - if result != "": - self.logger.debug(result) - - vims_test_result = "" - tempFile = os.path.join(self.test_dir, "temp.json") - try: - self.logger.debug("Trying to load test results") - with open(tempFile) as f: - vims_test_result = json.load(f) - f.close() - except: - self.logger.error("Unable to retrieve test results") + def clean(self): + self.main_agent.get_agent( + "nsr", + project_id=self.ob_projectid).delete(self.ob_nsr_id) + time.sleep(5) + os_utils.delete_instance(nova_client=os_utils.get_nova_client(), + instance_id=self.ob_instance_id) + # TODO question is the clean removing also the VM? + # I think so since is goinf to remove the tenant... + super(ImsVnf, self).clean() - try: - os.remove(tempFile) - except: - self.logger.error("Deleting file failed") + def main(self, **kwargs): + self.logger.info("Orchestra IMS VNF onboarding test starting") + self.execute() + self.logger.info("Orchestra IMS VNF onboarding test executed") + if self.criteria is "PASS": + return self.EX_OK + else: + return self.EX_RUN_ERROR - if vims_test_result != '': - return {'status': 'PASS', 'result': vims_test_result} - else: - return {'status': 'FAIL', 'result': ''} + def run(self): + kwargs = {} + return self.main(**kwargs) - def clean(self): - # TODO - super(ImsVnf, self).clean() + +if __name__ == '__main__': + test = ImsVnf() + test.deploy_orchestrator() + test.deploy_vnf() + test.clean() diff --git a/functest/opnfv_tests/vnf/ims/orchestra_ims.py b/functest/opnfv_tests/vnf/ims/orchestra_ims.py index 28f37f05..352b609b 100644 --- a/functest/opnfv_tests/vnf/ims/orchestra_ims.py +++ b/functest/opnfv_tests/vnf/ims/orchestra_ims.py @@ -8,150 +8,383 @@ # http://www.apache.org/licenses/LICENSE-2.0 import json -import os -import requests -import subprocess +import socket +import sys import time +import yaml import functest.core.vnf_base as vnf_base import functest.utils.functest_logger as ft_logger import functest.utils.functest_utils as ft_utils +import functest.utils.openstack_utils as os_utils +import os from functest.utils.constants import CONST +from org.openbaton.cli.agents.agents import MainAgent +from org.openbaton.cli.errors.errors import NfvoException -class ImsVnf(vnf_base.VnfOnBoardingBase): +def servertest(host, port): + args = socket.getaddrinfo(host, port, socket.AF_INET, socket.SOCK_STREAM) + for family, socktype, proto, canonname, sockaddr in args: + s = socket.socket(family, socktype, proto) + try: + s.connect(sockaddr) + except socket.error: + return False + else: + s.close() + return True + + +class ImsVnf(vnf_base.VnfOnBoardingBase): def __init__(self, project='functest', case='orchestra_ims', repo='', cmd=''): super(ImsVnf, self).__init__(project, case, repo, cmd) - self.logger = ft_logger.Logger("vIMS").getLogger() - self.case_dir = os.path.join(CONST.functest_test, 'vnf/ims/') - self.data_dir = CONST.dir_vIMS_data + self.ob_password = "openbaton" + self.ob_username = "admin" + self.ob_https = False + self.ob_port = "8080" + self.ob_ip = "localhost" + self.ob_instance_id = "" + self.logger = ft_logger.Logger("orchestra_ims").getLogger() + self.case_dir = os.path.join(CONST.dir_functest_test, 'vnf/ims/') + self.data_dir = CONST.dir_ims_data self.test_dir = CONST.dir_repo_vims_test - + self.ob_projectid = "" + self.keystone_client = os_utils.get_keystone_client() + self.ob_nsr_id = "" + self.main_agent = None # vIMS Data directory creation if not os.path.exists(self.data_dir): os.makedirs(self.data_dir) + # Retrieve the configuration + try: + self.config = CONST.__getattribute__( + 'vnf_{}_config'.format(self.case_name)) + except: + raise Exception("Orchestra VNF config file not found") + config_file = self.case_dir + self.config + self.imagename = get_config("openbaton.imagename", config_file) + self.market_link = get_config("openbaton.marketplace_link", + config_file) + self.images = get_config("tenant_images", config_file) def deploy_orchestrator(self, **kwargs): - # TODO - # put your code here to deploy openbaton - # from the functest docker located on the jumphost - # you have admin rights on OpenStack SUT - # you can cretae a VM, spawn docker on the jumphost - # spawn docker on a VM in the SUT, ..up to you - # - # note: this step can be ignored - # if OpenBaton is part of the installer + self.logger.info("Additional pre-configuration steps") + nova_client = os_utils.get_nova_client() + neutron_client = os_utils.get_neutron_client() + glance_client = os_utils.get_glance_client() + + # Import images if needed + self.logger.info("Upload some OS images if it doesn't exist") + temp_dir = os.path.join(self.data_dir, "tmp/") + for image_name, image_url in self.images.iteritems(): + self.logger.info("image: %s, url: %s" % (image_name, image_url)) + try: + image_id = os_utils.get_image_id(glance_client, + image_name) + self.logger.info("image_id: %s" % image_id) + except: + self.logger.error("Unexpected error: %s" % sys.exc_info()[0]) + + if image_id == '': + self.logger.info("""%s image doesn't exist on glance repository. Try + downloading this image and upload on glance !""" % image_name) + image_id = download_and_add_image_on_glance(glance_client, + image_name, + image_url, + temp_dir) + if image_id == '': + self.step_failure( + "Failed to find or upload required OS " + "image for this deployment") + network_dic = os_utils.create_network_full(neutron_client, + "openbaton_mgmt", + "openbaton_mgmt_subnet", + "openbaton_router", + "192.168.100.0/24") + + # orchestrator VM flavor + self.logger.info("Check medium Flavor is available, if not create one") + flavor_exist, flavor_id = os_utils.get_or_create_flavor( + "m1.medium", + "4096", + '20', + '2', + public=True) + self.logger.debug("Flavor id: %s" % flavor_id) + + if not network_dic: + self.logger.error("There has been a problem when creating the " + "neutron network") + + network_id = network_dic["net_id"] + + self.logger.info("Creating floating IP for VM in advance...") + floatip_dic = os_utils.create_floating_ip(neutron_client) + floatip = floatip_dic['fip_addr'] + + if floatip is None: + self.logger.error("Cannot create floating IP.") + + userdata = "#!/bin/bash\n" + userdata += "set -x\n" + userdata += "set -e\n" + userdata += "echo \"nameserver 8.8.8.8\" >> /etc/resolv.conf\n" + userdata += "apt-get install curl\n" + userdata += ("echo \"rabbitmq_broker_ip=%s\" > ./config_file\n" + % floatip) + userdata += "echo \"mysql=no\" >> ./config_file\n" + userdata += ("echo \"ssh-rsa AAAAB3NzaC1yc2EAAAADAQABAAABAQCuPXrV3" + "geeHc6QUdyUr/1Z+yQiqLcOskiEGBiXr4z76MK4abiFmDZ18OMQlc" + "fl0p3kS0WynVgyaOHwZkgy/DIoIplONVr2CKBKHtPK+Qcme2PVnCtv" + "EqItl/FcD+1h5XSQGoa+A1TSGgCod/DPo+pes0piLVXP8Ph6QS1k7S" + "ic7JDeRQ4oT1bXYpJ2eWBDMfxIWKZqcZRiGPgMIbJ1iEkxbpeaAd9O" + "4MiM9nGCPESmed+p54uYFjwEDlAJZShcAZziiZYAvMZhvAhe6USljc" + "7YAdalAnyD/jwCHuwIrUw/lxo7UdNCmaUxeobEYyyFA1YVXzpNFZya" + "XPGAAYIJwEq/ openbaton@opnfv\" >> /home/ubuntu/.ssh/aut" + "horized_keys\n") + userdata += "cat ./config_file\n" + userdata += ("curl -s http://get.openbaton.org/bootstrap " + "> ./bootstrap\n") + userdata += "export OPENBATON_COMPONENT_AUTOSTART=false\n" + bootstrap = "sh ./bootstrap release -configFile=./config_file" + userdata += bootstrap + "\n" + + userdata += ("echo \"nfvo.plugin.timeout=300000\" >> " + "/etc/openbaton/openbaton-nfvo.properties\n") + userdata += "service openbaton-nfvo restart\n" + userdata += "service openbaton-vnfm-generic restart\n" + + sg_id = os_utils.create_security_group_full(neutron_client, + "orchestra-sec-group", + "allowall") + + os_utils.create_secgroup_rule(neutron_client, sg_id, "ingress", + "icmp", 0, 255) + os_utils.create_secgroup_rule(neutron_client, sg_id, "egress", + "icmp", 0, 255) + os_utils.create_secgroup_rule(neutron_client, sg_id, "ingress", + "tcp", 1, 65535) + os_utils.create_secgroup_rule(neutron_client, sg_id, "ingress", + "udp", 1, 65535) + os_utils.create_secgroup_rule(neutron_client, sg_id, "egress", + "tcp", 1, 65535) + os_utils.create_secgroup_rule(neutron_client, sg_id, "egress", + "udp", 1, 65535) + + self.logger.info("Security group set") + + self.logger.info("Create instance....") + self.logger.info("flavor: m1.medium\n" + "image: %s\n" + "network_id: %s\n" + "userdata: %s\n" + % (self.imagename, network_id, userdata)) + + instance = os_utils.create_instance_and_wait_for_active( + "m1.medium", + os_utils.get_image_id(glance_client, self.imagename), + network_id, + "orchestra-openbaton", + config_drive=False, + userdata=userdata) + + self.ob_instance_id = instance.id + + self.logger.info("Adding sec group to orchestra instance") + os_utils.add_secgroup_to_instance(nova_client, + self.ob_instance_id, sg_id) + + self.logger.info("Associating floating ip: '%s' to VM '%s' " + % (floatip, "orchestra-openbaton")) + if not os_utils.add_floating_ip(nova_client, instance.id, floatip): + self.logger.error("Cannot associate floating IP to VM.") + self.step_failure("Cannot associate floating IP to VM.") + + self.logger.info("Waiting for nfvo to be up and running...") + x = 0 + while x < 100: + if servertest(floatip, "8080"): + break + else: + self.logger.debug("openbaton is not started yet") + time.sleep(5) + x += 1 + + if x == 100: + self.logger.error("Openbaton is not started correctly") + self.step_failure("Openbaton is not started correctly") + + self.ob_ip = floatip + self.ob_password = "openbaton" + self.ob_username = "admin" + self.ob_https = False + self.ob_port = "8080" + self.logger.info("Deploy orchestrator: OK") def deploy_vnf(self): - # deploy the VNF - # call openbaton to deploy the vIMS + self.logger.info("vIMS Deployment") + + self.main_agent = MainAgent(nfvo_ip=self.ob_ip, + nfvo_port=self.ob_port, + https=self.ob_https, + version=1, + username=self.ob_username, + password=self.ob_password) + + project_agent = self.main_agent.get_agent("project", self.ob_projectid) + for p in json.loads(project_agent.find()): + if p.get("name") == "default": + self.ob_projectid = p.get("id") + break + + self.logger.debug("project id: %s" % self.ob_projectid) + if self.ob_projectid == "": + self.logger.error("Default project id was not found!") + self.step_failure("Default project id was not found!") + + vim_json = { + "name": "vim-instance", + "authUrl": os_utils.get_credentials().get("auth_url"), + "tenant": os_utils.get_credentials().get("tenant_name"), + "username": os_utils.get_credentials().get("username"), + "password": os_utils.get_credentials().get("password"), + "keyPair": "opnfv", + # TODO change the keypair to correct value + # or upload a correct one or remove it + "securityGroups": [ + "default", + "orchestra-sec-group" + ], + "type": "openstack", + "location": { + "name": "opnfv", + "latitude": "52.525876", + "longitude": "13.314400" + } + } + + self.logger.debug("vim: %s" % vim_json) + + self.main_agent.get_agent( + "vim", + project_id=self.ob_projectid).create(entity=json.dumps(vim_json)) + + market_agent = self.main_agent.get_agent("market", + project_id=self.ob_projectid) + + nsd = {} + try: + self.logger.info("sending: %s" % self.market_link) + nsd = market_agent.create(entity=self.market_link) + self.logger.info("Onboarded nsd: " + nsd.get("name")) + except NfvoException as e: + self.step_failure(e.message) + + nsr_agent = self.main_agent.get_agent("nsr", + project_id=self.ob_projectid) + nsd_id = nsd.get('id') + if nsd_id is None: + self.step_failure("NSD not onboarded correctly") + + nsr = None + try: + nsr = nsr_agent.create(nsd_id) + except NfvoException as e: + self.step_failure(e.message) + + if nsr is None: + self.step_failure("NSR not deployed correctly") + + i = 0 + self.logger.info("waiting NSR to go to active...") + while nsr.get("status") != 'ACTIVE': + i += 1 + if i == 100: + self.step_failure("After %s sec the nsr did not go to active.." + % 5 * 100) + time.sleep(5) + nsr = json.loads(nsr_agent.find(nsr.get('id'))) + + deploy_vnf = {'status': "PASS", 'result': nsr} + self.ob_nsr_id = nsr.get("id") self.logger.info("Deploy VNF: OK") + return deploy_vnf def test_vnf(self): # Adaptations probably needed # code used for cloudify_ims # ruby client on jumphost calling the vIMS on the SUT - script = "source {0}venv_cloudify/bin/activate; " - script += "cd {0}; " - script += "cfy status | grep -Eo \"([0-9]{{1,3}}\.){{3}}[0-9]{{1,3}}\"" - cmd = "/bin/bash -c '" + script.format(self.data_dir) + "'" + return - try: - self.logger.debug("Trying to get clearwater manager IP ... ") - mgr_ip = os.popen(cmd).read() - mgr_ip = mgr_ip.splitlines()[0] - except: - self.step_failure("Unable to retrieve the IP of the " - "cloudify manager server !") - - api_url = "http://" + mgr_ip + "/api/v2" - dep_outputs = requests.get(api_url + "/deployments/" + - self.vnf.deployment_name + "/outputs") - dns_ip = dep_outputs.json()['outputs']['dns_ip'] - ellis_ip = dep_outputs.json()['outputs']['ellis_ip'] - - ellis_url = "http://" + ellis_ip + "/" - url = ellis_url + "accounts" - - params = {"password": "functest", - "full_name": "opnfv functest user", - "email": "functest@opnfv.fr", - "signup_code": "secret"} - - rq = requests.post(url, data=params) - i = 20 - while rq.status_code != 201 and i > 0: - rq = requests.post(url, data=params) - i = i - 1 - time.sleep(10) - - if rq.status_code == 201: - url = ellis_url + "session" - rq = requests.post(url, data=params) - cookies = rq.cookies - - url = ellis_url + "accounts/" + params['email'] + "/numbers" - if cookies != "": - rq = requests.post(url, cookies=cookies) - i = 24 - while rq.status_code != 200 and i > 0: - rq = requests.post(url, cookies=cookies) - i = i - 1 - time.sleep(25) - - if rq.status_code != 200: - self.step_failure("Unable to create a number: %s" - % rq.json()['reason']) - - nameservers = ft_utils.get_resolvconf_ns() - resolvconf = "" - for ns in nameservers: - resolvconf += "\nnameserver " + ns - - if dns_ip != "": - script = ('echo -e "nameserver ' + dns_ip + resolvconf + - '" > /etc/resolv.conf; ') - script += 'source /etc/profile.d/rvm.sh; ' - script += 'cd {0}; ' - script += ('rake test[{1}] SIGNUP_CODE="secret"') - - cmd = ("/bin/bash -c '" + - script.format(self.data_dir, self.inputs["public_domain"]) + - "'") - output_file = "output.txt" - f = open(output_file, 'w+') - subprocess.call(cmd, shell=True, stdout=f, - stderr=subprocess.STDOUT) - f.close() - - f = open(output_file, 'r') - result = f.read() - if result != "": - self.logger.debug(result) - - vims_test_result = "" - tempFile = os.path.join(self.test_dir, "temp.json") - try: - self.logger.debug("Trying to load test results") - with open(tempFile) as f: - vims_test_result = json.load(f) - f.close() - except: - self.logger.error("Unable to retrieve test results") + def clean(self): + self.main_agent.get_agent( + "nsr", + project_id=self.ob_projectid).delete(self.ob_nsr_id) + time.sleep(5) + os_utils.delete_instance(nova_client=os_utils.get_nova_client(), + instance_id=self.ob_instance_id) + # TODO question is the clean removing also the VM? + # I think so since is goinf to remove the tenant... + super(ImsVnf, self).clean() - try: - os.remove(tempFile) - except: - self.logger.error("Deleting file failed") + def main(self, **kwargs): + self.logger.info("Orchestra IMS VNF onboarding test starting") + self.execute() + self.logger.info("Orchestra IMS VNF onboarding test executed") + if self.criteria is "PASS": + return self.EX_OK + else: + return self.EX_RUN_ERROR - if vims_test_result != '': - return {'status': 'PASS', 'result': vims_test_result} - else: - return {'status': 'FAIL', 'result': ''} + def run(self): + kwargs = {} + return self.main(**kwargs) - def clean(self): - # TODO - super(ImsVnf, self).clean() + +if __name__ == '__main__': + test = ImsVnf() + test.deploy_orchestrator() + test.deploy_vnf() + test.clean() + + +# ---------------------------------------------------------- +# +# UTILS +# +# ----------------------------------------------------------- +def get_config(parameter, file): + """ + Returns the value of a given parameter in file.yaml + parameter must be given in string format with dots + Example: general.openstack.image_name + """ + with open(file) as f: + file_yaml = yaml.safe_load(f) + f.close() + value = file_yaml + for element in parameter.split("."): + value = value.get(element) + if value is None: + raise ValueError("The parameter %s is not defined in" + " reporting.yaml" % parameter) + return value + + +def download_and_add_image_on_glance(glance, image_name, + image_url, data_dir): + dest_path = data_dir + if not os.path.exists(dest_path): + os.makedirs(dest_path) + file_name = image_url.rsplit('/')[-1] + if not ft_utils.download_url(image_url, dest_path): + return False + image = os_utils.create_glance_image( + glance, image_name, dest_path + file_name) + if not image: + return False + return image diff --git a/functest/opnfv_tests/vnf/ims/orchestra_ims.yaml b/functest/opnfv_tests/vnf/ims/orchestra_ims.yaml new file mode 100644 index 00000000..2fb33df5 --- /dev/null +++ b/functest/opnfv_tests/vnf/ims/orchestra_ims.yaml @@ -0,0 +1,7 @@ +tenant_images: + ubuntu_14.04: http://cloud-images.ubuntu.com/trusty/current/trusty-server-cloudimg-amd64-disk1.img + openims: http://marketplace.openbaton.org:8082/api/v1/images/52e2ccc0-1dce-4663-894d-28aab49323aa/img +openbaton: + bootstrap: sh <(curl -s http://get.openbaton.org/bootstrap) release -configFile= + marketplace_link: http://marketplace.openbaton.org:8082/api/v1/nsds/fokus/OpenImsCore/3.2.0/json + imagename: ubuntu_14.04 diff --git a/functest/opnfv_tests/vnf/ims/orchestrator_cloudify.py b/functest/opnfv_tests/vnf/ims/orchestrator_cloudify.py index f3838f87..82a9dca0 100644 --- a/functest/opnfv_tests/vnf/ims/orchestrator_cloudify.py +++ b/functest/opnfv_tests/vnf/ims/orchestrator_cloudify.py @@ -21,7 +21,7 @@ from git import Repo import functest.utils.functest_logger as ft_logger -class Orchestrator: +class Orchestrator(object): def __init__(self, testcase_dir, inputs={}): self.testcase_dir = testcase_dir @@ -114,6 +114,7 @@ class Orchestrator: cmd = "/bin/bash -c '" + script + "'" error = execute_command(cmd, self.logger) if error: + self.logger.error("Failed to deploy cloudify-manager") return error self.logger.info("Cloudify-manager server is UP !") @@ -171,6 +172,7 @@ class Orchestrator: cmd = "/bin/bash -c '" + script + "'" error = execute_command(cmd, self.logger, 2000) if error: + self.logger.error("Failed to deploy blueprint") return error self.logger.info("The deployment of {0} is ended".format(dep_name)) @@ -228,7 +230,4 @@ def execute_command(cmd, logger, timeout=1800): logger.error("Error when executing command %s" % cmd) f = open(output_file, 'r') lines = f.readlines() - result = lines[len(lines) - 3] - result += lines[len(lines) - 2] - result += lines[len(lines) - 1] - return result + return lines[-5:] |