infoblox 0.0.2 → 0.0.3

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.
@@ -8,6 +8,8 @@ require 'infoblox/connection'
8
8
  require 'infoblox/resource'
9
9
  require 'infoblox/host'
10
10
  require 'infoblox/client'
11
+ require 'infoblox/ipv4addr'
12
+ require 'infoblox/network'
11
13
 
12
14
  module Infoblox
13
15
  WAPI_VERSION = '1.0'
@@ -12,10 +12,21 @@ module Infoblox
12
12
  Host.all
13
13
  end
14
14
 
15
+ ##
16
+ # Find all host records by wildcard name.
17
+ #
15
18
  def find_host_by_name(name)
16
19
  Host.find(:"name~" => name)
17
20
  end
18
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(:"ipv4addr~" => ip_fragment)
28
+ end
29
+
19
30
  ##
20
31
  # hostname : string
21
32
  # ip : ipv4 string, i.e. "10.40.20.3"
@@ -5,9 +5,18 @@ module Infoblox
5
5
 
6
6
  wapi_object "record:host"
7
7
 
8
+ def ipv4addrs=(attrs=[])
9
+ attrs.each do |att|
10
+ ipv4addrs << Ipv4addr.new(att)
11
+ end
12
+ end
13
+
8
14
  def add_ipv4addr(address)
15
+ ipv4addrs << Ipv4addr.new(:ipv4addr => address)
16
+ end
17
+
18
+ def ipv4addrs
9
19
  @ipv4addrs ||= []
10
- @ipv4addrs << {:ipv4addr => address}
11
20
  end
12
21
  end
13
22
  end
@@ -0,0 +1,8 @@
1
+ module Infoblox
2
+ class Ipv4addr < Resource
3
+ remote_attr_accessor :ipv4addr, :configure_for_dhcp
4
+ attr_accessor :network, :host
5
+
6
+ wapi_object "record:host_ipv4addr"
7
+ end
8
+ end
@@ -0,0 +1,12 @@
1
+ module Infoblox
2
+ class Network < Resource
3
+ remote_attr_accessor :network
4
+ attr_accessor :network_view
5
+
6
+ wapi_object "network"
7
+
8
+ def next_available_ip(num=1)
9
+ JSON.parse(connection.post(resource_uri + "?_function=next_available_ip&num=#{num}", {}).body)["ips"]
10
+ end
11
+ end
12
+ end
@@ -56,12 +56,14 @@ module Infoblox
56
56
  connection.delete(resource_uri).status == 200
57
57
  end
58
58
 
59
+ def get
60
+ connection.get(resource_uri)
61
+ end
62
+
59
63
  def resource_uri
60
64
  self._ref.nil? ? self.class.resource_uri : (BASE_PATH + self._ref)
61
65
  end
62
66
 
63
- private
64
-
65
67
  def remote_attribute_hash
66
68
  {}.tap do |hsh|
67
69
  self.class.remote_attrs.each do |k|
@@ -70,6 +72,8 @@ module Infoblox
70
72
  end
71
73
  end
72
74
 
75
+ private
76
+
73
77
  def connection
74
78
  self.class.connection
75
79
  end
@@ -1,3 +1,3 @@
1
1
  module Infoblox
2
- VERSION = "0.0.2"
2
+ VERSION = "0.0.3"
3
3
  end
@@ -4,7 +4,8 @@ describe Infoblox::Host, "#add_ipv4addr" do
4
4
  host = Infoblox::Host.new
5
5
  host.add_ipv4addr("10.10.10.10")
6
6
  host.add_ipv4addr("10.10.10.12")
7
- host.ipv4addrs.should eq([{:ipv4addr => "10.10.10.10"}, {:ipv4addr => "10.10.10.12"}])
7
+ host.ipv4addrs[0].should be_a(Infoblox::Ipv4addr)
8
+ host.ipv4addrs[0].ipv4addr.should eq("10.10.10.10")
8
9
  end
9
10
  end
10
11
 
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.0.2
4
+ version: 0.0.3
5
5
  prerelease:
6
6
  platform: ruby
7
7
  authors:
@@ -9,7 +9,7 @@ authors:
9
9
  autorequire:
10
10
  bindir: bin
11
11
  cert_chain: []
12
- date: 2013-08-14 00:00:00.000000000 Z
12
+ date: 2013-08-20 00:00:00.000000000 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: faraday
@@ -127,6 +127,8 @@ files:
127
127
  - lib/infoblox/client.rb
128
128
  - lib/infoblox/connection.rb
129
129
  - lib/infoblox/host.rb
130
+ - lib/infoblox/ipv4addr.rb
131
+ - lib/infoblox/network.rb
130
132
  - lib/infoblox/resource.rb
131
133
  - lib/infoblox/version.rb
132
134
  - spec/host_spec.rb