diff options
author | soumaya <soumaya.nayek@rebaca.com> | 2018-02-14 17:29:23 +0530 |
---|---|---|
committer | Cédric Ollivier <cedric.ollivier@orange.com> | 2018-02-15 16:59:28 +0100 |
commit | 703ce1ab7f6bd5fff51ced765ce6b7792b541eab (patch) | |
tree | 506d4e59f21ac7e041fa31903e14f3dc6d0a0065 | |
parent | 9476136e4f67cbb9853683c871bb699918a45ee6 (diff) |
Removed os_utils and fully switched to snaps
JIRA: FUNCTEST-925
Change-Id: Ibcbf42c34b764fda09d4d49513b261aae296a68b
Signed-off-by: soumaya <soumaya.nayek@rebaca.com>
-rw-r--r-- | functest/opnfv_tests/vnf/epc/juju_epc.py | 51 |
1 files changed, 39 insertions, 12 deletions
diff --git a/functest/opnfv_tests/vnf/epc/juju_epc.py b/functest/opnfv_tests/vnf/epc/juju_epc.py index 283a152fd..dc92bc920 100644 --- a/functest/opnfv_tests/vnf/epc/juju_epc.py +++ b/functest/opnfv_tests/vnf/epc/juju_epc.py @@ -17,27 +17,28 @@ import sys import uuid from copy import deepcopy from urlparse import urljoin +import pkg_resources +import yaml from functest.core import vnf from functest.opnfv_tests.openstack.snaps import snaps_utils from functest.utils.constants import CONST -import functest.utils.openstack_utils as os_utils -import pkg_resources from snaps.config.flavor import FlavorConfig from snaps.config.image import ImageConfig from snaps.config.network import NetworkConfig, SubnetConfig from snaps.config.router import RouterConfig +from snaps.config.security_group import ( + Direction, Protocol, SecurityGroupConfig, SecurityGroupRuleConfig) from snaps.config.user import UserConfig from snaps.openstack.create_flavor import OpenStackFlavor from snaps.openstack.create_image import OpenStackImage from snaps.openstack.create_network import OpenStackNetwork from snaps.openstack.create_router import OpenStackRouter +from snaps.openstack.create_security_group import OpenStackSecurityGroup from snaps.openstack.create_user import OpenStackUser from snaps.openstack.utils import keystone_utils -from snaps.openstack.utils import neutron_utils from snaps.openstack.utils import nova_utils -import yaml __author__ = "Amarendra Meher <amarendra@rebaca.com>" __author__ = "Soumaya K Nayek <soumaya.nayek@rebaca.com>" @@ -185,6 +186,21 @@ class JujuEpc(vnf.VnfOnBoarding): credentials_yaml)): raise vnf.VnfPreparationException + def _add_custom_rule(self, sec_grp_name): + """ To add custom rule for SCTP Traffic """ + sec_grp_rules = list() + security_group_init = OpenStackSecurityGroup( + self.snaps_creds, + SecurityGroupConfig( + name=sec_grp_name, + rule_settings=sec_grp_rules)) + security_group_init.initialize() + sctp_rule = SecurityGroupRuleConfig( + sec_grp_name=sec_grp_name, direction=Direction.ingress, + protocol=Protocol.sctp) + security_group_init.add_rule(sctp_rule) + self.created_object.append(security_group_init) + def prepare(self): """Prepare testcase (Additional pre-configuration steps).""" self.__logger.info("Additional pre-configuration steps") @@ -267,7 +283,7 @@ class JujuEpc(vnf.VnfOnBoarding): "OS_REGION_NAME", self.default_region_name), self.public_auth_url)) self.created_object.append(image_creator) - self.__logger.info("Credential information : %s", net_id) + self.__logger.info("Network ID : %s", net_id) juju_bootstrap_command = ( 'juju bootstrap abot-epc abot-controller --config network={} ' '--metadata-source ~ --config ssl-hostname-verification=false ' @@ -297,20 +313,21 @@ class JujuEpc(vnf.VnfOnBoarding): self.__logger.info("juju wait completed: %s", status) self.__logger.info("Deployed Abot-epc on Openstack") nova_client = nova_utils.nova_client(self.snaps_creds) - neutron_client = neutron_utils.neutron_client(self.snaps_creds) if status == 0: - instances = os_utils.get_instances(nova_client) + instances = get_instances(nova_client) + self.__logger.info("List of Instance: %s", instances) for items in instances: metadata = get_instance_metadata(nova_client, items) if 'juju-units-deployed' in metadata: - sec_group = ('juju-' + metadata['juju-controller-uuid'] + + sec_group = ('juju-' + + metadata['juju-controller-uuid'] + '-' + metadata['juju-model-uuid']) - self.sec_group_id = os_utils.get_security_group_id( - neutron_client, sec_group) + self.__logger.info("Instance: %s", sec_group) break self.__logger.info("Adding Security group rule....") - os_utils.create_secgroup_rule( - neutron_client, self.sec_group_id, 'ingress', 132) + # This will add sctp rule to a common Security Group Created + # by juju and shared to all deployed units. + self._add_custom_rule(sec_group) self.__logger.info("Copying the feature files to Abot_node ") os.system('juju scp -- -r {}/featureFiles abot-' 'epc-basic/0:~/'.format(self.case_dir)) @@ -481,6 +498,16 @@ def update_data(obj): return obj +def get_instances(nova_client): + """ To get all vm info of a project """ + try: + instances = nova_client.servers.list() + return instances + except Exception as exc: # pylint: disable=broad-except + logging.error("Error [get_instances(nova_client)]: %s", exc) + return None + + def get_instance_metadata(nova_client, instance): """ Get instance Metadata - Instance ID """ try: |