Class: OpenStack::Compute::Flavor

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

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(compute, id) ⇒ Flavor

This class provides an object for the “Flavor” of a server. The Flavor can generally be taken as the server specification, providing information on things like memory and disk space.

The disk attribute is an integer representing the disk space in GB. The memory attribute is an integer representing the RAM in MB.

This is called from the get_flavor method on a OpenStack::Compute::Connection object, returns a OpenStack::Compute::Flavor object, and will likely not be called directly.

>> flavor = cs.get_flavor(1)
=> #<OpenStack::Compute::Flavor:0x1014f8bc8 @name="256 server", @disk=10, @id=1, @ram=256>
>> flavor.name
=> "256 server"


22
23
24
25
26
27
28
29
30
31
# File 'lib/openstack/compute/flavor.rb', line 22

def initialize(compute,id)
  response = compute.connection.csreq("GET",compute.connection.service_host,"#{compute.connection.service_path}/flavors/#{URI.escape(id.to_s)}",compute.connection.service_port,compute.connection.service_scheme)
  OpenStack::Exception.raise_exception(response) unless response.code.match(/^20.$/)
  data = JSON.parse(response.body)['flavor']
  @id   = data['id']
  @name = data['name']
  @ram  = data['ram']
  @disk = data['disk']
  @vcpus = data['vcpus']
end

Instance Attribute Details

#diskObject (readonly)

Returns the value of attribute disk.



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

def disk
  @disk
end

#idObject (readonly)

Returns the value of attribute id.



5
6
7
# File 'lib/openstack/compute/flavor.rb', line 5

def id
  @id
end

#nameObject (readonly)

Returns the value of attribute name.



6
7
8
# File 'lib/openstack/compute/flavor.rb', line 6

def name
  @name
end

#ramObject (readonly)

Returns the value of attribute ram.



7
8
9
# File 'lib/openstack/compute/flavor.rb', line 7

def ram
  @ram
end

#vcpusObject (readonly)

Returns the value of attribute vcpus.



9
10
11
# File 'lib/openstack/compute/flavor.rb', line 9

def vcpus
  @vcpus
end