openstack_activeresource 0.6.3 → 0.7.0
Sign up to get free protection for your applications and to get access to all the features.
- data/VERSION +1 -1
- data/lib/open_stack/nova/compute/flavor.rb +29 -8
- data/openstack_activeresource.gemspec +2 -2
- data/test/test_nova_flavors.rb +12 -0
- metadata +3 -3
data/VERSION
CHANGED
@@ -1 +1 @@
|
|
1
|
-
0.
|
1
|
+
0.7.0
|
@@ -125,14 +125,24 @@ module OpenStack
|
|
125
125
|
# Returns a list of Flavor that can be used with the given constraints
|
126
126
|
#
|
127
127
|
# ==== Attributes
|
128
|
-
# * +constraints+ - Hash of constraints. Valid keys are: :
|
128
|
+
# * +constraints+ - Hash of constraints. Valid keys are: :min_ram, :min_vcpus, :min_disk, :max_ram, :max_vcpus, :max_disk
|
129
129
|
def self.find_by_constraints(constraints = {})
|
130
130
|
constraints = constraints.with_indifferent_access
|
131
|
-
constraints[:
|
132
|
-
constraints[:
|
133
|
-
constraints[:
|
134
|
-
|
135
|
-
|
131
|
+
constraints[:min_ram] ||= -1.0/0.0
|
132
|
+
constraints[:min_vcpus] ||= -1.0/0.0
|
133
|
+
constraints[:min_disk] ||= -1.0/0.0
|
134
|
+
constraints[:max_ram] ||= +1.0/0.0
|
135
|
+
constraints[:max_vcpus] ||= +1.0/0.0
|
136
|
+
constraints[:max_disk] ||= +1.0/0.0
|
137
|
+
|
138
|
+
self.all.select do |flavor|
|
139
|
+
flavor.ram >= constraints[:min_ram] and
|
140
|
+
flavor.vcpus >= constraints[:min_vcpus] and
|
141
|
+
flavor.disk >= constraints[:min_disk] and
|
142
|
+
flavor.ram <= constraints[:max_ram] and
|
143
|
+
flavor.vcpus <= constraints[:max_vcpus] and
|
144
|
+
flavor.disk <= constraints[:max_disk]
|
145
|
+
end
|
136
146
|
end
|
137
147
|
|
138
148
|
# Returns a list of Flavor that can be used with the given Image
|
@@ -143,8 +153,19 @@ module OpenStack
|
|
143
153
|
image_instance = image.is_a?(OpenStack::Nova::Compute::Image) ? image : Image.find(image)
|
144
154
|
|
145
155
|
constraints = {}
|
146
|
-
constraints[:
|
147
|
-
constraints[:
|
156
|
+
constraints[:min_ram] = image.min_ram if image_instance.min_ram > 0
|
157
|
+
constraints[:min_disk] = image.min_disk if image_instance.min_disk > 0
|
158
|
+
|
159
|
+
find_by_constraints constraints
|
160
|
+
end
|
161
|
+
|
162
|
+
# Returns a list of Flavor that can be used with the given quota-set
|
163
|
+
#
|
164
|
+
# ==== Attributes
|
165
|
+
# * +quota_set+ - An OpenStack::Nova::Compute::QuotaSet instance
|
166
|
+
def self.applicable_for_quota_set(quota_set)
|
167
|
+
constraints = {}
|
168
|
+
constraints[:max_ram] = quota_set.ram
|
148
169
|
|
149
170
|
find_by_constraints constraints
|
150
171
|
end
|
@@ -5,11 +5,11 @@
|
|
5
5
|
|
6
6
|
Gem::Specification.new do |s|
|
7
7
|
s.name = "openstack_activeresource"
|
8
|
-
s.version = "0.
|
8
|
+
s.version = "0.7.0"
|
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-06-
|
12
|
+
s.date = "2013-06-25"
|
13
13
|
s.description = "OpenStack Ruby and RoR bindings implemented with ActiveResource - See also http://www.unicloud.it"
|
14
14
|
s.email = "d.guerri@rd.unidata.it"
|
15
15
|
s.extra_rdoc_files = [
|
data/test/test_nova_flavors.rb
CHANGED
@@ -49,6 +49,18 @@ class TestOpenStackActiveResource < Test::Unit::TestCase
|
|
49
49
|
assert_not_nil flavor, "Cannot retrieve flavor"
|
50
50
|
end
|
51
51
|
|
52
|
+
assert_nothing_raised ActiveResource::ResourceNotFound, "Cannot get flavors applicable for an image" do
|
53
|
+
image = OpenStack::Nova::Compute::Image.first
|
54
|
+
flavors = OpenStack::Nova::Compute::Flavor.applicable_for_image image
|
55
|
+
assert_not_empty flavors, "Cannot retrieve flavors applicable for an image"
|
56
|
+
end
|
57
|
+
|
58
|
+
assert_nothing_raised ActiveResource::ResourceNotFound, "Cannot get flavors applicable for quota-set" do
|
59
|
+
quota_set = OpenStack::Nova::Compute::QuotaSet.find TEST_CONFIG[:user_tenant_id]
|
60
|
+
flavors = OpenStack::Nova::Compute::Flavor.applicable_for_quota_set quota_set
|
61
|
+
assert_not_empty flavors, "Cannot retrieve flavors applicable for quota-set"
|
62
|
+
end
|
63
|
+
|
52
64
|
return unless admin_test_possible?
|
53
65
|
|
54
66
|
auth_admin
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: openstack_activeresource
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.
|
4
|
+
version: 0.7.0
|
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-06-
|
12
|
+
date: 2013-06-25 00:00:00.000000000 Z
|
13
13
|
dependencies:
|
14
14
|
- !ruby/object:Gem::Dependency
|
15
15
|
name: activemodel
|
@@ -239,7 +239,7 @@ required_ruby_version: !ruby/object:Gem::Requirement
|
|
239
239
|
version: '0'
|
240
240
|
segments:
|
241
241
|
- 0
|
242
|
-
hash:
|
242
|
+
hash: -166848849655330033
|
243
243
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
244
244
|
none: false
|
245
245
|
requirements:
|