def update_user_prop_image_master_node(context, image_name): # Get the Glance manager of Master region glance_ops = context.glance_manager_list[context.master_region_name] # Process table data properties = dict() is_public = None if context.table is not None: for row in __dataset_utils__.prepare_data(context.table): if 'param_name' in row.headings: if row['param_name'] == 'is_public': is_public = row['param_value'] else: real_value = get_real_value_of_image_property( glance_ops, row['param_value']) value = real_value if real_value is not None else row[ 'param_value'] properties.update({row['param_name']: value}) if is_public: glance_ops.update_image_properties_by_name( image_name, is_public=is_public, custom_properties=properties) else: glance_ops.update_image_properties_by_name( image_name, custom_properties=properties)
def ami_image_is_present_in_all_target_nodes(context, image_name): properties = dict() for region in context.glance_manager_list: if region != context.master_region_name: glance_ops = context.glance_manager_list[region] if context.table is not None: for row in __dataset_utils__.prepare_data(context.table): if 'param_name' in row.headings: real_value = get_real_value_of_image_property(glance_ops, row['param_value']) value = real_value if real_value is not None else row['param_value'] properties.update({row['param_name']: value}) image_details = glance_ops.get_images(image_name) sync_properties = image_details[0].properties if 'is_public' in properties: # is_public is not a property, it is a normal metadata of the image (Glance) sync_properties.update({u'is_public': str(image_details[0].is_public)}) __logger__.info("Properties to check in the image '%s' from '%s': '%s'", image_name, region, properties) assert_that(sync_properties, equal_to(properties), "GlanceSync has NOT synchronized the correct metadata velues for '{}' in '{}'" .format(image_name, region))
def ami_image_is_present_in_all_target_nodes(context, image_name): properties = dict() for region in context.glance_manager_list: if region != context.master_region_name: glance_ops = context.glance_manager_list[region] if context.table is not None: for row in __dataset_utils__.prepare_data(context.table): if 'param_name' in row.headings: real_value = get_real_value_of_image_property( glance_ops, row['param_value']) value = real_value if real_value is not None else row[ 'param_value'] properties.update({row['param_name']: value}) image_details = glance_ops.get_images(image_name) sync_properties = image_details[0].properties if 'is_public' in properties: # is_public is not a property, it is a normal metadata of the image (Glance) sync_properties.update( {u'is_public': str(image_details[0].is_public)}) __logger__.info( "Properties to check in the image '%s' from '%s': '%s'", image_name, region, properties) assert_that( sync_properties, equal_to(properties), "GlanceSync has NOT synchronized the correct metadata velues for '{}' in '{}'" .format(image_name, region))
def __get_real_att_value_image_in_master__(context, value_pattern): """ HELPER. This function returns the attribute value of the given image (master node). :param value_pattern (string): Attribute name to get its value from the stored image. For instance: checksum(image_name): - It will return the value of the attribute 'checksum' of the given image 'image_name' (Glance of Master node) :return string: Real att value of the image or None, it the given value is not a valid pattern """ glance_ops = context.glance_manager_list[context.master_region_name] real_value = get_real_value_of_image_property(glance_ops, value_pattern) __logger__.info("Real value for pattern '%s': '%s'", value_pattern, real_value) return real_value
def update_user_prop_image_master_node(context, image_name): # Get the Glance manager of Master region glance_ops = context.glance_manager_list[context.master_region_name] # Process table data properties = dict() if context.table is not None: for row in __dataset_utils__.prepare_data(context.table): if 'param_name' in row.headings: real_value = get_real_value_of_image_property(glance_ops, row['param_value']) value = real_value if real_value is not None else row['param_value'] properties.update({row['param_name']: value}) glance_ops.update_image_properties_by_name(image_name, custom_properties=properties)
def create_new_image(context, region_name, image_name, image_filename=None): """ HELPER: Create new image using given params and step context. :param region_name (string): Name of the node where image will be created :param context (Behave Context): Behave context :param image_name (string): Name of the image :param image_file (string): Filename to be used as image. :return: None """ __logger__.info( "Creating new image '%s' in region '%s'. Image filename: '%s'", image_name, region_name, image_filename) __dataset_utils__ = DatasetUtils() # Get Glance Manager for the given region glance_ops = context.glance_manager_list[region_name] properties = dict() if context.table is not None: for row in __dataset_utils__.prepare_data(context.table): if 'param_name' in row.headings: real_value = get_real_value_of_image_property( glance_ops, row['param_value']) value = real_value if real_value is not None else row[ 'param_value'] properties.update({row['param_name']: value}) # Create new image (pubic=True by default) is_public = True if "is_public" in properties: is_public = properties["is_public"] properties.pop("is_public") __logger__.debug("Is the image '%s' public?: '%s'", image_name, is_public) __logger__.debug("Image properties: '%s'", properties) # If filename is None, it will be the same as the image_name image_filename = image_name if image_filename is None else image_filename __logger__.debug("Image filename to use: '%s'", image_filename) glance_ops.create_image(image_name, image_filename, custom_properties=properties, is_public=is_public) context.created_images_list.append(image_name)
def create_new_image(context, region_name, image_name, image_filename=None): """ HELPER: Create new image using given params and step context. :param region_name (string): Name of the node where image will be created :param context (Behave Context): Behave context :param image_name (string): Name of the image :param image_file (string): Filename to be used as image. :return: None """ __logger__.info("Creating new image '%s' in region '%s'. Image filename: '%s'", image_name, region_name, image_filename) __dataset_utils__ = DatasetUtils() # Get Glance Manager for the given region glance_ops = context.glance_manager_list[region_name] properties = dict() if context.table is not None: for row in __dataset_utils__.prepare_data(context.table): if 'param_name' in row.headings: real_value = get_real_value_of_image_property(glance_ops, row['param_value']) value = real_value if real_value is not None else row['param_value'] properties.update({row['param_name']: value}) # Create new image (pubic=True by default) is_public = True if "is_public" in properties: is_public = properties["is_public"] properties.pop("is_public") __logger__.debug("Is the image '%s' public?: '%s'", image_name, is_public) __logger__.debug("Image properties: '%s'", properties) # If filename is None, it will be the same as the image_name image_filename = image_name if image_filename is None else image_filename __logger__.debug("Image filename to use: '%s'", image_filename) glance_ops.create_image(image_name, image_filename, custom_properties=properties, is_public=is_public) context.created_images_list.append(image_name)