cancel
Showing results for 
Search instead for 
Did you mean: 

Tech Tip: Ruby and SOAP revisited

This article presents an alternative approach to the document Tech Tip: Using the SOAP Control API with Ruby.

An alternative method for using Riverbed's Control api with Ruby is to use the soap4r SOAP implementation. This may be found at http://dev.ctor.org/soap4r.

Note: At the time of writing the use of soap4r depends on the 'httpclient' Ruby library, formerly known as 'http-access2'.

Getting started

The first thing you have to do is obtain the published specification for Stingray's API. You can download this from the product's admin interface, Diagnose > Technical Support, clicking "Control API WSDL Files". Extract this zip file to get the WSDL files we are looking for.

Soap4r comes with a tool 'wsdl2ruby.rb' which will take our WSDL files and produce Ruby files which we can import into our scripts. T he invocation you will use will look something like this:

$ wsdl2ruby.rb --wsdl VirtualServer.wsdl --type client

... to create the following files:

VirtualServerClient.rb

VirtualServerDriver.rb

VirtualServerMappingRegistry.rb

Once this is done you can include these in the programs or scripts you write. The important difference here, from our previous Ruby example, is that we no longer have to define every function that we intend to use and the arguments it expects.

Here is the analogous listing enabled virtual servers example using soap4r:


#!/usr/local/bin/ruby



require "VirtualServerDriver.rb"


require "VirtualServer.rb"



endpoint = "https://zxtm:9090/soap"


username = "admin"


pass = "somepass"



driver = VirtualServerPort.new(endpoint)


driver.options["protocol.http.ssl_config.verify_mode"] = OpenSSL:Smiley FrustratedSL::VERIFY_NONE


driver.options["protocol.http.basic_auth"] << [endpoint,username,pass]



vslist = driver.getVirtualServerNames


enabled = driver.getEnabled(vslist)


vslist.length.times do |i|


   if enabled


      puts vslist


   end


end


Read more

Version history
Revision #:
1 of 1
Last update:
‎02-25-2013 07:38:AM
Updated by:
 
Labels (1)