Java Example of Storing
Library Content on a Datastore
This example is
based on the code in the
LibraryCrud.java
sample file.
For more information about storing the
contents of a local library, see
Content Library Storage.
For a complete and
up-to-date version of the sample code, see the
vSphere
Automation SDK Java samples 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 datastoreManagedObjectReference. * See thevSphere Web Services SDK Programming Guide* and the vSphere Web Services SDK samples. In addition, thevSphere Automation SDK for Javaprovides * theVimUtilutility class in thevmware.samples.vim.helperspackage. * You can use the utility to retrieve theManagedObjectReference* 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));