Skip to main content

VirtualDiskManager

Struct VirtualDiskManager 

Source
pub struct VirtualDiskManager { /* private fields */ }
Expand description

Most VirtualDiskManager APIs will be DEPRECATED as of vSphere 6.5.

Please use VStorageObjectManager APIs to manage Virtual disks.

This managed object type provides a way to manage and manipulate virtual disks on datastores. The source and the destination names are in the form of a URL or a datastore path.

A URL has the form

scheme://authority/folder/path?dcPath=dcPath&dsName=dsName

where

  • scheme is http or https.
  • authority specifies the hostname or IP address of the VirtualCenter or ESX server and optionally the port.
  • dcPath is the inventory path to the Datacenter containing the Datastore.
  • dsName is the name of the Datastore.
  • path is a slash-delimited path from the root of the datastore.

A datastore path has the form

[datastore] path

where

  • datastore is the datastore name.
  • path is a slash-delimited path from the root of the datastore.

An example datastore path is “[storage] path/to/file.extension”. A listing of all the files, disks and folders on a datastore can be obtained from the datastore browser.

See also HostDatastoreBrowser.

Implementations§

Source§

impl VirtualDiskManager

Source

pub fn new(client: Arc<dyn VimClient>, mo_id: &str) -> Self

Source

pub async fn copy_virtual_disk_task( &self, source_name: &str, source_datacenter: Option<&ManagedObjectReference>, dest_name: &str, dest_datacenter: Option<&ManagedObjectReference>, dest_spec: Option<&dyn VirtualDiskSpecTrait>, force: Option<bool>, ) -> Result<ManagedObjectReference>

Copy a virtual disk, performing conversions as specified in the spec.

If source (or destination) name is specified as a URL, then the corresponding datacenter parameter may be omitted.

If source and destination resolve to the same file system location, the call has no effect, regardless of destSpec content.

Requires Datastore.FileManagement privilege on both source and destination datastores.

Required privileges: System.View

§Parameters:
§source_name

The name of the source, either a datastore path or a URL referring to the virtual disk to be copied.

§source_datacenter

If sourceName is a datastore path, the datacenter for that datastore path. Not needed when invoked directly on ESX. If not specified on a call to VirtualCenter, sourceName must be a URL.

Refers instance of Datacenter.

§dest_name

The name of the destination, either a datastore path or a URL referring to the virtual disk to be created.

§dest_datacenter

If destName is a datastore path, the datacenter for that datastore path. Not needed when invoked directly on ESX. If not specified on a call to VirtualCenter, it is assumed that the destination path belongs to the source datacenter.

Refers instance of Datacenter.

§dest_spec

The specification of the virtual disk to be created. If not specified, a preallocated format and busLogic adapter type is assumed.

§force

The force flag is currently ignored. The FileAlreadyExists fault is thrown if the destination file already exists.

§Returns:

This method returns a Task object with which to monitor the operation.

Refers instance of Task.

§Errors:

FileFault: if an error occurs cloning the virtual disk.

InvalidDatastore: if the operation cannot be performed on the source or destination datastore.

InvalidDiskFormat: if the destination’s format is not supported.

Source

pub async fn create_virtual_disk_task( &self, name: &str, datacenter: Option<&ManagedObjectReference>, spec: &dyn VirtualDiskSpecTrait, ) -> Result<ManagedObjectReference>

Deprecated as of vSphere 6.5, use HostVStorageObjectManager.HostCreateDisk_Task instead.

Create a virtual disk.

The datacenter parameter may be omitted if a URL is used to name the disk.

Requires Datastore.FileManagement privilege on the datastore where the virtual disk is created.

Required privileges: System.View

§Parameters:
§name

The name of the disk, either a datastore path or a URL referring to the virtual disk to be created.

§datacenter

If name is a datastore path, the datacenter for that datastore path. Not needed when invoked directly on ESX. If not specified on a call to VirtualCenter, name must be a URL.

Refers instance of Datacenter.

§spec

The specification of the virtual disk to be created.

§Returns:

This method returns a Task object with which to monitor the operation.

Refers instance of Task.

§Errors:

FileFault: if an error occurs creating the virtual disk.

InvalidDatastore: if the operation cannot be performed on the datastore.

Source

pub async fn defragment_virtual_disk_task( &self, name: &str, datacenter: Option<&ManagedObjectReference>, ) -> Result<ManagedObjectReference>

Deprecated as of vSphere 6.5, use VirtualMachine.DefragmentAllDisks instead.

Defragment a sparse virtual disk.

This is defragmentation of the virtual disk file(s) in the host operating system, not defragmentation of the guest operating system filesystem inside the virtual disk.

The datacenter parameter may be omitted if a URL is used to name the disk.

Requires Datastore.FileManagement privilege on the datastore where the virtual disk resides.

Required privileges: System.View

§Parameters:
§name

The name of the disk, either a datastore path or a URL referring to the virtual disk that should be defragmented.

§datacenter

If name is a datastore path, the datacenter for that datastore path. Not needed when invoked directly on ESX. If not specified on a call to VirtualCenter, name must be a URL.

Refers instance of Datacenter.

§Returns:

This method returns a Task object with which to monitor the operation.

Refers instance of Task.

§Errors:

FileFault: if an error occurs defragmenting the virtual disk.

InvalidDatastore: if the operation cannot be performed on the datastore.

Source

pub async fn delete_virtual_disk_task( &self, name: &str, datacenter: Option<&ManagedObjectReference>, ) -> Result<ManagedObjectReference>

Deprecated as of vSphere 6.5, use HostVStorageObjectManager.HostDeleteVStorageObject_Task instead.

Delete a virtual disk.

All files relating to the disk will be deleted.

Deletion of virtual disk is prohibited if it is attached to VMs.

The datacenter parameter may be omitted if a URL is used to name the disk.

Requires Datastore.FileManagement privilege on the datastore where the virtual disk is removed.

Required privileges: System.View

§Parameters:
§name

The name of the disk, either a datastore path or a URL referring to the virtual disk to be deleted.

§datacenter

If name is a datastore path, the datacenter for that datastore path. Not needed when invoked directly on ESX. If not specified on a call to VirtualCenter, name must be a URL.

Refers instance of Datacenter.

§Returns:

This method returns a Task object with which to monitor the operation.

Refers instance of Task.

§Errors:

FileFault: if an error occurs deleting the virtual disk.

InvalidDatastore: if the operation cannot be performed on the datastore.

Source

pub async fn eager_zero_virtual_disk_task( &self, name: &str, datacenter: Option<&ManagedObjectReference>, ) -> Result<ManagedObjectReference>

Explicitly zero out unaccessed parts zeroedthick disk.

Effectively a no-op if the disk is already eagerZeroedThick. Unlike zeroFillVirtualDisk, which wipes the entire disk, this operation only affects previously unaccessed parts of the disk.

The datacenter parameter may be omitted if a URL is used to name the disk.

Requires Datastore.FileManagement privilege on the datastore where the virtual disk resides.

Required privileges: System.View

§Parameters:
§name

The name of the disk, either a datastore path or a URL referring to the virtual disk that should be inflated.

§datacenter

If name is a datastore path, the datacenter for that datastore path. Not needed when invoked directly on ESX. If not specified on a call to VirtualCenter, name must be a URL.

Refers instance of Datacenter.

§Returns:

This method returns a Task object with which to monitor the operation.

Refers instance of Task.

§Errors:

FileFault: if an error occurs while eager-zeroing the virtual disk.

InvalidDatastore: if the operation cannot be performed on the datastore.

Source

pub async fn extend_virtual_disk_task( &self, name: &str, datacenter: Option<&ManagedObjectReference>, new_capacity_kb: i64, eager_zero: Option<bool>, ) -> Result<ManagedObjectReference>

Deprecated as of vSphere 6.5, use HostVStorageObjectManager.HostExtendDisk_Task instead.

Expand the capacity of a virtual disk to the new capacity.

If the eagerZero flag is not specified, - the extended disk region of a zerothick disk will be zeroedthick - the extended disk region of a eagerzerothick disk will be eagerzeroedthick - a thin-provisioned disk will always be extended as a thin-provisioned disk. If the eagerZero flag TRUE, the extended region of the disk will always be eagerly zeroed. If the eagerZero flag FALSE, the extended region of a zeroedthick or eagerzeroedthick the disk will not be eagerly zeroed. This condition has no effect on a thin source disk.

The datacenter parameter may be omitted if a URL is used to name the disk.

Requires Datastore.FileManagement privilege on the datastore where the virtual disk resides.

Required privileges: System.View

§Parameters:
§name

The name of the disk, either a datastore path or a URL referring to the virtual disk whose capacity should be expanded.

§datacenter

If name is a datastore path, the datacenter for that datastore path. Not needed when invoked directly on ESX. If not specified on a call to VirtualCenter, name must be a URL.

Refers instance of Datacenter.

§new_capacity_kb

The new capacty of the virtual disk in Kb.

§eager_zero

If true, the extended part of the disk will be explicitly filled with zeroes.

§Returns:

This method returns a Task object with which to monitor the operation.

Refers instance of Task.

§Errors:

FileFault: if an error occurs extending the virtual disk.

InvalidDatastore: if the operation cannot be performed on the datastore.

Source

pub async fn import_unmanaged_snapshot( &self, vdisk: &str, datacenter: Option<&ManagedObjectReference>, vvol_id: &str, ) -> Result<()>

Import an unmanaged-snapshot from Virtual-Volume(VVol) enabled Storage Array.

Storage Array may support users to take snapshots indepedent of VMware stack. Such copies or snapshots are known as ‘Unmanaged-Snapshots’. We are providing an ability to end-users to import such unmanaged-snapshots as Virtual Disks.

End-user needs to know the VVol-Identifier to import unmanaged snapshot as VirtualDisk.

Once VirtualDisk is created, user can use ‘Datastore Browser’ to use with rest of Virtual Machine provisioning APIs.

Required privileges: System.View

§Parameters:
§vdisk

- The name of the disk to import, either a datastore path or a URL referring to the virtual disk from which to get geometry information.

§datacenter

If vdisk is a datastore path, the datacenter for that datastore path. Not needed when invoked directly on ESX. If not specified on a call to VirtualCenter, vdisk must be a URL.

Refers instance of Datacenter.

§vvol_id

- unmanaged snapshot identifier

§Errors:

NotFound: if VVol is not found

InvalidDatastore: if the operation cannot be performed on the datastore.

Source

pub async fn inflate_virtual_disk_task( &self, name: &str, datacenter: Option<&ManagedObjectReference>, ) -> Result<ManagedObjectReference>

Deprecated as of vSphere 6.5, use HostVStorageObjectManager.HostInflateDisk_Task instead.

Inflate a sparse or thin-provisioned virtual disk up to the full size.

Additional space allocated to the disk as a result of this operation will be filled with zeroes.

The datacenter parameter may be omitted if a URL is used to name the disk.

Requires Datastore.FileManagement privilege on the datastore where the virtual disk resides.

Required privileges: System.View

§Parameters:
§name

The name of the disk, either a datastore path or a URL referring to the virtual disk that should be inflated.

§datacenter

If name is a datastore path, the datacenter for that datastore path. Not needed when invoked directly on ESX. If not specified on a call to VirtualCenter, name must be a URL.

Refers instance of Datacenter.

§Returns:

This method returns a Task object with which to monitor the operation.

Refers instance of Task.

§Errors:

FileFault: if an error occurs inflating the virtual disk.

InvalidDatastore: if the operation cannot be performed on the datastore.

Source

pub async fn move_virtual_disk_task( &self, source_name: &str, source_datacenter: Option<&ManagedObjectReference>, dest_name: &str, dest_datacenter: Option<&ManagedObjectReference>, force: Option<bool>, profile: Option<&[Box<dyn VirtualMachineProfileSpecTrait>]>, ) -> Result<ManagedObjectReference>

Move a virtual disk and all related files from the source location specified by sourceName and sourceDatacenter to the destination location specified by destName and destDatacenter.

If source (or destination) name is specified as a URL, then the corresponding datacenter parameter may be omitted.

If source and destination resolve to the same file system location, the call has no effect.

Requires Datastore.FileManagement privilege on both source and destination datastores.

Required privileges: System.View

§Parameters:
§source_name

The name of the source, either a datastore path or a URL referring to the virtual disk to be moved.

§source_datacenter

If sourceName is a datastore path, the datacenter for that datastore path. Not needed when invoked directly on ESX. If not specified on a call to VirtualCenter, sourceName must be a URL.

Refers instance of Datacenter.

§dest_name

The name of the destination, either a datastore path or a URL referring to the destination virtual disk.

§dest_datacenter

If destName is a datastore path, the datacenter for that datastore path. Not needed when invoked directly on ESX. If not specified on a call to VirtualCenter, it is assumed that the destination path belongs to the source datacenter.

Refers instance of Datacenter.

§force

If true, overwrite any indentically named disk at the destination. If not specified, it is assumed to be false

§profile

User can specify new set of profile when moving virtual disk.

§Returns:

Refers instance of Task.

§Errors:

FileFault: if an error occurs renaming the virtual disk.

InvalidDatastore: if the operation cannot be performed on the source or destination datastore.

Source

pub async fn query_virtual_disk_fragmentation( &self, name: &str, datacenter: Option<&ManagedObjectReference>, ) -> Result<i32>

Return the percentage of fragmentation of the sparse virtual disk.

This is the fragmentation of virtual disk file(s) in the host operating system, not the fragmentation of the guest operating systemS filesystem inside the virtual disk.

The datacenter parameter may be omitted if a URL is used to name the disk.

Requires Datastore.FileManagement privilege on the datastore where the virtual disk resides.

Required privileges: System.View

§Parameters:
§name

The name of the disk, either a datastore path or a URL referring to the virtual disk for which to return the percentage of fragmentation.

§datacenter

If name is a datastore path, the datacenter for that datastore path. Not needed when invoked directly on ESX. If not specified on a call to VirtualCenter, name must be a URL.

Refers instance of Datacenter.

§Returns:

the percentage of fragmentation (as an integer between 0 and 100) of the sparse virtual disk.

§Errors:

FileFault: if an error occurs reading the virtual disk.

InvalidDatastore: if the operation cannot be performed on the datastore.

Source

pub async fn query_virtual_disk_geometry( &self, name: &str, datacenter: Option<&ManagedObjectReference>, ) -> Result<HostDiskDimensionsChs>

Get the disk geometry information for the virtual disk.

The datacenter parameter may be omitted if a URL is used to name the disk.

Requires Datastore.FileManagement privilege on the datastore where the virtual disk resides.

Required privileges: System.View

§Parameters:
§name

The name of the disk, either a datastore path or a URL referring to the virtual disk from which to get geometry information.

§datacenter

If name is a datastore path, the datacenter for that datastore path. Not needed when invoked directly on ESX. If not specified on a call to VirtualCenter, name must be a URL.

Refers instance of Datacenter.

§Returns:

The geometry information for this virtual disk.

§Errors:

FileFault: if an error occurs reading the virtual disk.

InvalidDatastore: if the operation cannot be performed on the datastore.

Source

pub async fn query_virtual_disk_uuid( &self, name: &str, datacenter: Option<&ManagedObjectReference>, ) -> Result<String>

Deprecated as of vSphere 6.5, use HostVStorageObjectManager.HostRetrieveVStorageObject instead.

Get the virtual disk SCSI inquiry page 0x83 data.

The datacenter parameter may be omitted if a URL is used to name the disk.

Requires Datastore.FileManagement privilege on the datastore where the virtual disk resides.

Required privileges: System.View

§Parameters:
§name

The name of the disk, either a datastore path or a URL referring to the virtual disk from which to get SCSI inquiry page 0x83 data.

§datacenter

If name is a datastore path, the datacenter for that datastore path. Not needed when invoked directly on ESX. If not specified on a call to VirtualCenter, name must be a URL.

Refers instance of Datacenter.

§Returns:

The hex representation of the unique ID for this virtual disk.

§Errors:

FileFault: if an error occurs reading the virtual disk.

InvalidDatastore: if the operation cannot be performed on the datastore.

Source

pub async fn release_managed_snapshot( &self, vdisk: &str, datacenter: Option<&ManagedObjectReference>, ) -> Result<()>

Release a snapshot previously imported with importUnmanagedSnapshot

Required privileges: System.View

§Parameters:
§vdisk

- The name of the disk to release, either a datastore path or a URL referring to the virtual disk.

§datacenter

If vdisk is a datastore path, the datacenter for that datastore path. Not needed when invoked directly on ESX. If not specified on a call to VirtualCenter, vdisk must be a URL.

Refers instance of Datacenter.

§Errors:

FileNotFound: if vdisk is not found

InvalidDatastore: if the operation cannot be performed on the datastore.

Source

pub async fn set_virtual_disk_uuid( &self, name: &str, datacenter: Option<&ManagedObjectReference>, uuid: &str, ) -> Result<()>

Deprecated as of vSphere 6.5, use HostVStorageObjectManager.HostRegisterDisk to register a disk as vStorageObject with new unique UUID.

Set the virtual disk SCSI inquiry page 0x83 data.

The datacenter parameter may be omitted if a URL is used to name the disk.

Requires Datastore.FileManagement privilege on the datastore where the virtual disk resides.

Required privileges: System.View

§Parameters:
§name

The name of the disk, either a datastore path or a URL referring to the virtual disk whose SCSI inquiry page 0x83 data should be set.

§datacenter

If name is a datastore path, the datacenter for that datastore path. Not needed when invoked directly on ESX. If not specified on a call to VirtualCenter, name must be a URL.

Refers instance of Datacenter.

§uuid

The hex representation of the unique ID for this virtual disk.

§Errors:

FileFault: if an error occurs updating the virtual disk.

InvalidDatastore: if the operation cannot be performed on the datastore.

Source

pub async fn shrink_virtual_disk_task( &self, name: &str, datacenter: Option<&ManagedObjectReference>, copy: Option<bool>, ) -> Result<ManagedObjectReference>

Deprecated as of vSphere 6.5, use VirtualMachine.ShrinkDisk_Task instead.

Shrink a sparse virtual disk.

The datacenter parameter may be omitted if a URL is used to name the disk.

The optional parameter copy specifies whether to shrink the disk in copy-shrink mode or in-place mode. In copy-shrink mode, additional space is required, but will result in a shrunk disk that is also defragmented. In-place shrink does not require additional space, but will increase fragmentation. The default behavior is to perform copy-shrink if the parameter is not specified.

Requires Datastore.FileManagement privilege on the datastore where the virtual disk resides.

Required privileges: System.View

§Parameters:
§name

The name of the disk, either a datastore path or a URL referring to the virtual disk that should be shrink.

§datacenter

If name is a datastore path, the datacenter for that datastore path. Not needed when invoked directly on ESX. If not specified on a call to VirtualCenter, name must be a URL.

Refers instance of Datacenter.

§copy

If true or omitted, performs shrink in copy-shrink mode, otherwise shrink in in-place mode.

§Returns:

This method returns a Task object with which to monitor the operation.

Refers instance of Task.

§Errors:

FileFault: if an error occurs shrinking the virtual disk.

InvalidDatastore: if the operation cannot be performed on the datastore.

Source

pub async fn zero_fill_virtual_disk_task( &self, name: &str, datacenter: Option<&ManagedObjectReference>, ) -> Result<ManagedObjectReference>

Overwrite all blocks of the virtual disk with zeros.

All data will be lost.

The datacenter parameter may be omitted if a URL is used to name the disk.

Requires Datastore.FileManagement privilege on the datastore where the virtual disk resides.

Required privileges: System.View

§Parameters:
§name

The name of the disk, either a datastore path or a URL referring to the virtual disk whose blocks should be overwritten with zeroes.

§datacenter

If name is a datastore path, the datacenter for that datastore path. Not needed when invoked directly on ESX. If not specified on a call to VirtualCenter, name must be a URL.

Refers instance of Datacenter.

§Returns:

This method returns a Task object with which to monitor the operation.

Refers instance of Task.

§Errors:

FileFault: if an error occurs zero filling the virtual disk.

InvalidDatastore: if the operation cannot be performed on the datastore.

Trait Implementations§

Source§

impl Clone for VirtualDiskManager

Source§

fn clone(&self) -> VirtualDiskManager

Returns a duplicate of the value. Read more
1.0.0 · Source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more

Auto Trait Implementations§

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> AsAny for T
where T: 'static,

Source§

fn as_any_ref<'a>(&'a self) -> &'a (dyn Any + 'static)

Cast a reference to Any trait.

Source§

fn as_any_box(self: Box<T>) -> Box<dyn Any>

Cast to a boxed reference to Any trait.

Source§

fn type_id(&self) -> TypeId

Get the underlying type identifier.
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<To, T> CastInto<To> for T
where To: CastFrom<T> + ?Sized, T: 'static + ?Sized,

Source§

fn into_ref<'a>(&'a self) -> Option<&'a To>

Casts a reference to a trait object. If the cast fails, std::option::Option::None is returned.
Source§

fn into_box(self: Box<T>) -> Result<Box<To>, Box<dyn Any>>

Casts a boxed trait object to another trait object. If the cast fails, the original boxed trait object is returned in std::result::Result::Err.
Source§

impl<T> CloneToUninit for T
where T: Clone,

Source§

unsafe fn clone_to_uninit(&self, dest: *mut u8)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dest. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T> Instrument for T

Source§

fn instrument(self, span: Span) -> Instrumented<Self>

Instruments this type with the provided Span, returning an Instrumented wrapper. Read more
Source§

fn in_current_span(self) -> Instrumented<Self>

Instruments this type with the current Span, returning an Instrumented wrapper. Read more
Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T> PolicyExt for T
where T: ?Sized,

Source§

fn and<P, B, E>(self, other: P) -> And<T, P>
where T: Policy<B, E>, P: Policy<B, E>,

Create a new Policy that returns Action::Follow only if self and other return Action::Follow. Read more
Source§

fn or<P, B, E>(self, other: P) -> Or<T, P>
where T: Policy<B, E>, P: Policy<B, E>,

Create a new Policy that returns Action::Follow if either self or other returns Action::Follow. Read more
Source§

impl<T> ToOwned for T
where T: Clone,

Source§

type Owned = T

The resulting type after obtaining ownership.
Source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
Source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. Read more
Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.
Source§

impl<T> WithSubscriber for T

Source§

fn with_subscriber<S>(self, subscriber: S) -> WithDispatch<Self>
where S: Into<Dispatch>,

Attaches the provided Subscriber to this type, returning a WithDispatch wrapper. Read more
Source§

fn with_current_subscriber(self) -> WithDispatch<Self>

Attaches the current default Subscriber to this type, returning a WithDispatch wrapper. Read more
Source§

impl<T> ErasedDestructor for T
where T: 'static,