vCAC: Provision a Virtual Machine Blueprint from PowerShell
Despite VMware’s efforts to make vCAC look more appealing our customers still like a GUI that actually looks as if it was from this century. And it is really no […]
Audit and Consulting of Information Systems and Business Processes
Despite VMware’s efforts to make vCAC look more appealing our customers still like a GUI that actually looks as if it was from this century. And it is really no […]
Despite VMware’s efforts to make vCAC look more appealing our customers still like a GUI that actually looks as if it was from this century. And it is really no problem to build something like the Telerik Kendo based ‘Self Service Portal’ (the one that will sadly be replaced by something in else in the next version of vCAC). My personal preference currently is to use ‘Lightswitch’ (a HTML5 RAD development framework in Visual Studio). This is especially useful when you want the customer only to see a few options and not the “standard” properties you always have to provide in vCAC.
Now the question: how do I easily provision a blueprint from my shiny new GUI? PowerShell to the rescue – again … Using the “mgmtContext” you will see there is a method called “SubmitVirtualMachineRequest” that has 2 overloads:
PS > $m.SubmitVirtualMachineRequest OverloadDefinitions ------------------- guid SubmitVirtualMachineRequest( guid templateId, guid groupId, string requestingUser, string owner, string reason, System.Collections.Generic.IEnumerable [DynamicOps.ManagementModel.Common.Shim.NameValue] properties ) guid SubmitVirtualMachineRequest( DynamicOps.ManagementModel.Common.Requests.MachineRequest request )
The former is actually a wrapper for the latter, building a ‘MachineRequest’ on the fly:
PS > $r = New-Object DynamicOps.ManagementModel.Common.Requests.MachineRequest PS > $r |gm -Type Property TypeName: DynamicOps.ManagementModel.Common.Requests.MachineRequest Name MemberType Definition ---- ---------- ---------- GroupId Property guid GroupId {get;set;} Owner Property string Owner {get;set;} Properties Property System.Collections.Generic.List[DynamicOps.ManagementModel.Common.Shim.NameValue] Properties {get;set;} Reason Property string Reason {get;set;} RequestingUser Property string RequestingUser {get;set;} TemplateId Property guid TemplateId {get;set;}
With that you can easily set properties like blueprint, provisioning group, owner, … for this request.
PS > $r.GroupId = ($m.ProvisioningGroups |? GroupName -eq 'vCenterProvisioningGroup').GroupID; PS > $r.TemplateId = ($m.VirtualMachineTemplates |? VirtualMachineTemplateName -eq 'BP01').VirtualMachineTemplateID; PS > $r.Owner = 'SHAREDOP\someEndUser'; PS > $r.RequestingUser = 'SHAREDOP\ProvisioningAdmin'; PS > $r.Reason = 'doit';
The last step is to parametrise the request by adding new and setting predefined properties in the blueprint. Make sure you create distinct Property objects because adding them to the list only adds a reference of the property object:
$l = New-Object System.Collections.Generic.List[DynamicOps.ManagementModel.Common.Shim.NameValue]; PS > $p = New-Object DynamicOps.ManagementModel.Common.Shim.NameValue; PS > $p ExtensionData : IsEncrypted : False IsHidden : False IsRuntime : False Name : Value : PS > $p.Name = 'aNewProperty' PS > $p.Value = 'some Value' PS > $l.Add($p) PS > $l ExtensionData : IsEncrypted : False IsHidden : False IsRuntime : False Name : aNewProperty Value : some Value
After adding all properties you can check your input and submit the request. A subsequent fetch for the returned machine id will give you all the details:
PS > $r TemplateId : b9fe831b-26fd-4ef0-b5c2-ee8f258f1727 GroupId : da5e1157-cb38-4733-87fe-0779a5e6e127 RequestingUser : SHAREDOP\ProvisioningAdmin Owner : SHAREDOP\someEndUser Reason : doit Properties : {aNewProperty, SecurityLevelRequired, Sysprep.UserData.OrgName} PS > $VirtualMachineID = $m.SubmitVirtualMachineRequest($r) PS > $VirtualMachineID Guid ---- e8643ea7-ef59-4f5f-8577-e7c7cc73dacd PS > $vm = $m.VirtualMachines |? VirtualMachineID -eq $VirtualMachineID PS > $vm VirtualMachineID : e8643ea7-ef59-4f5f-8577-e7c7cc73dacd VirtualMachineName : DUB100139 Expires : 10/22/2013 1:01:43 PM InitiatorType : Created Notes : DUB100139 GuestOS : VMUniqueID : dcbe279e-8658-48c5-8a8f-1a9f51afd5fe PlatformDetails : On VMCreationDate : 10/19/2013 11:01:43 AM VMDeleteDate : LastLoggedDate : ...
As an alternative you check your machine properties in the vCAC console:
From there you can hook into the provisioning process as usual and change hostname and the like. Almost too easy …
This is very nice article,
In our requirement, we need to create a same new UI for request a machine in vCAC self service portal. Can you please suggest some solution or help links for create and implement a new UI in vCAC self service portal.
Thanks,
Jalps
I already replied to the original message in https://communities.vmware.com/message/2332145#2332145. But here is an additional approach you might want to take. You can build a new web page based on the same Kendo controls from Telerik as the SelfServicePortal and have it linked to the original portal (then you preserve the look and feel of the page). and with this you can still reuse it even after upgrading to the next version of vCAC.