Over the winter holiday I started to explore the vCloud API and one of our SDKs, vCloud SDK for PHP. VMware provides two additional vCloud SDKs: Java and .NET. I had used Java in college and I wanted to stay away from anything Windows related, so I thought I give PHP a try and it was the closest thing to Perl 😉
Since this was my first time using the vCloud API and SDK, I thought what better way to learn than to create a script similar to my vSphere Health Check Report for vCloud Director? This not only helped me to understand the objects in vCloud Director from an API perspective but no such reporting tool exists today for administrators and end users of vCloud Director.
Here is an example of what a report could look like: vCloudDirectorReport.html
To use the script, you will need the following per-requiste:
- Install vCloud SDK for PHP, take a look at article on how to get setup.
- Running vCloud Director 1.5 (Script uses the new API Query Service)
- Download both config.php which includes configuration parameters for the script and vmwarevCloudDirectorReport.php script.
To get a list of the available commandline options, just type "php vmwarevCloudDirectorReport.php":
Error: missing required parameters
VMware vCloud Director Report v1.0.0
This script provides a detail report of your VMware vCloud Director system
# php vCloudReport.php -s -u -p [Options]
-s|--server [req] IP or hostname of the vCloud Director.
-u|--user [req] User name in the form [email protected] for the vCloud Director instance.
-p|--pswd [req] Password for user.
-t|--type [req] Type of report [system|orgadmin|orguser].
-r|--report [opt*] Name of html output file (e.g. vCloudReport.html).
# php query.php -s 127.0.0.1 -u [email protected] -p password -t system
# php query.php -s 127.0.0.1 -u [email protected] -p password -t orgadmin
# php query.php -s 127.0.0.1 -u [email protected] -p password -t orguser
The config.php can be used to store the vCloud URL and credentials or you may specify it via the commandline using -s, -u and -p arguments. In addition, you will also need to specify -t flag which is based on the type of user you are logging into whether that is system (administrator), orgadmin or orguser.
The report can easily be customized by toggling parameters in config.php which includes the following parameters:
Depending on the report type, certain flags will be applicable. By default, all flags are enabled but you my disable ones you do not wish to see.
Here is an example of the script logging into vCloud Director instance with the administrator account in the System organization:
This is the first iteration of the script, I plan on adding additional information and if you have any feedback/suggestions, please leave a comment below.