Exemple #1
0
    def builder_did_create_target_image(self, builder, target, image_id,
                                        template, parameters):
        self.log.info(
            'builder_did_create_target_image() called in RHEVM plugin')
        self.status = "BUILDING"

        # TODO: This is a convenience variable for refactoring - rename
        self.new_image_id = builder.target_image.identifier

        # TODO: More convenience vars - revisit
        self.template = template
        self.target = target
        self.builder = builder

        # This lets our logging helper know what image is being operated on
        self.active_image = self.builder.target_image

        self.tdlobj = oz.TDL.TDL(
            xmlstring=self.template.xml,
            rootpw_required=self.app_config["tdl_require_root_pw"])

        # Add in target specific content
        #TODO-URGENT: Work out how to do this in the new framework
        #self.add_target_content()

        # Oz assumes unique names - TDL built for multiple backends guarantees
        # they are not unique.  We don't really care about the name so just
        # force uniqueness
        #  Oz now uses the tdlobject name property directly in several places
        # so we must change it
        self.tdlobj.name = "factory-build-" + self.new_image_id

        # In contrast to our original builders, we enter the cloud plugins with a KVM file already
        # created as the base_image.  As a result, all the Oz building steps are gone (and can be found
        # in the OS plugin(s)

        # OS plugin has already provided the initial file for us to work with
        # which we can currently assume is a raw KVM compatible image
        self.image = builder.target_image.data

        # Add the cloud-info file
        self.modify_oz_filesystem()

        # Finally, if our format is qcow2, do the transformation here if needed
        if ("rhevm_image_format" in self.app_config) and  (self.app_config["rhevm_image_format"] == "qcow2") \
           and not check_qcow_size(self.image):
            self.log.debug("Converting RAW image to qcow2 format")
            # TODO: When RHEV adds support, use the -c option to compress these images to save space
            #       (at that point, remove the qcow check as we always want to compress)
            qemu_img_cmd = qemu_convert_cmd(self.image,
                                            self.image + ".tmp.qcow2")
            (stdout, stderr, retcode) = subprocess_check_output(qemu_img_cmd)
            os.unlink(self.image)
            os.rename(self.image + ".tmp.qcow2", self.image)

        self.percent_complete = 100
        self.status = "COMPLETED"
Exemple #2
0
    def builder_did_create_target_image(self, builder, target, image_id, template, parameters):
        self.log.info('builder_did_create_target_image() called in RHEVM plugin')
        self.status="BUILDING"

        # TODO: This is a convenience variable for refactoring - rename
        self.new_image_id = builder.target_image.identifier

        # TODO: More convenience vars - revisit
        self.template = template
        self.target = target
        self.builder = builder

        # This lets our logging helper know what image is being operated on
        self.active_image = self.builder.target_image

        self.tdlobj = oz.TDL.TDL(xmlstring=self.template.xml, rootpw_required=self.app_config["tdl_require_root_pw"])

        # Add in target specific content
        #TODO-URGENT: Work out how to do this in the new framework
        #self.add_target_content()

        # Oz assumes unique names - TDL built for multiple backends guarantees
        # they are not unique.  We don't really care about the name so just
        # force uniqueness
        #  Oz now uses the tdlobject name property directly in several places
        # so we must change it
        self.tdlobj.name = "factory-build-" + self.new_image_id

        # In contrast to our original builders, we enter the cloud plugins with a KVM file already
        # created as the base_image.  As a result, all the Oz building steps are gone (and can be found
        # in the OS plugin(s)

        # OS plugin has already provided the initial file for us to work with
        # which we can currently assume is a raw KVM compatible image
        self.image = builder.target_image.data

        # Add the cloud-info file
        self.modify_oz_filesystem()

        # Finally, if our format is qcow2, do the transformation here if needed
        if ("rhevm_image_format" in self.app_config) and  (self.app_config["rhevm_image_format"] == "qcow2") \
           and not check_qcow_size(self.image):
            self.log.debug("Converting RAW image to qcow2 format")
            # TODO: When RHEV adds support, use the -c option to compress these images to save space
            #       (at that point, remove the qcow check as we always want to compress)
            qemu_img_cmd = qemu_convert_cmd( self.image, self.image + ".tmp.qcow2" )
            (stdout, stderr, retcode) = subprocess_check_output(qemu_img_cmd)
            os.unlink(self.image)
            os.rename(self.image + ".tmp.qcow2", self.image)

        self.percent_complete=100
        self.status="COMPLETED"
Exemple #3
0
    def builder_did_create_target_image(self, builder, target, image_id, template, parameters):
        self.target = target
        self.builder = builder
        self.modify_oz_filesystem()

        # OS plugin has already provided the initial file for us to work with
        # which we can currently assume is a raw image
        input_image = builder.target_image.data

        # Support conversion to alternate preferred image format
        # Currently only handle qcow2, but the size reduction of
        # using this avoids the performance penalty of uploading
        # (and launching) raw disk images on slow storage
        if self.app_config.get("openstack_image_format", "raw") == "qcow2":
            # None of the existing input base_image plugins produce compressed qcow2 output
            # the step below is either going from raw to compressed qcow2 or
            # uncompressed qcow2 to compressed qcow2
            self.log.debug("Converting image to compressed qcow2 format")
            tmp_output = input_image + ".tmp.qcow2"
            convert_cmd = qemu_convert_cmd(input_image, tmp_output, True)
            (stdout, stderr, retcode) = subprocess_check_output(convert_cmd)
            os.unlink(input_image)
            os.rename(tmp_output, input_image)
Exemple #4
0
    def builder_did_create_target_image(self, builder, target, image_id, template, parameters):
        self.target=target
        self.builder=builder 
        self.modify_oz_filesystem()

        # OS plugin has already provided the initial file for us to work with
        # which we can currently assume is a raw image
        input_image = builder.target_image.data

        # Support conversion to alternate preferred image format
        # Currently only handle qcow2, but the size reduction of
        # using this avoids the performance penalty of uploading
        # (and launching) raw disk images on slow storage
        if self.app_config.get('openstack_image_format', 'raw') == 'qcow2':
            # None of the existing input base_image plugins produce compressed qcow2 output
            # the step below is either going from raw to compressed qcow2 or
            # uncompressed qcow2 to compressed qcow2
            self.log.debug("Converting image to compressed qcow2 format")
            tmp_output = input_image + ".tmp.qcow2"
            convert_cmd = qemu_convert_cmd(input_image, tmp_output, True)
            (stdout, stderr, retcode) = subprocess_check_output(convert_cmd)
            os.unlink(input_image)
            os.rename(tmp_output, input_image)