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/compute/models/linode/kernels.rb

32 lines
764 B
Ruby

require 'fog/core/collection'
require 'fog/compute/models/linode/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)
connection.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