cancel
Showing results for 
Search instead for 
Did you mean: 

Tech Tip: Using the SOAP Control API with Ruby

The following code uses Stingray's Control API to list all the running virtual servers on a cluster. The code is written in Ruby.

 

listVS.rb 

 

Running the example

 

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
#!/usr/bin/ruby
 
 
require 'http-access2'
 
require 'soap/rpc/driver'
 
 
# Fix these for your admin server, password etc
 
 
user = 'admin'
 
pass = 'admin'
 
 
client = SOAP::RPC: p river.new( url, 'http://soap.zeus.com/zxtm/1.0/VirtualServer/' )
 
client.add_method( 'getVirtualServerNames' )
 
client.add_method( 'getEnabled', 'names' )
 
 
client.options[ 'protocol.http.ssl_config.verify_mode' ] = OpenSSL: SSL::VERIFY_NONE
 
client.options[ 'protocol.http.basic_auth' ] << [ url, user, pass ]
 
 
 
vservers = client.getVirtualServerNames
 
enabled = client.getEnabled( vservers )
 
 
vservers.length.times do |i|
 
   if enabled
 
      puts vservers
 
   end
 
end

 

Run the Ruby script as follows:

 

$ listVS.rb

Main website

Mail servers

Test site

 

Notes

 

As well as Ruby 1.8, you will need to install the http-access2 and openssl Ruby packages in order for the HTTPS Basic Authentication used by Stingray's SOAP server to functions correctly.

 

Read more

 

Version history
Revision #:
2 of 2
Last update:
‎01-13-2021 05:39:PM
Updated by:
 
Labels (1)
Contributors