Find Snapshot Creation Date of a vCloud Director VM


Last month while working on a customer ticket, I came across a request from customer where he wanted to know snapshot creation date for one of his VM as he can not find this detail from vCD UI.

To confirm this, I logged into vCD and navigated to my test lab to see what are the information available.

On navigating through vCD I found that vCD only tells that whether or not snapshot exists for a vApp/VM.

You can see in below screenshot in top right corner that there is no option for selection snapshot creation date.

snap-1.PNG

On drilling down to VM level also, I did not found any option for checking snapshot creation date.

snap-2.PNG

After banging my head for 20 minutes or so, I decided to use API calls as many times I have found some info which is not visible in vCD GUI. And the trick worked for me. I was able to pull the snapshot creation date via API calls.

The steps for doing so is summarized as below:

For sake of security, I have replaced the original token code with ‘xxxxx’

1: Generate session key/Auth token

# curl -sik -H “Accept:application/*+xml;version=5.6” -u “admin@system” -X POST https://p15v3-vcd.vchs.vmware.com/api/sessions | grep auth
Enter host password for user ‘admin@system’:

The above query will return auth token which you can use in next queries


x-vcloud-authorization: XXXXXXXXXXXXXXXXXXX

2: Get Otg UUID

Next is to grab the Org UUID by executing below command:

# curl -sik -H “Accept:application/*+xml;version=5.6” -H “x-vcloud-authorization: XXXXXXXXXXXXXXXXXXX” -X GET https://p15v3-vcd.vchs.vmware.com/api/org/ | grep bdd75fd4-a319-47d5-b4f2-77aad691488f

By executing above query, you will get href of your org.

<Org href=”https://au-south-1-15.vchs.vmware.com/api/compute/api/org/4f5feba5-bb82-456e-8898-95d4970f2624” name=”bdd75fd4-a319-47d5-b4f2-77aad691488f” type=”application/vnd.vmware.vcloud.org+xml”/>

3: Get Org VDC UUID

# curl -sik -H “Accept:application/*+xml;version=5.6” -H “x-vcloud-authorization: XXXXXXXXXXXXXXXXXXX” -X GET https://au-south-1-15.vchs.vmware.com/api/compute/api/org/4f5feba5-bb82-456e-8898-95d4970f2624 | grep vdc

The above query will return you a list of Org vDC’s (in case if you have more than one VDC)

<Link rel=”down” href=”https://au-south-1-15.vchs.vmware.com/api/compute/api/vdc/89ca1c69-0ea1-47f3-b3c1-e91608908966” name=”Manish-Lab-DontDel” type=”application/vnd.vmware.vcloud.vdc+xml”/>

<Link rel=”down” href=”https://au-south-1-15.vchs.vmware.com/api/compute/api/vdc/9b4158ea-65f7-4a14-9bf4-15caac87597b&#8221; name=”VCHS” type=”application/vnd.vmware.vcloud.vdc+xml”/>

<Link rel=”down” href=”https://au-south-1-15.vchs.vmware.com/api/compute/api/vdc/e89232de-3507-4b66-98d7-8ec25e99c826&#8243; name=”vSphere-6.5-Lab-Manish” type=”application/vnd.vmware.vcloud.vdc+xml”/>

My VM exists in VDC ‘Manish-Lab-DontDel’ so I used the corresponding VDC href in my next query

4: Find VM UUID

# curl -sik -H “Accept:application/*+xml;version=5.6” -H “x-vcloud-authorization: XXXXXXXXXXXXXXXXXXX” -X GET https://au-south-1-15.vchs.vmware.com/api/compute/api/vdc/89ca1c69-0ea1-47f3-b3c1-e91608908966 | grep SQLSRV

<ResourceEntity href=”https://au-south-1-15.vchs.vmware.com/api/compute/api/vApp/vapp-cbec4a09-a42f-4f4f-8c73-05a9028d288d” name=”SQLSRV” type=”application/vnd.vmware.vcloud.vApp+xml”/>

5: Find Snapshot details

Now to get snapshot info, append /snapshotSection at the end of the url which you got in previous query

# curl -sik -H “Accept:application/*+xml;version=5.6” -H “x-vcloud-authorization: XXXXXXXXXXXXXXXXXXX” -X GET https://au-south-1-15.vchs.vmware.com/api/compute/api/vApp/vapp-cbec4a09-a42f-4f4f-8c73-05a9028d288d/snapshotSection

You will get an XML output which contains the snapshot creation date

snap-3

 

Advertisements

About Alex Hunt

Hi All I am Manish Kumar Jha aka Alex Hunt. I am currently working in VMware Software India Pvt Ltd as Operations System Engineer (vCloud Air Operations). I have around 5 Years of IT experience and have exposure on VMware vSphere, vCloud Director, RHEL and modern data center technologies like Cisco UCS and Cisco Nexus 1000v and NSX. If you find any post informational to you please press like and share it across social media and leave your comments if you want to discuss further on any post. Disclaimer: All the information on this website is published in good faith and for general information purpose only. I don’t make any warranties about the completeness, reliability and accuracy of this information. Any action you take upon the information you find on this blog is strictly at your own risk. The Views and opinions published on this blog are my own and not the opinions of my employer or any of the vendors of the product discussed.
This entry was posted in vCloud Director, Vmware. Bookmark the permalink.

One Response to Find Snapshot Creation Date of a vCloud Director VM

  1. adamrushuk says:

    Hi Alex,
    Thanks for the useful post, as I’ve been doing more work with the vCloud API recently and needed to find the same information myself.

    I used this PowerCLI in the end as I’m more comfortable with PowerShell:

    PowerCLI C:\> $VM = Get-CIVM -Name “TestVM”
    PowerCLI C:\> $VM.ExtensionData.GetSnapshotSection().snapshot

    PoweredOn : False
    Created : 13/01/2017 09:02:59
    Size : 42949672960
    AnyAttr :
    VCloudExtension :

    Like

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s