Update the Linode avail_linodeplans request and Flavor model.

- Add transfer, price_hourly and available attributes to Flavor.
- Add an HOURLY attribute to the mock.
- Update the data center ids in the mock AVAIL attribute.
This commit is contained in:
Phil Ross 2015-10-24 23:05:44 +01:00
parent cb96248d6c
commit ddf26cc438
4 changed files with 25 additions and 10 deletions

View File

@ -8,8 +8,11 @@ module Fog
attribute :disk
attribute :name
attribute :ram
attribute :transfer
attribute :price
attribute :price_hourly
attribute :cores
attribute :available
def bits
0 # these are determined by images you select not the hardware

View File

@ -24,7 +24,14 @@ module Fog
def map_flavor(flavor)
flavor = flavor.each_with_object({}) { |(k, v), h| h[k.downcase.to_sym] = v }
flavor.merge! :id => flavor[:planid], :name => flavor[:label]
flavor.merge! :id => flavor[:planid], :name => flavor[:label],
:transfer => flavor[:xfer], :price_hourly => flavor[:hourly],
:available => map_available(flavor[:avail])
end
def map_available(available)
return nil unless available
available.each_with_object({}) { |(k, v), h| h[k.to_i] = v }
end
end
end

View File

@ -56,8 +56,10 @@ module Fog
"DISK" => 20,
"CORES" => 1,
"AVAIL" => {
"3"=>48, "2"=>207, "7"=>161, "6"=>143, "4"=>108, "8"=>60
}
"2" => 500, "3" => 500, "4" => 500, "6" => 500, "7" => 500,
"8" => 500, "9" => 500, "10" => 500
},
"HOURLY" => 0.03
}
end
end

View File

@ -3,12 +3,14 @@ Shindo.tests('Fog::Compute[:linode] | linodeplans requests', ['linode']) do
@linodeplans_format = Linode::Compute::Formats::BASIC.merge({
'DATA' => [{
'AVAIL' => {
'2' => Integer,
'3' => Integer,
'4' => Integer,
'6' => Integer,
'7' => Integer,
'8' => Integer
'2' => Integer,
'3' => Integer,
'4' => Integer,
'6' => Integer,
'7' => Integer,
'8' => Integer,
'9' => Integer,
'10' => Integer
},
'DISK' => Integer,
'PLANID' => Integer,
@ -16,7 +18,8 @@ Shindo.tests('Fog::Compute[:linode] | linodeplans requests', ['linode']) do
'RAM' => Integer,
'LABEL' => String,
'XFER' => Integer,
'CORES' => Integer
'CORES' => Integer,
'HOURLY' => Float
}]
})