Class: ComputeFlavors
- Inherits:
-
Object
- Object
- ComputeFlavors
- Defined in:
- lib/danarchy_sys/openstack/compute/flavors.rb
Overview
OpenStack Flavor Management
Instance Method Summary collapse
- #all_flavors(*filter) ⇒ Object
- #get_flavor_by_id(flavor_id) ⇒ Object
- #get_flavor_by_name(flavor_name) ⇒ Object
-
#initialize(compute, flavors) ⇒ ComputeFlavors
constructor
A new instance of ComputeFlavors.
Constructor Details
#initialize(compute, flavors) ⇒ ComputeFlavors
Returns a new instance of ComputeFlavors.
4 5 6 7 |
# File 'lib/danarchy_sys/openstack/compute/flavors.rb', line 4 def initialize(compute, flavors) @compute = compute @flavors = flavors end |
Instance Method Details
#all_flavors(*filter) ⇒ Object
9 10 11 12 |
# File 'lib/danarchy_sys/openstack/compute/flavors.rb', line 9 def all_flavors(*filter) filter = filter.shift || {'status' => ['ACTIVE']} @flavors = @compute.flavors(filters: filter) end |
#get_flavor_by_id(flavor_id) ⇒ Object
20 21 22 23 24 |
# File 'lib/danarchy_sys/openstack/compute/flavors.rb', line 20 def get_flavor_by_id(flavor_id) @flavors.collect do |i| i if i.id == flavor_id end.compact!.first end |
#get_flavor_by_name(flavor_name) ⇒ Object
14 15 16 17 18 |
# File 'lib/danarchy_sys/openstack/compute/flavors.rb', line 14 def get_flavor_by_name(flavor_name) @flavors.collect do |f| f if f.name.end_with?(flavor_name) end.compact!.first end |