Create Library Items
Creates a library item in content library from a virtual machine. This operation creates a library item in content library whose content is a virtual machine template created from the source virtual machine, using the supplied create specification. The virtual machine template is stored in a newly created library item. if you do not have all of the privileges described as follows: - Operation execution requires System.Read. - The resource com.vmware.content.Library referenced by the attribute LibraryItems.CreateSpec.library requires ContentLibrary.AddLibraryItem. - The resource VirtualMachine referenced by the attribute LibraryItems.CreateSpec.source-vm requires System.Read. - The resource Datastore referenced by the attribute LibraryItems.CreateSpecVmHomeStorage.datastore requires System.Read. - The resource com.vmware.spbm.StorageProfile referenced by the attribute LibraryItems.CreateSpecVmHomeStoragePolicy.policy requires System.Read. - The resource Datastore referenced by the attribute LibraryItems.CreateSpecDiskStorage.datastore requires System.Read. - The resource com.vmware.spbm.StorageProfile referenced by the attribute LibraryItems.CreateSpecDiskStoragePolicy.policy requires System.Read. - The resource com.vmware.vcenter.vm.hardware.Disk referenced by the map key of attribute LibraryItems.CreateSpec.disk-storage-overrides requires System.Read. - The resource Folder referenced by the attribute LibraryItems.CreatePlacementSpec.folder requires System.Read. - The resource ResourcePool referenced by the attribute LibraryItems.CreatePlacementSpec.resource-pool requires System.Read. - The resource HostSystem referenced by the attribute LibraryItems.CreatePlacementSpec.host requires System.Read. - The resource ClusterComputeResource referenced by the attribute LibraryItems.CreatePlacementSpec.cluster requires System.Read.
Request
URLURL
Header Parameters
Header Parameters
Required session ID, acquired from Create Session API under CIS product
vmware-api-session-id example
"b00db39f948d13ea1e59b4d6fce56389"
Request Body
information used to create the library item from the source virtual machine.
{
"library": "string",
"name": "string",
"placement": {},
"source_vm": "string"
}
Identifier of the source virtual machine to create the library item from. When clients pass a value of this structure as a parameter, the field must be an identifier for the resource type: VirtualMachine. When operations return a value of this structure as a result, the field will be an identifier for the resource type: VirtualMachine.
Identifier of the library in which the new library item should be created. When clients pass a value of this structure as a parameter, the field must be an identifier for the resource type: com.vmware.content.Library. When operations return a value of this structure as a result, the field will be an identifier for the resource type: com.vmware.content.Library.
Name of the library item.
Information used to place the virtual machine template. This field is currently required. In the future, if this field is unset, the system will place the virtual machine template on a suitable resource. If specified, each field will be used for placement. If the fields result in disjoint placement, the operation will fail. If the fields along with the placement values of the source virtual machine result in disjoint placement, the operation will fail.
Storage specification for the virtual machine template’s disks. If both LibraryItems.CreateSpec.disk-storage-overrides and LibraryItems.CreateSpec.disk-storage are unset, the virtual machine template’s disks are placed in the default storage backing associated with the library specified by LibraryItems.CreateSpec.library. If LibraryItems.CreateSpec.disk-storage-overrides is unset and LibraryItems.CreateSpec.disk-storage is specified, all of the virtual machine template’s disks are created with the storage spec specified by LibraryItems.CreateSpec.disk-storage.
If LibraryItems.CreateSpec.disk-storage-overrides is specified and LibraryItems.CreateSpec.disk-storage is unset, disks with identifiers that are not in LibraryItems.CreateSpec.disk-storage-overrides are placed in the default storage backing associated with the library specified by LibraryItems.CreateSpec.library.
If both LibraryItems.CreateSpec.disk-storage-overrides and LibraryItems.CreateSpec.disk-storage are specified, disks with identifiers that are not in LibraryItems.CreateSpec.disk-storage-overrides are created with the storage spec specified by LibraryItems.CreateSpec.disk-storage.
Storage specification for individual disks in the virtual machine template. This is specified as a mapping between disk identifiers in the source virtual machine and their respective storage specifications. If both LibraryItems.CreateSpec.disk-storage-overrides and LibraryItems.CreateSpec.disk-storage are unset, the virtual machine template’s disks are placed in the default storage backing associated with the library specified by LibraryItems.CreateSpec.library. If LibraryItems.CreateSpec.disk-storage-overrides is unset and LibraryItems.CreateSpec.disk-storage is specified, all of the virtual machine template’s disks are created with the storage spec specified by LibraryItems.CreateSpec.disk-storage.
If LibraryItems.CreateSpec.disk-storage-overrides is specified and LibraryItems.CreateSpec.disk-storage is unset, disks with identifiers that are not in LibraryItems.CreateSpec.disk-storage-overrides are placed in the default storage backing associated with the library specified by LibraryItems.CreateSpec.library.
If both LibraryItems.CreateSpec.disk-storage-overrides and LibraryItems.CreateSpec.disk-storage are specified, disks with identifiers that are not in LibraryItems.CreateSpec.disk-storage-overrides are created with the storage spec specified by LibraryItems.CreateSpec.disk-storage.
When clients pass a value of this structure as a parameter, the key in the field map must be an identifier for the resource type: com.vmware.vcenter.vm.hardware.Disk. When operations return a value of this structure as a result, the key in the field map will be an identifier for the resource type: com.vmware.vcenter.vm.hardware.Disk.
Description of the library item. If unset, the newly created library item has the same description as the source virtual machine.
Storage location for the virtual machine template’s configuration and log files. If unset, the virtual machine template’s configuration and log files are placed on the default storage backing associated with the library specified by LibraryItems.CreateSpec.library.
Authentication
Response
Response BodyResponse Body
Identifier of the newly created library item. The result will be an identifier for the resource type: com.vmware.content.library.Item.
Errors
com.vmware.vapi.std.errors.already_exists : if an entity with the name specified by LibraryItems.CreateSpec.name already exists in the folder specified by LibraryItems.CreatePlacementSpec.folder. | com.vmware.vapi.std.errors.invalid_argument : if LibraryItems.CreateSpec contains invalid arguments. | com.vmware.vapi.std.errors.not_allowed_in_current_state : if the operation cannot be performed because of the source virtual machine’s current state. | com.vmware.vapi.std.errors.resource_in_use : if the source virtual machine is busy.
com.vmware.vapi.std.errors.unauthenticated : if the user that requested the operation cannot be authenticated.
com.vmware.vapi.std.errors.unauthorized : if the user that requested the operation is not authorized to perform the operation.
com.vmware.vapi.std.errors.not_found : if the source virtual machine specified by LibraryItems.CreateSpec.source-vm does not exist. if the library specified by LibraryItems.CreateSpec.library does not exist.
com.vmware.vapi.std.errors.error : if the system reports an error while responding to the request. | com.vmware.vapi.std.errors.resource_inaccessible : if there was an error accessing a file from the source virtual machine. | com.vmware.vapi.std.errors.unable_to_allocate_resource : if any of the resources needed to create the virtual machine template could not be allocated.
com.vmware.vapi.std.errors.service_unavailable : if any of the services involved in the operation are unavailable.
‘Default’ means this response is used for all HTTP codes that are not covered individually for this operation.
Code Samples
PowerCLI Client SDK Example
PowerCLI Client SDK All Parameters Example
cURL Command
Vendor Extensions
x-vmw-doc-deprecated-method: post
x-vmw-doc-deprecated-path: /rest/vcenter/vm-template/library-items
x-vmw-doc-operation: create