mirror of
https://github.com/fog/fog.git
synced 2022-11-09 13:51:43 -05:00
Merge branch 'master' of git://github.com/fog/fog into terremark_xml_parser_fixes
This commit is contained in:
commit
259a48f34a
7 changed files with 59 additions and 41 deletions
|
@ -69,7 +69,7 @@ module Fog
|
|||
ip = new data
|
||||
|
||||
if options[:attach] && serverid
|
||||
server.attach_ip ip
|
||||
server.ips.attach ip, serverid
|
||||
ip.serverid = serverid
|
||||
end
|
||||
|
||||
|
|
|
@ -14,11 +14,8 @@ module Fog
|
|||
attribute :cpucores
|
||||
attribute :memorysize
|
||||
attribute :disksize
|
||||
attribute :cpu
|
||||
attribute :memory
|
||||
attribute :disk
|
||||
attribute :uptime
|
||||
attribute :transfer
|
||||
attribute :uptime
|
||||
attribute :templatename
|
||||
attribute :managedhosting
|
||||
attribute :platform
|
||||
|
@ -27,6 +24,7 @@ module Fog
|
|||
attribute :state
|
||||
attribute :iplist
|
||||
attribute :description
|
||||
attribute :usage
|
||||
attribute :glera_enabled, :aliases => "gleraenabled"
|
||||
attribute :supported_features, :aliases => "supportedfeatures"
|
||||
|
||||
|
|
|
@ -24,8 +24,14 @@ module Fog
|
|||
if details.empty? || status.empty?
|
||||
nil
|
||||
else
|
||||
status['server'].merge!({ :serverid => identifier})
|
||||
details['server']['usage'] = Hash.new
|
||||
|
||||
%w|cpu memory disk transfer|.each do |attr|
|
||||
details['server']['usage'][attr] = status['server'].delete(attr)
|
||||
end
|
||||
|
||||
details['server'].merge!(status['server'])
|
||||
|
||||
new(details['server'])
|
||||
end
|
||||
rescue
|
||||
|
|
|
@ -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
|
||||
|
|
|
@ -120,21 +120,21 @@ module Fog
|
|||
def header_to_key(opt)
|
||||
opt.gsub(metadata_prefix, '').split('-').map {|k| k[0, 1].downcase + k[1..-1]}.join('_').to_sym
|
||||
end
|
||||
|
||||
|
||||
def metadata_to_headers
|
||||
header_map = header_mapping
|
||||
Hash[metadata.map {|k, v| [header_map[k], v] }]
|
||||
end
|
||||
hash = {}
|
||||
metadata.each_pair do |k,v|
|
||||
key = metakey(k,v)
|
||||
hash[key] = v
|
||||
end
|
||||
hash
|
||||
end
|
||||
|
||||
def header_mapping
|
||||
header_map = metadata.dup
|
||||
header_map.each_pair {|k, v| header_map[k] = key_to_header(k)}
|
||||
def metakey(key, value)
|
||||
prefix = value.nil? ? "X-Remove-Object-Meta-" : "X-Object-Meta-"
|
||||
prefix + key.to_s.split(/[-_]/).map(&:capitalize).join('-')
|
||||
end
|
||||
|
||||
def key_to_header(key)
|
||||
metadata_prefix + key.to_s.split(/[-_]/).map(&:capitalize).join('-')
|
||||
end
|
||||
|
||||
|
||||
def metadata_attributes
|
||||
if last_modified
|
||||
headers = service.head_object(directory.key, self.key).headers
|
||||
|
|
|
@ -3,7 +3,7 @@ Shindo.tests('Fog::Rackspace::Storage | file', ['rackspace']) do
|
|||
pending if Fog.mocking?
|
||||
|
||||
def object_meta_attributes
|
||||
@instance.connection.head_object(@directory.key, @instance.key).headers.reject {|k, v| !(k =~ /X-Object-Meta-/)}
|
||||
@instance.service.head_object(@directory.key, @instance.key).headers.reject {|k, v| !(k =~ /X-Object-Meta-/)}
|
||||
end
|
||||
|
||||
def clear_metadata
|
||||
|
@ -64,8 +64,20 @@ Shindo.tests('Fog::Rackspace::Storage | file', ['rackspace']) do
|
|||
@instance.metadata[:foo] = nil
|
||||
@instance.save
|
||||
object_meta_attributes
|
||||
end
|
||||
end
|
||||
|
||||
tests("removes one key while leaving the other") do
|
||||
@instance.metadata[:color] = "green"
|
||||
@instance.save
|
||||
returns({"X-Object-Meta-Foo"=>"bar", "X-Object-Meta-Color"=>"green"}) { object_meta_attributes }
|
||||
|
||||
tests("set metadata[:color] = nil").returns({"X-Object-Meta-Foo"=>"bar"}) do
|
||||
@instance.metadata[:color] = nil
|
||||
@instance.save
|
||||
|
||||
object_meta_attributes
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
tests('#metadata keys') do
|
||||
|
@ -105,7 +117,6 @@ Shindo.tests('Fog::Rackspace::Storage | file', ['rackspace']) do
|
|||
@instance.save
|
||||
object_meta_attributes['X-Object-Meta-Foo-Bar']
|
||||
end
|
||||
|
||||
end
|
||||
|
||||
end
|
||||
|
|
Loading…
Add table
Reference in a new issue