vcenter vm template library items: create

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. Warning: This operation is available as technical preview. It may be changed in a future release.

Request:

HTTP request

POST https://{server}/rest/vcenter/vm-template/library-items

Request Body Structure:

{
    "spec"{
        "description""string",
        "disk_storage"{
            "datastore""obj-103",
            "storage_policy"{
                "policy""obj-103",
                "type""USE_SPECIFIED_POLICY"
            }
        },
        "disk_storage_overrides"[
            {
                "key""obj-103",
                "value"{
                    "datastore""obj-103",
                    "storage_policy"{
                        "policy""obj-103",
                        "type""USE_SPECIFIED_POLICY"
                    }
                }
            }
        ],
        "library""obj-103",
        "name""string",
        "placement"{
            "cluster""obj-103",
            "folder""obj-103",
            "host""obj-103",
            "resource_pool""obj-103"
        },
        "source_vm""obj-103",
        "vm_home_storage"{
            "datastore""obj-103",
            "storage_policy"{
                "policy""obj-103",
                "type""USE_SPECIFIED_POLICY"
            }
        }
    }
}

Request Body Parameters:

Name Type Description
bold = required
spec create_spec information used to create the library item from the source virtual machine.
spec.source_vm string Identifier of the source virtual machine to create the library item from. Warning: This attribute is available as technical preview. It may be changed in a future release.

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.

spec.name string Name of the library item. Warning: This attribute is available as technical preview. It may be changed in a future release.

Optional. This field is optional because it was added in a newer version than its parent node.

spec.description string Description of the library item. Warning: This attribute is available as technical preview. It may be changed in a future release.

Optional. If unset, the newly created library item has the same description as the source virtual machine.

spec.library string Identifier of the library in which the new library item should be created. Warning: This attribute is available as technical preview. It may be changed in a future release.

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.

spec.vm_home_storage create_spec_vm_home_storage Storage location for the virtual machine template's configuration and log files. Warning: This attribute is available as technical preview. It may be changed in a future release.

Optional. If unset, the virtual machine template's configuration and log files are placed on the default storage backing associated with the library specified by library.

spec.vm_home_storage.datastore string Identifier of the datastore for the virtual machine template's configuration and log files. Warning: This attribute is available as technical preview. It may be changed in a future release.

Optional. This field is currently required. If unset, storage_policy must be set. The server picks a datastore that is compatible with the specified storage policy.

If both datastore and storage_policy are specified, and the storage policy is incompatible with the datastore, then the virtual machine template will be flagged as being out of compliance with the specified storage policy.

. When clients pass a value of this structure as a parameter, the field must be an identifier for the resource type: Datastore. When operations return a value of this structure as a result, the field will be an identifier for the resource type: Datastore.
spec.vm_home_storage.storage_policy create_spec_vm_home_storage_policy Storage policy for the virtual machine template's configuration and log files. Warning: This attribute is available as technical preview. It may be changed in a future release.

Optional. If unset, datastore must be specified and the virtual machine template's configuration and log files are created with the default storage policy associated with the datastore.

spec.vm_home_storage.storage_policy.type string Policy type to be used when creating the virtual machine template's configuration and log files. Warning: This attribute is available as technical preview. It may be changed in a future release.

Policy type for the virtual machine template's configuration and log files. Warning: This enumeration is available as technical preview. It may be changed in a future release. Value is one of:
USE_SPECIFIED_POLICY: Use the specified policy. Warning: This constant is available as technical preview. It may be changed in a future release.

spec.vm_home_storage.storage_policy.policy string Identifier for the storage policy to use. Warning: This attribute is available as technical preview. It may be changed in a future release.

Optional. It is only relevant when type has value USE_SPECIFIED_POLICY. This field is optional and it is only relevant when the value of type is USE_SPECIFIED_POLICY.When clients pass a value of this structure as a parameter, the field must be an identifier for the resource type: com.vmware.spbm.StorageProfile. When operations return a value of this structure as a result, the field will be an identifier for the resource type: com.vmware.spbm.StorageProfile.

spec.disk_storage create_spec_disk_storage Storage specification for the virtual machine template's disks. Warning: This attribute is available as technical preview. It may be changed in a future release.

Optional. If both disk_storage_overrides and disk_storage are unset, the virtual machine template's disks are placed in the default storage backing associated with the library specified by library.

If disk_storage_overrides is unset and disk_storage is specified, all of the virtual machine template's disks are created with the storage spec specified by disk_storage.

If disk_storage_overrides is specified and disk_storage is unset, disks with identifiers that are not in disk_storage_overrides are placed in the default storage backing associated with the library specified by library.

If both disk_storage_overrides and disk_storage are specified, disks with identifiers that are not in disk_storage_overrides are created with the storage spec specified by disk_storage.

.
spec.disk_storage.datastore string Identifier for the datastore associated with a virtual machine template's disk. Warning: This attribute is available as technical preview. It may be changed in a future release.

Optional. This field is currently required. If unset, storage_policy must be set. The server picks a datastore that is compatible with the specified storage policy.

If both datastore and storage_policy are specified, and the storage policy is incompatible with the datastore, then the disk will be flagged as being out of compliance with the specified storage policy.

. When clients pass a value of this structure as a parameter, the field must be an identifier for the resource type: Datastore. When operations return a value of this structure as a result, the field will be an identifier for the resource type: Datastore.
spec.disk_storage.storage_policy create_spec_disk_storage_policy Storage policy for a virtual machine template's disk. Warning: This attribute is available as technical preview. It may be changed in a future release.

Optional. If unset, datastore must be specified and the virtual machine template's disk is created with the default storage policy associated with the datastore.

spec.disk_storage.storage_policy.type string Policy type to be used when creating a virtual machine template's disk. Warning: This attribute is available as technical preview. It may be changed in a future release.

Policy type for a virtual machine template's disk. Warning: This enumeration is available as technical preview. It may be changed in a future release. Value is one of:
USE_SPECIFIED_POLICY: Use the specified policy. Warning: This constant is available as technical preview. It may be changed in a future release.

spec.disk_storage.storage_policy.policy string Identifier for the storage policy to use. Warning: This attribute is available as technical preview. It may be changed in a future release.

Optional. It is only relevant when type has value USE_SPECIFIED_POLICY. This field is optional and it is only relevant when the value of type is USE_SPECIFIED_POLICY.When clients pass a value of this structure as a parameter, the field must be an identifier for the resource type: com.vmware.spbm.StorageProfile. When operations return a value of this structure as a result, the field will be an identifier for the resource type: com.vmware.spbm.StorageProfile.

spec.disk_storage_overrides list 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. Warning: This attribute is available as technical preview. It may be changed in a future release.

Optional. If both disk_storage_overrides and disk_storage are unset, the virtual machine template's disks are placed in the default storage backing associated with the library specified by library.

If disk_storage_overrides is unset and disk_storage is specified, all of the virtual machine template's disks are created with the storage spec specified by disk_storage.

If disk_storage_overrides is specified and disk_storage is unset, disks with identifiers that are not in disk_storage_overrides are placed in the default storage backing associated with the library specified by library.

If both disk_storage_overrides and disk_storage are specified, disks with identifiers that are not in disk_storage_overrides are created with the storage spec specified by disk_storage.

. When clients pass a value of this structure as a parameter, the key in the field key/value pairs 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 key/value pairs will be an identifier for the resource type: com.vmware.vcenter.vm.hardware.Disk.
spec.disk_storage_overrides[].key string
spec.disk_storage_overrides[].value create_spec_disk_storage
spec.disk_storage_overrides[].value.datastore string Identifier for the datastore associated with a virtual machine template's disk. Warning: This attribute is available as technical preview. It may be changed in a future release.

Optional. This field is currently required. If unset, storage_policy must be set. The server picks a datastore that is compatible with the specified storage policy.

If both datastore and storage_policy are specified, and the storage policy is incompatible with the datastore, then the disk will be flagged as being out of compliance with the specified storage policy.

. When clients pass a value of this structure as a parameter, the field must be an identifier for the resource type: Datastore. When operations return a value of this structure as a result, the field will be an identifier for the resource type: Datastore.
spec.disk_storage_overrides[].value.storage_policy create_spec_disk_storage_policy Storage policy for a virtual machine template's disk. Warning: This attribute is available as technical preview. It may be changed in a future release.

Optional. If unset, datastore must be specified and the virtual machine template's disk is created with the default storage policy associated with the datastore.

spec.disk_storage_overrides[].value.storage_policy.type string Policy type to be used when creating a virtual machine template's disk. Warning: This attribute is available as technical preview. It may be changed in a future release.

Policy type for a virtual machine template's disk. Warning: This enumeration is available as technical preview. It may be changed in a future release. Value is one of:
USE_SPECIFIED_POLICY: Use the specified policy. Warning: This constant is available as technical preview. It may be changed in a future release.

spec.disk_storage_overrides[].value.storage_policy.policy string Identifier for the storage policy to use. Warning: This attribute is available as technical preview. It may be changed in a future release.

Optional. It is only relevant when type has value USE_SPECIFIED_POLICY. This field is optional and it is only relevant when the value of type is USE_SPECIFIED_POLICY.When clients pass a value of this structure as a parameter, the field must be an identifier for the resource type: com.vmware.spbm.StorageProfile. When operations return a value of this structure as a result, the field will be an identifier for the resource type: com.vmware.spbm.StorageProfile.

spec.placement create_placement_spec Information used to place the virtual machine template. Warning: This attribute is available as technical preview. It may be changed in a future release.

Optional. 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.

.
spec.placement.folder string Virtual machine folder into which the virtual machine template should be placed. Warning: This attribute is available as technical preview. It may be changed in a future release.

Optional. If unset, the virtual machine template will be placed in the same folder as the source virtual machine.When clients pass a value of this structure as a parameter, the field must be an identifier for the resource type: Folder. When operations return a value of this structure as a result, the field will be an identifier for the resource type: Folder.

spec.placement.resource_pool string Resource pool into which the virtual machine template should be placed. Warning: This attribute is available as technical preview. It may be changed in a future release.

Optional. If unset, the system will attempt to choose a suitable resource pool for the virtual machine template; if a resource pool cannot be chosen, the library item creation operation will fail.When clients pass a value of this structure as a parameter, the field must be an identifier for the resource type: ResourcePool. When operations return a value of this structure as a result, the field will be an identifier for the resource type: ResourcePool.

spec.placement.host string Host onto which the virtual machine template should be placed. If host and resource_pool are both specified, resource_pool must belong to host. If host and cluster are both specified, host must be a member of cluster. Warning: This attribute is available as technical preview. It may be changed in a future release.

Optional. This field may be unset if resource_pool or cluster is specified. If unset, the system will attempt to choose a suitable host for the virtual machine template; if a host cannot be chosen, the library item creation operation will fail.When clients pass a value of this structure as a parameter, the field must be an identifier for the resource type: HostSystem. When operations return a value of this structure as a result, the field will be an identifier for the resource type: HostSystem.

spec.placement.cluster string Cluster onto which the virtual machine template should be placed. If cluster and resource_pool are both specified, resource_pool must belong to cluster. If cluster and host are both specified, host must be a member of cluster. Warning: This attribute is available as technical preview. It may be changed in a future release.

Optional. If resource_pool or host is specified, it is recommended that this field be unset.When clients pass a value of this structure as a parameter, the field must be an identifier for the resource type: ClusterComputeResource. When operations return a value of this structure as a result, the field will be an identifier for the resource type: ClusterComputeResource.

Response:

HTTP Status Code: 200

Representation:

{
    "value""obj-103"
}

Response Type:

Name Type Description
bold = required
value string Identifier of the newly created library item.

Errors:

HTTP Status Code Type Description
400 already_exists if an entity with the name specified by vcenter.vm_template.library_items.create_spec.name already exists in the folder specified by vcenter.vm_template.library_items.create_placement_spec.folder.
500 error if the system reports an error while responding to the request.
400 invalid_argument if vcenter.vm_template.library_items.create_spec contains invalid arguments.
400 not_allowed_in_current_state if the operation cannot be performed because of the source virtual machine's current state.
404 not_found if the source virtual machine specified by vcenter.vm_template.library_items.create_spec.source_vm does not exist.
400 resource_inaccessible if there was an error accessing a file from the source virtual machine.
400 resource_in_use if the source virtual machine is busy.
503 service_unavailable if any of the services involved in the operation are unavailable.
400 unable_to_allocate_resource if any of the resources needed to create the virtual machine template could not be allocated.
401 unauthenticated if the user that requested the operation cannot be authenticated.
403 unauthorized if the user that requested the operation is not authorized to perform the operation.