Exemple #1
0
    def upload_image(self, context, session, instance, vdi_uuids, image_id):
        params = self._make_params(context, session, image_id)
        params['vdi_uuids'] = vdi_uuids

        props = params['properties'] = {}
        props['auto_disk_config'] = instance['auto_disk_config']
        props['os_type'] = instance['os_type'] or CONF.default_os_type

        compression_level = vm_utils.get_compression_level()
        if compression_level:
            props['xenapi_image_compression_level'] = compression_level

        auto_disk_config = utils.get_auto_disk_config_from_instance(instance)
        if utils.is_auto_disk_config_disabled(auto_disk_config):
            props["auto_disk_config"] = "disabled"

        try:
            self._call_glance_plugin(session, 'upload_vhd', params)
        except exception.PluginRetriesExceeded:
            raise exception.CouldNotUploadImage(image_id=image_id)
    def _get_metadata(self, context, instance, image_id):
        metadata = IMAGE_API.get(context, image_id)
        metadata['disk_format'] = 'vhd'
        metadata['container_format'] = 'ovf'
        metadata['auto_disk_config'] = str(instance['auto_disk_config'])
        metadata['os_type'] = instance.get('os_type') or (
            CONF.xenserver.default_os_type)
        # Set size as zero, so that it will update the size in the end
        # based on the uploaded image data.
        metadata['size'] = 0

        # Adjust the auto_disk_config value basing on instance's
        # system metadata.
        # TODO(mriedem): Consider adding an abstract base class for the
        # various image handlers to contain common code like this.
        auto_disk = nova_utils.get_auto_disk_config_from_instance(instance)
        if nova_utils.is_auto_disk_config_disabled(auto_disk):
            metadata['auto_disk_config'] = "disabled"

        return metadata
    def upload_image(self, context, session, instance, image_id, vdi_uuids):
        params = self._make_params(context, session, image_id)
        params["vdi_uuids"] = vdi_uuids

        props = params["properties"] = {}
        props["auto_disk_config"] = instance["auto_disk_config"]
        props["os_type"] = instance.get("os_type", None) or (CONF.xenserver.default_os_type)

        compression_level = vm_utils.get_compression_level()
        if compression_level:
            props["xenapi_image_compression_level"] = compression_level

        auto_disk_config = utils.get_auto_disk_config_from_instance(instance)
        if utils.is_auto_disk_config_disabled(auto_disk_config):
            props["auto_disk_config"] = "disabled"

        try:
            self._call_glance_plugin(context, instance, session, "upload_vhd2", params)
        except exception.PluginRetriesExceeded:
            raise exception.CouldNotUploadImage(image_id=image_id)
Exemple #4
0
    def upload_image(self, context, session, instance, vdi_uuids, image_id):
        params = self._make_params(context, session, image_id)
        params['vdi_uuids'] = vdi_uuids

        props = params['properties'] = {}
        props['auto_disk_config'] = instance['auto_disk_config']
        props['os_type'] = instance['os_type'] or CONF.default_os_type

        compression_level = vm_utils.get_compression_level()
        if compression_level:
            props['xenapi_image_compression_level'] = compression_level

        auto_disk_config = utils.get_auto_disk_config_from_instance(instance)
        if utils.is_auto_disk_config_disabled(auto_disk_config):
            props["auto_disk_config"] = "disabled"

        try:
            self._call_glance_plugin(session, 'upload_vhd', params)
        except exception.PluginRetriesExceeded:
            raise exception.CouldNotUploadImage(image_id=image_id)
Exemple #5
0
    def _get_metadata(self, context, instance, image_id):
        metadata = IMAGE_API.get(context, image_id)
        metadata['disk_format'] = 'vhd'
        metadata['container_format'] = 'ovf'
        metadata['auto_disk_config'] = str(instance['auto_disk_config'])
        metadata['os_type'] = instance.get('os_type') or (
            CONF.xenserver.default_os_type)
        # Set size as zero, so that it will update the size in the end
        # based on the uploaded image data.
        metadata['size'] = 0

        # Adjust the auto_disk_config value basing on instance's
        # system metadata.
        # TODO(mriedem): Consider adding an abstract base class for the
        # various image handlers to contain common code like this.
        auto_disk = nova_utils.get_auto_disk_config_from_instance(instance)
        if nova_utils.is_auto_disk_config_disabled(auto_disk):
            metadata['auto_disk_config'] = "disabled"

        return metadata
Exemple #6
0
    def upload_image(self, context, session, instance, image_id, vdi_uuids):
        params = {'vdi_uuids': vdi_uuids}
        props = params['properties'] = {}
        props['auto_disk_config'] = instance['auto_disk_config']
        props['os_type'] = instance.get(
            'os_type', None) or (CONF.xenserver.default_os_type)

        compression_level = vm_utils.get_compression_level()
        if compression_level:
            props['xenapi_image_compression_level'] = compression_level

        auto_disk_config = utils.get_auto_disk_config_from_instance(instance)
        if utils.is_auto_disk_config_disabled(auto_disk_config):
            props["auto_disk_config"] = "disabled"

        try:
            self._call_glance_plugin(context, instance, session,
                                     host_glance.upload_vhd, image_id, params)
        except xenapi_exception.PluginRetriesExceeded:
            raise exception.CouldNotUploadImage(image_id=image_id)
Exemple #7
0
    def upload_image(self, context, session, instance, image_id, vdi_uuids):
        params = {'vdi_uuids': vdi_uuids}
        props = params['properties'] = {}
        props['auto_disk_config'] = instance['auto_disk_config']
        props['os_type'] = instance.get('os_type', None) or (
                CONF.xenserver.default_os_type)

        compression_level = vm_utils.get_compression_level()
        if compression_level:
            props['xenapi_image_compression_level'] = compression_level

        auto_disk_config = utils.get_auto_disk_config_from_instance(instance)
        if utils.is_auto_disk_config_disabled(auto_disk_config):
            props["auto_disk_config"] = "disabled"

        try:
            self._call_glance_plugin(context, instance, session,
                                     host_glance.upload_vhd, image_id, params)
        except xenapi_exception.PluginRetriesExceeded:
            raise exception.CouldNotUploadImage(image_id=image_id)
        except xenapi_exception.PluginImageNotFound:
            raise exception.ImageNotFound(image_id=image_id)
Exemple #8
0
 def test_is_auto_disk_config_disabled_false(self):
     self.assertFalse(utils.is_auto_disk_config_disabled("false"))
Exemple #9
0
 def test_is_auto_disk_config_disabled_none(self):
     self.assertFalse(utils.is_auto_disk_config_disabled(None))
Exemple #10
0
 def test_is_auto_disk_config_disabled(self):
     self.assertTrue(utils.is_auto_disk_config_disabled("Disabled "))
Exemple #11
0
 def test_is_auto_disk_config_disabled_false(self):
     self.assertFalse(utils.is_auto_disk_config_disabled("false"))
Exemple #12
0
 def test_is_auto_disk_config_disabled_none(self):
     self.assertFalse(utils.is_auto_disk_config_disabled(None))
Exemple #13
0
 def test_is_auto_disk_config_disabled(self):
     self.assertTrue(utils.is_auto_disk_config_disabled("Disabled "))