.NET Example of
Creating a Local Content Library
This example
creates a local library with name
AcmeLibrary
, which is stored on the local file
system where
runs.
This example uses the steps that are
described in the
Create a Local Content Library
procedure.
For related code
samples, see the
vSphere Automation SDK .NET
samples at GitHub.
... // Create a StorageBacking instance to back the library content on the local file system. var libraryBacking = new StorageBacking(); libraryBacking.SetType(vmware.content.library.StorageBacking.Type.OTHER); libraryBacking.SetStorageUri(new Uri("file:///tmp")); libraryModel.SetStorageBackings(new List<StorageBacking>() { libraryBacking }); // Create a LibraryModel that represents a local library. var libraryModel = new LibraryModel(); libraryModel.SetType(vmware.content.LibraryModel.LibraryType.LOCAL); libraryModel.SetName("AcmeLibrary"); // Access the LocalLibrary service by using thevSphere Automationendpoint. LocalLibrary localLibraryService = ServiceManager.VapiConnection.GetService<LocalLibrary>(); // Call the Create method of the LocalLibrary service // passing the LibraryModel instance as an argument. var libraryId = localLibraryService.Create(Guid.NewGuid().ToString(), libraryModel);