mirror of
https://github.com/fog/fog.git
synced 2022-11-09 13:51:43 -05:00
added kernel modes
This commit is contained in:
parent
b26732a74e
commit
6fb039d3e8
5 changed files with 51 additions and 6 deletions
|
@ -13,6 +13,8 @@ module Fog
|
|||
collection :images
|
||||
model :server
|
||||
collection :servers
|
||||
model :kernel
|
||||
collection :kernels
|
||||
|
||||
request_path 'fog/compute/requests/linode'
|
||||
request :avail_datacenters
|
||||
|
|
|
@ -7,12 +7,7 @@ module Fog
|
|||
identity :id
|
||||
attribute :name
|
||||
attribute :bits
|
||||
attribute :kernel_id
|
||||
attribute :image_size
|
||||
|
||||
def kernel
|
||||
Kernel.populate kernel_id
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
|
|
12
lib/fog/compute/models/linode/kernel.rb
Normal file
12
lib/fog/compute/models/linode/kernel.rb
Normal file
|
@ -0,0 +1,12 @@
|
|||
require 'fog/core/model'
|
||||
|
||||
module Fog
|
||||
module Linode
|
||||
class Compute
|
||||
class Kernel < Fog::Model
|
||||
identity :id
|
||||
attribute :name
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
32
lib/fog/compute/models/linode/kernels.rb
Normal file
32
lib/fog/compute/models/linode/kernels.rb
Normal file
|
@ -0,0 +1,32 @@
|
|||
require 'fog/core/collection'
|
||||
require 'fog/compute/models/linode/kernel'
|
||||
|
||||
module Fog
|
||||
module Linode
|
||||
class Compute
|
||||
class Kernels < Fog::Collection
|
||||
model Fog::Linode::Compute::Kernel
|
||||
|
||||
def all
|
||||
load kernels
|
||||
end
|
||||
|
||||
def get(id)
|
||||
new kernels(id).first
|
||||
rescue Fog::Linode::Compute::NotFound
|
||||
nil
|
||||
end
|
||||
|
||||
private
|
||||
def kernels(id=nil)
|
||||
connection.avail_kernels(id).body['DATA'].tap { |data| map_kernels data }
|
||||
end
|
||||
|
||||
def map_kernels(kernels)
|
||||
kernels.map! { |kernel| kernel.each_with_object({}) { |(k, v), h| h[k.downcase.to_sym] = v } }
|
||||
kernels.each { |kernel| kernel.merge! :id => kernel[:kernelid], :name => kernel[:label] }
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
|
@ -2,7 +2,11 @@ module Fog
|
|||
module Linode
|
||||
class Compute
|
||||
class Real
|
||||
def avail_kernels(options={})
|
||||
def avail_kernels(kernel_id=nil)
|
||||
options = {}
|
||||
if kernel_id
|
||||
options.merge!(:kernelId => kernel_id)
|
||||
end
|
||||
request(
|
||||
:expects => 200,
|
||||
:method => 'GET',
|
||||
|
|
Loading…
Reference in a new issue