1
0
Fork 0
mirror of https://github.com/fog/fog.git synced 2022-11-09 13:51:43 -05:00
fog--fog/lib/fog/linode/models/compute/kernels.rb
2013-01-07 20:53:28 +00:00

32 lines
753 B
Ruby

require 'fog/core/collection'
require 'fog/linode/models/compute/kernel'
module Fog
module Compute
class Linode
class Kernels < Fog::Collection
model Fog::Compute::Linode::Kernel
def all
load kernels
end
def get(id)
new kernels(id).first
rescue Fog::Compute::Linode::NotFound
nil
end
private
def kernels(id=nil)
service.avail_kernels(id).body['DATA'].map { |kernel| map_kernel kernel }
end
def map_kernel(kernel)
kernel = kernel.each_with_object({}) { |(k, v), h| h[k.downcase.to_sym] = v }
kernel.merge! :id => kernel[:kernelid], :name => kernel[:label]
end
end
end
end
end