To make the library content available for other vCenter Server instances across the vSphere Automation environment, you must publish the library. Depending on your workflow, select a method for publishing the local library. You can publish a local library that already exists in your vSphere Automation environment.
Procedure
Example
- Java
-
This example is based on the code in the
LibraryPublishSubscribe.java sample file.
This example uses the steps that are described in the Publish an Existing Content Library procedure.
Note: For a complete and up-to-date version of the Java sample code, see the vsphere-automation-sdk-java VMware repository at GitHub.... // Access the LocalLibrary service. LocalLibrary localLibraryService = this.vapiAuthHelper.getStubFactory().createStub(LocalLibrary.class, sessionStubconfig); // Retrieve an existing local library. LibraryModel libraryModel = localLibraryService.get(libraryId); PublishInfo publishInfo = new PublishInfo(); // Configure how the local library is published by using BASIC authentication. publishInfo.setUserName("vcsp"); publishInfo.setPassword("password".toCharArray()); publishInfo.setAuthenticationMethod(AuthenticationMethod.BASIC); // Set the local library to published and update the library instance. publishInfo.setPublished(true); libraryModel.setPublishInfo(publishInfo); localLibraryService.update(libraryModel.getId(), libraryModel);
- Python
-
This example is based on the code in the
library_publish_subscribe.py sample file.
This example uses the steps that are described in the Publish an Existing Content Library procedure.
Note: For a complete and up-to-date version of the sample code, see the vsphere-automation-sdk-python VMware repository at GitHub.... # Retrieve an existing local library. local_library_stub = content_client.LocalLibrary(my_stub_config) local_library = local_library_stub.get(my_library_id) # Specify how the local library is published, using BASIC authentication. publish_info = library_client.PublishInfo() publish_info.user_name = ’vcsp’ # Can omit this value; if specified, it must be ’vcsp’. publish_info.password = ’password’ publish_info.authentication_method = library_client.PublishInfo.AuthenticationMethod.BASIC publish_info.published = True # Update the LibraryModel object retieved in step 1 # and configure it with the PublishInfo object. local_library.publish_info = publish_info # Use the LibraryModel object to update the library instance. local_library_stub.update(library_id=my_library_id, update_spec=local_library)