simple_lb 0.0.2
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.
- checksums.yaml +7 -0
- data/bin/simple_lb +7 -0
- data/lib/simple_lb.rb +115 -0
- metadata +46 -0
checksums.yaml
ADDED
@@ -0,0 +1,7 @@
|
|
1
|
+
---
|
2
|
+
SHA1:
|
3
|
+
metadata.gz: a9c94f3030c226cf47b52e26708cdd82e71c0806
|
4
|
+
data.tar.gz: 445280cbdaa56fb1dd23ce034273dd0d1d8de740
|
5
|
+
SHA512:
|
6
|
+
metadata.gz: 286bc6ad548c7a26147913aadd9b103fcef3a3d4eec9bad42e17e2fc40f4d5ee57f9a2a42ca850a198576fbdc1721a5a32eb60ca35f8fd2004e0cac56f79b252
|
7
|
+
data.tar.gz: df1e6c7e6b6c49650211310495a4843f8fec4aca79106685cd1d7e5993fec12e55c0b0ca3b3cbc6351f871f66451b0119d9e3b3be4fcc14d11c9347d8f7080de
|
data/bin/simple_lb
ADDED
data/lib/simple_lb.rb
ADDED
@@ -0,0 +1,115 @@
|
|
1
|
+
#!/Users/xjs5/.rvm/rubies/ruby-2.0.0-p353/bin/ruby
|
2
|
+
#
|
3
|
+
|
4
|
+
class VirtualServer
|
5
|
+
require 'savon'
|
6
|
+
|
7
|
+
def initialize (args)
|
8
|
+
@vs_attrs = args.to_a
|
9
|
+
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"
|
12
|
+
end
|
13
|
+
$vs_name = @vs_attrs.shift
|
14
|
+
$vs_address = @vs_attrs.shift
|
15
|
+
$pool_member1 = @vs_attrs.shift
|
16
|
+
|
17
|
+
VirtualServer.create_config
|
18
|
+
VirtualServer.create_soap_connection('Pool')
|
19
|
+
VirtualServer.create_soap_connection('VirtualServer')
|
20
|
+
end
|
21
|
+
|
22
|
+
def self.create_config
|
23
|
+
path = File.expand_path "~/.bigip.yml"
|
24
|
+
config = YAML.load(File.read(path)) rescue nil
|
25
|
+
unless config then
|
26
|
+
config = {
|
27
|
+
:ipaddress => '172.16.222.120',
|
28
|
+
:user => 'admin',
|
29
|
+
:password => 'admin'
|
30
|
+
}
|
31
|
+
File.open(path, "w") { |f|
|
32
|
+
YAML.dump(config, f)
|
33
|
+
}
|
34
|
+
abort "Created config file #{path} update with your bigip info"
|
35
|
+
end
|
36
|
+
@ipaddress = config[:ipaddress]
|
37
|
+
@user = config[:user]
|
38
|
+
@password = config[:password]
|
39
|
+
end
|
40
|
+
|
41
|
+
def self.create_soap_connection (locallb_prop)
|
42
|
+
@soap =
|
43
|
+
Savon.client do |s|
|
44
|
+
s.wsdl "https://#{@ipaddress}/iControl/iControlPortal.cgi?WSDL=LocalLB.#{locallb_prop}"
|
45
|
+
s.basic_auth [@user, @password]
|
46
|
+
s.ssl_verify_mode :none
|
47
|
+
s.endpoint "https://#{@ipaddress}/iControl/iControlPortal.cgi"
|
48
|
+
s.namespace "urn:iControl:LocalLB/#{locallb_prop}"
|
49
|
+
s.convert_request_keys_to :none
|
50
|
+
end
|
51
|
+
case locallb_prop
|
52
|
+
when 'VirtualServer'
|
53
|
+
self.create_virtual_server(@soap,$vs_name,$vs_address)
|
54
|
+
when 'Pool'
|
55
|
+
self.create_pool(@soap,$vs_name,$pool_member1)
|
56
|
+
end
|
57
|
+
end
|
58
|
+
|
59
|
+
def self.create_pool (soap,pool_name,pool_member)
|
60
|
+
r =
|
61
|
+
soap.call :create do |pool|
|
62
|
+
pool.message 'pool_names' => {:item => ["#{pool_name}"]},
|
63
|
+
'lb_methods' => {:item => ['LB_METHOD_ROUND_ROBIN']},
|
64
|
+
'members' => {
|
65
|
+
:item =>
|
66
|
+
{ :item => [:address => pool_member, :port => '80']}}
|
67
|
+
end
|
68
|
+
unless @vs_attrs.blank?
|
69
|
+
@vs_attrs.each do |member|
|
70
|
+
soap.call :add_member do | pool |
|
71
|
+
pool.message 'pool_names' => {:item => ["#{pool_name}"]},
|
72
|
+
'members' => {
|
73
|
+
:item =>
|
74
|
+
{ :item => [:address => member, :port => '80']}}
|
75
|
+
end
|
76
|
+
r.success?
|
77
|
+
end
|
78
|
+
end
|
79
|
+
end
|
80
|
+
# monitor stuff
|
81
|
+
#soap.call :set_monitor_association do |m|
|
82
|
+
# m.message :monitor_associations => { 'pool_names' => ["#{vs_server_name}"]},
|
83
|
+
# { 'monitor_rule' => ['http']}
|
84
|
+
|
85
|
+
#end
|
86
|
+
#m.success?
|
87
|
+
#Virtual Server
|
88
|
+
def self.create_virtual_server (soap,vs_name,vs_address)
|
89
|
+
vsdefinitions = [
|
90
|
+
:name => vs_name,
|
91
|
+
:address => vs_address,
|
92
|
+
:port => '80',
|
93
|
+
:protocol => 'PROTOCOL_TCP' ]
|
94
|
+
vswildmasks = '255.255.255.255'
|
95
|
+
vsresources = [
|
96
|
+
:type => 'RESOURCE_TYPE_POOL',
|
97
|
+
:default_pool_name => vs_name ]
|
98
|
+
vsprofiles = [
|
99
|
+
:profile_type => 'PROFILE_TYPE_FAST_L4',
|
100
|
+
:profile_context => 'PROFILE_CONTEXT_TYPE_ALL',
|
101
|
+
:profile_name => 'tcp' ]
|
102
|
+
r =
|
103
|
+
soap.call :create do |vs|
|
104
|
+
vs.message :definitions => {:item => vsdefinitions},
|
105
|
+
:wildmasks => {:item => vswildmasks},
|
106
|
+
:resources => {:item => vsresources},
|
107
|
+
:profiles => {:item =>
|
108
|
+
{:item => vsprofiles}}
|
109
|
+
end
|
110
|
+
r.success?
|
111
|
+
end
|
112
|
+
end
|
113
|
+
#VirtualServer.create_config
|
114
|
+
#VirtualServer.create_soap_connection('Pool')
|
115
|
+
#VirtualServer.create_soap_connection('VirtualServer')
|
metadata
ADDED
@@ -0,0 +1,46 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: simple_lb
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
version: 0.0.2
|
5
|
+
platform: ruby
|
6
|
+
authors:
|
7
|
+
- Jason Swat
|
8
|
+
autorequire:
|
9
|
+
bindir: bin
|
10
|
+
cert_chain: []
|
11
|
+
date: 2014-03-11 00:00:00.000000000 Z
|
12
|
+
dependencies: []
|
13
|
+
description: Creates a simple load balance pool and server on an F5 ltm
|
14
|
+
email: jason.swat@gmail.com
|
15
|
+
executables:
|
16
|
+
- simple_lb
|
17
|
+
extensions: []
|
18
|
+
extra_rdoc_files: []
|
19
|
+
files:
|
20
|
+
- bin/simple_lb
|
21
|
+
- lib/simple_lb.rb
|
22
|
+
homepage: https://github.com/jasonswat/simple_lb
|
23
|
+
licenses:
|
24
|
+
- Apache
|
25
|
+
metadata: {}
|
26
|
+
post_install_message:
|
27
|
+
rdoc_options: []
|
28
|
+
require_paths:
|
29
|
+
- lib
|
30
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
31
|
+
requirements:
|
32
|
+
- - '>='
|
33
|
+
- !ruby/object:Gem::Version
|
34
|
+
version: '0'
|
35
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
36
|
+
requirements:
|
37
|
+
- - '>='
|
38
|
+
- !ruby/object:Gem::Version
|
39
|
+
version: '0'
|
40
|
+
requirements: []
|
41
|
+
rubyforge_project:
|
42
|
+
rubygems_version: 2.2.1
|
43
|
+
signing_key:
|
44
|
+
specification_version: 4
|
45
|
+
summary: simple_lb
|
46
|
+
test_files: []
|