4. Networking Examples : 4.5 VXLAN ORG Network for Disaster Recovery : 4.5.4 Updated vCloud DR Recovery Process : 4.5.4.4. Authenticate to vCloud Director
   
4.5.4.4. Authenticate to vCloud Director
The following example shows how to authenticate to vCloud Director.
Request
POST https://vcloud.cloudlab.com/api/sessions
$ curl -k -v -c cookie.txt -u "administrator@System:akimbi" -H "Accept:application/*+xml;version=5.1" -d "" https://<VCD-IP>/api/sessions

Response
* About to connect() to <VCD-IP> port 443 (#0)
* Trying <VCD-IP>... connected
* Connected to <VCD-IP> (<VCD-IP>) port 443 (#0)
* SSLv3, TLS handshake, Client hello (1):
* SSLv3, TLS handshake, Server hello (2):
* SSLv3, TLS handshake, CERT (11):
* SSLv3, TLS handshake, Server key exchange (12):
* SSLv3, TLS handshake, Server finished (14):
* SSLv3, TLS handshake, Client key exchange (16):
* SSLv3, TLS change cipher, Client hello (1):
* SSLv3, TLS handshake, Finished (20):
* SSLv3, TLS change cipher, Client hello (1):
* SSLv3, TLS handshake, Finished (20):
* SSL connection using DHE-RSA-AES256-SHA
* Server certificate:
* subject: C=US; ST=California; L=Palo Alto; O=VMware, Inc.; CN=*.eng.vmware.com
* start date: 2009-11-17 00:00:00 GMT
* expire date: 2012-11-20 23:59:59 GMT
* common name: *.example.vmware.com (does not match '<VCD-IP>')
* issuer: C=US; O=DigiCert Inc; OU=www.digicert.com; CN=DigiCert High Assurance CA-3
* SSL certificate verify ok.
* Server auth using Basic with user 'administrator@System'
> POST /api/sessions HTTP/1.1
> Authorization: Basic YWRtaW5pc3RyYXRvckBTeXN0ZW06YWtpbWJp
> User-Agent: curl/7.21.4 (universal-apple-darwin11.0) libcurl/7.21.4 OpenSSL/0.9.8r zlib/1.2.5
> Host: <VCD-IP>
> Accept:application/*+xml;version=5.1
> Content-Length: 0
> Content-Type: application/x-www-form-urlencoded
>
< HTTP/1.1 200 OK
< Date: Tue, 24 Jul 2012 18:11:38 GMT
< x-vcloud-authorization: +UDXmIeKSZ9QnPpg9OPNEhtC5QgTUzvNmyJ6IZgx6hI=
* Added cookie vcloud-token="+UDXmIeKSZ9QnPpg9OPNEhtC5QgTUzvNmyJ6IZgx6hI=" for domain <VCD-IP>, path /, expire 0
< Set-Cookie: vcloud-token=+UDXmIeKSZ9QnPpg9OPNEhtC5QgTUzvNmyJ6IZgx6hI=; Secure; Path=/
< Content-Type: application/vnd.vmware.vcloud.session+xml;version=5.1
< Date: Tue, 24 Jul 2012 18:11:39 GMT
< Content-Length: 1259
<
<?xml version="1.0" encoding="UTF-8"?>
<Session xmlns="http://www.vmware.com/vcloud/v1.5" user="administrator" org="System" type="application/vnd.vmware.vcloud.session+xml" href="https://10.147.50.34/api/session/" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://www.vmware.com/vcloud/v1.5 http://<VCD-IP> /api/v1.5/schema/master.xsd">
<Link rel="down" type="application/vnd.vmware.vcloud.orgList+xml" href="https://<VCD-IP> /api/org/"/>
<Link rel="down" type="application/vnd.vmware.admin.vcloud+xml" href="https://<VCD-IP> /api/admin/"/>
<Link rel="down" type="application/vnd.vmware.admin.vmwExtension+xml" href="https://<VCD-IP>/api/admin/extension"/>
<Link rel="down" type="application/vnd.vmware.vcloud.org+xml" name="System" href="https://<VCD-IP>/api/org/a93c9db9-7471-3192-8d09-a8f7eeda85f9"/>
<Link rel="down" type="application/vnd.vmware.vcloud.query.queryList+xml" href="https://<VCD-IP>/api/query"/>
<Link rel="entityResolver" type="application/vnd.vmware.vcloud.entity+xml" href="https://<VCD-IP>/api/entity/"/>
<Link rel="down:extensibility" type="application/vnd.vmware.vcloud.apiextensibility+xml" href="https://<VCD-IP>/api/extensibility"/>
</Session>
* Connection #0 to host <VCD-IP> left intact
* Closing connection #0
* SSLv3, TLS alert, Client hello (1):
(Optional) Return the vCloud Director metadata.
Request
POST https://vcloud.cloudlab.com/api/query
$ curl -k -v -b cookie.txt -H "Accept:application/*+xml;version=5.1" https://<VCD-IP>/api/query
This presents a list if many elements, such as organization, adminOrgNetwork, providerVdc, externalNetwork, and edgeGateway.
Response (Modified to separate the vCloud Director objects.)
Organization:
<Link rel="down" type="application/vnd.vmware.vcloud.query.records+xml" name="organization" href="https://<VCD-IP>/api/query?type=organization&amp;format=records"/>
adminOrgNetwork:
<Link rel="down" type="application/vnd.vmware.vcloud.query.references+xml" name="adminOrgNetwork" href="https://<VCD-IP>/api/query?type=adminOrgNetwork&amp;format=references"/>
providerVdc:
<Link rel="down" type="application/vnd.vmware.vcloud.query.references+xml" name="providerVdc" href="https://<VCD-IP>/api/query?type=providerVdc&amp;format=references"/>
externalNetwork:
<Link rel="down" type="application/vnd.vmware.vcloud.query.references+xml" name="externalNetwork" href="https://<VCD-IP>/api/query?type=externalNetwork&amp;format=references"/>
edgeGateway:
<Link rel="down" type="application/vnd.vmware.vcloud.query.references+xml" name="edgeGateway" href="https://<VCD-IP>/api/query?type=edgeGateway&amp;format=references"/>