Caution: Articles written for technical not grammatical accuracy, If poor grammar offends you proceed with caution ;-)
I keep getting asked for an example of integrating into a CMDB. The challenge with this is which CMDB, Asset, or Ticketing system do you create an example around. They are all very different and most organizations have heavily customized them. My solution was to create a sample system to demonstrate vCAC’s capabilities and leave the specifics of any particular CMDB out of the equation.
In this tutorial I’m going to show you how to integrate vCAC 5.1 into an external system of your choosing. In my example I’m using a simple SQL database with a very simple web front end. My workflow is going to call a PowerShell Script that uses SQL statements to update the database with the value I want populated. Now you can take this and have execute code to talk to a specific API or database, btu the point is how to get the data you want from vCAC when you want it and make it usable to push to another system.
I have provided my sample database, web front-end, Workflows,and Scripts download here.
Installing the sample CMDB
Once you have downloaded the “CMDBExample.zip” follow the below instructions to install.
- You will need to have “SQLCmd.exe” on your “server. If you do not have it, install the SQL Management Studio and that should install it for you. Once you are done make sure to re-boot and verify that you can open and CMD prompt and run “sqlcmd.exe” to validate the path exists.
- Open a “PowerShell” Console, make sure your “RemoteExecutionPolicy” is set to “remoteSigned“. the navigate to the extracted files from the CMDBExample.zip.
- Run the installer by typing “./InstallCMDB.ps1 {hostname of SQL Server}“
- Next we need to import the property sets that contain the custom properties for the integration. Go to “Enterprise Administrator” and select “Build Profiles” then select “New Build Profile“.
- When the “New Build Profile” page opens select “Manage Property Sets” in the upper right corner.
- Scroll down to the bottom and then browse for the Property Set named “CMDB_Data_Properties.xml” included with the “CMDBExample.zip“.
- Provide a “Name” and optionally a description for the property set and click “Ok“
- Repeat steps 6-7 and import the “CMDB_Workflow_Properties“. Once finished you will see both sets listed under “Existing Property Sets“. Click “Back To Build Profile“
- Give the “Build Profile” a “Name” and then from the drop down list select “CMDBDataProperties” (Or whatever you named it) and click “Load“. Repeat this step and select the “CMDBWorkFlowProperties” and click “Load“.
- Now edit the “Values” of the properties to what you like and click “Ok” to save the “Build Profile“.
- Add the “Build Profile” to whatever blueprint you like and make a “New Request“. When the machine get’s to the “MachineProvisioned” state it will create the asset in our database. Open “http://{host}/CMDB” to see the machine listed.
- On “Expire” the status of the machine will update to “Expired” and on “Destroy” the status will update to “Destroyed“
- CostCetner – I define this at the Provisioning Group and either define or prompt user. This way I get the cost code based on the group it was requested under.
- Datacenter – I define this at the Compute Resource because compute resources are clusters or hosts tied to physical hardware located in a datacenter.
- HostingPlatform – I define this at either the endpoint or the Compute Resource. Compute Resousrce is flexible, vCenter endpoint might manage different versions of vSphere.
- ProjectID – I define where ever it makes sense at the time. I usually prompt user unless there are specific blueprints or a group for a project then I define the projectID value.
- ServiceTier – I typically define this at the reservation.
- VirtualMachine.Admin.Department – I define this at the Provisioning Group, could also do a drop down to have user pick.
- VirtualMachine.Admin.OS – I define this at the blueprint.
Note: I have only tested this on a vCAC server.
The installer will perform the following:
1. Create the SQL Database & Tables
2. Update PowerShell Scripts for the database server you entered
3. Load the PowerShell scripts into the repository
4. Update the Workflow Stubs in the repository
5. Copy the CMDB website
6. Update database connection in CMDB web.config for database you entered
7. Create the IIS Application for the CMDB web interface
There are three Powershell Scripts that get imported into the repository. AssetCreate, AssetExpire, and AssetDestroy. Check them out. The most important part to take note of is at the top where the vCAC properties are being assigned to variables. Once you have access to your property values the rest of the code can be what you want it to be – SQL Queries, API Calls, Whatever you need.
Note: If you look at the properties included in this example, there is a property named “Datacenter”. The same same property I used in my “Relational Drop Down List” example. By assigning it a vlaue I’m going to make it the default choice in the drop down list. Users can still change it, but this will be the default choice selected on the request page.
- In this example we have all the properteis in a build profile which isn’t very useful. Taking the properties and placing them throughout vCAC gives it much more value. Here is I use the properties in this example:
I usually then create a build profile to enable the CMDB on a blueprint and define the workflow properties in the build profile.
For information on modifying a workflow stub to execute PowerShell scripts see my article “vCloud Automation Center – vCAC 5.1 – Workflow Designer Walk-Through – Add Computer Account to Active Directory OU“.
The link for the CMDB_Example.zip does not work.
All fixed. Thanks for beta testing that for me 😉
Great job! This worked perfect in my demo VM!
Awesome. I am working on building an installer for an external IPDB example I have. Should hopefully be available by mid next week. I have been busy delivering training this week.
Thanks for sharing. Is there any way we can edit/add a new entry in the cmdb for any VM reconfigurations. End users are able to reconfigure their VM’s with respect to cpu, memory and strorage and new modified VM configuration needs to be captured in CMDB.
I see only stubs for Provisioned/Expiring/Disposed etc, nothing for reconfiguration.