f5-icontrol 0.3.1 → 0.3.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.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
- SHA1:
3
- metadata.gz: 67be269b116b38facac67624090cfbe091f282cd
4
- data.tar.gz: 591e3403939a847a88cf58b7bc59449b1354f916
2
+ SHA256:
3
+ metadata.gz: cbee28f646b9200087841aa35846106d4246bafecd3db0ce256d26dc0945f7fb
4
+ data.tar.gz: 527e6119839ee1891c3a696477e043eef9e63fadb7249d054252997d49b3c7b6
5
5
  SHA512:
6
- metadata.gz: cb6cd282e3ab8cfc44094568c260dd767e0162c0a66e60d595d19eebc6cad170def76b6f05f041693b56963f0c312fb0c1c9e362aa71eebc4be82c92b316511b
7
- data.tar.gz: 21109f36b56d2908bb6a5b2985d376b1ee9785cd97d687eb20ff2b324f51018371d8519936de704b07dbbac2d03655566fbd6f5c731b71df115649aca67ddb93
6
+ metadata.gz: 348e4ff11cf46ab6d756bb4b4fab8eecbe676a1a0947958f73f3aa3d9ad4cfc6764a56fa775a2129f760115a77a5c20b0e110b7c79563cf5bd842531ceb4ab80
7
+ data.tar.gz: 63a0f8df5e1b8624069bcab887ffa5b5cde4833d182a7bef28417b918d6763347de2c49a939a8689f9369899e46c7f3bd504545ab44d65b5b5452c1e621b0a13
@@ -1,4 +1,9 @@
1
1
  # Changelog
2
+
3
+ ## 0.3.6
4
+ mattlqx - properly truncate hostname and scheme from reference links
5
+ ## 0.3.5
6
+ mattlqx - prevent underscores in pool names
2
7
  ## 0.2.5
3
8
  swalberg - support setting pool member connection limits
4
9
  ## 0.2.4
@@ -22,12 +22,13 @@ Gem::Specification.new do |spec|
22
22
  spec.add_dependency "rest-client"
23
23
  spec.add_dependency "thor"
24
24
  spec.add_dependency "json"
25
+ spec.add_dependency "wasabi", "<= 3.5.0"
25
26
 
26
27
  spec.add_development_dependency "awesome_print"
27
28
  spec.add_development_dependency "bundler", "~> 1.3"
28
29
  spec.add_development_dependency "byebug"
29
30
  spec.add_development_dependency "rake"
30
31
  spec.add_development_dependency "rspec"
31
- spec.add_development_dependency "webmock", "~> 2.1.0"
32
+ spec.add_development_dependency "webmock", "~> 3.7.0"
32
33
  spec.add_development_dependency "vcr"
33
34
  end
@@ -25,9 +25,9 @@ module F5
25
25
 
26
26
  def client
27
27
  return @client if @client
28
- config = YAML.load_file("#{ENV['HOME']}/.f5.yml")
28
+ config = YAML.load_file(options[:config])
29
29
  if config.key?('username') && options[:lb] == 'default'
30
- puts "Warning: credentials in .f5.yml should be put under a named load balancer."
30
+ puts "Warning: credentials in #{options[:config]} should be put under a named load balancer."
31
31
  configure_lb_as(config)
32
32
  else
33
33
  configure_lb_as config[options[:lb]]
@@ -360,9 +360,120 @@ module F5
360
360
 
361
361
  end
362
362
 
363
+ class Config < Subcommand
364
+ desc "list", "Lists the current configuration variables."
365
+ def list
366
+ response = client.Management.DBVariable.get_list
367
+
368
+ dbVariables = Array(response[:item])
369
+ if dbVariables.empty?
370
+ puts "No config variables found"
371
+ else
372
+ dbVariables.each do |p|
373
+ puts "#{p[:name]}: #{p[:value]}"
374
+ end
375
+ end
376
+ end
377
+ end
378
+
379
+ class Device < Subcommand
380
+ desc "list", "Lists the all devices regardless of device group."
381
+ def list
382
+ response = client.Management.Device.get_list
383
+
384
+ devices = Array(response[:item])
385
+ if devices.empty?
386
+ puts "No devices found"
387
+ else
388
+ devices.each do |p|
389
+ puts p
390
+ end
391
+ end
392
+ end
393
+ end
394
+
395
+ class DeviceGroup < Subcommand
396
+ desc "list", "Lists the all device groups."
397
+ def list
398
+ response = client.Management.DeviceGroup.get_list
399
+
400
+ devices = Array(response[:item])
401
+ if devices.empty?
402
+ puts "No devices found"
403
+ else
404
+ devices.each do |p|
405
+ puts p
406
+ end
407
+ end
408
+ end
409
+
410
+ desc "status DEVICE_GROUP", "Shows the sync status between devices in the specified device group. (Shows status of all device groups of one is not specified.)"
411
+ def status(device_group=nil)
412
+ response = client.Management.DeviceGroup.get_sync_status(device_groups: { item: [ device_group ] })
413
+ puts "STATUS: #{response[:item][:status]}";
414
+ puts "STATUS COLOR: #{response[:item][:color]}";
415
+ puts "STATUS DESCRIPTION: #{response[:item][:member_state]}";
416
+ puts "STATUS SUMMARY: #{response[:item][:summary]}";
417
+ puts "STATUS DETAILS:"
418
+ puts response[:item][:details][:item].nil? ? "No further details." : response[:item][:details][:item]
419
+ end
420
+
421
+ desc "sync DEVICE_GROUP DEVICE_WITH_CHANGES_PENDING", "This will sync configs between devices in the specified device group."
422
+ def sync(device_group, device)
423
+ device = "#{device.gsub(%r{^/Common/}, '')}"
424
+ response = client.System.ConfigSync.synchronize_to_group_v2(group: device_group, device: "/Common/#{device}", force: false)
425
+ if response.nil? || response.empty?
426
+ puts "Sync completed."
427
+ else
428
+ puts "Sync did not complete."
429
+ end
430
+ end
431
+ end
432
+
433
+ class VirtualServer < Subcommand
434
+
435
+ desc "list", "Lists all the virtual servers"
436
+ def list
437
+ response = client.LocalLB.VirtualServer.get_list
438
+
439
+ virtualservers = Array(response[:item])
440
+ if virtualservers.empty?
441
+ puts "No virtual servers found"
442
+ else
443
+ virtualservers.each do |p|
444
+ puts p
445
+ end
446
+ end
447
+ end
448
+
449
+ desc "show VSERVER_NAME", "Shows information about a virtual server"
450
+ def show(vserver)
451
+ destination = extract_items client.LocalLB.VirtualServer.get_destination(virtual_servers: { item: [vserver] } )
452
+ protocol = extract_items client.LocalLB.VirtualServer.get_protocol(virtual_servers: { item: [vserver] } )
453
+ default_pool = extract_items client.LocalLB.VirtualServer.get_default_pool_name(virtual_servers: { item: [vserver] } )
454
+
455
+ puts "%-25s %-20s %-20s %-20s" % ["Destination Address", "Destination Port", "Protocol", "Default Pool"]
456
+ puts "%-25s %-20s %-20s %-20s" % [destination[:address], destination[:port], protocol.split('_').last, default_pool]
457
+ end
458
+
459
+ desc "status VSERVER_NAME", "Shows the status of the virtual server"
460
+ def status(vserver)
461
+ response = client.LocalLB.VirtualServer.get_object_status(virtual_servers: { item: [vserver] } )
462
+
463
+ availability = response[:item][:availability_status].split('_').last
464
+ enabled = response[:item][:enabled_status].split('_').last
465
+ status_description = response[:item][:status_description]
466
+
467
+ puts "%-40s %-20s %-20s %-20s" % ["Name", "Availability", "Enabled", "Status Description"]
468
+ puts "%-40s %-20s %-20s %-20s" % [vserver, availability, enabled, status_description]
469
+ end
470
+ end
471
+
363
472
  class Application < Thor
364
473
  class_option :lb, default: 'default'
365
474
 
475
+ class_option :config, :type => :string, :default => "#{ENV['HOME']}/.f5.yml", :desc => "Defines the location of the configuration file."
476
+
366
477
  desc "node SUBCOMMAND ...ARGS", "manage nodes"
367
478
  subcommand "node", Node
368
479
 
@@ -377,6 +488,18 @@ module F5
377
488
 
378
489
  desc "vlan SUBCOMMAND ...ARGS", "manage vlans"
379
490
  subcommand "vlan", VLAN
491
+
492
+ desc "config SUBCOMMAND ...ARGS", "view config values"
493
+ subcommand "config", Config
494
+
495
+ desc "device SUBCOMMAND ...ARGS", "manage devices"
496
+ subcommand "device", Device
497
+
498
+ desc "devicegroup SUBCOMMAND ...ARGS", "manage device groups"
499
+ subcommand "devicegroup", DeviceGroup
500
+
501
+ desc "vserver SUBCOMMAND ...ARGS", "manage virtual servers"
502
+ subcommand "vserver", VirtualServer
380
503
  end
381
504
  end
382
505
  end
@@ -63,7 +63,9 @@ module F5
63
63
 
64
64
  private
65
65
  def url
66
- method_chain = @method_chain.gsub /_/, '-'
66
+ pool_match = @method_chain.match %r{(/pool/[A-Za-z0-9\-_~]+)}
67
+ method_chain = @method_chain.tr '_', '-'
68
+ method_chain = method_chain.sub %r{/pool/[A-Za-z0-9\-_~]+}, pool_match[1] unless pool_match.nil?
67
69
  method_chain.gsub! %r{^/}, ''
68
70
  "https://#{@args[:host]}/#{method_chain}"
69
71
  end
@@ -15,7 +15,7 @@ module F5
15
15
  potential_collection = "#{method}Reference"
16
16
  if @args.key? potential_collection
17
17
  link = @args[potential_collection]["link"]
18
- link.gsub! /^http?s:\/\/localhost\//, ""
18
+ link.sub! %r{^https?://[A-Za-z0-9\-._]+/}, ""
19
19
  return F5::Icontrol::RAPI.new(link, @credentials)
20
20
  end
21
21
  end
@@ -1,5 +1,5 @@
1
1
  module F5
2
2
  module Icontrol
3
- VERSION = '0.3.1'
3
+ VERSION = '0.3.7'
4
4
  end
5
5
  end
@@ -40,6 +40,15 @@ describe F5::Icontrol::RAPI do
40
40
  expect(WebMock).to have_requested(:get, "#{baseurl}/foo-bar/")
41
41
  end
42
42
 
43
+ it "preserves underscores in pool names" do
44
+ stub_request(:get, "#{baseurl}/pool/foo_bar").
45
+ to_return(body: pool_collection)
46
+
47
+ subject.pool.load('foo_bar')
48
+
49
+ expect(WebMock).to have_requested(:get, "#{baseurl}/pool/foo_bar")
50
+ end
51
+
43
52
  it "understands `each` implicitly calls `get_collection`" do
44
53
  stub_request(:get, "#{baseurl}/foo/bar/").
45
54
  to_return(body: pool_collection)
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.3.1
4
+ version: 0.3.7
5
5
  platform: ruby
6
6
  authors:
7
7
  - Sean Walberg
8
- autorequire:
8
+ autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2017-09-12 00:00:00.000000000 Z
11
+ date: 2020-09-11 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: savon
@@ -66,6 +66,20 @@ dependencies:
66
66
  - - ">="
67
67
  - !ruby/object:Gem::Version
68
68
  version: '0'
69
+ - !ruby/object:Gem::Dependency
70
+ name: wasabi
71
+ requirement: !ruby/object:Gem::Requirement
72
+ requirements:
73
+ - - "<="
74
+ - !ruby/object:Gem::Version
75
+ version: 3.5.0
76
+ type: :runtime
77
+ prerelease: false
78
+ version_requirements: !ruby/object:Gem::Requirement
79
+ requirements:
80
+ - - "<="
81
+ - !ruby/object:Gem::Version
82
+ version: 3.5.0
69
83
  - !ruby/object:Gem::Dependency
70
84
  name: awesome_print
71
85
  requirement: !ruby/object:Gem::Requirement
@@ -142,14 +156,14 @@ dependencies:
142
156
  requirements:
143
157
  - - "~>"
144
158
  - !ruby/object:Gem::Version
145
- version: 2.1.0
159
+ version: 3.7.0
146
160
  type: :development
147
161
  prerelease: false
148
162
  version_requirements: !ruby/object:Gem::Requirement
149
163
  requirements:
150
164
  - - "~>"
151
165
  - !ruby/object:Gem::Version
152
- version: 2.1.0
166
+ version: 3.7.0
153
167
  - !ruby/object:Gem::Dependency
154
168
  name: vcr
155
169
  requirement: !ruby/object:Gem::Requirement
@@ -480,7 +494,7 @@ homepage: https://github.com/swalberg/f5-icontrol
480
494
  licenses:
481
495
  - MIT
482
496
  metadata: {}
483
- post_install_message:
497
+ post_install_message:
484
498
  rdoc_options: []
485
499
  require_paths:
486
500
  - lib
@@ -495,9 +509,8 @@ required_rubygems_version: !ruby/object:Gem::Requirement
495
509
  - !ruby/object:Gem::Version
496
510
  version: '0'
497
511
  requirements: []
498
- rubyforge_project:
499
- rubygems_version: 2.5.1
500
- signing_key:
512
+ rubygems_version: 3.1.2
513
+ signing_key:
501
514
  specification_version: 4
502
515
  summary: A gem to manage F5 BigIP devices using the iControl API
503
516
  test_files: