simple_lb 0.0.6 → 0.0.7

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (3) hide show
  1. checksums.yaml +4 -4
  2. data/lib/simple_lb.rb +43 -55
  3. metadata +1 -1
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: c9bf1e179de7b9a7f6a09e8e27a30ddbef85c0d1
4
- data.tar.gz: a59def210689e8669e90f8ed7f8eb3d018bc5103
3
+ metadata.gz: 1b8f191062f29a321e15c15aaa73a6f703ad6953
4
+ data.tar.gz: 966bbbb5db2c616744e6c453f2813f8737858e7f
5
5
  SHA512:
6
- metadata.gz: 9c072e6eadce2f22eeb9f818e2792a040fa451db989200eb99e5505e7fa0793ddccb14813274635b5246f7922d94101c57a177480a348132456867d0fe28ad0b
7
- data.tar.gz: aea684fa0ce6ac156bb462498fac4989a4d82d68d06a3835167f0269e0deeef82c64b4094a42c6f97a6bae621d89c8e39557dd713179a2e0796bc1a1cb684dfd
6
+ metadata.gz: 24857751d831aa06ab1db95a5a8fc11890003c747495ecec90eaa949e38fd70abd485e96f1d55a37aa8df4db231dc99ef8d8f66cc1ee5d1a90a6ce8c82d16f9e
7
+ data.tar.gz: 74965b083856f47ec412604d5e5a2342ec599dcbe6c1b256a40df5f6da271514a2b816e1d1de958577692ab1c40df4b20e642c6cfd1ef17a7686162d9e4e188f
data/lib/simple_lb.rb CHANGED
@@ -1,14 +1,14 @@
1
- #!/Users/xjs5/.rvm/rubies/ruby-2.0.0-p353/bin/ruby
2
1
  #
3
-
4
2
  class VirtualServer
5
- require 'savon'
3
+ require 'savon'
6
4
 
7
- def initialize (args)
5
+ def initialize(args)
8
6
  @@vs_attrs = args.to_a
9
7
  if @@vs_attrs.blank?
10
- puts "Usage: simple_lb <virtual_server_name> <vs_ipaddress> <member1_ip> <member2_ip>"
11
- puts "Example: simple_lb my_virtuals_server 192.168.10.100 192.168.10.102 192.168.10.103"
8
+ puts 'Usage:'
9
+ puts 'simple_lb <vs_server_name> <vs_ipaddress> <member1_ip> <member2_ip>'
10
+ puts 'Example:'
11
+ puts 'simple_lb my_vserver 192.168.10.100 192.168.10.102 192.168.10.103'
12
12
  exit
13
13
  end
14
14
  $vs_name = @@vs_attrs.shift
@@ -17,21 +17,18 @@ require 'savon'
17
17
  VirtualServer.create_config
18
18
  VirtualServer.create_soap_connection('Pool')
19
19
  VirtualServer.create_soap_connection('VirtualServer')
20
- puts "array #{@@vs_attrs}"
21
20
  end
22
21
 
23
22
  def self.create_config
24
- path = File.expand_path "~/.bigip.yml"
23
+ path = File.expand_path '~/.bigip.yml'
25
24
  config = YAML.load(File.read(path)) rescue nil
26
- unless config then
25
+ unless config
27
26
  config = {
28
- :ipaddress => '172.16.222.120',
29
- :user => 'admin',
30
- :password => 'admin'
31
- }
32
- File.open(path, "w") { |f|
33
- YAML.dump(config, f)
27
+ ipaddress: '172.16.222.120',
28
+ user: 'admin',
29
+ password: 'admin'
34
30
  }
31
+ File.open(path, 'w') { |f| YAML.dump(config, f) }
35
32
  abort "Created config file #{path} update with your bigip info"
36
33
  end
37
34
  @ipaddress = config[:ipaddress]
@@ -39,7 +36,7 @@ require 'savon'
39
36
  @password = config[:password]
40
37
  end
41
38
 
42
- def self.create_soap_connection (locallb_prop)
39
+ def self.create_soap_connection(locallb_prop)
43
40
  @soap =
44
41
  Savon.client do |s|
45
42
  s.wsdl "https://#{@ipaddress}/iControl/iControlPortal.cgi?WSDL=LocalLB.#{locallb_prop}"
@@ -51,63 +48,54 @@ require 'savon'
51
48
  end
52
49
  case locallb_prop
53
50
  when 'VirtualServer'
54
- self.create_virtual_server(@soap,$vs_name,$vs_address)
51
+ create_virtual_server(@soap, $vs_name, $vs_address)
55
52
  when 'Pool'
56
- self.create_pool(@soap,$vs_name,$pool_member1)
53
+ create_pool(@soap, $vs_name, $pool_member1)
57
54
  end
58
55
  end
59
56
 
60
- def self.create_pool (soap,pool_name,pool_member)
61
- r =
62
- soap.call :create do |pool|
63
- pool.message 'pool_names' => {:item => ["#{pool_name}"]},
64
- 'lb_methods' => {:item => ['LB_METHOD_ROUND_ROBIN']},
65
- 'members' => {
66
- :item =>
67
- { :item => [:address => pool_member, :port => '80']}}
57
+ def self.create_pool(soap, pool_name, pool_member)
58
+ r =
59
+ soap.call :create do |pool|
60
+ pool.message 'pool_names' => { item: ["#{pool_name}"] },
61
+ 'lb_methods' => { item: ['LB_METHOD_ROUND_ROBIN'] },
62
+ 'members' => { item:
63
+ { item:
64
+ [address: pool_member, port: '80'] } }
68
65
  end
69
- puts "array #{@@vs_attrs}"
70
66
  unless @@vs_attrs.blank?
71
67
  @@vs_attrs.each do |member|
72
- puts "mem #{member}"
73
68
  soap.call :add_member do |pool|
74
- pool.message 'pool_names' => {:item => ["#{pool_name}"]},
75
- 'members' => {
76
- :item =>
77
- { :item => [:address => member, :port => '80']}}
69
+ pool.message 'pool_names' => { item: ["#{pool_name}"] },
70
+ 'members' => { item:
71
+ { item:
72
+ [address: member, port: '80'] } }
78
73
  end
79
74
  r.success?
80
75
  end
81
76
  end
82
77
  end
83
- # monitor stuff
84
- #soap.call :set_monitor_association do |m|
85
- # m.message :monitor_associations => { 'pool_names' => ["#{vs_server_name}"]},
86
- # { 'monitor_rule' => ['http']}
87
78
 
88
- #end
89
- #m.success?
90
- def self.create_virtual_server (soap,vs_name,vs_address)
79
+ def self.create_virtual_server(soap, vs_name, vs_address)
91
80
  vsdefinitions = [
92
- :name => vs_name,
93
- :address => vs_address,
94
- :port => '80',
95
- :protocol => 'PROTOCOL_TCP' ]
96
- vswildmasks = '255.255.255.255'
81
+ name: vs_name,
82
+ address: vs_address,
83
+ port: '80',
84
+ protocol: 'PROTOCOL_TCP']
85
+ vswildmasks = '255.255.255.255'
97
86
  vsresources = [
98
- :type => 'RESOURCE_TYPE_POOL',
99
- :default_pool_name => vs_name ]
87
+ type: 'RESOURCE_TYPE_POOL',
88
+ default_pool_name: vs_name]
100
89
  vsprofiles = [
101
- :profile_type => 'PROFILE_TYPE_FAST_L4',
102
- :profile_context => 'PROFILE_CONTEXT_TYPE_ALL',
103
- :profile_name => 'tcp' ]
104
- r =
90
+ profile_type: 'PROFILE_TYPE_FAST_L4',
91
+ profile_context: 'PROFILE_CONTEXT_TYPE_ALL',
92
+ profile_name: 'tcp']
93
+ r =
105
94
  soap.call :create do |vs|
106
- vs.message :definitions => {:item => vsdefinitions},
107
- :wildmasks => {:item => vswildmasks},
108
- :resources => {:item => vsresources},
109
- :profiles => {:item =>
110
- {:item => vsprofiles}}
95
+ vs.message definitions: { item: vsdefinitions },
96
+ wildmasks: { item: vswildmasks },
97
+ resources: { item: vsresources },
98
+ profiles: { item: { item: vsprofiles } }
111
99
  end
112
100
  r.success?
113
101
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: simple_lb
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.6
4
+ version: 0.0.7
5
5
  platform: ruby
6
6
  authors:
7
7
  - Jason Swat