Exemplo n.º 1
0
 def detach_disk_from_vm(self,
                         vm_ref,
                         instance,
                         device,
                         destroy_disk=False):
     """Detach disk from VM by reconfiguration."""
     instance_name = instance.name
     client_factory = self._session.vim.client.factory
     vmdk_detach_config_spec = vm_util.get_vmdk_detach_config_spec(
         client_factory, device, destroy_disk)
     disk_key = device.key
     LOG.debug(
         "Reconfiguring VM instance %(instance_name)s to detach "
         "disk %(disk_key)s", {
             'instance_name': instance_name,
             'disk_key': disk_key
         },
         instance=instance)
     vm_util.reconfigure_vm(self._session, vm_ref, vmdk_detach_config_spec)
     LOG.debug(
         "Reconfigured VM instance %(instance_name)s to detach "
         "disk %(disk_key)s", {
             'instance_name': instance_name,
             'disk_key': disk_key
         },
         instance=instance)
Exemplo n.º 2
0
    def _update_volume_details(self, vm_ref, volume_uuid, device_uuid):
        # Store the uuid of the volume_device
        volume_option = 'volume-%s' % volume_uuid
        extra_opts = {volume_option: device_uuid}

        client_factory = self._session.vim.client.factory
        extra_config_specs = vm_util.get_vm_extra_config_spec(
            client_factory, extra_opts)
        vm_util.reconfigure_vm(self._session, vm_ref, extra_config_specs)
Exemplo n.º 3
0
    def _update_volume_details(self, vm_ref, volume_uuid, device_uuid):
        # Store the uuid of the volume_device
        volume_option = 'volume-%s' % volume_uuid
        extra_opts = {volume_option: device_uuid}

        client_factory = self._session.vim.client.factory
        extra_config_specs = vm_util.get_vm_extra_config_spec(
                                    client_factory, extra_opts)
        vm_util.reconfigure_vm(self._session, vm_ref, extra_config_specs)
Exemplo n.º 4
0
    def attach_disk_to_vm(self,
                          vm_ref,
                          instance,
                          adapter_type,
                          disk_type,
                          vmdk_path=None,
                          disk_size=None,
                          linked_clone=False,
                          device_name=None):
        """Attach disk to VM by reconfiguration."""
        instance_name = instance.name
        client_factory = self._session.vim.client.factory
        devices = self._session._call_method(vim_util, "get_dynamic_property",
                                             vm_ref, "VirtualMachine",
                                             "config.hardware.device")
        (controller_key, unit_number,
         controller_spec) = vm_util.allocate_controller_key_and_unit_number(
             client_factory, devices, adapter_type)

        vmdk_attach_config_spec = vm_util.get_vmdk_attach_config_spec(
            client_factory, disk_type, vmdk_path, disk_size, linked_clone,
            controller_key, unit_number, device_name)
        if controller_spec:
            vmdk_attach_config_spec.deviceChange.append(controller_spec)

        LOG.debug(
            "Reconfiguring VM instance %(instance_name)s to attach "
            "disk %(vmdk_path)s or device %(device_name)s with type "
            "%(disk_type)s", {
                'instance_name': instance_name,
                'vmdk_path': vmdk_path,
                'device_name': device_name,
                'disk_type': disk_type
            },
            instance=instance)
        vm_util.reconfigure_vm(self._session, vm_ref, vmdk_attach_config_spec)
        LOG.debug(
            "Reconfigured VM instance %(instance_name)s to attach "
            "disk %(vmdk_path)s or device %(device_name)s with type "
            "%(disk_type)s", {
                'instance_name': instance_name,
                'vmdk_path': vmdk_path,
                'device_name': device_name,
                'disk_type': disk_type
            },
            instance=instance)
Exemplo n.º 5
0
 def detach_disk_from_vm(self, vm_ref, instance, device,
                         destroy_disk=False):
     """Detach disk from VM by reconfiguration."""
     instance_name = instance.name
     client_factory = self._session.vim.client.factory
     vmdk_detach_config_spec = vm_util.get_vmdk_detach_config_spec(
                                 client_factory, device, destroy_disk)
     disk_key = device.key
     LOG.debug("Reconfiguring VM instance %(instance_name)s to detach "
               "disk %(disk_key)s",
               {'instance_name': instance_name, 'disk_key': disk_key},
               instance=instance)
     vm_util.reconfigure_vm(self._session, vm_ref, vmdk_detach_config_spec)
     LOG.debug("Reconfigured VM instance %(instance_name)s to detach "
               "disk %(disk_key)s",
               {'instance_name': instance_name, 'disk_key': disk_key},
               instance=instance)
Exemplo n.º 6
0
    def attach_disk_to_vm(self, vm_ref, instance,
                          adapter_type, disk_type, vmdk_path=None,
                          disk_size=None, linked_clone=False,
                          device_name=None):
        """Attach disk to VM by reconfiguration."""
        instance_name = instance.name
        client_factory = self._session.vim.client.factory
        devices = self._session._call_method(vim_util,
                                    "get_dynamic_property", vm_ref,
                                    "VirtualMachine", "config.hardware.device")
        (controller_key, unit_number,
         controller_spec) = vm_util.allocate_controller_key_and_unit_number(
                                                              client_factory,
                                                              devices,
                                                              adapter_type)

        vmdk_attach_config_spec = vm_util.get_vmdk_attach_config_spec(
                                    client_factory, disk_type, vmdk_path,
                                    disk_size, linked_clone, controller_key,
                                    unit_number, device_name)
        if controller_spec:
            vmdk_attach_config_spec.deviceChange.append(controller_spec)

        LOG.debug("Reconfiguring VM instance %(instance_name)s to attach "
                  "disk %(vmdk_path)s or device %(device_name)s with type "
                  "%(disk_type)s",
                  {'instance_name': instance_name, 'vmdk_path': vmdk_path,
                   'device_name': device_name, 'disk_type': disk_type},
                  instance=instance)
        vm_util.reconfigure_vm(self._session, vm_ref, vmdk_attach_config_spec)
        LOG.debug("Reconfigured VM instance %(instance_name)s to attach "
                  "disk %(vmdk_path)s or device %(device_name)s with type "
                  "%(disk_type)s",
                  {'instance_name': instance_name, 'vmdk_path': vmdk_path,
                   'device_name': device_name, 'disk_type': disk_type},
                  instance=instance)