Class: OpenStack::Compute::Flavor
- Inherits:
-
Object
- Object
- OpenStack::Compute::Flavor
- Defined in:
- lib/openstack/compute/flavor.rb
Instance Attribute Summary collapse
-
#disk ⇒ Object
readonly
Returns the value of attribute disk.
-
#id ⇒ Object
readonly
Returns the value of attribute id.
-
#name ⇒ Object
readonly
Returns the value of attribute name.
-
#ram ⇒ Object
readonly
Returns the value of attribute ram.
-
#vcpus ⇒ Object
readonly
Returns the value of attribute vcpus.
Instance Method Summary collapse
-
#initialize(compute, id) ⇒ Flavor
constructor
This class provides an object for the “Flavor” of a server.
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
#disk ⇒ Object (readonly)
Returns the value of attribute disk.
8 9 10 |
# File 'lib/openstack/compute/flavor.rb', line 8 def disk @disk end |
#id ⇒ Object (readonly)
Returns the value of attribute id.
5 6 7 |
# File 'lib/openstack/compute/flavor.rb', line 5 def id @id end |
#name ⇒ Object (readonly)
Returns the value of attribute name.
6 7 8 |
# File 'lib/openstack/compute/flavor.rb', line 6 def name @name end |
#ram ⇒ Object (readonly)
Returns the value of attribute ram.
7 8 9 |
# File 'lib/openstack/compute/flavor.rb', line 7 def ram @ram end |
#vcpus ⇒ Object (readonly)
Returns the value of attribute vcpus.
9 10 11 |
# File 'lib/openstack/compute/flavor.rb', line 9 def vcpus @vcpus end |