CloudForms Now

InfoBlox IPAM and CloudFORMS Integration Part 1

This subject is only the hottest on the block at the moment…why? I guess because InfoBlox is pretty cool, it provides DHCP, DNS and IP Address Management services for any size of network. Its fairly easy to configure and InfoBlox are a good company who allow you to try their software for 60 days eval license. You can integrate using simple RestAPI (there is a Ruby GEM, but I don’t advise using it, I found it problematic, and Rest is so easy anyway!)

Part 1 will show you how to extend the provisioning StateMachine to obtain an IP address from InfoBlox.

To work this solution you will need;

Adding the InfoBlox Methods

Part 1 supplies the first method, Get_IP. This will obtain an IP Address from InfoBlox. Part 2 will show you later how you can release the IP Address back to InfoBlox upon the retirement of a Virtual Machine.

Import the cfnow namespace from here https://github.com/jonnyfiveiq/CloudFORMSNOW/blob/master/Integrations/Provisioning/INFOBLOX/cfnow_ipam.xml

The new namespace includes a class called InfoBlox, with and instance and a method called get_ip. You will need to edit the get_ip method to specify your username, password and grid server address as follows;

username = “admin”
password = “Smartvm!23”
server = “10.16.132.47”

Adjusting the VM Provisioning State Machine

This is really quite easy, simply edit the Factory / StateMachines / VMProvision_VM / template as follows;

Take note to add /cfnow/infoblox/get_ip to the AcquireIPAddress state value.

That really concludes enabling the Get IP Address functions for CloudFORMS the following sections of this blog detail how to demonstrate it in a working use case.

Creating a Service to Leverage the Get_IP

The Get_IP method will be called on every provision of a VM, the code within the method does rely on something quite special to exist, which will only be found in a Service Deployment. So do NOT try to deploy VMs using “Provision VM” menu item after enabling this solution as it will not work any more, you can easily fork the Service Provision to use a custom VM Provision thats enabled for IPAM so not to break the old skool VM Provision. Anyway the item the code relies on  is a field in a dialog that will tell IPAM what network to fetch an IP address from. The use case here is that you have TEST, QA and PRODUCTION environments (networks) defined in IPAM. When deploying a new service in CloudFORMS you will have the ability to specify the destination environment to deploy/provision the service into, this will determine the network that should support the service. So you need to create a service dialog as follows;

The configuration behind the drop down MUST be as follows;

You can add other environments or change the names, if you do you need to do so in the dialog AND the method. case statement.


case environment

when "qa"
$evm.log("info","qa")

@gateway = "192.168.1.254"
@network = "192.168.1.0/24"
@dnsdomain = "acme.com"

when "test"
$evm.log("info","test")

@gateway = "192.168.2.254"
@network = "192.168.1.0/24"
@dnsdomain = "acme.com"

when "production"
$evm.log("info","production")

@gateway = "192.168.1.254"
@network = "192.168.1.0/24"
@dnsdomain = "acme.com"

else
$evm.log("info","NOTHING")

end

As you can see from this section of the method, you can list the network to search within IPAM for, the gateway to assign and the DNS Domain to register into for each environment. The selection you make in the dialog directly links to the case statement tot select the network, gateway and DNS domain, the method uses the network to ask InfoBlox IPAM to supply a subnet mask and IP address. The IP address is actually the next available it knows of in the network.

The next thing to do is to wrap this up into a service. This you need to create a standard service item or bundle. Give it a resource to deploy, and use a dialog that uses the drop down list box to provide the environment look up.

Note, when doing a catalog bundle you must order the resources in serial manner otherwise the IPAM system can deliver the same IP address to more than one system.

Putting it all together

With you service configured with a dialog that has the environment drop down, and you have the infoblox methods imported and the vm provisioning state machine calling the new get_ip method. The only last thing to do is ensure that the resource that your service is calling is configured correctly. The resource will need to be a operating system that supports either kickstart or sysprep customisation specifications. In my examples I will use RHEL and Kickstart.

My RHEL virtual machine was prepared as follows;

I added a customisation specification to vSphere. Here are some screen shots to the specification customization.


So when we deploy within CloudFORMS it will look something like…


And when the service resource is provisioned, e.g. that the VM is created and the state machine calls the get_ip methods, the automate log will show something like;


[----] I, [2013-11-14T04:38:57.570595 #6938:a6f810] INFO -- : Q-task_id([miq_provision_1000000000072]) Processing State=[AcquireIPAddress]
[----] I, [2013-11-14T04:38:57.571350 #6938:a6f810] INFO -- : Q-task_id([miq_provision_1000000000072]) Following Relationship [miqaedb:/cfnow/infoblox/get_ip#create]
[----] I, [2013-11-14T04:38:57.598465 #6938:a6f810] INFO -- : Q-task_id([miq_provision_1000000000072]) Invoking [inline] method [cfnow/infoblox/get_ip] with inputs [{}]
[----] I, [2013-11-14T04:38:57.941651 #6938:659d598] INFO -- : Q-task_id([miq_provision_1000000000072]) <User-Defined Method> ********* InfoBlox - GetIP STARTED *********
[----] I, [2013-11-14T04:38:58.306802 #6938:659d598] INFO -- : Q-task_id([miq_provision_1000000000072]) <User-Defined Method> production
[----] I, [2013-11-14T04:38:58.307772 #6938:659d598] INFO -- : Q-task_id([miq_provision_1000000000072]) <User-Defined Method> GetIP --> Network Search - 192.168.1.0/24
[----] I, [2013-11-14T04:38:58.366190 #6938:659d598] INFO -- : Q-task_id([miq_provision_1000000000072]) <User-Defined Method> GetIP --> Network Found - network/ZG5zLm5ldHdvcmskMTkyLjE2OC4xLjAvMjQvMA:192.168.1.0/24/default
[----] I, [2013-11-14T04:38:58.367233 #6938:659d598] INFO -- : Q-task_id([miq_provision_1000000000072]) <User-Defined Method> GetIP --> NextIP on - network/ZG5zLm5ldHdvcmskMTkyLjE2OC4xLjAvMjQvMA:192.168.1.0/24/default
[----] I, [2013-11-14T04:38:58.589829 #6938:659d598] INFO -- : Q-task_id([miq_provision_1000000000072]) <User-Defined Method> GetIP --> NextIP is - 192.168.1.3
[----] I, [2013-11-14T04:38:58.709810 #6938:659d598] INFO -- : Q-task_id([miq_provision_1000000000072]) <User-Defined Method> GetIP --> JH-Service_0006.acme.com with IP Address 192.168.1.3 created successfully
[----] I, [2013-11-14T04:38:58.713179 #6938:659d598] INFO -- : Q-task_id([miq_provision_1000000000072]) <User-Defined Method> GetIP --> Netmask = 255.255.255.0
[----] I, [2013-11-14T04:38:58.716879 #6938:659d598] INFO -- : Q-task_id([miq_provision_1000000000072]) <User-Defined Method> GetIP --> Hostname = JH-Service_0006
[----] I, [2013-11-14T04:38:58.717736 #6938:659d598] INFO -- : Q-task_id([miq_provision_1000000000072]) <User-Defined Method> GetIP --> IP Address = 192.168.1.3
[----] I, [2013-11-14T04:38:58.719000 #6938:659d598] INFO -- : Q-task_id([miq_provision_1000000000072]) <User-Defined Method> GetIP --> Netmask = 255.255.255.0
[----] I, [2013-11-14T04:38:58.719740 #6938:659d598] INFO -- : Q-task_id([miq_provision_1000000000072]) <User-Defined Method> GetIP --> Gateway = 192.168.1.254
[----] I, [2013-11-14T04:38:59.029502 #6938:659d598] INFO -- : Q-task_id([miq_provision_1000000000072]) <User-Defined Method> ********* InfoBlox - GetIP COMPLETED *********
[----] I, [2013-11-14T04:38:59.042234 #6938:a6f810] INFO -- : Q-task_id([miq_provision_1000000000072]) Method exited with rc=MIQ_OK
[----] I, [2013-11-14T04:38:59.251708 #6938:a6f810] INFO -- : Q-task_id([miq_provision_1000000000072]) Followed Relationship [miqaedb:/cfnow/infoblox/get_ip#create]
[----] I, [2013-11-14T04:38:59.252109 #6938:a6f810] INFO -- : Q-task_id([miq_provision_1000000000072]) Processed State=[AcquireIPAddress] with Result=[ok]

And thats it! The Service is provisioning….

Last thing to do is show the IP address in the new Service resource VM.