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.… Read More

Exploring vSphere 6.5 API-Part 3: Esxi Host

In last 2 post of this series, we learn about digging out info about datacenter,cluster and virtual machines.

In this post we will learn about API options available for Esxi hosts.

If you have missed earlier posts of this series, you can read them from here:

1: Exploring vSphere 6.5 API-Datacenter & Cluster

2: Exploring vSphere 6.5 API-Virtual Machines

Let’s get started with fetching info about esxi hosts.

1: List all hosts present in a vCenter

Following query will list all esxi hosts that are present across all cluster/datacenter which are there in a vcenter.

# curl -sik -H ‘Accept: application/json’ -H ‘vmware-api-session-id: 7c639fb1e988b4c59dd77adef4c5d06c’ -X GET https://vcentersrv01.alex.local/rest/vcenter/host

Output
[code]
{“host”:”host-28″,”name”:”esxi01.alex.local”,”connection_state”:”CONNECTED”,”power_state”:”POWERED_ON”}

{“host”:”host-31″,”name”:”esxi02.alex.local”,”connection_state”:”CONNECTED”,”power_state”:”POWERED_ON”}

{“host”:”host-33″,”name”:”esxi03.alex.local”,”connection_state”:”CONNECTED”,”power_state”:”POWERED_ON”}

{“host”:”host-35″,”name”:”esxi04.alex.local”,”connection_state”:”CONNECTED”,”power_state”:”POWERED_ON”}

[/code]

 

2: List all host in a specific datacenter

You can limit search of esxi host to specific datacenter by using filter.datacenters option

# curl -sik -H ‘Accept: application/json’ -H ‘vmware-api-session-id: 7c639fb1e988b4c59dd77adef4c5d06c’ -X GET
https://vcentersrv01.alex.local/rest/vcenter/host?filter.datacenters=datacenter-2

3: List all hosts in a specific cluster

# curl -sik -H ‘Accept: application/json’ -H ‘vmware-api-session-id: 7c639fb1e988b4c59dd77adef4c5d06c’ -X GET https://vcentersrv01.alex.local/rest/vcenter/host?filter.clusters=domain-c7Read More

Storage Migrate a vCloud Director VM using Rest API

If you are using vCloud Director in your environment and if you have ever tried doing a Storage vMotion of a VM from vSphere directly, you will notice a warning saying that its not recommended to modify the entity since its managed by VCD.

sv-1

This is because of the the fact that with VCD, the management layer lies with itself and not with vSphere. All changes to the entities should be made via vCD and not vSphere.

Although doing a storage migration will not break anything but as a best practice we should avoid that.

So what to do if one of your backend LUN is full and you need to evacuate that by migrating some vm’s to another datastore which have enough free space. The answer is by using “Rest API”.

About the VMware vCloud API

The VMware vCloud API provides support for developers who are building interactive clients of VMware vCloud Director using a RESTful application development style.… Read More

Exploring vSphere 6.5 API-Part 2: Virtual Machines

In last post of this series we looked into some basic Rest API’s to fetch info about datacenter and cluster.

In this post we will explore API options for virtual machines. Out of all the components like host, cluster etc, max number of available API options are for virtual machines.

Let’s start with figuring out available options:

To start exploring the different API options available for virtual machine, you can use below query:

1: List all VM’s in all datacenter

Output of above query will give you VM ID, cpu/memory stats, VM name and their power status.

all-vm

2: List Powered off VM’s

You can list all powered off VM’s in datacenter using the filter power_states in above query.… Read More

Exploring vSphere 6.5 API-Part 1: Datacenter & Cluster

I am using API for quite a bit now in our prod environment which is based on vCloud Director and many times API’s had proved a handy way to troubleshoot issues where GUI was not providing a way to proceed.

Inspired by vCD API’s, i decided to test that in my vSphere 6.5 lab and in this post I will try to demonstrate few queries which can be helpful in fetching info in your infrastructure.

In my lab I am exploring REST API’s using a linux tool called curl.

1: You can browse list of API’s by browsing https://vcenter-fqdn/ and clicking on “Browse vSphere Rest API’s”

api-url

 

2: To start with you can use below query to see what are the different options available

# curl -sik -H ‘Accept:application/json’ -u “vc-user” -X GET https://vcenter-fqdn/rest/

You will see below URL’s in output:

3: You can list the available components which can be explored via REST API by using below query

# curl -sik -H ‘Accept:application/json’ -u “vcadmin@alex” -X GET https://vcentersrv03.alex.local/rest/com/vmware/vapi/rest/navigation/componentRead More