vSphere Web Services API
| Local Methods | ||
Managed Object Types | Data Object Types | All Properties | All Methods |
Managed Object - FileManager(vim.FileManager)
- Property of
- ServiceContent
- See also
- Datacenter, FileLockInfoResult, HostSystem
- Since
- VI API 2.5
Managed Object Description
This managed object type provides a way to manage and manipulate files and folders 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=dsNamewhere
- scheme is
http
orhttps
. - 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.
- datastore is the datastore name.
- path is a slash-delimited path from the root of the datastore.
A datastore path has the form
[datastore] pathwhere
See HostDatastoreBrowser
Properties
Name | Type | Description |
---|---|---|
None |
Methods
Methods defined in this Managed Object |
---|
ChangeOwner, CopyDatastoreFile_Task, DeleteDatastoreFile_Task, MakeDirectory, MoveDatastoreFile_Task, QueryFileLockInfo |
ChangeOwner(changeOwner)
Change the owner for a file.This method is currently not supported.
- Required Privileges
- None
- Since
- vSphere API Release 4.0
Parameters
Name | Type | Description |
---|---|---|
_this | ManagedObjectReference | A reference to the FileManager used to make the method call. |
name | xsd:string |
Since vSphere API Release 4.0 |
datacenter* P | ManagedObjectReference
to a Datacenter |
Since vSphere API Release 4.0 |
owner | xsd:string |
Since vSphere API Release 4.0 |
Return Value
Type | Description |
---|---|
None |
Faults
Type | Description |
---|---|
FileFault | |
InvalidDatastore | |
RuntimeFault | Thrown if any type of runtime fault is thrown that is not covered by the other faults; for example, a communication error. |
UserNotFound |
Events
Type | |
---|---|
None |
Show WSDL type definition
CopyDatastoreFile_Task(copyFile)
Copies the source file or folder to the destination.If the destination file does not exist, it is created. If the destination file exists, the force parameter determines whether to overwrite it with the source or not. Folders can be copied recursively. In this case, the destination, if it exists, must be a folder, else one will be created. Existing files on the destination that conflict with source files can be overwritten using the force parameter. Files and disks are always copied in binary format during recursive copy.
If source (or destination) name is specified as a URL, then the corresponding datacenter parameter may be omitted.
If any intermediate level folder specified by the source and destination does not exist, a FileNotFound fault is thrown.
If a file of a virtual machine is overwritten on the destination datastore as a result of the force parameter, it may corrupt that virtual machine.
If the source is an extent of a virtual disk, this operation treats the extent as a file.
If source and destination resolve to the same file system location, the call has no effect.
It is important to note that this operation will provide transactional guarantees only for a file. No guarantees are provided when copying a folder. If the intent is to clone a virtual machine registered in the inventory, with transactional guarantees, please refer to CloneVM_Task.
Datastore.FileManagement privilege is required on both source and destination datastores.
- Required Privileges
- None
Parameters
Name | Type | Description |
---|---|---|
_this | ManagedObjectReference | A reference to the FileManager used to make the method call. |
sourceName | xsd:string |
The name of the source, either a URL or a
datastore path referring to the file or folder to be copied.
Since VI API 2.5 |
sourceDatacenter* P | ManagedObjectReference
to a 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.
Since VI API 2.5 |
destinationName | xsd:string |
The name of the destination, either a
URL or a datastore path referring to the destination file
or folder.
Since VI API 2.5 |
destinationDatacenter* P | ManagedObjectReference
to a Datacenter |
If destinationName 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.
Since VI API 2.5 |
force* | xsd:boolean |
If true, overwrite any identically named file
at the destination. If not specified, it is assumed to be false.
Since VI API 2.5 |
Return Value
Type | Description |
---|---|
ManagedObjectReference
to a Task | This method returns a Task object with which to monitor the operation. |
Faults
Type | Description |
---|---|
CannotAccessFile | Thrown if the source cannot be accessed because of insufficient permissions. |
FileAlreadyExists | Thrown if a file with the given name already exists at the destination, and the force flag is false. |
FileFault | Thrown if there is a generic file error |
FileLocked | Thrown if the source file or folder is currently locked or in use. |
FileNotFound | Thrown if the file or folder specified by sourceName is not found, or, any intermediate level folder specified by the destinationName is not found. |
InvalidDatastore | Thrown if the operation cannot be performed on the source or destination datastores. Typically, a specific subclass of this exception is thrown. |
NoDiskSpace | Thrown if there is not enough space available at the destination datastore. |
RuntimeFault | Thrown if any type of runtime fault is thrown that is not covered by the other faults; for example, a communication error. |
Events
Type | |
---|---|
None |
DeleteDatastoreFile_Task(deleteFile)
Deletes the specified file or folder from the datastore. If a file of a virtual machine is deleted, it may corrupt that virtual machine. Folder deletes are always recursive. The datacenter parameter may be omitted if a URL is used to name the file or folder.If the source is an extent of a virtual disk, this operation treats the extent as a file.
It is important to note that this operation will provide transactional guarantees only for a file. No guarantees are provided when deleting folders. If the intent is to delete a virtual machine registered in the inventory, please refer to Destroy_Task.
Requires Datastore.FileManagement privilege on the datastore.
- Required Privileges
- None
Parameters
Name | Type | Description |
---|---|---|
_this | ManagedObjectReference | A reference to the FileManager used to make the method call. |
name | xsd:string |
The name of the file or folder, either a URL or a datastore path
referring to the file or folder to be deleted.
Since VI API 2.5 |
datacenter* P | ManagedObjectReference
to a 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.
Since VI API 2.5 |
Return Value
Type | Description |
---|---|
ManagedObjectReference
to a Task | This method returns a Task object with which to monitor the operation. |
Faults
Type | Description |
---|---|
CannotDeleteFile | Thrown if the delete operation on the file or folder fails. |
FileFault | Thrown if there is a generic file error |
FileLocked | Thrown if the source file or folder is currently locked or in use. |
FileNotFound | Thrown if the file or folder specified by name is not found. |
InvalidDatastore | Thrown if the operation cannot be performed on the datastore. Typically, a specific subclass of this exception is thrown. |
RuntimeFault | Thrown if any type of runtime fault is thrown that is not covered by the other faults; for example, a communication error. |
Events
Type | |
---|---|
None |
MakeDirectory(makeDirectory)
Create a folder using the specified name. If the parent or intermediate level folders do not exist, and the parameter createParentDirectories is false, a FileNotFound fault is thrown. If the intermediate level folders do not exist, and the parameter createParentDirectories is true, all the non-existent folders are created.Requires Datastore.FileManagement privilege on the datastore.
- Required Privileges
- None
Parameters
Name | Type | Description |
---|---|---|
_this | ManagedObjectReference | A reference to the FileManager used to make the method call. |
name | xsd:string |
The name of the folder, either a URL or a datastore path
referring to the folder to be created.
Since VI API 2.5 |
datacenter* P | ManagedObjectReference
to a 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.
Since VI API 2.5 |
createParentDirectories* | xsd:boolean |
If true, any non-existent intermediate level
folders will be created. If not specified,
it is assumed to be false.
Since VI API 2.5 |
Return Value
Type | Description |
---|---|
None |
Faults
Type | Description |
---|---|
CannotCreateFile | Thrown if the create operation on the folder fails. |
FileAlreadyExists | Thrown if a file or folder with the given name already exists at the destination. |
FileFault | Thrown if there is a generic file error |
FileNotFound | Thrown if the createParentDirectories is false and a intermediate level folder specified by name is not found. |
InvalidDatastore | Thrown if the operation cannot be performed on the datastore. Typically, a specific subclass of this exception is thrown. |
RuntimeFault | Thrown if any type of runtime fault is thrown that is not covered by the other faults; for example, a communication error. |
Events
Type | |
---|---|
None |
Show WSDL type definition
MoveDatastoreFile_Task(moveFile)
Moves the source file or folder to the destination.If the destination file does not exist, it is created. If the destination file exists, the force parameter determines whether to overwrite it with the source or not. If the source path is a folder, then the destination path must not exist; the destination cannot be overwritten even with a force flag in that case. Folder moves are recursive, treating all files and disks to move as binary.
If source (or destination) name is specified as a URL, then the corresponding datacenter parameter may be omitted.
If any intermediate level folder specified by the source and destination does not exist, a FileNotFound fault is thrown.
If a file of a virtual machine is moved, it may corrupt that virtual machine. If a file of a virtual machine is overwritten on the destination datastore as a result of the force parameter, it may corrupt that virtual machine.
If the source is an extent of a virtual disk, this operation treats the extent as a file.
If source and destination resolve to the same file system location, the call has no effect.
It is important to note that this operation will provide transactional guarantees only for a file. No guarantees are provided for folder moves. If the intent is to move a virtual machine registered in the inventory, with transactional guarantees, please refer to RelocateVM_Task. If the intent is to rename a virtual machine registered in the inventory, please refer to Rename_Task.
Datastore.FileManagement privilege is required on both source and destination datastores.
- Required Privileges
- None
Parameters
Name | Type | Description |
---|---|---|
_this | ManagedObjectReference | A reference to the FileManager used to make the method call. |
sourceName | xsd:string |
The name of the source, either a URL or a datastore path
referring to the file or folder to be moved.
Since VI API 2.5 |
sourceDatacenter* P | ManagedObjectReference
to a 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.
Since VI API 2.5 |
destinationName | xsd:string |
The name of the destination, either a URL or a
datastore path referring to the destination file or folder.
Since VI API 2.5 |
destinationDatacenter* P | ManagedObjectReference
to a Datacenter |
If destinationName 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.
Since VI API 2.5 |
force* | xsd:boolean |
If true, overwrite any identically named file
at the destination. If not specified, it is assumed to be false.
Since VI API 2.5 |
Return Value
Type | Description |
---|---|
ManagedObjectReference
to a Task | This method returns a Task object with which to monitor the operation. |
Faults
Type | Description |
---|---|
CannotAccessFile | Thrown if the source file or folder cannot be moved because of insufficient permissions. |
FileAlreadyExists | Thrown if a file with the given name already exists at the destination, and the force flag is false. For folders, if the destination exists, this fault is thrown regardless. |
FileFault | Thrown if there is a generic file error |
FileLocked | Thrown if the source file or folder is currently locked or in use. |
FileNotFound | Thrown if the file or folder specified by sourceName is not found, or, any intermediate level folder specified by the destinationName is not found. |
InvalidDatastore | Thrown if the operation cannot be performed on the source or destination datastores. Typically, a specific subclass of this exception is thrown. |
NoDiskSpace | Thrown if there is not enough space available on the destination datastore. |
RuntimeFault | Thrown if any type of runtime fault is thrown that is not covered by the other faults; for example, a communication error. |
Events
Type | |
---|---|
None |
QueryFileLockInfo(queryFileLockInfo)
Fetches as much information as possible for the file path passed in. The main purpose of the API is to show caller any lock information that can be queried from the host. The API gathers various information depending on which file-system (VMFS/NFS/VSAN) the file is located on.- Required Privileges
- System.View
- Since
- vSphere API Release 8.0.2.0
Parameters
Name | Type | Description |
---|---|---|
_this | ManagedObjectReference | A reference to the FileManager used to make the method call. |
path | xsd:string |
Full file path to look up lock information on.
For example specific VM file like:
/vmfs/volumes/datastore1/vm/vm-flat.vmdk
Since vSphere API Release 8.0.2.0 |
host* | ManagedObjectReference
to a HostSystem |
Host id is required if API is invoked on vCenter Server.
It is optional if invoked on host directly. Esx does not
require this parameter.
Since vSphere API Release 8.0.2.0 |
Return Value
Type | Description |
---|---|
FileLockInfoResult |
Faults
Type | Description |
---|---|
FileFault | Thrown if there is a generic file error. |
InvalidDatastore | Thrown if the operation cannot be performed on the datastore. Typically, a specific subclass of this exception is thrown. |
RuntimeFault | Thrown if any type of runtime fault is thrown that is not covered by the other faults; for example, a communication error. |
Events
Type | |
---|---|
None |
Show WSDL type definition
Top of page | Local Methods | ||
Managed Object Types | Data Object Types | All Properties | All Methods |