'Detach volume storage to VM instance.'

def _detach_volume_vmdk(self, connection_info, instance):

    vm_ref = vm_util.get_vm_ref(self._session, instance)
    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)
    vmdk = vm_util.get_vmdk_info(self._session, volume_ref)
    if (vmdk.adapter_type == constants.ADAPTER_TYPE_IDE):
        state = vm_util.get_vm_state(self._session, instance)
        if (state.lower() != 'poweredoff'):
            raise exception.Invalid((_('%s    does    not    support    disk    hotplug.') % vmdk.adapter_type))
    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)
    self._update_volume_details(vm_ref, data['volume_id'], '')
    LOG.debug('Detached    VMDK:    %s', connection_info, instance=instance)
