You can create a local content library programmatically by using the vSphere Automation API. The API allows you to populate the content library with OVF and vApp templates. You can use these templates to deploy virtual machines or vApps in your virtual environment.

Prerequisites

Required privileges:
  • Content library.Create local library on the vCenter Server instance where you want to create the library.
  • Datastore.Allocate space on the destination datastore.

Procedure

  1. Access the LocalLibrary service that provides support for creating local content libraries.
  2. Create a StorageBacking instance and define the storage location.
  3. (Optional) Create a SecurityPolicies instance to define the security policy rules for the library. For vSphere 7.0 Update3, you can only define rules for an OVF and OVA templates in the library by using the OVF_STRICT_VERIFICATION security rule. When the OVF security policy is configured for a local content library, an OVF or OVA template can be synchronized or imported to the library only after its certificate is validated against a trusted certificate authority.
  4. Create a LibraryModel instance and set the properties of the new local library.
    If you want to apply a security policy on the local library, you must use the setSecurityPolicyId(java.lang.String securityPolicyId) method or the security_policy_id parameter of the LibraryModel instance.
  5. Call the create function on the LocalLibrary object and pass the LibraryModel as a parameter.

Results

A local content library is created on the vCenter Server instance and you can edit its contents.

What to do next

You maintain the contents of the local library by managing its library items. See How To Use Library Items and Content Library Support for OVF and OVA Packages. You can also share the library content by publishing the local library. See Publish an Existing Content Library.