Class: ComputeFlavors

Inherits:
Object
  • Object
show all
Defined in:
lib/danarchy_sys/openstack/compute/flavors.rb

Overview

OpenStack Flavor Management

Instance Method Summary collapse

Constructor Details

#initialize(compute) ⇒ ComputeFlavors

Returns a new instance of ComputeFlavors.



4
5
6
# File 'lib/danarchy_sys/openstack/compute/flavors.rb', line 4

def initialize(compute)
  @compute = compute
end

Instance Method Details

#all_flavorsObject



8
9
10
# File 'lib/danarchy_sys/openstack/compute/flavors.rb', line 8

def all_flavors
  @compute.flavors
end

#get_flavor(flavor_name) ⇒ Object



24
25
26
27
28
29
30
31
32
33
34
# File 'lib/danarchy_sys/openstack/compute/flavors.rb', line 24

def get_flavor(flavor_name)
  flavors = all_flavors

  # Get flavor object based on input flavor_name.
  flavor = 'nil'
  flavors.each do |f|
    flavor = f if f.name.end_with?(flavor_name)
  end

  flavor
end

#get_flavor_by_id(flavor_id) ⇒ Object



36
37
38
39
40
41
42
43
44
45
46
# File 'lib/danarchy_sys/openstack/compute/flavors.rb', line 36

def get_flavor_by_id(flavor_id)
  flavors = all_flavors

  # Get flavor based on input flavor_id.
  flavor = 'nil'
  flavors.each do |i|
    flavor = i if i.id == flavor_id
  end

  flavor
end

#list_flavorsObject



12
13
14
15
16
17
18
19
20
21
22
# File 'lib/danarchy_sys/openstack/compute/flavors.rb', line 12

def list_flavors
  flavors = all_flavors
  flavor_list = []

  # Get flavor names into array
  flavors.each do |i|
    flavor_list.push(i.name.split('.')[1])
  end

  flavor_list
end