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]