infoblox 0.1.0 → 0.2.0

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.
data/README.md CHANGED
@@ -16,43 +16,28 @@ Or install it yourself as:
16
16
 
17
17
  $ gem install infoblox
18
18
 
19
- ## Command-line usage
20
- The infoblox gem installs a command-line script called "infoblox," which supports
21
- querying, adding, and removing host names from dns records:
22
-
23
- infoblox --help
24
-
25
-
26
- ## Ruby client usage
27
- The Client class has a few helper methods to make certain operations easier. Creating a host record:
28
-
29
- client = Infoblox::Client.new(:username => "foo",
30
- :password => "bar",
31
- :host => "https://foo-bar-dns.example.com")
32
-
33
-
34
- client.create_host("build-machine.internal", "10.10.3.3")
35
- client.delete_host("build-machine.internal")
36
- client.find_host_by_name("build-")
37
-
38
- One can also use the resource classes directly to run arbitrary query logic. An instance
39
- of the Infoblox::Connection class is necessary:
19
+ # Usage
20
+ An instance of the Infoblox::Connection class is necessary:
40
21
 
41
22
  connection = Infoblox::Connection.new(:username => '', :password => '', :host => '')
42
23
 
43
- Infoblox::Network.find(connection, {"_return_fields" => "extensible_attributes"})
24
+ Once a connection is made, one can use the resource class methods to query records:
25
+
26
+ Infoblox::Network.all(connection)
44
27
  # => [...]
45
28
 
46
29
  Infoblox::Host.find(connection, {"name~" => "demo[0-9]{1,}-web.domain"})
47
30
  # => [...]
48
31
 
49
- The Resource sub-classes also support `get`, `post`, `put`, and `delete`. For example, creating a network is pretty straightforward:
32
+ The resource class instances support `get`, `post`, `put`, and `delete`. For example, creating a network is pretty straightforward:
50
33
 
51
34
  network = Infoblox::Network.new(:connection => connection)
52
35
  network.network = "10.20.30.0/24"
53
36
  network.extensible_attributes = {"VLAN" => "my_vlan"}
54
37
  network.auto_create_reversezone = true
55
38
  network.post # true
39
+ network.network = "10.20.31.0/24"
40
+ network.put # true
56
41
 
57
42
  ## Contributing
58
43
 
data/lib/infoblox.rb CHANGED
@@ -6,7 +6,6 @@ require 'openssl'
6
6
  require 'infoblox/version'
7
7
  require 'infoblox/connection'
8
8
  require 'infoblox/resource'
9
- require 'infoblox/client'
10
9
  require 'infoblox/resource/cname'
11
10
  require 'infoblox/resource/host'
12
11
  require 'infoblox/resource/host_ipv4addr'
@@ -1,3 +1,3 @@
1
1
  module Infoblox
2
- VERSION = "0.1.0"
2
+ VERSION = "0.2.0"
3
3
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: infoblox
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.0
4
+ version: 0.2.0
5
5
  prerelease:
6
6
  platform: ruby
7
7
  authors:
@@ -110,8 +110,7 @@ dependencies:
110
110
  description: A Ruby wrapper to the Infoblox WAPI
111
111
  email:
112
112
  - billy.reisinger@govdelivery.com
113
- executables:
114
- - infoblox
113
+ executables: []
115
114
  extensions: []
116
115
  extra_rdoc_files: []
117
116
  files:
@@ -121,10 +120,8 @@ files:
121
120
  - LICENSE.txt
122
121
  - README.md
123
122
  - Rakefile
124
- - bin/infoblox
125
123
  - infoblox.gemspec
126
124
  - lib/infoblox.rb
127
- - lib/infoblox/client.rb
128
125
  - lib/infoblox/connection.rb
129
126
  - lib/infoblox/resource.rb
130
127
  - lib/infoblox/resource/cname.rb
data/bin/infoblox DELETED
@@ -1,56 +0,0 @@
1
- #!/usr/bin/env ruby
2
-
3
- require 'infoblox'
4
- require 'pp'
5
- require 'optparse'
6
-
7
- def print_host(*hosts)
8
- hosts.flatten.each do |h|
9
- puts "Host\t#{h.name}"
10
- puts "IP \t" + h.ipv4addrs.map{|i| i["ipv4addr"]}.join(",")
11
- puts "Ref \t" + h._ref
12
- end
13
- end
14
-
15
- options = {}
16
- OptionParser.new do |opts|
17
- opts.banner = "Usage: #{$0}.rb [options]"
18
- opts.on("-u", "--user USER", "username for infoblox") do |u|
19
- options[:username] = u
20
- end
21
- opts.on("-p", "--pass PASSWORD", "password for infoblox") do |p|
22
- options[:password] = p
23
- end
24
- opts.on("-f", "--find SEARCH", "find the specified hosts (fuzzy match) and print info") do |f|
25
- options[:find] = f
26
- end
27
- opts.on("-h", "--host INFOBLOX_HOST", "the hostname of the Infoblox appliance, including protocol") do |h|
28
- options[:host] = h
29
- end
30
- opts.on("-c", "--create HOST_AND_IP", "create the specified host. Supply the host and ip address, separated by a comma (no space).") do |c|
31
- options[:create] = c
32
- end
33
- opts.on("-d", "--delete HOST", "delete the specified host ") do |d|
34
- options[:delete] = d
35
- end
36
- opts.on("-v", "--[no-]verbose", "Run verbosely") do |v|
37
- options[:verbose] = v
38
- end
39
-
40
- end.parse!
41
-
42
- if options[:verbose]
43
- options[:logger] = Logger.new(STDOUT)
44
- end
45
-
46
- client = Infoblox::Client.new(options)
47
-
48
- if options[:find]
49
- print_host client.find_host_by_name(options[:find])
50
- end
51
- if options[:delete]
52
- print_host client.delete_host(options[:delete])
53
- end
54
- if options[:create]
55
- pp client.create_host(*options[:create].split(','))
56
- end
@@ -1,53 +0,0 @@
1
- module Infoblox
2
- class Client
3
- ##
4
- # :username
5
- # :password
6
- # :host (host if infoblox appliance, including protocol)
7
- def initialize(options={})
8
- self.connection = Connection.new(options)
9
- end
10
-
11
- def all_hosts
12
- Host.all(connection)
13
- end
14
-
15
- ##
16
- # Find all host records by wildcard name.
17
- #
18
- def find_host_by_name(name)
19
- Host.find(connection, :"name~" => name)
20
- end
21
-
22
- ##
23
- # Find all ipv4addr records by ip address fragment.
24
- # ex: find_ips('10.10.2') => [#<Infoblox::Ipv4addr>...]
25
- #
26
- def find_ips(ip_fragment)
27
- Ipv4addr.find(connection, :"ipv4addr~" => ip_fragment)
28
- end
29
-
30
- ##
31
- # Create a host record for the given IP address
32
- # hostname : string
33
- # ip : ipv4 string, i.e. "10.40.20.3"
34
- def create_host(hostname, ip, dns=true)
35
- host = Host.new(:name => hostname, :configure_for_dns => true, :connection => connection)
36
- host.add_ipv4addr(ip)
37
- host.create
38
- end
39
-
40
- ##
41
- # Remove all host entries for a given host
42
- #
43
- def delete_host(hostname)
44
- if !(hosts = Host.find(connection, :name => hostname)).empty?
45
- hosts.map(&:delete)
46
- hosts
47
- else
48
- raise Exception.new("host #{hostname} not found")
49
- false
50
- end
51
- end
52
- end
53
- end