- self.logger.info("Instance '%s' is ACTIVE." % vmname)
-
- self.add_secgroup(vmname, vm.id, sg_id)
-
- return vm
-
- def waitVmActive(self, nova, vm):
- # sleep and wait for VM status change
- sleep_time = 3
- count = self.vm_boot_timeout / sleep_time
- while True:
- status = os_utils.get_instance_status(nova, vm)
- self.logger.debug("Status: %s" % status)
- if status == "ACTIVE":
- return True
- if status == "ERROR" or status == "error":
- return False
- if count == 0:
- self.logger.debug("Booting a VM timed out...")
- return False
- count -= 1
- time.sleep(sleep_time)
- return False
-
- def add_secgroup(self, vmname, vm_id, sg_id):
- self.logger.info("Adding '%s' to security group '%s'..." %
- (vmname, self.sg_name))
- os_utils.add_secgroup_to_instance(self.nova_client, vm_id, sg_id)
-
- def get_test_ip(self, vm):
- test_ip = vm.networks.get(self.private_net_name)[0]
- self.logger.debug("Instance '%s' got %s" % (vm.name, test_ip))
- return test_ip
-
- def parse_result(self, code, start_time, stop_time):
- test_status = "FAIL"
- if code == 0:
- self.logger.info("vPing OK")
- duration = round(stop_time - start_time, 1)
- self.logger.info("vPing duration:'%s'" % duration)
- test_status = "PASS"
- elif code == -2:
- duration = 0
- self.logger.info("Userdata is not supported in nova boot. "
- "Aborting test...")
+ self.cirros_image_config = None
+
+ def run(self):
+ """
+ Begins the test execution which should originate from the subclass
+ """
+ self.logger.info('Begin virtual environment setup')
+
+ self.start_time = time.time()
+ self.logger.info("vPing Start Time:'%s'" % (
+ datetime.fromtimestamp(self.start_time).strftime(
+ '%Y-%m-%d %H:%M:%S')))
+
+ image_base_name = '{}-{}'.format(
+ CONST.__getattribute__('vping_image_name'),
+ str(self.guid))
+ os_image_settings = openstack_tests.cirros_image_settings(
+ image_base_name, image_metadata=self.cirros_image_config)
+ self.logger.info("Creating image with name: '%s'" % image_base_name)
+
+ self.image_creator = deploy_utils.create_image(
+ self.os_creds, os_image_settings)
+ self.creators.append(self.image_creator)
+
+ private_net_name = CONST.__getattribute__(
+ 'vping_private_net_name') + self.guid
+ private_subnet_name = CONST.__getattribute__(
+ 'vping_private_subnet_name') + self.guid
+ private_subnet_cidr = CONST.__getattribute__(
+ 'vping_private_subnet_cidr')
+
+ vping_network_type = None
+ vping_physical_network = None
+ vping_segmentation_id = None
+
+ if (hasattr(CONST, 'vping_network_type')):
+ vping_network_type = CONST.__getattribute__(
+ 'vping_network_type')
+ if (hasattr(CONST, 'vping_physical_network')):
+ vping_physical_network = CONST.__getattribute__(
+ 'vping_physical_network')
+ if (hasattr(CONST, 'vping_segmentation_id')):
+ vping_segmentation_id = CONST.__getattribute__(
+ 'vping_segmentation_id')
+
+ self.logger.info(
+ "Creating network with name: '%s'" % private_net_name)
+ self.network_creator = deploy_utils.create_network(
+ self.os_creds,
+ NetworkSettings(
+ name=private_net_name,
+ network_type=vping_network_type,
+ physical_network=vping_physical_network,
+ segmentation_id=vping_segmentation_id,
+ subnet_settings=[SubnetSettings(
+ name=private_subnet_name,
+ cidr=private_subnet_cidr)]))
+ self.creators.append(self.network_creator)
+
+ self.logger.info(
+ "Creating flavor with name: '%s'" % self.flavor_name)
+ scenario = CONST.__getattribute__('DEPLOY_SCENARIO')
+ flavor_metadata = None
+ if 'ovs' in scenario or 'fdio' in scenario:
+ flavor_metadata = create_flavor.MEM_PAGE_SIZE_LARGE
+ flavor_creator = OpenStackFlavor(
+ self.os_creds,
+ FlavorSettings(name=self.flavor_name, ram=512, disk=1, vcpus=1,
+ metadata=flavor_metadata))
+ flavor_creator.create()
+ self.creators.append(flavor_creator)
+
+ def _execute(self):
+ """
+ Method called by subclasses after environment has been setup
+ :return: the exit code
+ """
+ self.logger.info('Begin test execution')
+
+ test_ip = self.vm1_creator.get_port_ip(
+ self.vm1_creator.instance_settings.port_settings[0].name)
+
+ if self.vm1_creator.vm_active(
+ block=True) and self.vm2_creator.vm_active(block=True):
+ result = self._do_vping(self.vm2_creator, test_ip)