mirror of
https://github.com/fog/fog.git
synced 2022-11-09 13:51:43 -05:00
Merge pull request #1554 from smgt/glesys-add-platform-to-templates
[glesys] add platform to templates
This commit is contained in:
commit
03c2841a0d
2 changed files with 23 additions and 20 deletions
|
@ -1,25 +1,16 @@
|
|||
require 'fog/core/model'
|
||||
|
||||
module Fog
|
||||
module Glesys
|
||||
class Compute
|
||||
|
||||
module Compute
|
||||
class Glesys
|
||||
class Template < Fog::Model
|
||||
extend Fog::Deprecation
|
||||
|
||||
identity :name
|
||||
|
||||
attribute :platform
|
||||
attribute :operating_system, :aliases => "operatingsystem"
|
||||
attribute :minimum_memory_size, :aliases => "minimummemorysize"
|
||||
attribute :minimum_disk_size, :aliases => "minimumdisksize"
|
||||
attribute :instance_cost, :aliases => "instancecost"
|
||||
attribute :license_cost, :aliases => "licensecost"
|
||||
|
||||
def list
|
||||
service.template_list
|
||||
end
|
||||
|
||||
end
|
||||
end
|
||||
end
|
||||
|
|
|
@ -4,22 +4,34 @@ require 'fog/glesys/models/compute/template'
|
|||
module Fog
|
||||
module Compute
|
||||
class Glesys
|
||||
|
||||
class Templates < Fog::Collection
|
||||
|
||||
model Fog::Glesys::Compute::Template
|
||||
model Fog::Compute::Glesys::Template
|
||||
|
||||
def all
|
||||
request = service.template_list.body
|
||||
templates = request['response']['templates']
|
||||
|
||||
# Only select OpenVZ and Xen platforms
|
||||
# Glesys only offers Xen and OpenVZ but they have other platforms in the list
|
||||
templates = templates.select do |platform, templates|
|
||||
%w|openvz xen|.include?(platform.downcase)
|
||||
end.collect{|platform, templates| templates}.flatten
|
||||
images = platform :openvz, :xen
|
||||
load(images)
|
||||
end
|
||||
|
||||
load(templates)
|
||||
def openvz
|
||||
images = platform :openvz
|
||||
load(images)
|
||||
end
|
||||
|
||||
def xen
|
||||
images = platform :xen
|
||||
load(images)
|
||||
end
|
||||
|
||||
private
|
||||
|
||||
def platform(*platforms)
|
||||
images = service.template_list.body['response']['templates']
|
||||
images.select do |platform, images|
|
||||
platforms.include?(platform.downcase.to_sym)
|
||||
end.collect{|platform, images| images}.flatten
|
||||
end
|
||||
|
||||
end
|
||||
|
|
Loading…
Reference in a new issue