Exemplo n.º 1
0
    def _detach_volume_vmdk(self, connection_info, instance):
        """Detach volume storage to VM instance."""
        vm_ref = vm_util.get_vm_ref(self._session, instance)
        # Detach Volume from VM
        LOG.debug("_detach_volume_vmdk: %s",
                  connection_info,
                  instance=instance)
        data = connection_info['data']
        volume_ref = self._get_volume_ref(data['volume'])

        device = self._get_vmdk_backed_disk_device(vm_ref, data)

        # Get details required for adding disk device such as
        # adapter_type, disk_type
        vmdk = vm_util.get_vmdk_info(self._session, volume_ref)

        # IDE does not support disk hotplug
        if (instance.vm_state == vm_states.ACTIVE
                and vmdk.adapter_type == constants.ADAPTER_TYPE_IDE):
            msg = _('%s does not support disk hotplug.') % vmdk.adapter_type
            raise exception.Invalid(msg)

        self._consolidate_vmdk_volume(instance,
                                      vm_ref,
                                      device,
                                      volume_ref,
                                      adapter_type=vmdk.adapter_type,
                                      disk_type=vmdk.disk_type)

        self.detach_disk_from_vm(vm_ref, instance, device)
        LOG.debug("Detached VMDK: %s", connection_info, instance=instance)
Exemplo n.º 2
0
    def _detach_volume_vmdk(self, connection_info, instance):
        """Detach volume storage to VM instance."""
        vm_ref = vm_util.get_vm_ref(self._session, instance)
        # Detach Volume from VM
        LOG.debug("_detach_volume_vmdk: %s", connection_info,
                  instance=instance)
        data = connection_info['data']
        volume_ref = self._get_volume_ref(data['volume'])

        device = self._get_vmdk_backed_disk_device(vm_ref, data)

        # Get details required for adding disk device such as
        # adapter_type, disk_type
        vmdk = vm_util.get_vmdk_info(self._session, volume_ref)

        # IDE does not support disk hotplug
        if (instance.vm_state == vm_states.ACTIVE and
            vmdk.adapter_type == constants.ADAPTER_TYPE_IDE):
            msg = _('%s does not support disk hotplug.') % vmdk.adapter_type
            raise exception.Invalid(msg)

        self._consolidate_vmdk_volume(instance, vm_ref, device, volume_ref,
                                      adapter_type=vmdk.adapter_type,
                                      disk_type=vmdk.disk_type)

        self.detach_disk_from_vm(vm_ref, instance, device)
        LOG.debug("Detached VMDK: %s", connection_info, instance=instance)
Exemplo n.º 3
0
    def _attach_volume_vmdk(self,
                            connection_info,
                            instance,
                            adapter_type=None):
        """Attach vmdk volume storage to VM instance."""
        vm_ref = vm_util.get_vm_ref(self._session, instance)
        LOG.debug("_attach_volume_vmdk: %s",
                  connection_info,
                  instance=instance)
        data = connection_info['data']
        volume_ref = self._get_volume_ref(data['volume'])

        # Get details required for adding disk device such as
        # adapter_type, disk_type
        vmdk = vm_util.get_vmdk_info(self._session, volume_ref)
        adapter_type = adapter_type or vmdk.adapter_type

        # IDE does not support disk hotplug
        if (instance.vm_state == vm_states.ACTIVE
                and adapter_type == constants.ADAPTER_TYPE_IDE):
            msg = _('%s does not support disk hotplug.') % adapter_type
            raise exception.Invalid(msg)

        # Attach the disk to virtual machine instance
        self.attach_disk_to_vm(vm_ref,
                               instance,
                               adapter_type,
                               vmdk.disk_type,
                               vmdk_path=vmdk.path)

        # Store the uuid of the volume_device
        self._update_volume_details(vm_ref, data['volume_id'],
                                    vmdk.device.backing.uuid)

        LOG.debug("Attached VMDK: %s", connection_info, instance=instance)
Exemplo n.º 4
0
    def _attach_volume_vmdk(self, connection_info, instance,
                            adapter_type=None):
        """Attach vmdk volume storage to VM instance."""
        vm_ref = vm_util.get_vm_ref(self._session, instance)
        LOG.debug("_attach_volume_vmdk: %s", connection_info,
                  instance=instance)
        data = connection_info['data']
        volume_ref = self._get_volume_ref(data['volume'])

        # Get details required for adding disk device such as
        # adapter_type, disk_type
        vmdk = vm_util.get_vmdk_info(self._session, volume_ref)
        adapter_type = adapter_type or vmdk.adapter_type

        # IDE does not support disk hotplug
        if (instance.vm_state == vm_states.ACTIVE and
            adapter_type == constants.ADAPTER_TYPE_IDE):
            msg = _('%s does not support disk hotplug.') % adapter_type
            raise exception.Invalid(msg)

        # Attach the disk to virtual machine instance
        self.attach_disk_to_vm(vm_ref, instance, adapter_type, vmdk.disk_type,
                               vmdk_path=vmdk.path)

        # Store the uuid of the volume_device
        self._update_volume_details(vm_ref, data['volume_id'],
                                    vmdk.device.backing.uuid)

        LOG.debug("Attached VMDK: %s", connection_info, instance=instance)