2011-03-01 16:37:27 -05:00
|
|
|
require 'fog/core/collection'
|
2011-08-24 21:24:45 -04:00
|
|
|
require 'fog/linode/models/compute/stack_script'
|
2011-03-01 16:37:27 -05:00
|
|
|
|
|
|
|
module Fog
|
2011-06-16 19:28:54 -04:00
|
|
|
module Compute
|
|
|
|
class Linode
|
2011-03-01 16:37:27 -05:00
|
|
|
class StackScripts < Fog::Collection
|
2011-06-16 19:28:54 -04:00
|
|
|
model Fog::Compute::Linode::StackScript
|
2011-03-01 16:37:27 -05:00
|
|
|
|
|
|
|
def all
|
|
|
|
load stackscripts
|
|
|
|
end
|
|
|
|
|
|
|
|
def get(id)
|
|
|
|
new stackscripts(id).first
|
2011-06-16 19:28:54 -04:00
|
|
|
rescue Fog::Compute::Linode::NotFound
|
2011-03-01 16:37:27 -05:00
|
|
|
nil
|
|
|
|
end
|
|
|
|
|
|
|
|
private
|
|
|
|
def stackscripts(id=nil)
|
|
|
|
connection.stackscript_list(id).body['DATA'].map { |script| map_stackscript script }
|
|
|
|
end
|
|
|
|
|
|
|
|
def map_stackscript(script)
|
|
|
|
script = script.each_with_object({}) { |(k, v), h| h[k.downcase.to_sym] = v }
|
|
|
|
script.merge! :id => script[:stackscriptid], :name => script[:label]
|
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|