infoblox 0.0.8 → 0.0.9
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/lib/infoblox/resource.rb +20 -2
- data/lib/infoblox/resource/network.rb +2 -1
- data/lib/infoblox/resource/network_container.rb +2 -1
- data/lib/infoblox/version.rb +1 -1
- data/spec/resource_spec.rb +28 -13
- metadata +1 -1
data/lib/infoblox/resource.rb
CHANGED
@@ -17,6 +17,17 @@ module Infoblox
|
|
17
17
|
end
|
18
18
|
end
|
19
19
|
|
20
|
+
##
|
21
|
+
# Define a remote attribute that can only be sent during a
|
22
|
+
# POST operation.
|
23
|
+
#
|
24
|
+
def self.remote_post_accessor(*args)
|
25
|
+
args.each do |a|
|
26
|
+
attr_accessor a
|
27
|
+
remote_post_attrs << a
|
28
|
+
end
|
29
|
+
end
|
30
|
+
|
20
31
|
##
|
21
32
|
# Define a remote attribute that is write-only
|
22
33
|
#
|
@@ -35,6 +46,10 @@ module Infoblox
|
|
35
46
|
@remote_write_only_attrs ||= []
|
36
47
|
end
|
37
48
|
|
49
|
+
def self.remote_post_attrs
|
50
|
+
@remote_post_attrs ||= []
|
51
|
+
end
|
52
|
+
|
38
53
|
def self._return_fields
|
39
54
|
self.remote_attrs.join(",")
|
40
55
|
end
|
@@ -87,7 +102,7 @@ module Infoblox
|
|
87
102
|
end
|
88
103
|
|
89
104
|
def post
|
90
|
-
self._ref = connection.post(resource_uri, remote_attribute_hash(write = true)).body
|
105
|
+
self._ref = connection.post(resource_uri, remote_attribute_hash(write = true, post = true)).body
|
91
106
|
true
|
92
107
|
end
|
93
108
|
alias_method :create, :post
|
@@ -108,7 +123,7 @@ module Infoblox
|
|
108
123
|
self._ref.nil? ? self.class.resource_uri : (BASE_PATH + self._ref)
|
109
124
|
end
|
110
125
|
|
111
|
-
def remote_attribute_hash(write=false)
|
126
|
+
def remote_attribute_hash(write=false, post=false)
|
112
127
|
{}.tap do |hsh|
|
113
128
|
self.class.remote_attrs.each do |k|
|
114
129
|
hsh[k] = self.send(k)
|
@@ -116,6 +131,9 @@ module Infoblox
|
|
116
131
|
self.class.remote_write_only_attrs.each do |k|
|
117
132
|
hsh[k] = self.send(k)
|
118
133
|
end if write
|
134
|
+
self.class.remote_post_attrs.each do |k|
|
135
|
+
hsh[k] = self.send(k)
|
136
|
+
end if post
|
119
137
|
end
|
120
138
|
end
|
121
139
|
|
@@ -1,7 +1,8 @@
|
|
1
1
|
module Infoblox
|
2
2
|
class Network < Resource
|
3
3
|
remote_attr_accessor :network, :extensible_attributes
|
4
|
-
|
4
|
+
remote_post_accessor :auto_create_reversezone
|
5
|
+
|
5
6
|
attr_accessor :network_view, :network_container
|
6
7
|
|
7
8
|
wapi_object "network"
|
@@ -1,7 +1,8 @@
|
|
1
1
|
module Infoblox
|
2
2
|
class NetworkContainer < Resource
|
3
3
|
remote_attr_accessor :network, :extensible_attributes
|
4
|
-
|
4
|
+
remote_post_accessor :auto_create_reversezone
|
5
|
+
|
5
6
|
attr_accessor :network_view
|
6
7
|
|
7
8
|
wapi_object "networkcontainer"
|
data/lib/infoblox/version.rb
CHANGED
data/spec/resource_spec.rb
CHANGED
@@ -2,6 +2,8 @@ require 'spec_helper'
|
|
2
2
|
class FooResource < Infoblox::Resource
|
3
3
|
remote_attr_accessor :name, :junction
|
4
4
|
remote_attr_writer :do_it
|
5
|
+
remote_post_accessor :sect
|
6
|
+
|
5
7
|
attr_accessor :animal
|
6
8
|
wapi_object "foo:animal"
|
7
9
|
end
|
@@ -34,19 +36,32 @@ describe Infoblox::Resource, "#add_ipv4addr" do
|
|
34
36
|
FooResource.all.should eq([])
|
35
37
|
end
|
36
38
|
|
37
|
-
|
38
|
-
|
39
|
-
|
40
|
-
|
41
|
-
|
42
|
-
|
43
|
-
|
44
|
-
|
45
|
-
|
46
|
-
|
47
|
-
|
48
|
-
|
49
|
-
|
39
|
+
it "should put with the right attributes" do
|
40
|
+
conn = double
|
41
|
+
uri = Infoblox::BASE_PATH + "abcd"
|
42
|
+
allow(conn).to receive(:put).with(uri, {:name => "jerry", :junction => "32", :do_it => false}).and_return(FooResponse.new("[]"))
|
43
|
+
FooResource.connection = conn
|
44
|
+
f = FooResource.new
|
45
|
+
f._ref = "abcd"
|
46
|
+
f.do_it = false
|
47
|
+
f.junction = "32"
|
48
|
+
f.name = "jerry"
|
49
|
+
f.sect = :fulburns
|
50
|
+
f.put
|
51
|
+
end
|
52
|
+
|
53
|
+
it "should post with the right attributes" do
|
54
|
+
conn = double
|
55
|
+
uri = Infoblox::BASE_PATH + "foo:animal"
|
56
|
+
allow(conn).to receive(:post).with(uri, {:name => "jerry", :junction => "32", :do_it => false, :sect => :fulburns}).and_return(FooResponse.new("abcdefg"))
|
57
|
+
FooResource.connection = conn
|
58
|
+
f = FooResource.new
|
59
|
+
f.do_it = false
|
60
|
+
f.junction = "32"
|
61
|
+
f.name = "jerry"
|
62
|
+
f.sect = :fulburns
|
63
|
+
f.post
|
64
|
+
f._ref.should eq('abcdefg')
|
50
65
|
end
|
51
66
|
end
|
52
67
|
|