openstack_activeresource 0.6.3 → 0.7.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/VERSION CHANGED
@@ -1 +1 @@
1
- 0.6.3
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: :ram, :vcpus, :disk
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[:ram] ||= -1.0/0.0
132
- constraints[:vcpus] ||= -1.0/0.0
133
- constraints[:disk] ||= -1.0/0.0
134
-
135
- self.all.select { |flavor| flavor.ram >= constraints[:ram] and flavor.vcpus >= constraints[:vcpus] and flavor.disk >= constraints[:disk] }
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[:ram] = image.min_ram if image_instance.min_ram > 0
147
- constraints[:disk] = image.min_disk if image_instance.min_disk > 0
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.6.3"
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-14"
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 = [
@@ -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.6.3
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-14 00:00:00.000000000 Z
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: 4007087770125427657
242
+ hash: -166848849655330033
243
243
  required_rubygems_version: !ruby/object:Gem::Requirement
244
244
  none: false
245
245
  requirements: