mirror of
https://github.com/fog/fog.git
synced 2022-11-09 13:51:43 -05:00
started linode models
This commit is contained in:
parent
8a25dd46dd
commit
1d172b85b3
7 changed files with 64 additions and 0 deletions
|
@ -7,6 +7,12 @@ module Fog
|
|||
recognizes :provider # remove post deprecation
|
||||
|
||||
model_path 'fog/compute/models/linode'
|
||||
model :flavor
|
||||
collection :flavors
|
||||
model :image
|
||||
collection :images
|
||||
model :server
|
||||
collection :servers
|
||||
|
||||
request_path 'fog/compute/requests/linode'
|
||||
request :avail_datacenters
|
||||
|
|
24
lib/fog/compute/models/linode/flavor.rb
Normal file
24
lib/fog/compute/models/linode/flavor.rb
Normal file
|
@ -0,0 +1,24 @@
|
|||
require 'fog/core/model'
|
||||
|
||||
module Fog
|
||||
module Linode
|
||||
class Compute
|
||||
class Flavor < Fog::Model
|
||||
identity :id
|
||||
|
||||
attribute :disk
|
||||
attribute :name
|
||||
attribute :ram
|
||||
attribute :price
|
||||
|
||||
def cores
|
||||
4 # linode always has 4 cores
|
||||
end
|
||||
|
||||
def bits
|
||||
0 # these are determined by images you select not the hardware
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
34
lib/fog/compute/models/linode/flavors.rb
Normal file
34
lib/fog/compute/models/linode/flavors.rb
Normal file
|
@ -0,0 +1,34 @@
|
|||
require 'fog/core/collection'
|
||||
require 'fog/compute/models/linode/flavor'
|
||||
|
||||
module Fog
|
||||
module Linode
|
||||
class Compute
|
||||
|
||||
class Flavors < Fog::Collection
|
||||
|
||||
model Fog::Linode::Compute::Flavor
|
||||
|
||||
def all
|
||||
load flavors
|
||||
end
|
||||
|
||||
def get(id)
|
||||
new flavors(id).first
|
||||
rescue Fog::Linode::Compute::NotFound
|
||||
nil
|
||||
end
|
||||
|
||||
private
|
||||
def flavors(flavor_id=nil)
|
||||
connection.avail_linodeplans(flavor_id).body['DATA'].tap { |data| map_flavors data }
|
||||
end
|
||||
|
||||
def map_flavors(flavors)
|
||||
flavors.map! { |flavor| flavor.each_with_object({}) { |(k, v), h| h[k.downcase.to_sym] = v } }
|
||||
flavors.each { |flavor| flavor.merge! :name => flavor[:label], :id => flavor[:planid] }
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
0
lib/fog/compute/models/linode/image.rb
Normal file
0
lib/fog/compute/models/linode/image.rb
Normal file
0
lib/fog/compute/models/linode/images.rb
Normal file
0
lib/fog/compute/models/linode/images.rb
Normal file
0
lib/fog/compute/models/linode/server.rb
Normal file
0
lib/fog/compute/models/linode/server.rb
Normal file
0
lib/fog/compute/models/linode/servers.rb
Normal file
0
lib/fog/compute/models/linode/servers.rb
Normal file
Loading…
Reference in a new issue