aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--functest/opnfv_tests/vnf/ims/cloudify_ims.py160
-rw-r--r--functest/opnfv_tests/vnf/ims/cloudify_ims.yaml6
2 files changed, 91 insertions, 75 deletions
diff --git a/functest/opnfv_tests/vnf/ims/cloudify_ims.py b/functest/opnfv_tests/vnf/ims/cloudify_ims.py
index c8a3498a9..b3b0ee4a9 100644
--- a/functest/opnfv_tests/vnf/ims/cloudify_ims.py
+++ b/functest/opnfv_tests/vnf/ims/cloudify_ims.py
@@ -12,6 +12,7 @@
import logging
import os
import time
+import uuid
from cloudify_rest_client import CloudifyClient
from cloudify_rest_client.executions import Execution
@@ -25,6 +26,7 @@ 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.user import UserConfig
from snaps.config.vm_inst import FloatingIpConfig, VmInstanceConfig
from snaps.openstack.create_flavor import OpenStackFlavor
from snaps.openstack.create_image import OpenStackImage
@@ -33,6 +35,7 @@ from snaps.openstack.create_keypairs import OpenStackKeypair
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 xtesting.energy import energy
@@ -112,19 +115,6 @@ class CloudifyIms(clearwater_ims_base.ClearwaterOnBoardingBase):
compute_quotas = self.os_project.update_compute_quotas(compute_quotas)
network_quotas = self.os_project.update_network_quotas(network_quotas)
- # needs some images
- self.__logger.info("Upload some OS images if it doesn't exist")
- for image_name, image_file in self.images.iteritems():
- self.__logger.info("image: %s, file: %s", image_name, image_file)
- if image_file and image_name:
- image_creator = OpenStackImage(
- self.snaps_creds,
- ImageConfig(
- name=image_name, image_user='cloud',
- img_format='qcow2', image_file=image_file))
- image_creator.create()
- self.created_object.append(image_creator)
-
def deploy_orchestrator(self):
# pylint: disable=too-many-locals,too-many-statements
"""
@@ -132,18 +122,59 @@ class CloudifyIms(clearwater_ims_base.ClearwaterOnBoardingBase):
network, security group, fip, VM creation
"""
- # network creation
-
start_time = time.time()
+
+ # orchestrator VM flavor
+ self.__logger.info("Get or create flavor for cloudify manager vm ...")
+ flavor_settings = FlavorConfig(
+ name="{}-{}".format(
+ self.orchestrator['requirements']['flavor']['name'],
+ self.uuid),
+ ram=self.orchestrator['requirements']['flavor']['ram_min'],
+ disk=50,
+ vcpus=2)
+ flavor_creator = OpenStackFlavor(self.snaps_creds, flavor_settings)
+ flavor_creator.create()
+ self.created_object.append(flavor_creator)
+
+ self.__logger.info("Creating a second user to bypass issues ...")
+ user_creator = OpenStackUser(
+ self.snaps_creds,
+ UserConfig(
+ name='cloudify_network_bug-{}'.format(self.uuid),
+ password=str(uuid.uuid4()),
+ project_name=self.tenant_name,
+ domain_name=self.snaps_creds.user_domain_name,
+ roles={'_member_': self.tenant_name}))
+ user_creator.create()
+ self.created_object.append(user_creator)
+
+ snaps_creds = user_creator.get_os_creds(self.snaps_creds.project_name)
+ self.__logger.debug("snaps creds: %s", snaps_creds)
+
self.__logger.info("Creating keypair ...")
kp_file = os.path.join(self.data_dir, "cloudify_ims.pem")
keypair_settings = KeypairConfig(
name='cloudify_ims_kp-{}'.format(self.uuid),
private_filepath=kp_file)
- keypair_creator = OpenStackKeypair(self.snaps_creds, keypair_settings)
+ keypair_creator = OpenStackKeypair(snaps_creds, keypair_settings)
keypair_creator.create()
self.created_object.append(keypair_creator)
+ # needs some images
+ self.__logger.info("Upload some OS images if it doesn't exist")
+ for image_name, image_file in self.images.iteritems():
+ self.__logger.info("image: %s, file: %s", image_name, image_file)
+ if image_file and image_name:
+ image_creator = OpenStackImage(
+ snaps_creds,
+ ImageConfig(
+ name=image_name, image_user='cloud',
+ img_format='qcow2', image_file=image_file))
+ image_creator.create()
+ self.created_object.append(image_creator)
+
+ # network creation
self.__logger.info("Creating full network ...")
subnet_settings = SubnetConfig(
name='cloudify_ims_subnet-{}'.format(self.uuid),
@@ -152,12 +183,12 @@ class CloudifyIms(clearwater_ims_base.ClearwaterOnBoardingBase):
network_settings = NetworkConfig(
name='cloudify_ims_network-{}'.format(self.uuid),
subnet_settings=[subnet_settings])
- network_creator = OpenStackNetwork(self.snaps_creds, network_settings)
+ network_creator = OpenStackNetwork(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)
+ ext_net_name = snaps_utils.get_ext_net_name(snaps_creds)
router_creator = OpenStackRouter(
- self.snaps_creds,
+ snaps_creds,
RouterConfig(
name='cloudify_ims_router-{}'.format(self.uuid),
external_gateway=ext_net_name,
@@ -178,36 +209,21 @@ class CloudifyIms(clearwater_ims_base.ClearwaterOnBoardingBase):
sec_grp_name="sg-cloudify-manager-{}".format(self.uuid),
direction=Direction.ingress, protocol=Protocol.udp,
port_range_min=1, port_range_max=65535))
-
security_group_creator = OpenStackSecurityGroup(
- self.snaps_creds,
+ snaps_creds,
SecurityGroupConfig(
name="sg-cloudify-manager-{}".format(self.uuid),
rule_settings=sg_rules))
-
security_group_creator.create()
self.created_object.append(security_group_creator)
- # orchestrator VM flavor
- self.__logger.info("Get or create flavor for cloudify manager vm ...")
-
- flavor_settings = FlavorConfig(
- name=self.orchestrator['requirements']['flavor']['name'],
- ram=self.orchestrator['requirements']['flavor']['ram_min'],
- disk=50,
- vcpus=2)
- flavor_creator = OpenStackFlavor(self.snaps_creds, flavor_settings)
- flavor_creator.create()
- self.created_object.append(flavor_creator)
image_settings = ImageConfig(
name=self.orchestrator['requirements']['os_image'],
image_user='centos',
exists=True)
-
port_settings = PortConfig(
name='cloudify_manager_port-{}'.format(self.uuid),
network_name=network_settings.name)
-
manager_settings = VmInstanceConfig(
name='cloudify_manager-{}'.format(self.uuid),
flavor=flavor_settings.name,
@@ -218,26 +234,23 @@ class CloudifyIms(clearwater_ims_base.ClearwaterOnBoardingBase):
name='cloudify_manager_fip-{}'.format(self.uuid),
port_name=port_settings.name,
router_name=router_creator.router_settings.name)])
-
manager_creator = OpenStackVmInstance(
- self.snaps_creds, manager_settings, image_settings,
+ snaps_creds, manager_settings, image_settings,
keypair_settings)
-
self.__logger.info("Creating cloudify manager VM")
manager_creator.create()
self.created_object.append(manager_creator)
- public_auth_url = keystone_utils.get_endpoint(
- self.snaps_creds, 'identity')
+ public_auth_url = keystone_utils.get_endpoint(snaps_creds, 'identity')
cfy_creds = dict(
- keystone_username=self.snaps_creds.username,
- keystone_password=self.snaps_creds.password,
- keystone_tenant_name=self.snaps_creds.project_name,
+ keystone_username=snaps_creds.username,
+ keystone_password=snaps_creds.password,
+ keystone_tenant_name=snaps_creds.project_name,
keystone_url=public_auth_url,
- region=self.snaps_creds.region_name,
- user_domain_name=self.snaps_creds.user_domain_name,
- project_domain_name=self.snaps_creds.project_domain_name)
+ region=snaps_creds.region_name,
+ user_domain_name=snaps_creds.user_domain_name,
+ project_domain_name=snaps_creds.project_domain_name)
self.__logger.info("Set creds for cloudify manager %s", cfy_creds)
cfy_client = CloudifyClient(
@@ -247,38 +260,35 @@ class CloudifyIms(clearwater_ims_base.ClearwaterOnBoardingBase):
self.orchestrator['object'] = cfy_client
self.__logger.info("Attemps running status of the Manager")
- cfy_status = None
- retry = 10
- while str(cfy_status) != 'running' and retry:
+ for loop in range(10):
try:
self.__logger.debug(
"status %s", cfy_client.manager.get_status())
cfy_status = cfy_client.manager.get_status()['status']
self.__logger.info(
"The current manager status is %s", cfy_status)
+ if str(cfy_status) != 'running':
+ raise Exception("Cloudify Manager isn't up and running")
+ self.__logger.info("Put OpenStack creds in manager")
+ secrets_list = cfy_client.secrets.list()
+ for k, val in cfy_creds.iteritems():
+ if not any(d.get('key', None) == k for d in secrets_list):
+ cfy_client.secrets.create(k, val)
+ else:
+ cfy_client.secrets.update(k, val)
+ break
except Exception: # pylint: disable=broad-except
- self.__logger.info(
- "Cloudify Manager isn't up and running. Retrying ...")
- retry = retry - 1
- time.sleep(30)
-
- if str(cfy_status) == 'running':
- self.__logger.info("Cloudify Manager is up and running")
+ self.logger.info(
+ "try %s: Cloudify Manager isn't up and running", loop + 1)
+ time.sleep(30)
else:
- raise Exception("Cloudify Manager isn't up and running")
-
- self.__logger.info("Put OpenStack creds in manager")
- secrets_list = cfy_client.secrets.list()
- for k, val in cfy_creds.iteritems():
- if not any(d.get('key', None) == k for d in secrets_list):
- cfy_client.secrets.create(k, val)
- else:
- cfy_client.secrets.update(k, val)
+ self.logger.error("Cloudify Manager isn't up and running")
+ return False
duration = time.time() - start_time
- self.__logger.info("Put private keypair in manager")
if manager_creator.vm_ssh_active(block=True):
+ self.__logger.info("Put private keypair in manager")
ssh = manager_creator.ssh_client()
scp = SCPClient(ssh.get_transport(), socket_timeout=15.0)
scp.put(kp_file, '~/')
@@ -290,6 +300,9 @@ class CloudifyIms(clearwater_ims_base.ClearwaterOnBoardingBase):
self.run_blocking_ssh_command(
ssh, cmd, "Unable to install packages on manager")
self.run_blocking_ssh_command(ssh, 'cfy status')
+ else:
+ self.__logger.error("Cannot connect to manager")
+ return False
self.details['orchestrator'].update(status='PASS', duration=duration)
@@ -312,16 +325,18 @@ class CloudifyIms(clearwater_ims_base.ClearwaterOnBoardingBase):
descriptor.get('file_name'), descriptor.get('name'))
self.__logger.info("Get or create flavor for all clearwater vm")
flavor_settings = FlavorConfig(
- name=self.vnf['requirements']['flavor']['name'],
+ name="{}-{}".format(
+ self.vnf['requirements']['flavor']['name'],
+ self.uuid),
ram=self.vnf['requirements']['flavor']['ram_min'],
disk=25,
- vcpus=1)
+ vcpus=2)
flavor_creator = OpenStackFlavor(self.snaps_creds, flavor_settings)
flavor_creator.create()
self.created_object.append(flavor_creator)
self.vnf['inputs'].update(dict(
- flavor_id=self.vnf['requirements']['flavor']['name'],
+ flavor_id=flavor_settings.name,
))
self.__logger.info("Create VNF Instance")
@@ -339,7 +354,8 @@ class CloudifyIms(clearwater_ims_base.ClearwaterOnBoardingBase):
execution = cfy_client.executions.start(descriptor.get('name'),
'install')
# Show execution log
- execution = wait_for_execution(cfy_client, execution, self.__logger)
+ execution = wait_for_execution(
+ cfy_client, execution, self.__logger, timeout=3600)
duration = time.time() - start_time
@@ -459,7 +475,7 @@ def get_config(parameter, file_path):
return value
-def wait_for_execution(client, execution, logger, timeout=1500, ):
+def wait_for_execution(client, execution, logger, timeout=3600, ):
"""Wait for a workflow execution on Cloudify Manager."""
# if execution already ended - return without waiting
if execution.status in Execution.END_STATES:
@@ -479,7 +495,7 @@ def wait_for_execution(client, execution, logger, timeout=1500, ):
execution_id=execution.id,
_offset=offset,
_size=batch_size,
- include_logs=False,
+ include_logs=True,
sort='@timestamp').items
offset = offset + len(event_list)
diff --git a/functest/opnfv_tests/vnf/ims/cloudify_ims.yaml b/functest/opnfv_tests/vnf/ims/cloudify_ims.yaml
index 3d4969242..a40fcc6b3 100644
--- a/functest/opnfv_tests/vnf/ims/cloudify_ims.yaml
+++ b/functest/opnfv_tests/vnf/ims/cloudify_ims.yaml
@@ -9,7 +9,7 @@ orchestrator:
version: '4.0'
requirements:
flavor:
- name: m1.medium
+ name: cloudify.medium
ram_min: 4096
os_image: 'cloudify_manager_4.0'
vnf:
@@ -21,7 +21,7 @@ vnf:
version: '122'
requirements:
flavor:
- name: m1.small
+ name: cloudify.small
ram_min: 2048
compute_quotas:
cores: 50
@@ -32,7 +32,7 @@ vnf:
port: 50
inputs:
image_id: 'ubuntu_14.04'
- flavor_id: 'm1.small'
+ flavor_id: 'cloudify.small'
agent_user: ubuntu
key_pair_name: cloudify_ims_kp
private_key_path: '/etc/cloudify/cloudify_ims.pem'