def _create_numa_image(self, properties, location=None, name=None, disk_format=None, img_name="test-img"): """ The NUMA data can be put in the image properties instead of in the extra_specs of a flavor. This returns a glance image that can be used :param properties: a dict of k:v pairs :param location: (str) URL for cirros image to download :param name: file name of cirros image :param disk_format: (str) eg "qcow2" :param img_name: (str) a name to give the image :return: """ if location is None: location = self.config["cirros"]["location"] if name is None: name = self.config["cirros"]["name"] if disk_format is None: disk_format = self.config["cirros"]["disk_format"] cirros_loc = get_cloud_image(location, name) self.data.update({"cirros": cirros_loc}) # create the glance image with the image property set img = create_image(self.numa.glance, cirros_loc, disk_format=disk_format, img_name=img_name, properties=properties) return img
def test_mandatory_no_config(self): """ Tests image property with mandatory config drive, and no boot config drive option is set - Creates a glance image with img_config_drive set to "mandatory" - boots an image without specifying a config drive - verifies that the config drive is automatically created """ # Get an image that we can inject the property into location = self.config["cirros"]["location"] name = self.config["cirros"]["name"] disk_format = self.config["cirros"]["disk_format"] cirros_loc = self.sanity.get_cloud_image(location, name) self.data.update({"cirros": cirros_loc}) # create the glance image with the image property set self.logger.info("Creating config drive image...") config_drive_prop = {"img_config_drive": "mandatory"} img = create_image(self.sanity.glance, cirros_loc, disk_format=disk_format, img_name="config_drive_image", properties=config_drive_prop) time.sleep(5) # Make sure the property was set props = img.properties self.assertTrue("img_config_drive" in props) self.assertTrue(props.get("img_config_drive") == "mandatory") self.data.update({"image": img}) # Now, boot up the instance with this image and the small flavor self.logger.info("Booting up instance...") flave = self.sanity.get_flavor("m1.small") self.assertTrue(flave and flave.name == "m1.small") self.logger.info("Image status: {}".format(img)) instance = self.sanity.boot_instance(img, flave, scheduler_hints=self.group_id) # FIXME: This is a very fragile way of determining if the config # drive got created. Will this work on kilo if the logs change? # Create a monitor that will look for when the config drive is created. # We need to know where our initial boot object is first self.logger.info("Creating log monitor") inst = self.sanity.discover()[0] host_ip = inst.host.host cmd = "tail -f /var/log/nova/nova-compute.log" mon_name = "config_drive" iid = instance.id watcher = self.sanity.monitor(cmd, mon_name, host_ip, ConfigDriveHandler, iid) self.data["instances"] = [instance] # Poll for the instance self.logger.info("Waiting for instance to become ACTIVE") achieved = smog.nova.poll_status(instance, "ACTIVE") self.assertTrue(achieved) status = watcher.handler.result msg = "Status was {}".format(status) self.logger.info(msg) self.assertTrue(status[0] == "Success", "Monitor should find success")