Ejemplo n.º 1
0
    def finish_migration(self, context, migration, instance, disk_info,
                         network_info, image_meta, resize_instance=False,
                         block_device_info=None):
        """Completes a resize."""
        LOG.debug("`Finish migration` method called.")
        if volumeutils.ebs_root_in_block_devices(block_device_info):
            root_path = None
        else:
            root_path = pathutils.lookup_root_vhd_path(instance)
            if not root_path:
                raise vbox_exc.VBoxException(
                    i18n._("Cannot find boot VHD file for instance: %s") %
                    instance.name)
            base_disk_path = imagecache.get_cached_image(context, instance)
            self._check_disk(root_path, base_disk_path)

        ephemeral_path = pathutils.lookup_ephemeral_vhd_path(instance)
        if not ephemeral_path:
            ephemeral_path = self._vbox_ops.create_ephemeral_disk(instance)

        if resize_instance:
            self._resize_disk(instance, instance.root_gb * units.Ki, root_path)
            self._resize_disk(instance,
                              instance.get('ephemeral_gb', 0) * units.Ki,
                              ephemeral_path)

        self._vbox_ops.create_instance(instance, image_meta, network_info,
                                       overwrite=False)
        self._vbox_ops.storage_setup(instance, root_path, ephemeral_path,
                                     block_device_info)
Ejemplo n.º 2
0
    def finish_revert_migration(self, context, instance, network_info,
                                block_device_info=None):
        """Finish reverting a resize."""
        LOG.debug("`Finish revert migration` method called.")
        self._revert_migration_files(instance)
        self._vbox_ops.create_instance(instance, image_meta={},
                                       network_info=network_info,
                                       overwrite=False)

        if volumeutils.ebs_root_in_block_devices(block_device_info):
            root_path = None
        else:
            root_path = pathutils.lookup_root_vhd_path(instance)
        eph_path = pathutils.lookup_ephemeral_vhd_path(instance)

        self._vbox_ops.storage_setup(instance, root_path, eph_path,
                                     block_device_info)
Ejemplo n.º 3
0
    def finish_revert_migration(self,
                                context,
                                instance,
                                network_info,
                                block_device_info=None):
        """Finish reverting a resize."""
        LOG.debug("`Finish revert migration` method called.")
        self._revert_migration_files(instance)
        self._vbox_ops.create_instance(instance,
                                       image_meta={},
                                       network_info=network_info,
                                       overwrite=False)

        if volumeutils.ebs_root_in_block_devices(block_device_info):
            root_path = None
        else:
            root_path = pathutils.lookup_root_vhd_path(instance)
        eph_path = pathutils.lookup_ephemeral_vhd_path(instance)

        self._vbox_ops.storage_setup(instance, root_path, eph_path,
                                     block_device_info)
Ejemplo n.º 4
0
    def finish_migration(self,
                         context,
                         migration,
                         instance,
                         disk_info,
                         network_info,
                         image_meta,
                         resize_instance=False,
                         block_device_info=None):
        """Completes a resize."""
        LOG.debug("`Finish migration` method called.")
        if volumeutils.ebs_root_in_block_devices(block_device_info):
            root_path = None
        else:
            root_path = pathutils.lookup_root_vhd_path(instance)
            if not root_path:
                raise vbox_exc.VBoxException(
                    i18n._("Cannot find boot VHD file for instance: %s") %
                    instance.name)
            base_disk_path = imagecache.get_cached_image(context, instance)
            self._check_disk(root_path, base_disk_path)

        ephemeral_path = pathutils.lookup_ephemeral_vhd_path(instance)
        if not ephemeral_path:
            ephemeral_path = self._vbox_ops.create_ephemeral_disk(instance)

        if resize_instance:
            self._resize_disk(instance, instance.root_gb * units.Ki, root_path)
            self._resize_disk(instance,
                              instance.get('ephemeral_gb', 0) * units.Ki,
                              ephemeral_path)

        self._vbox_ops.create_instance(instance,
                                       image_meta,
                                       network_info,
                                       overwrite=False)
        self._vbox_ops.storage_setup(instance, root_path, ephemeral_path,
                                     block_device_info)