bluecat 0.1.0 → 0.1.1
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/.gitignore +17 -0
- data/.rspec +2 -0
- data/.travis.yml +5 -0
- data/Gemfile +4 -0
- data/LICENSE.txt +21 -0
- data/README.md +75 -0
- data/Rakefile +6 -0
- data/bluecat.gemspec +30 -0
- data/lib/bluecat.rb +6 -0
- data/lib/bluecat/client.rb +46 -0
- data/lib/bluecat/version.rb +3 -0
- metadata +19 -4
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: a901c48568977b23c1d782579260f8df25da8bcf
|
4
|
+
data.tar.gz: a039e858964fde468590531a01368e35e2e9b098
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 3b189d48d8206ac13caee05e69cd1c0f17336ef520db10d3b3753ead0a67fa9d9ffbc3defcdefd85740445c9c69ab58b4d4fcbea7d90e669cc7424b25dac1190
|
7
|
+
data.tar.gz: 6dfd3d4c6c973de14bf66e8d9d33448c6c58e6c5d3c532b7ef1d967413cee085c707cbe52c1fc683c0c6c09a722a32e0a190719ccaef5a74e9e391382c21a5f6
|
data/.gitignore
ADDED
data/.rspec
ADDED
data/.travis.yml
ADDED
data/Gemfile
ADDED
data/LICENSE.txt
ADDED
@@ -0,0 +1,21 @@
|
|
1
|
+
The MIT License (MIT)
|
2
|
+
|
3
|
+
Copyright (c) 2017 Dustin Wheeler
|
4
|
+
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
7
|
+
in the Software without restriction, including without limitation the rights
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
10
|
+
furnished to do so, subject to the following conditions:
|
11
|
+
|
12
|
+
The above copyright notice and this permission notice shall be included in
|
13
|
+
all copies or substantial portions of the Software.
|
14
|
+
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
21
|
+
THE SOFTWARE.
|
data/README.md
ADDED
@@ -0,0 +1,75 @@
|
|
1
|
+
# Bluecat
|
2
|
+
|
3
|
+
This gem wraps certain operations with the Bluecat Address Management API via `savon`. I use this specifically to integrate with [Foreman](https://theforeman.org) so there is a lot that this gem cannot do, yet. That said, I am open to pull requests to add more features.
|
4
|
+
|
5
|
+
## Installation
|
6
|
+
|
7
|
+
Add this line to your application's Gemfile:
|
8
|
+
|
9
|
+
```ruby
|
10
|
+
gem 'bluecat'
|
11
|
+
```
|
12
|
+
|
13
|
+
And then execute:
|
14
|
+
|
15
|
+
$ bundle
|
16
|
+
|
17
|
+
Or install it yourself as:
|
18
|
+
|
19
|
+
$ gem install bluecat
|
20
|
+
|
21
|
+
## Usage
|
22
|
+
|
23
|
+
```ruby
|
24
|
+
require 'bluecat'
|
25
|
+
require 'pp'
|
26
|
+
|
27
|
+
client = Bluecat::Client.new(wsdl: 'https://hostname/Services/API?wsdl')
|
28
|
+
client.login('api-username', 'api-password')
|
29
|
+
|
30
|
+
# This is the object ID of where to start
|
31
|
+
# your search.
|
32
|
+
container_id = 1
|
33
|
+
|
34
|
+
pp client.ip4_networks(container_id).to_a
|
35
|
+
|
36
|
+
client.logout
|
37
|
+
```
|
38
|
+
|
39
|
+
It is a "best practice" (according to Bluecat's documentation) to logout at the end of a session. When I use this in other projects, I might expose it like so:
|
40
|
+
|
41
|
+
```ruby
|
42
|
+
class SomeUseCase
|
43
|
+
# All access to API happens through this method
|
44
|
+
def bluecat
|
45
|
+
username = HammerCLI::Settings.get(:bluecat, :username)
|
46
|
+
password = HammerCLI::Settings.get(:bluecat, :password)
|
47
|
+
|
48
|
+
client = Bluecat::Client.new(wsdl: HammerCLI::Settings.get(:bluecat, :wsdl))
|
49
|
+
client.login(username, password)
|
50
|
+
|
51
|
+
yield client
|
52
|
+
|
53
|
+
client.logout
|
54
|
+
end
|
55
|
+
|
56
|
+
def execute
|
57
|
+
bluecat do |client|
|
58
|
+
# Do things with the client
|
59
|
+
client.ip4_networks(@container_id).take(10)
|
60
|
+
end
|
61
|
+
end
|
62
|
+
end
|
63
|
+
```
|
64
|
+
|
65
|
+
In this way, the client will log in and out for every operation. This may not be best for your use-case.
|
66
|
+
|
67
|
+
## Contributing
|
68
|
+
|
69
|
+
Bug reports and pull requests are welcome on GitHub at https://github.com/mdwheele/bluecat.
|
70
|
+
|
71
|
+
|
72
|
+
## License
|
73
|
+
|
74
|
+
The gem is available as open source under the terms of the [MIT License](http://opensource.org/licenses/MIT).
|
75
|
+
|
data/Rakefile
ADDED
data/bluecat.gemspec
ADDED
@@ -0,0 +1,30 @@
|
|
1
|
+
# coding: utf-8
|
2
|
+
lib = File.expand_path('../lib', __FILE__)
|
3
|
+
$LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
|
4
|
+
require 'bluecat/version'
|
5
|
+
|
6
|
+
Gem::Specification.new do |spec|
|
7
|
+
spec.name = "bluecat"
|
8
|
+
spec.version = Bluecat::VERSION
|
9
|
+
spec.authors = ["Dustin Wheeler"]
|
10
|
+
spec.email = ["mdwheele@ncsu.edu"]
|
11
|
+
|
12
|
+
spec.summary = %q{Bluecat Address Management Client}
|
13
|
+
spec.description = %q{Use this gem to interact with the Bluecat Address Management SOAP API}
|
14
|
+
spec.homepage = "https://github.com/mdwheele/bluecat"
|
15
|
+
spec.license = "MIT"
|
16
|
+
|
17
|
+
spec.files = `git ls-files -z`.split("\x0").reject do |f|
|
18
|
+
f.match(%r{^(test|spec|features)/})
|
19
|
+
end
|
20
|
+
spec.bindir = "bin"
|
21
|
+
spec.executables = spec.files.grep(%r{^bin/}) { |f| File.basename(f) }
|
22
|
+
spec.require_paths = ["lib"]
|
23
|
+
|
24
|
+
spec.add_dependency 'thor', '~> 0.19'
|
25
|
+
spec.add_dependency 'savon', '~> 2.11'
|
26
|
+
|
27
|
+
spec.add_development_dependency "bundler", "~> 1.14"
|
28
|
+
spec.add_development_dependency "rake", "~> 10.0"
|
29
|
+
spec.add_development_dependency "rspec", "~> 3.0"
|
30
|
+
end
|
data/lib/bluecat.rb
ADDED
@@ -0,0 +1,46 @@
|
|
1
|
+
require "savon"
|
2
|
+
|
3
|
+
module Bluecat
|
4
|
+
class Client
|
5
|
+
def initialize(wsdl: '')
|
6
|
+
@client ||= Savon.client(wsdl: wsdl, ssl_verify_mode: :none)
|
7
|
+
end
|
8
|
+
|
9
|
+
def ops
|
10
|
+
@client.operations
|
11
|
+
end
|
12
|
+
|
13
|
+
def ip4_networks(container_id)
|
14
|
+
start = 0
|
15
|
+
count = 10
|
16
|
+
|
17
|
+
Enumerator.new do |yielder|
|
18
|
+
loop do
|
19
|
+
response = @client.call(:get_ip4_networks_by_hint, message: { container_id: container_id, start: start, count: count, options: '' }, cookies: @cookies)
|
20
|
+
retval = response.body[:get_ip4_networks_by_hint_response][:return]
|
21
|
+
|
22
|
+
raise StopIteration if retval == nil
|
23
|
+
|
24
|
+
# Last item will be hash if not more than one. Make it an array.
|
25
|
+
retval[:item] = [retval[:item]] unless retval[:item].is_a?(Array)
|
26
|
+
|
27
|
+
retval[:item].each do | item |
|
28
|
+
range = item[:properties].split('|')[0].split('=')[1]
|
29
|
+
yielder.yield({ id: item[:id], name: item[:name], ip_range: range })
|
30
|
+
end
|
31
|
+
|
32
|
+
start += count
|
33
|
+
end
|
34
|
+
end
|
35
|
+
end
|
36
|
+
|
37
|
+
def login(username, password)
|
38
|
+
response = @client.call(:login, message: { username: username, password: password })
|
39
|
+
@cookies = response.http.cookies
|
40
|
+
end
|
41
|
+
|
42
|
+
def logout
|
43
|
+
@client.call(:logout, cookies: @cookies)
|
44
|
+
end
|
45
|
+
end
|
46
|
+
end
|
metadata
CHANGED
@@ -1,12 +1,12 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: bluecat
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.1.
|
4
|
+
version: 0.1.1
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Dustin Wheeler
|
8
8
|
autorequire:
|
9
|
-
bindir:
|
9
|
+
bindir: bin
|
10
10
|
cert_chain: []
|
11
11
|
date: 2017-04-27 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
@@ -83,10 +83,25 @@ dependencies:
|
|
83
83
|
description: Use this gem to interact with the Bluecat Address Management SOAP API
|
84
84
|
email:
|
85
85
|
- mdwheele@ncsu.edu
|
86
|
-
executables:
|
86
|
+
executables:
|
87
|
+
- console
|
88
|
+
- setup
|
87
89
|
extensions: []
|
88
90
|
extra_rdoc_files: []
|
89
|
-
files:
|
91
|
+
files:
|
92
|
+
- ".gitignore"
|
93
|
+
- ".rspec"
|
94
|
+
- ".travis.yml"
|
95
|
+
- Gemfile
|
96
|
+
- LICENSE.txt
|
97
|
+
- README.md
|
98
|
+
- Rakefile
|
99
|
+
- bin/console
|
100
|
+
- bin/setup
|
101
|
+
- bluecat.gemspec
|
102
|
+
- lib/bluecat.rb
|
103
|
+
- lib/bluecat/client.rb
|
104
|
+
- lib/bluecat/version.rb
|
90
105
|
homepage: https://github.com/mdwheele/bluecat
|
91
106
|
licenses:
|
92
107
|
- MIT
|