How to add additional NICs to a virtual machine on a blueprint

Joshua Andrews
by Joshua Andrews

Categories

 Here at SovLabs, we offer up many tips and tricks to use for deploying virtual machines. A recent common query is “how to add additional NICs to a virtual machine on a blueprint?” Use cases vary. Perhaps for one application a single NIC suffices, but you may need two NICs when deployed for a different app, or perhaps in one environment there is a separate OOB management network. Whatever the reason, here are two ways to add additional NICs to virtual machines on the fly.

 

Requirements

Both of these solutions require a SovLabs IPAM/DNS license and a configured IPAM endpoint at at least one IPAM profile.  You can find out more about using IPAM profiles on our modules pages. Both of these solutions also leverage SovLabs_IPAMProfile_nic1 which is one of several behind-the-scenes property groups leveraged by the SovLabs IPAM profile framework.

You’ll also need a blueprint with one VM and an existing NIC0 configured using an IPAM profile. And since we are using the SovLabs IPAM profiles to manipulate the network configuration, neither of these solutions require network components on your VM.

How to add additional NICs to a virtual machine on a blueprint 1

Adding a property with the Property Toolkit Module

The first method is actually illustrated step-by-step on our How-To pages. This method leverages our Property Toolkit Module to add the custom property group SovLabs_IPAMProfile_nic1 to the blueprint when needed.

You can follow along on the guide referenced above, but basically you add a boolean Custom Property (here named josh001-AddNIC1 with a  label of Add a network?) to your blueprint... 

How to add additional NICs to a virtual machine on a blueprint 2

...and then add SovLabs_CreateProperties_AddNic1 custom property. 

How to add additional NICs to a virtual machine on a blueprint 3

The SovLabs_CreateProperties part of the name triggers the SovLabs Property Toolkit module to create a new property based on the value.  The Template Engine logic statement in the value field is:

{"name": "NoNic1Required",

"value": "NoNic1Required"}

This logic statement will create a new property with a name of SovLabs_IPAMProfile_nic1 and a value of IPAMSolar60NIC1 when the  “Add a network?” checkbox is selected. Otherwise a property of NoNic1Required is created with a value of NoNic1Required, which will be ignored during a request.  

 

Setting a value on an existing property

If you have not licensed the SovLabs Property Toolkit, or are just looking for other options, you can also add the SovLabs_IPAMProfile_nic1 property to the VM directly, and provide it a value as needed.

For this method, you use the same josh001-AddNIC1 boolean property, but add the SovLabs_IPAMProfile_nic1 property with a slightly different Template Engine logic.

How to add additional NICs to a virtual machine on a blueprint 4

Here, the logic is:

This logic sets the value of SovLabs_IPAMProfile_nic1 to IPAMSolar60NIC1 when the checkbox is selected, and otherwise leaves it blank.

 

Checking your work

When you are working with Template Engine logic, don’t forget to leverage the SovLabs Template Tester. 

How to add additional NICs to a virtual machine on a blueprint 5

The Template Tester lets you check both the properties for a deployed VM, and quickly test logic out against those properties.

Here are the properties of a VM deployed with a second NIC (note there is some photoshop editing to make it readable). 

How to add additional NICs to a virtual machine on a blueprint 6

 

If you post the logic into the Template field...

How to add additional NICs to a virtual machine on a blueprint 7

You’ll see the resulting output:

How to add additional NICs to a virtual machine on a blueprint 8

 

To check the logic when the josh001-AddNIC1 boolean isn’t checked, you can edit the Properties JSON field, setting it to false.

How to add additional NICs to a virtual machine on a blueprint 9

And check the resulting output to verify the value is blank when the checkbox is cleared:

How to add additional NICs to a virtual machine on a blueprint 10

Conclusion

We hope that you found these solutions for dynamically adding NICs to blueprints useful and can come away with a better understanding of simple uses of the Property Toolkit and Template Engine.

Note that these solutions just scratch the surface, especially with Property Toolkit. Adding properties on the fly means not having blank/unused properties if you don’t want them, and, of course, Property Toolkit is really good at more exotic stuff like automatically renaming your deployments and making component profiles dynamic.  You can also make adding NICs more exotic by leveraging the Template Engine to create the IPAM profile name on the fly using properties from throughout the hierarchy - not just a static profile name like I used.  

Happy Clouding!

The first step in providing reliable self-service automation for your CMP is starting a free trial.

Free Trial
Wave One Wave One
Wave Two Wave Two