'Attach disk to VM by reconfiguration.'

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, disk_io_limits=None):

    instance_name = instance.name
    client_factory = self._session.vim.client.factory
    devices = self._session._call_method(vutil, 'get_object_property', vm_ref, '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, disk_io_limits)
    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)
