class ComputeFlavors

OpenStack Flavor Management

Public Class Methods

new(compute, flavors) click to toggle source
# File lib/danarchy_sys/openstack/compute/flavors.rb, line 4
def initialize(compute, flavors)
  @compute = compute
  @flavors = flavors
end

Public Instance Methods

all_flavors(*filter) click to toggle source
# 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) click to toggle source
# 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) click to toggle source
# 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