Ravello with Cloudforms


Very excited about this one, if you have not seen Ravello, check it out http://www.ravellosystems.com, here is a summary…

“Run VMWare workload in AWS”

Whats even cooler, you can actually run hypervisors in AWS, which if you have been playing with EC2 you will know is impossible with them, without some sorcery!

Moving on….as I am not here to sell you Ravello,, though I can admit that we use them a LOT, very cheap and great API which is what this post is about.

I had a good friend ask if we could provision instances in Ravello using Cloudforms, there was no need to have visualisation of the instances after provision, just standard fire and forget from our service catalog.

So we first start with our service catalog item, here it is here;

Screen Shot 2014-04-09 at 09.52.20


The idea here is that we can take a blue print in Ravello and spin out as many of these as we wish. A blue print in Ravello is like a bunch of virtual machines in a design view, once you are happy with your design you publish it and those machines are available. So in our use case we have one blue print that we will want to instantiate many times. We also in the dialog collect some naming detail for the new application being instantiated from the blue print, we also give the choice of hostname prefix. This is because in our blue prints we may want to change the hostnames of the virtual machines when the application is instantiated, why? If we only instantiated one copy of the blue print then it would be fine, but if we do many then the hostnames would conflict with one another in each application instantiated from the blue print.

We also offer the drop down list box of what blue print to use as the template for this new Ravello application. Here is another graphic to show you the options of this;

Screen Shot 2014-04-09 at 09.52.01

This list of blue prints comes dynamically from Ravello.

After clicking submit we will get out applications; this is what it looks like in Ravello once Cloudforms has run the service install.

This run I entered 4 as the number of students (instantiations) .

Screen Shot 2014-04-09 at 10.18.33

Cloudforms shows in the service request queue the job being executed and processed, you could hook up approval and quota checks for this if you wanted.

Screen Shot 2014-04-09 at 10.04.48

Screen Shot 2014-04-09 at 10.00.43


So in Ravello finally we need to check did the hostname change for each instantiated application from the blueprint?

Screen Shot 2014-04-09 at 10.18.58

And if you look in the top right of the screen estate you can see the hostname field and the student number and prefix has been updated, this would be incremented for each instantiation of the blueprint for each application.

So if you want to integrate Cloudforms and Ravello, here is the method, its mega simple, a rest api thats was fairly simple to get together thought the documentation could do with more samples!

There is also a Ruby GEM for Ravello, though this can be good, we at Cloudforms tend to use RestAPI first, because then we do not have to worry about GEM management across the appliances, especially when the Ravello GEM is just an abstraction of the RestAPI anyway.


# Automate Method
$evm.log("info", "--------------------------RAVELLO APPLICATION START-----------------")
$evm.log("info", "--------------------------RAVELLO APPLICATION START-----------------")
$evm.log("info", "--------------------------RAVELLO APPLICATION START-----------------")</code>

# Method Code Goes here

require 'rubygems'
require 'rest_client'
require 'xmlsimple'
require 'json'
require 'cgi'

#how many students do you want?
$totalStudents = $evm.root['dialog_totalstudents'].to_i
@applicationNamePrefix = $evm.root['dialog_applicationnameprefix']
@applicationDescription = $evm.root['dialog_applicationdescription']
#hostname prefix, will result as hostnameX, example - hostname1, hostname2, hostname3...
@hostnamePrefix = $evm.root['dialog_hostnameprefix']
#Search String
@searchString = "NOreplaceNO"
#whats the bluePrint you want to use for the application(s)
@bluePrint = $evm.root['dialog_blueprint'].to_i
#whats your account username and password
rawUsername = $evm.root['dialog_username']
rawPassword = $evm.root['dialog_password']
@username = CGI::escape(rawUsername)
@password = CGI::escape(rawPassword)

$i = 1
while $i &lt;= $totalStudents do studentNumber = "%.3i" %$i
  $evm.log("info", "StudentNumber = #{studentNumber}")
  applicationName = "#{@applicationNamePrefix}-" + studentNumber.to_s
  applicationDescription = "#{@applicationDescription} - #{applicationName}"
  $evm.log("info", "Creating Application for #{applicationName}")
  #create the application from a known bluePrint
  rtr = RestClient.post "https://#{@username}:#{@password}@cloud.ravellosystems.com/api/v1/applications/", {:name =&gt; "#{applicationName}", :description =&gt; "#{applicationDescription}", :baseBlueprintId =&gt; @bluePrint.to_i}.to_json, :content_type =&gt; :json, :accept =&gt; 'application/json'

  #find the applicationID
  rtr_parsed = JSON.parse(rtr)
  applicationID = rtr_parsed['id']

  #fetch the newly created application
  data = RestClient.get "https://#{@username}:#{@password}@cloud.ravellosystems.com/api/v1/applications/#{applicationID}", :content_type =&gt; :json, :accept =&gt; 'application/json'
  entity = JSON.parse(data)
  new = entity

  x = 0
  new['design']['vms'].each do | a |
  $evm.log("info", "Processing #{a['hostnames']}")
  if a['hostnames'].to_s[/NOreplaceNO/].to_s == "NOreplaceNO"
    dooie = new['design']['vms'][x]['hostnames'][0]
    dooie.gsub!("NOreplaceNO",@hostnamePrefix.to_s + studentNumber.to_s)
    new['design']['vms'][x]['hostnames'][0] = dooie
    $evm.log("info", "New Hostname = #{new['design']['vms'][x]['hostnames']}")
  x = x+1

#save the changes back to the application
yoyo = RestClient.put "https://#{@username}:#{@password}@cloud.ravellosystems.com/api/v1/applications/#{applicationID}", new.to_json, :content_type =&gt; :json, :accept =&gt; :json

#publish the application to Amazon
yoyo = RestClient.post "https://#{@username}:#{@password}@cloud.ravellosystems.com/api/v1/applications/#{applicationID}/publish", {:preferredCloud =&gt; "AMAZON", :optimizationLevel =&gt; "PERFORMANCE_OPTIMIZED" , :preferredRegion =&gt; "Virginia"}.to_json, :content_type =&gt; :json, :accept =&gt; 'application/json'

$i +=1

$evm.log("info", "--------------------------RAVELLO APPLICATION END-----------------")
$evm.log("info", "--------------------------RAVELLO APPLICATION END-----------------")
$evm.log("info", "--------------------------RAVELLO APPLICATION END-----------------")

$evm.log("info", "Automate Method Ended")
exit MIQ_OK

You can download this code https://github.com/jonnyfiveiq/CloudFORMSNOW/blob/master/Integrations/Provisioning/Ravello/ravello.rb

As a note to this, Ravello offers two cloud platforms as destination, we have ONLY ever used AWS as a destination platform, you can see this in the code as



Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Google photo

You are commenting using your Google account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s