openstack_activeresource 0.1.6 → 0.1.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.
data/VERSION
CHANGED
@@ -1 +1 @@
|
|
1
|
-
0.1.
|
1
|
+
0.1.7
|
@@ -20,7 +20,7 @@ module OpenStack
|
|
20
20
|
module Compute
|
21
21
|
|
22
22
|
class SecurityGroup < Base
|
23
|
-
self.element_name = "
|
23
|
+
self.element_name = "security_group"
|
24
24
|
self.collection_name = "os-security-groups"
|
25
25
|
|
26
26
|
schema do
|
@@ -35,7 +35,7 @@ module OpenStack
|
|
35
35
|
end
|
36
36
|
|
37
37
|
class SecurityGroup::Rule < Base
|
38
|
-
self.element_name = "
|
38
|
+
self.element_name = "security_group_rule"
|
39
39
|
self.collection_name = "os-security-group-rules"
|
40
40
|
|
41
41
|
schema do
|
@@ -67,13 +67,13 @@ module OpenStack
|
|
67
67
|
:ip_protocol => attributes[:ip_protocol],
|
68
68
|
:from_port => attributes[:from_port],
|
69
69
|
:to_port => attributes[:to_port],
|
70
|
-
:cidr => attributes[:cidr] || attributes[:ip_range][:cidr],
|
70
|
+
:cidr => attributes[:cidr] || (attributes[:ip_range].present? ? attributes[:ip_range][:cidr] : nil,
|
71
71
|
:parent_group_id => attributes[:parent_group].present? ? attributes[:parent_group].id : nil
|
72
72
|
}
|
73
73
|
super(new_attributes, persisted)
|
74
74
|
end
|
75
75
|
|
76
|
-
#
|
76
|
+
# Override ActiveRecord::encode method
|
77
77
|
# Custom encoding to deal with openstack API
|
78
78
|
def encode(options={})
|
79
79
|
to_encode = {
|
@@ -114,4 +114,3 @@ module OpenStack
|
|
114
114
|
end
|
115
115
|
end
|
116
116
|
end
|
117
|
-
|
@@ -83,9 +83,16 @@ module OpenStack
|
|
83
83
|
new_attributes[:flavor_id] = attributes[:flavor_id]
|
84
84
|
end
|
85
85
|
|
86
|
-
|
86
|
+
if persisted
|
87
|
+
# We ignore the list of security group names provided in attributes[:security_group]
|
88
|
+
# Security group ids will be retrieved when needed
|
89
|
+
new_attributes[:security_group_ids] = []
|
90
|
+
else
|
87
91
|
|
88
|
-
|
92
|
+
new_attributes[:security_group_ids] = attributes[:security_group_ids] || attributes[:security_groups].map { |sg| sg.id }
|
93
|
+
end
|
94
|
+
|
95
|
+
super(new_attributes, persisted)
|
89
96
|
|
90
97
|
self
|
91
98
|
end
|
@@ -104,7 +111,7 @@ module OpenStack
|
|
104
111
|
# Optional attributes (openstack will not accept empty attribute for update/create)
|
105
112
|
to_encode[:server][:user_data] = Base64.encode64(user_data) if user_data.present?
|
106
113
|
to_encode[:server][:key_name] = key_pair_id if key_pair_id.present?
|
107
|
-
to_encode[:server][:security_groups] =
|
114
|
+
to_encode[:server][:security_groups] = security_groups.map { |sg| {:name => sg.name} }
|
108
115
|
|
109
116
|
to_encode.send("to_#{self.class.format.extension}", options)
|
110
117
|
end
|
@@ -136,13 +143,19 @@ module OpenStack
|
|
136
143
|
end
|
137
144
|
|
138
145
|
def security_groups
|
139
|
-
|
146
|
+
if persisted?
|
147
|
+
get('os-security-groups').map { |sg| OpenStack::Nova::Compute::SecurityGroup.new(sg, true) }
|
148
|
+
else
|
149
|
+
security_group_ids.map { |sg_id| OpenStack::Nova::Compute::SecurityGroup.find sg_id }
|
150
|
+
end
|
140
151
|
end
|
141
152
|
|
142
153
|
def security_groups=(security_groups)
|
143
154
|
return if persisted? # Do Nothing (it's a read-only attribute for OpenStack)
|
144
155
|
|
145
|
-
|
156
|
+
security_group_ids = security_groups.map { |sg| sg.id }
|
157
|
+
|
158
|
+
security_groups
|
146
159
|
end
|
147
160
|
|
148
161
|
def addresses
|
@@ -283,29 +296,6 @@ module OpenStack
|
|
283
296
|
post(:action, {}, {:'resume' => nil}.to_json)
|
284
297
|
end
|
285
298
|
|
286
|
-
private
|
287
|
-
|
288
|
-
def get_security_groups
|
289
|
-
security_group_ids.map { |sg_id|
|
290
|
-
SecurityGroup.find sg_id
|
291
|
-
}
|
292
|
-
end
|
293
|
-
|
294
|
-
def get_security_group_ids(security_groups=nil)
|
295
|
-
if security_groups.nil?
|
296
|
-
if persisted?
|
297
|
-
|
298
|
-
get('os-security-groups').map { |security_group| security_group.with_indifferent_access[:id] }
|
299
|
-
else
|
300
|
-
|
301
|
-
[]
|
302
|
-
end
|
303
|
-
else
|
304
|
-
|
305
|
-
security_groups.map { |security_group| security_group.id }
|
306
|
-
end
|
307
|
-
end
|
308
|
-
|
309
299
|
end
|
310
300
|
|
311
301
|
end
|
@@ -5,11 +5,11 @@
|
|
5
5
|
|
6
6
|
Gem::Specification.new do |s|
|
7
7
|
s.name = "openstack_activeresource"
|
8
|
-
s.version = "0.1.
|
8
|
+
s.version = "0.1.7"
|
9
9
|
|
10
10
|
s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version=
|
11
11
|
s.authors = ["Davide Guerri"]
|
12
|
-
s.date = "2013-01-
|
12
|
+
s.date = "2013-01-07"
|
13
13
|
s.description = "OpenStack Ruby and RoR bindings implemented with ActiveResource - See also http://www.unicloud.it"
|
14
14
|
s.email = "d.guerri@unidata.it"
|
15
15
|
s.extra_rdoc_files = [
|
metadata
CHANGED
@@ -2,7 +2,7 @@
|
|
2
2
|
name: openstack_activeresource
|
3
3
|
version: !ruby/object:Gem::Version
|
4
4
|
prerelease:
|
5
|
-
version: 0.1.
|
5
|
+
version: 0.1.7
|
6
6
|
platform: ruby
|
7
7
|
authors:
|
8
8
|
- Davide Guerri
|
@@ -10,7 +10,7 @@ autorequire:
|
|
10
10
|
bindir: bin
|
11
11
|
cert_chain: []
|
12
12
|
|
13
|
-
date: 2013-01-
|
13
|
+
date: 2013-01-07 00:00:00 Z
|
14
14
|
dependencies:
|
15
15
|
- !ruby/object:Gem::Dependency
|
16
16
|
name: activemodel
|
@@ -170,7 +170,7 @@ required_ruby_version: !ruby/object:Gem::Requirement
|
|
170
170
|
requirements:
|
171
171
|
- - ">="
|
172
172
|
- !ruby/object:Gem::Version
|
173
|
-
hash:
|
173
|
+
hash: 3406496553585609494
|
174
174
|
segments:
|
175
175
|
- 0
|
176
176
|
version: "0"
|