You can cut, paste, and edit the JavaScript example to write scripts for content transfer between vCloud Automation Center hosts by using the Content service.

For more information about scripting in vCenter Orchestrator, see Developing with VMware vCenter Orchestrator.

Transfer Content from One vCloud Automation Center Host to Another vCloud Automation Center Host

This example script performs the following actions:

  1. Defines the source host that is based on a tenant administrator role.

  2. Exports the content of the source host.

  3. Defines the target host that is based on a tenant administrator role.

  4. Imports the content to the target source.

Table 1. Input Variables

Variable

Type

sourceHost

string

targetHost

string

var CONTENT_MANAGEMENT_SERVICE = "com.vmware.csp.core.content.service.api";
var content;

System.log("Source host: " + sourceHost.url);
System.log("Source tenant: " + sourceHost.tenant);

var contentClientExport = sourceHost.createRestClient(CONTENT_MANAGEMENT_SERVICE);
System.log("Exporting...");
content = contentClientExport.getFile("content");
System.log("Export successful");

System.log("Target host: " + targetHost.url);
System.log("Target tenant: " + targetHost.tenant);

var contentClientImport = targetHost.createRestClient(CONTENT_MANAGEMENT_SERVICE);
System.log("Importing...");
contentClientImport.postFile("content", content);
System.log("Import successful");