Create a Local Content LibraryLast Updated December 16, 2024
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. Required privileges:
- on thevCenter Serverinstance where you want to create the library.
- on the destination datastore.
- Access theLocalLibraryservice that provides support for creating local content libraries.
- Create aStorageBackinginstance and define the storage location.
- Create aSecurityPoliciesinstance 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 theOVF_STRICT_VERIFICATIONsecurity 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.
- Create aLibraryModelinstance and set the properties of the new local library.If you want to apply a security policy on the local library, you must use thesetSecurityPolicyId(java.lang.String securityPolicyId)method or thesecurity_policy_idparameter of theLibraryModelinstance.
- Call the create function on theLocalLibraryobject and pass theLibraryModelas a parameter.
A local content library is created on the
vCenter Server
instance and you can edit its contents.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.
- Java
- This example is based on the code in theLibraryCrud.javasample file.This example uses the steps that are described in the Create a Local Content Library procedure.For a complete and up-to-date version of the Java sample code, see thevsphere-automation-sdk-javaVMware repository at GitHub.
- Python
- This example creates a local library with nameAcmeLibrary, which is stored on the local file system wherevCenter Serverruns.This example uses the steps that are described in the Create a Local Content Library procedure.For related code samples, see thevsphere-automation-sdk-pythonVMware repository at GitHub.