A content library instance represents a container for a set of library items. A content library item instance represents the logical object stored in the content library, which might be one or more usable files.
You create and manage the content of a content library on a single vCenter Server instance, but you can distribute the content to other vCenter Server instances. Depending on your needs, you can maintain two types of content libraries: local and subscribed. You can shape the contents of a library item and then combine several library items in a local content library. Furthermore, you can publish the library to make its content available to other users.
Content Library Types
You can create two types of libraries, local and subscribed.
- Local library.
- You can create a local library as the source for content you want to save or share. Create the local library on a single vCenter Server instance. You can add items to a local library or remove them. You can publish a local library and as a result this content library service endpoint can be accessed by other vCenter Server instances in your virtual environment. When you publish a library, you can configure a password for authentication.
- Subscribed library.
- You can create a subscribed library and populate its content by synchronizing to a local library. A subscribed library contains copies of the local library files or just the metadata of the library items. The local library can be located on the same vCenter Server instance as the subscribed library, or the subscribed library can reference a local library on a different vCenter Server instance. You cannot add library items to a subscribed library. You can only add items to the source library. After synchronization, both libraries will contain the same items.
Content Library Items
Library items are VM templates, vApp templates, or other VMware objects that can be contained in a content library.
VMs and vApps have several files, such as log files, disk files, memory files, and snapshot files that are part of a single library item. You can create library items in a specific local library or remove items from a local library. You can also upload files to an item in a local library so that the libraries subscribed to it can download the files to their NFS or SMB server, or datastore.
For information about the tasks that you can perform by using the content library service, see How to Use Content Libraries.
Content Library Storage
When you create a local library, you can store its contents on a datastore managed by the vCenter Server instance or on a remote file system.
Depending on the type of storage that you have, you can use Virtual Machine File System (VMFS) or Network File System (NFS) for storing content on a datastore.
For storing content on a remote file system, you can enter the path to the NFS storage that is mounted on the Linux file system of the vCenter Server instance. For example, you can use the following URI formats: nfs://<server>/<path>?version=4
and nfs://<server>/<path>
. If you have a vCenter Server instance that runs on a Windows machine, you can specify the Server Massage Block (SMB) URI to the Windows shared folders that store the library content. For example, you can use the following URI format: smb://<unc-server>/<path>
.
- Java
-
This example is based on the code in the
LibraryCrud.java sample file and shows how to store library content on a datastore.
For more information about storing the contents of a local library, see Content Library Storage.
Note: For a complete and up-to-date version of the Java sample code, see the vsphere-automation-sdk-java VMware repository at GitHub.... // Create a StorageBacking instance for storing the library content on a datastore. StorageBacking libraryBacking = new StorageBacking(); libraryBacking.setType(Type.DATASTORE); /* * Pass the value of the datastore ManagedObjectReference. * See the vSphere Web Services SDK Programming Guide * and the vSphere Web Services SDK samples. In addition, the vSphere Automation SDK for Java provides * the VimUtil utility class in the vmware.samples.vim.helpers package. * You can use the utility to retrieve the ManagedObjectReference * of the datastore entity. */ libraryBacking.setDatastoreId("datastore-123"); // Create a LibraryModel that represents a local library backed on a datastore. LibraryModel libraryModel = new LibraryModel(); libraryModel.setName("AcmeLibrary"); libraryModel.setDescription("Local library backed by VC datastore"); libraryModel.setType(LibraryType.LOCAL); libraryModel.setStorageBackings(Collections.singletonList(libraryBacking));
- Python
-
This example is based on the code in the
library_crud.py sample file and shows how to store library content on a datastore.
For more information about storing the contents of a local library, see Content Library Storage.
Note: For a complete and up-to-date version of the sample code, see the vsphere-automation-sdk-python VMware repository at GitHub.... # Create a StorageBacking instance of datastore type. library_backing = library_client.StorageBacking() library_backing.type = library_client.StorageBacking.Type.DATASTORE # Pass the value of the datastore managed object reference. # The vSphere Automation SDK for Python contains # the GetDatastoreByName class, which sample resource is located in the # /client/samples/src/com/vmware/vcloud/suite/sample/vim/helpers/ directory. # You can use the utility to retrieve the managed object reference of the datastore entity. library_backing.datastore_id = ‘datastore-123’ # Create a LibraryModel that represents a local library backed on a datastore. library_model = content_client.LibraryModel() library_model.name = ‘AcmeLibrary’ library_model.storage_backings = [library_backing]