f5-icontrol 0.1.4 → 0.1.5
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/README.md +8 -3
- data/bin/f5 +0 -8
- data/lib/f5/cli/application.rb +180 -6
- data/lib/f5/icontrol/version.rb +1 -1
- metadata +3 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: af1d81830bb6821e3a7ef6040d632673be052a82
|
4
|
+
data.tar.gz: 436e1982d1adc3b0354e93b9f436288f5c24609f
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: fa4feeb14c8b10e1f04e17fdc285f40c1712483c937062d4d84baa1e7b365b0a10690c4c4fca87ed5d49165808f4a240a6e2ba30737cd65cd53b1b88316268e8
|
7
|
+
data.tar.gz: 61170981d9e12599418f8b55cef318467ba45fdc9517dc292b28605e250f7c05d6f449ff16510caf1b68225f4f06905c7e2875d37c00520335534513c5788478
|
data/README.md
CHANGED
@@ -55,9 +55,14 @@ See specs subdir for more examples, especially as it pertains to passing paramet
|
|
55
55
|
There's a command line version that's still being roughed out. You'll need a `~/.f5.yml` file containing your login information:
|
56
56
|
|
57
57
|
```
|
58
|
-
|
59
|
-
|
60
|
-
|
58
|
+
default:
|
59
|
+
host: foo.bar.com
|
60
|
+
username: admin
|
61
|
+
password: abc123
|
62
|
+
lb2:
|
63
|
+
host: 1.2.3.4
|
64
|
+
username: admin
|
65
|
+
password: abc123
|
61
66
|
```
|
62
67
|
|
63
68
|
Then run `f5` and it'll provide help
|
data/bin/f5
CHANGED
@@ -3,12 +3,4 @@
|
|
3
3
|
require 'f5/cli/application'
|
4
4
|
require 'f5/icontrol'
|
5
5
|
|
6
|
-
config ||= YAML.load_file("#{ENV['HOME']}/.f5.yml")
|
7
|
-
|
8
|
-
F5::Icontrol.configure do |f5|
|
9
|
-
f5.host = config['host']
|
10
|
-
f5.username = config['username']
|
11
|
-
f5.password = config['password']
|
12
|
-
end
|
13
|
-
|
14
6
|
F5::Cli::Application.start(ARGV)
|
data/lib/f5/cli/application.rb
CHANGED
@@ -2,7 +2,177 @@ require 'thor'
|
|
2
2
|
|
3
3
|
module F5
|
4
4
|
module Cli
|
5
|
-
class
|
5
|
+
class Subcommand < Thor
|
6
|
+
|
7
|
+
private
|
8
|
+
|
9
|
+
def extract_items(response, opts = nil)
|
10
|
+
items = response[:item]
|
11
|
+
|
12
|
+
if items.nil?
|
13
|
+
return opts == :as_array ? [] : nil
|
14
|
+
end
|
15
|
+
|
16
|
+
if items.is_a?(Hash) && items.has_key?(:item)
|
17
|
+
items = items[:item]
|
18
|
+
end
|
19
|
+
if opts == :as_array && items.is_a?(Hash)
|
20
|
+
[ items ]
|
21
|
+
else
|
22
|
+
items
|
23
|
+
end
|
24
|
+
end
|
25
|
+
|
26
|
+
def client
|
27
|
+
return @client if @client
|
28
|
+
config = YAML.load_file("#{ENV['HOME']}/.f5.yml")
|
29
|
+
if config.key?('username') && options[:lb] == 'default'
|
30
|
+
puts "Warning: credentials in .f5.yml should be put under a named load balancer."
|
31
|
+
configure_lb_as(config)
|
32
|
+
else
|
33
|
+
configure_lb_as config[options[:lb]]
|
34
|
+
end
|
35
|
+
F5::Icontrol::API.new
|
36
|
+
end
|
37
|
+
|
38
|
+
def configure_lb_as(config)
|
39
|
+
F5::Icontrol.configure do |f5|
|
40
|
+
f5.host = config['host']
|
41
|
+
f5.username = config['username']
|
42
|
+
f5.password = config['password']
|
43
|
+
end
|
44
|
+
end
|
45
|
+
|
46
|
+
def itemize(option)
|
47
|
+
{
|
48
|
+
item: [ option ]
|
49
|
+
}
|
50
|
+
end
|
51
|
+
|
52
|
+
end
|
53
|
+
|
54
|
+
class SelfIP < Subcommand
|
55
|
+
desc "list", "Lists all the self IPs"
|
56
|
+
def list
|
57
|
+
response = client.Networking.SelfIPV2.get_list
|
58
|
+
|
59
|
+
selfips = extract_items(response, :as_array)
|
60
|
+
if selfips.empty?
|
61
|
+
puts "No selfips found"
|
62
|
+
else
|
63
|
+
selfips.each do |selfip|
|
64
|
+
puts selfip
|
65
|
+
end
|
66
|
+
end
|
67
|
+
end
|
68
|
+
|
69
|
+
desc "show NAME", "Shows information about a self IP"
|
70
|
+
def show(name)
|
71
|
+
address = extract_items client.Networking.SelfIPV2.get_address(self_ips: { item: [ name ] })
|
72
|
+
netmask = extract_items client.Networking.SelfIPV2.get_netmask(self_ips: { item: [ name ] })
|
73
|
+
vlan = extract_items client.Networking.SelfIPV2.get_vlan(self_ips: { item: [ name ] })
|
74
|
+
trafficgroup = extract_items client.Networking.SelfIPV2.get_traffic_group(self_ips: { item: [ name ] })
|
75
|
+
floating = extract_items client.Networking.SelfIPV2.get_floating_state(self_ips: { item: [ name ] })
|
76
|
+
|
77
|
+
puts "#{address}/#{netmask}"
|
78
|
+
puts vlan
|
79
|
+
puts "#{trafficgroup} #{floating == 'STATE_ENABLED' ? 'FLOATING' : 'NONFLOATING'}"
|
80
|
+
end
|
81
|
+
|
82
|
+
desc "create NAME IP/NETMASK VLAN", "Creates a self IP"
|
83
|
+
option :floating, type: :boolean, default: false
|
84
|
+
option :traffic_group, default: 'traffic-group-local-only'
|
85
|
+
def create(name, address, vlan)
|
86
|
+
(ip, netmask) = address.split(/\//)
|
87
|
+
result = client.Networking.SelfIPV2.create(
|
88
|
+
self_ips: itemize(name),
|
89
|
+
vlan_names: itemize(vlan),
|
90
|
+
addresses: itemize(ip),
|
91
|
+
netmasks: itemize(netmask),
|
92
|
+
traffic_groups: itemize(options[:traffic_group]),
|
93
|
+
floating_states: itemize(options[:floating] ? 'STATE_ENABLED' : 'STATE_DISABLED')
|
94
|
+
)
|
95
|
+
end
|
96
|
+
end
|
97
|
+
|
98
|
+
class Interface < Subcommand
|
99
|
+
|
100
|
+
desc "list", "Lists all the interfaces"
|
101
|
+
def list
|
102
|
+
response = client.Networking.Interfaces.get_list
|
103
|
+
|
104
|
+
interfaces = extract_items(response, :as_array)
|
105
|
+
if interfaces.empty?
|
106
|
+
puts "No interfaces found"
|
107
|
+
else
|
108
|
+
interfaces.each do |interface|
|
109
|
+
puts interface
|
110
|
+
end
|
111
|
+
end
|
112
|
+
end
|
113
|
+
end
|
114
|
+
|
115
|
+
class VLAN < Subcommand
|
116
|
+
|
117
|
+
desc "list", "Lists all the vlans"
|
118
|
+
def list
|
119
|
+
response = client.Networking.VLAN.get_list
|
120
|
+
|
121
|
+
vlans = extract_items(response, :as_array)
|
122
|
+
if vlans.empty?
|
123
|
+
puts "No VLANs found"
|
124
|
+
else
|
125
|
+
vlans.each do |vlan|
|
126
|
+
puts vlan
|
127
|
+
end
|
128
|
+
end
|
129
|
+
end
|
130
|
+
|
131
|
+
desc "show VLAN_NAME", "Show a particular vlan"
|
132
|
+
def show(name)
|
133
|
+
members = extract_items client.Networking.VLAN.get_member(vlans: { item: [ name ] } ), :as_array
|
134
|
+
|
135
|
+
vid = extract_items client.Networking.VLAN.get_vlan_id(vlans: { item: [ name ] } )
|
136
|
+
|
137
|
+
failsafe_state = extract_items client.Networking.VLAN.get_failsafe_state(vlans: { item: [ name ] } )
|
138
|
+
|
139
|
+
puts "VLAN id #{vid} and failsafe is #{failsafe_state}"
|
140
|
+
members.each do |member|
|
141
|
+
puts "Interface %s is a %s and tag state is %s" % [ member[:member_name], member[:member_type], member[:tag_state] ]
|
142
|
+
end
|
143
|
+
end
|
144
|
+
|
145
|
+
desc "create VLAN_ID VLAN_NAME member1type:member1name ", "Create a vlan with the name and ID, attached to the given members"
|
146
|
+
def create(vid, name, *members)
|
147
|
+
if members.empty?
|
148
|
+
puts "I need at least one member interface"
|
149
|
+
exit
|
150
|
+
end
|
151
|
+
|
152
|
+
memberdata = members.map do |m|
|
153
|
+
(mtype, mname) = m.split /:/
|
154
|
+
if mname.nil?
|
155
|
+
puts "Each member must be in the form of interface/trunk:id"
|
156
|
+
exit
|
157
|
+
end
|
158
|
+
{ member_name: mname,
|
159
|
+
member_type: (mtype == 'trunk' ? 'MEMBER_TRUNK' : 'MEMBER_INTERFACE'),
|
160
|
+
tag_state: 'MEMBER_TAGGED' }
|
161
|
+
end
|
162
|
+
|
163
|
+
response = client.Networking.VLAN.create_v2(
|
164
|
+
vlans: { item: [ name ] },
|
165
|
+
vlan_ids: { item: [ vid ] },
|
166
|
+
members: { item: [ item: memberdata ] },
|
167
|
+
failsafe_states: { item: [ 'STATE_DISABLED' ] },
|
168
|
+
timeouts: { item: [ 100 ] } #???
|
169
|
+
)
|
170
|
+
puts response
|
171
|
+
|
172
|
+
end
|
173
|
+
end
|
174
|
+
|
175
|
+
class Pool < Subcommand
|
6
176
|
|
7
177
|
desc "list", "Lists all the pools"
|
8
178
|
def list
|
@@ -103,7 +273,6 @@ module F5
|
|
103
273
|
end
|
104
274
|
|
105
275
|
private
|
106
|
-
|
107
276
|
def pool_members(pool)
|
108
277
|
response = client.LocalLB.Pool.get_member_v2(pool_names: { item: [ pool ] } )
|
109
278
|
|
@@ -113,17 +282,22 @@ module F5
|
|
113
282
|
members.map { |m| { address: m[:address], port: m[:port] } }
|
114
283
|
end
|
115
284
|
|
116
|
-
def client
|
117
|
-
@client || F5::Icontrol::API.new
|
118
|
-
end
|
119
|
-
|
120
285
|
end
|
121
286
|
|
122
287
|
class Application < Thor
|
288
|
+
class_option :lb, default: 'default'
|
123
289
|
|
124
290
|
desc "pool SUBCOMMAND ...ARGS", "manage pools"
|
125
291
|
subcommand "pool", Pool
|
126
292
|
|
293
|
+
desc "interface SUBCOMMAND ...ARGS", "manage interfaces"
|
294
|
+
subcommand "interface", Interface
|
295
|
+
|
296
|
+
desc "selfip SUBCOMMAND ...ARGS", "manage self IPs"
|
297
|
+
subcommand "selfip", SelfIP
|
298
|
+
|
299
|
+
desc "vlan SUBCOMMAND ...ARGS", "manage vlans"
|
300
|
+
subcommand "vlan", VLAN
|
127
301
|
end
|
128
302
|
end
|
129
303
|
end
|
data/lib/f5/icontrol/version.rb
CHANGED
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: f5-icontrol
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.1.
|
4
|
+
version: 0.1.5
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Sean Walberg
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date:
|
11
|
+
date: 2015-06-05 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: savon
|
@@ -411,3 +411,4 @@ test_files:
|
|
411
411
|
- spec/cli/pool_spec.rb
|
412
412
|
- spec/models/api_spec.rb
|
413
413
|
- spec/spec_helper.rb
|
414
|
+
has_rdoc:
|