In this example, I have one blueprint. This blueprint will be used to deploy the same template in two different physical locations.
Both the template and customization spec is identical in both locations – hence I am able to use the same Blueprint.
Might not be the best way of doing it – but it depends on the environment I guess.
Here I have two Datacenters, Garage and Solar – Although eventually I started to use Banzai for some reason – so from this point on – it is Garage and Banzai 😀
I want to be able to have the following drop down options in the blue print
First we need to deal with other pre-requisites though. As mentioned, I got two Datacenters, as a result I also have two Endpoints and two Compute Resources.
On your IaaS Server(s), the one with the Manager Service, browse to the following location
C:\Program Files (x86)\VMware\vCAC\Server\Website\XmlData
You will find there an XML file
DataCenterLocations.xml
Open it with a text editor
<?xml version=”1.0″ encoding=”utf-8″ ?>
<CustomDataType>
<Data Name=”Garage” Description=”Garage Hosting”/>
<Data Name=”Banzai” Description=”Virtual Cluster”/>
</CustomDataType>
Here you can see where I went wrong. Even though my datacenter is called Solar, I called it here Banzai. Doesn’t matter though, as this is merely a ‘link’ to your resources and the name doesn’t matter. So change the above file to reflect your locations.
Once you changed the file, restart the Manager service
Now back to vRA.
Here you can see I have two Compute Resources
Edit each of the resources. Here select the Location you have configured in the XML file.
So you can see I got two locations / clusters / Datacenters etc.
- vCenter
- Garage
- vCS Datacenter called Garage
- Garage
- vCenter-03
- Banzai
- vCS Datacenter called Solar
- Banzai
Next we need to create an Action in vRealize Orchestrator
I have tried different variants but this is what works for me. You may need to change bits accordingly, but if you understand a little bit of code, this shouldn’t be a problem. I haven’t touched vRO scripts ever and kinda managed it 🙂
If you worked with vRO before – you will know that you can use Actions in Workflows. The workflow will have all the ‘ins’ and ‘outs’ and also the presentation around it. All this is handled by vRA – so you won’t create a whole workflow – just an Action.
Here I created three Actions
- DatacenterNetwork
- Datacenter <> Network mapping. The Network values displayed in the Blueprint depend on the Datacenter selected
- HostStorage
- Host <> Storage mapping. The Storage values displayed in the Blueprint depend on the Host selected
- DatacenterHost
- Datacenter <> Host mapping. The Host values displayed in the Blueprint depend on the Datacenter selected
Note: ignore LocationSelection here, that’s a different attempt of mine.
Let’s do them. So first, create a new module. As you can see above – I called mine vra.prod.vspherelab
Select the Module and create an Action – click Add Action
See the values used in my example below.
DatacenterNetwork
Give it a name
Move over to the Scripting tab.
Change the Return Type to Array/String
Now add the actual script
// Network to Datacenter mapping
if(datacenternetwork)
{
switch(datacenternetwork){
case “Garage”:
return [“External”,”Internal”];
break;
case “Banzai”:
return [“External”,”Internal”];
break;
};
}else {
return [“Please Select Datacenter”];
};
So here when you select as datacenter Garage – You have the options for the networks called External or Internal.
HostStorage
Give it a name
Move over to the Scripting tab.
Change the Return Type to Array/String
Now add the actual script
// Storage to Host mapping
if(hoststorage)
{
switch(hoststorage){
case “”:
return [“NFS”];
break;
case “vesxi-03.vspherelab.co.uk”:
return [“NFS”,”vESXi-03-Local”];
break;
case “vesxi-04.vspherelab.co.uk”:
return [“NFS”,”vESXi-04-Local”];
break;
};
}else {
return [“”];
};
Here, depending on the hosts selected (remember, the first datacenter Garage does not have a host selection, the available storage is NFS, yet it won’t display in the blueprint.
I tried to remove the NFS bit but it wouldn’t work. As I said, I am new to the coding game but this worked for me.
Plus this way, even though you cannot select the storage for Garage, the value NFS is being passed onto the property, so if you got multiple LUNs, the VM will end up on the one you want.
Hope it makes vaguely sense.
DatacenterHost
Give it a name
Move over to the Scripting tab.
Change the Return Type to Array/String
Now add the actual script
// Host to Datacenter mapping
if(datacenterhost)
{
switch(datacenterhost){
case “Garage”:
return [“”];
break;
case “Banzai”:
return [“vesxi-03.vspherelab.co.uk”,”vesxi-04.vspherelab.co.uk”];
break;
};
}else {
return [“Please Select Datacenter”];
};
Here depending on the datacenter selected, a list of available hosts is being displayed. The hosts are here as they are displayed in vCenter – using the full FQDN.
Note: All that is hard-coded of course. So if you add additional hosts / networks / LUNs etc., you will need to change the code. Not sure how this can be automated.
Anyway, yuou should end up with three Actions now
That’s done in vRO, back to vRA
The custom properties I will be using now are
- Vrm.DataCenter.Location
- VirtualMachine.Network0.Name
- VirtualMachine.Storage.Name
- VirtualMachine.Admin.ForceHost
Which are combined into a group called DeploymentLocations, so they can be easily added to any Blueprint.
Browse to Administration > Property Dictionary > Property Definitions
Create the custom property definitions as follow. The Name is the display name, whilst the Value is actually that, the value.
In the below example the Value reflects the Name in the XML file (confused yet?)
So …
Vrm.DataCenter.Location
- Give it a name – this is the custom property
- Give it a label – this is what is being displayed in the Blueprint
- Select the tenants – here I just make it available to All tenants
- Display advise – select Dropdown
- Values – Predefined values
- Name
- Garage (Can be anything)
- Banzai
- Value
- Garage (Name from XML)
- Banzai (Name from XML)
- Name
VirtualMachine.Network0.Name
- Give it a name – this is the custom property
- Give it a label – this is what is being displayed in the Blueprint
- Select the tenants – here I just make it available to All tenants
- Display advise – select Dropdown
Click External values
Browse to the newly created Action DatacenterNetwork and click OK
Tick Bind – and close the error
Select the dependency Vrm.Datacenter.Location
Your Property Definition should now look like this.
Now repeat the process for the remaining ones
VirtualMachine.Storage.Name
Select the Action HostStorage and bind it to VirtualMachine.Admin.ForceHost.
You’ll notice that here it is set to NOT require a selection. If I would set it to yes, I would have to enter a host for Garage, which, as I mentioned, I don’t want to do. There might be a better way, but not sure how yet.
Now repeat the process for the remaining one
VirtualMachine.Admin.ForceHost
Select the Action DatacenterHost and bind it to Vrm.Datacenter.Location.
Same as above. I set the Required value to NO.
You should have now 4 custom properties
Now we can create a group. Ensure you selected Show in Request
Add it to the Blueprint
Now we can test it. When deploying the blueprint you should see the configured dropdown menus.
If you don’t like the order, then configure the order you wish when configuring the custom property
Which will then change the display order when requesting the Blueprint.
Now test the relationships. Here you can see that the Network Selection is empty.
Now select the Datacenter. Here you can see the network becoming available
As I said before – I don’t need a host as DRS is enabled
Storage is not visible either. In order to make storage available, I’d have to be able to select a host, but as mentioned, we don’t want it as the cluster is DRS enabled.
This is what I was referring to.
switch(hoststorage){
case “”:
return [“NFS”];
Anyway, feel free to play with the value and see what works for you.
Now when selecting the datacenter,I can select the hosts
And once a host is selected you are able to select the configured storage – local to the host, and shared
So, hope this was helpful. One would argue that this approach is a bit more complicated than during the vCAC 6.x times (where you had to use XML files) – but developers will love this approach 🙂
Ps: I am not a developer so I have to bolt this together the way I did – so please be gentle 😀