mirror of
https://github.com/fog/fog.git
synced 2022-11-09 13:51:43 -05:00
[glesys|compute] fix for changes in api
This commit is contained in:
parent
76e3447c61
commit
d7e3ee870a
5 changed files with 218 additions and 155 deletions
|
@ -79,7 +79,7 @@ module Fog
|
|||
def request(method_name, options = {})
|
||||
|
||||
options.merge!( {:format => 'json'})
|
||||
|
||||
|
||||
begin
|
||||
parser = options.delete(:parser)
|
||||
data = @connection.request(
|
||||
|
@ -96,7 +96,9 @@ module Fog
|
|||
|
||||
data.body = MultiJson.decode(data.body)
|
||||
|
||||
unless data.body['response']['status']['code'] == '200'
|
||||
response_code = data.body['response']['status']['code']
|
||||
|
||||
unless response_code.to_i == 200
|
||||
raise Fog::Compute::Glesys::Error, "#{data.body['response']['status']['text']}"
|
||||
end
|
||||
data
|
||||
|
|
|
@ -15,11 +15,11 @@ module Fog
|
|||
attribute :memorysize
|
||||
attribute :disksize
|
||||
attribute :transfer
|
||||
attribute :template
|
||||
attribute :templatename
|
||||
attribute :managedhosting
|
||||
attribute :platform
|
||||
attribute :cost
|
||||
attribute :rootpw
|
||||
attribute :rootpassword
|
||||
attribute :keepip
|
||||
attribute :state
|
||||
attribute :iplist
|
||||
|
@ -32,7 +32,7 @@ module Fog
|
|||
|
||||
def start
|
||||
requires :identity
|
||||
connection.start(:serverid => identity)
|
||||
connection.start(:serverid => identity)
|
||||
end
|
||||
|
||||
def stop
|
||||
|
@ -47,24 +47,24 @@ module Fog
|
|||
|
||||
def save
|
||||
raise "Operation not supported" if self.identity
|
||||
requires :hostname, :rootpw
|
||||
requires :hostname, :rootpassword
|
||||
|
||||
options = {
|
||||
:datacenter => datacenter || "Falkenberg",
|
||||
:platform => platform || "Xen",
|
||||
:hostname => hostname,
|
||||
:template => template || "Debian-6 x64",
|
||||
:disksize => disksize || "10",
|
||||
:memorysize => memorysize || "512",
|
||||
:cpucores => cpucores || "1",
|
||||
:rootpw => rootpw,
|
||||
:transfer => transfer || "500",
|
||||
:datacenter => datacenter || "Falkenberg",
|
||||
:platform => platform || "Xen",
|
||||
:hostname => hostname,
|
||||
:templatename => templatename || "Debian-6 x64",
|
||||
:disksize => disksize || "10",
|
||||
:memorysize => memorysize || "512",
|
||||
:cpucores => cpucores || "1",
|
||||
:rootpassword => rootpassword,
|
||||
:transfer => transfer || "500",
|
||||
}
|
||||
data = connection.create(options)
|
||||
merge_attributes(data.body['response']['server'])
|
||||
data.status == 200 ? true : false
|
||||
end
|
||||
|
||||
|
||||
end
|
||||
end
|
||||
end
|
||||
|
|
|
@ -11,61 +11,19 @@ class Glesys
|
|||
'serverid' => String,
|
||||
'hostname' => String,
|
||||
'datacenter' => String,
|
||||
'platform' => String,
|
||||
'platform' => String
|
||||
}],
|
||||
'status' => {
|
||||
'code' => String,
|
||||
'text' => String
|
||||
}
|
||||
}
|
||||
|
||||
CREATE = {
|
||||
'debug' => {
|
||||
'input' => {
|
||||
"rootpw" => String,
|
||||
"disksize" => String,
|
||||
"memorysize" => String,
|
||||
"datacenter" => String,
|
||||
"cpucores" => String,
|
||||
"transfer" => String,
|
||||
"template" => String,
|
||||
"description" => String,
|
||||
"hostname" => String,
|
||||
"platform" => String
|
||||
}
|
||||
},
|
||||
'server' => {
|
||||
'serverid' => String,
|
||||
'hostname' => String,
|
||||
'iplist' => [{
|
||||
'cost' => String,
|
||||
'version' => String,
|
||||
'ip' => String
|
||||
}]
|
||||
},
|
||||
'status' => {
|
||||
'code' => String,
|
||||
'text' => String
|
||||
}
|
||||
}
|
||||
|
||||
DESTROY = {
|
||||
'debug' => {
|
||||
'input' => {
|
||||
'serverid' => String,
|
||||
'keepip' => String,
|
||||
}
|
||||
},
|
||||
'status' => {
|
||||
'code' => String,
|
||||
'text' => String
|
||||
'timestamp' => String,
|
||||
'code' => Integer,
|
||||
'text' => String
|
||||
}
|
||||
}
|
||||
|
||||
DETAILS = {
|
||||
'debug' => {
|
||||
'input' => {
|
||||
'serverid' => String
|
||||
'serverid' => Fog::Nullable::String
|
||||
}
|
||||
},
|
||||
'server' => {
|
||||
|
@ -74,29 +32,59 @@ class Glesys
|
|||
'amount' => Float,
|
||||
'timeperiod' => String,
|
||||
'currency' => String
|
||||
},
|
||||
'serverid' => String,
|
||||
'datacenter' => String,
|
||||
'memory' => String,
|
||||
'cpucores' => String,
|
||||
'transfer' => String,
|
||||
'template' => String,
|
||||
'iplist' => [{
|
||||
'cost' => String,
|
||||
'version' => String,
|
||||
'ip' => String
|
||||
},
|
||||
'serverid' => String,
|
||||
'datacenter' => String,
|
||||
'memorysize' => Integer,
|
||||
'cpucores' => Integer,
|
||||
'transfer' => Integer,
|
||||
'templatename' => String,
|
||||
'iplist' => [{
|
||||
'cost' => Integer,
|
||||
'version' => Fog::Nullable::Integer,
|
||||
'ipaddress' => Fog::Nullable::String,
|
||||
'currency' => String
|
||||
}],
|
||||
'description' => String,
|
||||
'hostname' => String,
|
||||
'disk' => String,
|
||||
'platform' => String
|
||||
'disksize' => Integer,
|
||||
'platform' => String,
|
||||
'state' => Fog::Nullable::String
|
||||
},
|
||||
'status' => {
|
||||
'code' => String,
|
||||
'text' => String
|
||||
'timestamp' => String,
|
||||
'code' => Integer,
|
||||
'text' => String
|
||||
}
|
||||
}
|
||||
|
||||
STOP = DETAILS.merge(
|
||||
'debug' => {
|
||||
'input' => {
|
||||
'serverid' => Fog::Nullable::String,
|
||||
'type' => String
|
||||
}
|
||||
}
|
||||
)
|
||||
|
||||
CREATE = DETAILS.merge(
|
||||
'debug' => {
|
||||
'input' => {
|
||||
'serverid' => Fog::Nullable::String,
|
||||
'hostname' => String,
|
||||
'rootpassword' => String,
|
||||
'datacenter' => String,
|
||||
'platform' => String,
|
||||
'templatename' => String,
|
||||
'disksize' => String,
|
||||
'memorysize' => String,
|
||||
'cpucores' => String,
|
||||
'transfer' => String,
|
||||
'description' => String
|
||||
}
|
||||
}
|
||||
)
|
||||
|
||||
STATUS = {
|
||||
'debug' => {
|
||||
'input' => {
|
||||
|
@ -104,44 +92,51 @@ class Glesys
|
|||
}
|
||||
},
|
||||
'server' => {
|
||||
'memory' => String,
|
||||
'bandwidth' => {
|
||||
'last30days' => Integer,
|
||||
'today' => Integer,
|
||||
'max' => String
|
||||
'memory' => {
|
||||
'usage' => Fog::Nullable::Integer,
|
||||
'max' => Fog::Nullable::Integer,
|
||||
'unit' => Fog::Nullable::String
|
||||
},
|
||||
'cpu' => String,
|
||||
'disk' => String,
|
||||
'state' => String
|
||||
'transfer' => {
|
||||
'usage' => Fog::Nullable::Integer,
|
||||
'max' => Fog::Nullable::Integer,
|
||||
'unit' => Fog::Nullable::String
|
||||
},
|
||||
'disk' => {
|
||||
'usage' => Fog::Nullable::Integer,
|
||||
'max' => Fog::Nullable::Integer,
|
||||
'unit' => Fog::Nullable::String
|
||||
},
|
||||
'state' => String,
|
||||
'transfer' => {
|
||||
'usage' => Fog::Nullable::Integer,
|
||||
'max' => Fog::Nullable::Integer,
|
||||
'unit' => Fog::Nullable::String
|
||||
},
|
||||
'cpu' => [],
|
||||
'uptime' => {
|
||||
'current' => Fog::Nullable::Integer,
|
||||
'unit' => String
|
||||
}
|
||||
},
|
||||
'status' => {
|
||||
'code' => String,
|
||||
'text' => String
|
||||
'timestamp' => String,
|
||||
'code' => Integer,
|
||||
'text' => String
|
||||
}
|
||||
}
|
||||
|
||||
START = {
|
||||
DESTROY = {
|
||||
'debug' => {
|
||||
'input' => {
|
||||
'serverid' => String
|
||||
'serverid' => String,
|
||||
'keepip' => String
|
||||
}
|
||||
},
|
||||
'status' => {
|
||||
'code' => String,
|
||||
'text' => String
|
||||
}
|
||||
}
|
||||
|
||||
STOP = {
|
||||
'debug' => {
|
||||
'input' => {
|
||||
'serverid' => String,
|
||||
'type' => String
|
||||
}
|
||||
},
|
||||
'status' => {
|
||||
'code' => String,
|
||||
'text' => String
|
||||
'timestamp' => String,
|
||||
'code' => Integer,
|
||||
'text' => String
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -153,21 +148,27 @@ class Glesys
|
|||
'input' => []
|
||||
},
|
||||
'iplist' => [{
|
||||
'price' => {
|
||||
'amount' => String,
|
||||
'timeperiod' => String,
|
||||
'currency' => String
|
||||
'cost' => {
|
||||
'amount' => Integer,
|
||||
'timeperiod' => String,
|
||||
'currency' => String
|
||||
},
|
||||
'datacenter' => String,
|
||||
'serverid' => Fog::Nullable::String,
|
||||
'platform' => String,
|
||||
'ip' => String,
|
||||
'version' => String,
|
||||
'PTR' => String,
|
||||
'netmask' => Fog::Nullable::String,
|
||||
'broadcast' => Fog::Nullable::String,
|
||||
'gateway' => Fog::Nullable::String,
|
||||
'nameservers' => [],
|
||||
'datacenter' => String,
|
||||
'serverid' => Fog::Nullable::String,
|
||||
'platform' => String,
|
||||
'ipaddress' => String,
|
||||
'ipversion' => Integer,
|
||||
'ptr' => String,
|
||||
'reserved' => String
|
||||
}],
|
||||
'status' => {
|
||||
'code' => String,
|
||||
'text' => String
|
||||
'timestamp' => String,
|
||||
'code' => Integer,
|
||||
'text' => String
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -179,16 +180,17 @@ class Glesys
|
|||
'platform' => String
|
||||
}
|
||||
},
|
||||
'iplist' => [],
|
||||
'status' => {
|
||||
'code' => String,
|
||||
'text' => String
|
||||
'iplist' => {
|
||||
'ipversion' => Integer,
|
||||
'datacenter' => String,
|
||||
'platform' => String,
|
||||
"ipaddresses" => []
|
||||
},
|
||||
'status' => {
|
||||
'timestamp' => String,
|
||||
'code' => Integer,
|
||||
'text' => String
|
||||
},
|
||||
'ipinfo' => {
|
||||
'datacenter' => String,
|
||||
'ipversion' => Integer,
|
||||
'platform' => String
|
||||
}
|
||||
}
|
||||
|
||||
IPLIST_CATCH_RELEASE = {
|
||||
|
@ -197,9 +199,29 @@ class Glesys
|
|||
'ipaddress' => String,
|
||||
}
|
||||
},
|
||||
'details' => {
|
||||
'cost' => {
|
||||
'amount' => Integer,
|
||||
'timeperiod' => String,
|
||||
'currency' => String
|
||||
},
|
||||
'ipaddress' => String,
|
||||
'netmask' => String,
|
||||
'broadcast' => String,
|
||||
'gateway' => String,
|
||||
'nameservers' => [],
|
||||
'datacenter' => String,
|
||||
'serverid' => Fog::Nullable::String,
|
||||
'platform' => String,
|
||||
'ipaddress' => String,
|
||||
'ipversion' => Integer,
|
||||
'ptr' => String,
|
||||
'reserved' => String
|
||||
},
|
||||
'status' => {
|
||||
'code' => String,
|
||||
'text' => String
|
||||
'timestamp' => String,
|
||||
'code' => Integer,
|
||||
'text' => String
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -212,23 +234,24 @@ class Glesys
|
|||
},
|
||||
'templates' => {
|
||||
'Xen' => [{
|
||||
'name' => String,
|
||||
'os' => String,
|
||||
'min_mem_size' => String,
|
||||
'min_disk_size' => String,
|
||||
'platform' => String
|
||||
'name' => String,
|
||||
'operatingsystem' => String,
|
||||
'minimummemorysize' => Integer,
|
||||
'minimumdisksize' => Integer,
|
||||
'platform' => String
|
||||
}],
|
||||
'OpenVZ' => [{
|
||||
'name' => String,
|
||||
'os' => String,
|
||||
'min_mem_size' => String,
|
||||
'min_disk_size' => String,
|
||||
'platform' => String
|
||||
'name' => String,
|
||||
'operatingsystem' => String,
|
||||
'minimummemorysize' => Integer,
|
||||
'minimumdisksize' => Integer,
|
||||
'platform' => String
|
||||
}]
|
||||
},
|
||||
'status' => {
|
||||
'code' => String,
|
||||
'text' => String
|
||||
'timestamp' => String,
|
||||
'code' => Integer,
|
||||
'text' => String
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -9,7 +9,7 @@ Shindo.tests('Fog::Compute[:glesys] | ip requests', ['glesys']) do
|
|||
pending if Fog.mocking?
|
||||
Fog::Compute[:glesys].ip_list_own.body['response']
|
||||
end
|
||||
|
||||
|
||||
tests("#ip_list_free(:datacenter => 'Falkenberg, :platform => 'Xen', :ipversion => 4)"
|
||||
).formats(Glesys::Compute::Formats::Ips::IPLIST_ALL) do
|
||||
pending if Fog.mocking?
|
||||
|
@ -18,10 +18,10 @@ Shindo.tests('Fog::Compute[:glesys] | ip requests', ['glesys']) do
|
|||
:platform => "Xen",
|
||||
:ipversion => 4
|
||||
)
|
||||
@free_ip = ips.body['response']['iplist'].first
|
||||
@free_ip = ips.body['response']['iplist']['ipaddresses'].first
|
||||
ips.body['response']
|
||||
end
|
||||
|
||||
|
||||
tests("#ip_take(:datacenter => 'Falkenberg', :platform => 'Xen', :ipversion => 4, :ipaddress => #{@free_ip})"
|
||||
).formats(Glesys::Compute::Formats::Ips::IPLIST_CATCH_RELEASE) do
|
||||
pending if Fog.mocking?
|
||||
|
|
|
@ -3,10 +3,14 @@ Shindo.tests('Fog::Compute[:glesys] | server requests', ['glesys']) do
|
|||
@serverid = nil
|
||||
@hostname = "fog-#{Time.now.to_i}"
|
||||
|
||||
@create = ":hostname => #@hostname, :rootpw => 'pw#{Time.now.to_i}', "+
|
||||
":datacenter => 'Falkenberg', :platform => 'Xen', :template => 'Debian-6 x64', "+
|
||||
@create = ":hostname => #@hostname, :rootpassword => 'pw#{Time.now.to_i}', "+
|
||||
":datacenter => 'Falkenberg', :platform => 'Xen', :templatename => 'Debian-6 x64', "+
|
||||
":disksize => '10', :memorysize => '512', :cpucores => '1', :transfer => '500'"
|
||||
|
||||
@create_vz = ":hostname => #@hostname, :rootpassword => 'pw#{Time.now.to_i}', "+
|
||||
":datacenter => 'Stockholm', :platform => 'OpenVZ', :templatename => 'Debian 6.0 64-bit', "+
|
||||
":disksize => '10', :memorysize => '256', :cpucores => '2', :transfer => '500'"
|
||||
|
||||
tests('success') do
|
||||
|
||||
tests("#list_servers()").formats(Glesys::Compute::Formats::Servers::LIST) do
|
||||
|
@ -17,15 +21,15 @@ Shindo.tests('Fog::Compute[:glesys] | server requests', ['glesys']) do
|
|||
tests("#create(#{@create})").formats(Glesys::Compute::Formats::Servers::CREATE) do
|
||||
pending if Fog.mocking?
|
||||
vm = Fog::Compute[:glesys].create(
|
||||
:hostname => @hostname,
|
||||
:rootpw => "pw#{Time.now.to_i}",
|
||||
:datacenter => "Falkenberg",
|
||||
:platform => "Xen",
|
||||
:template => "Debian-6 x64",
|
||||
:disksize => "10",
|
||||
:memorysize => "512",
|
||||
:cpucores => "1",
|
||||
:transfer => "500"
|
||||
:hostname => @hostname,
|
||||
:rootpassword => "pw#{Time.now.to_i}",
|
||||
:datacenter => "Falkenberg",
|
||||
:platform => "Xen",
|
||||
:templatename => "Debian-6 x64",
|
||||
:disksize => "10",
|
||||
:memorysize => "512",
|
||||
:cpucores => "1",
|
||||
:transfer => "500"
|
||||
)
|
||||
|
||||
@serverid = vm.body['response']['server']['serverid']
|
||||
|
@ -58,7 +62,7 @@ Shindo.tests('Fog::Compute[:glesys] | server requests', ['glesys']) do
|
|||
s.wait_for { s.state == 'stopped' }
|
||||
end
|
||||
|
||||
tests("#start(:serverid => #{@serverid})").formats(Glesys::Compute::Formats::Servers::START) do
|
||||
tests("#start(:serverid => #{@serverid})").formats(Glesys::Compute::Formats::Servers::DETAILS) do
|
||||
pending if Fog.mocking?
|
||||
Fog::Compute[:glesys].start(:serverid => @serverid).body['response']
|
||||
end
|
||||
|
@ -73,6 +77,40 @@ Shindo.tests('Fog::Compute[:glesys] | server requests', ['glesys']) do
|
|||
Fog::Compute[:glesys].destroy(:serverid => @serverid).body['response']
|
||||
end
|
||||
|
||||
# Test of OpenVZ
|
||||
tests("#create(#{@create_vz})").formats(Glesys::Compute::Formats::Servers::CREATE) do
|
||||
pending if Fog.mocking?
|
||||
vm = Fog::Compute[:glesys].create(
|
||||
:hostname => @hostname,
|
||||
:rootpassword => "pw#{Time.now.to_i}",
|
||||
:datacenter => "Stockholm",
|
||||
:platform => "OpenVZ",
|
||||
:templatename => "Debian 6.0 64-bit",
|
||||
:disksize => "10",
|
||||
:memorysize => "256",
|
||||
:cpucores => "2",
|
||||
:transfer => "500"
|
||||
)
|
||||
|
||||
@serverid = vm.body['response']['server']['serverid']
|
||||
vm.body['response']
|
||||
end
|
||||
|
||||
tests("#server_details(#{@serverid})").formats(Glesys::Compute::Formats::Servers::DETAILS) do
|
||||
pending if Fog.mocking?
|
||||
Fog::Compute[:glesys].server_details(@serverid).body['response']
|
||||
end
|
||||
|
||||
unless Fog.mocking?
|
||||
Fog::Compute[:glesys].servers.get(@serverid).wait_for { ready? }
|
||||
end
|
||||
|
||||
tests("#destroy(:serverid => #{@serverid})").formats(Glesys::Compute::Formats::Servers::DESTROY) do
|
||||
pending if Fog.mocking?
|
||||
Fog::Compute[:glesys].destroy(:serverid => @serverid).body['response']
|
||||
end
|
||||
|
||||
|
||||
end
|
||||
|
||||
tests('failure') do
|
||||
|
|
Loading…
Reference in a new issue