■ Getting Access to vCloud Director – Shows how to connect and authenticate with the vCloud API.
■ Inventory Access – Shows how to retrieve data for different Organization types.
■ Retrieving Catalog information – Shows how to retrieve Catalog entries for backup.
■ Retrieving vApp Configuration – Shows how to list virtual machines and vApp configuration data.
■ Preventing Updates to a vApp During Backup or Restore – Shows how to use maintenance mode to quiesce vApp configuration.
■ Associating vCloud Resources with vSphere Entities – Shows how to get Managed Object References of virtual machines and storage resources from vCloud Director.
■ Restoring vApps – Shows how to import virtual machines into vApps.The backup/restore software component must use system administrator privileges to connect to vCloud Director, so that it can access any Organization. The system administrator always logs into the System organization. When Administrator@System is used as the user name for the API, Administrator is the login name and System is the System Organization name.Using system administrator privileges to connect to vCloud Director also allows the backup/restore software to access additional information relating a vApp to the corresponding resources in vSphere. This is described in Inventory Access.Example: vCloud Director login code sample using Administrator@System/<password> shows how to log in using C# with the vCloud SDK for .NET. After logging in, the code shows how to access Organization data.Example: vCloud Director login code sample using Administrator@System/<password> shows how to get a reference to the user view of an Organization. Example: Get Admin Org and Admin VDC shows how to get a reference to the admin view of an Organization and a VDC.Example: Get Admin Org and Admin VDCThe admin view of resources such as Organization, VDC, and vApp provides extra information that is useful to users with administrative privileges. For example, in the case of a vApp, admin view provides information about vCenter and the virtual machines that belong to the vApp. The admin view provides information such as Managed Object References that vCenter uses for those entities. See Associating vCloud Resources with vSphere Entities for more information about getting vCenter Managed Object References.Example: Get Provider VDC shows how to get a Provider VDC.Example: Get Provider VDCUsing the vCloud SDK for .NET allows you to access vCloud Director from a C# development environment. These examples show how to use .NET methods. The vCloud SDK for .NET simplifies access to the vCloud API. For more information about using the SDK, see the vCloud SDK for .NET Developer's Guide.The vCloud API is REST-based. For more information about the vCloud API, see the vCloud API Programming Guide. Example: REST API Calls To Get Provider VDC shows the REST API calls that accomplish the tasks shown in Example: vCloud Director login code sample using Administrator@System/<password>, Example: Get Admin Org and Admin VDC, and Example: Get Provider VDC, after logging in.Example: REST API Calls To Get Provider VDCGET https://vCloud/api/adminGET https://vCloud/api/admin/extensionIn general, if you do not need admin views or provider views, you can use an Organization reference to get a VDC reference, and you can use the VDC reference to get a list of vApps belonging to the VDC. Example: List vApps in a VDC for a Given Organization shows how to list the hierarchy of Organizations, VDCs, and vApps known to vCloud Director. This example assumes you have already logged in to vCloud Director.The .NET SDK code in Example: List vApps in a VDC for a Given Organization translates to the API calls shown in Example: REST API Calls To List vApps in a VDC for a Given OrganizationGET https://vCloud/api/adminGET https://vCloud/api/admin/extensionYou can use a provider VDC reference to enumerate its associated datastores, as shown in Example: List Datastores. This example assumes you have already logged in to vCloud Director.Example: List DatastoresExample: List Catalogs and Catalog Items for a Given Organization shows inventory traversal to access the Catalog items in a given Organization, and assumes you have already logged in to vCloud Director and obtained a map of Organizations, as in Example: vCloud Director login code sample using Administrator@System/<password>.Example: REST API Calls To List Catalog Items shows the REST API calls that accomplish some of the tasks shown in Example: List Catalogs and Catalog Items for a Given Organization.Example: REST API Calls To List Catalog ItemsGet virtual machine startup information. Returns StartupSectionType.Get mapping of all the network sections using their name. Returns Dictionary<string, NetworkSection_TypeNetwork>.Get network configuration details for a vApp. The information typically contains IP scope (gateway, netmask, DNS settings, IP range), Parent network, Fence Mode settings, and so on. Returns NetworkConfigSectionType.Get lease settings information. It includes deployment and storage lease settings for the vApp. Returns LeaseSettingsSectionType.Get owner information for the vApp. Returns ReferenceType.Example: REST API Calls To Get vApp Configuration shows the REST API calls used to get vApp configuration data.The following methods, applied to an object of type VM, retrieve configuration data structures from vCloud Director.Get hardware requirements of the virtual machine. Returns VirtualhardwareSection_Type.Get information about the guest operating system installed on this virtual machine. Returns OperatingSystemSectionType.Get information about virtual network devices used by this virtual machine. Returns NetworkConnectionSectionType.Get version of VMware Tools installed on the virtual machine. Returns RuntimeInfoSectionType.Example: REST API Calls To Get Virtual Machine Configuration Data shows the REST API calls corresponding to the virtual machine configuration sections available from the SDK for .NET.The backup software must select maintenance mode for the vApp before starting backup or restore operations, and deselect maintenance mode for the vApp after the operations are completed. Example: Protecting a vApp with Maintenance Mode shows how to select and deselect maintenance mode for a vApp.Example: REST API Calls To Protect a vApp with Maintenance Mode shows the corresponding REST API calls to select and deselect maintenance mode for a vApp.For example, any given virtual machine is known in vCloud Director by a URN that contains the UUID and resource type. The same resource is identified in vSphere using its native identification, a MoRef (Managed object reference). Additional information provided in the vCloud API makes the necessary link between the two entities by mapping their ID in the two systems. The mapping context is shown in Mapping to a Virtual Machine from a vApp.The vCloud API describes the mapping in terms of XML elements, shown in Example: XML Mapping a Virtual Machine URL to a MoRef. The box in the example highlights XML data that maps a virtual machine from vCloud Director to vSphere. The MoRef of the virtual machine is in bold type.The object type is shown as VIRTUAL_MACHINE.
Besides the virtual machine object itself, the VmVIMInfo element encapsulated in the VCloudExtension element of Example: XML Mapping a Virtual Machine URL to a MoRef lists a datastore object and a host object. Each section provides the vSphere entity reference (MoRef) for the corresponding entity, along with its type. The types are DATASTORE and HOST, respectively. In vCloud Director, the virtual machine can be described as virtual machine vm-63 stored in datastore datastore-29 and managed by vCenter Server dao_w2k8_vc.In a similar way, Example: XML Mapping a Datacenter URL to a MoRef shows the administrative view of a VDC wherein the VCloudExtension element provides additional information about the corresponding entities in vSphere. In this particular case, the VDC in the example is based on a resource pool configured in vCenter Server, named dao_w2k8_vc. More information on this server can be obtained by using the vCloud API and its reference URL, which is available as the href property. The MoRef element provides the ID of the resource pool that backs the given VDC, as known to vSphere. Since a MoRef is treated as an opaque value, the VimObjectType element specifies the type of object that the MoRef points to. Combining these elements enables you to use the vSphere API and to locate the Resource Pool served by the specified vCenter Server.Example: Using the SDK for .NET To Access MoRefs shows how to use SDK helper methods to access the vSphere specific information for the virtual machines of a given vApp.The return value of the methods has type VimObjectRefType, which provides a reference to a vCenter Server, a MoRef to the vSphere entity, and the type of the entity it is referring to.To re-create the vApp using the vCloud SDK for .NET, the backup software must use two method calls: ImportVmAsVapp and ImportVmIntoVapp. Use the ImportVmAsVapp method to create a vApp from any one of the child virtual machines. Then call the ImportVmIntoVapp method once for each remaining child virtual machine.Example: Importing Virtual Machines into vApps shows how to use both methods to create a vApp using the vCloud SDK.Example: REST API Calls To Restore a vApp shows the corresponding REST API calls used to rebuild a vApp in vCloud Director.Example: REST API Calls To Restore a vApp