[GleSYS] Add ability to persist changes on existing server

This commit is contained in:
Christoffer Artmann 2015-03-06 10:33:36 +01:00
parent 6c22118fa5
commit bd48df8757
5 changed files with 70 additions and 20 deletions

View File

@ -19,6 +19,7 @@ module Fog
# Server
request :create
request :edit
request :destroy
request :list_servers
request :server_details

View File

@ -53,28 +53,39 @@ module Fog
end
def save
raise "Operation not supported" if self.identity
requires :hostname, :rootpassword
if self.identity
options = {
:serverid => self.identity,
:disksize => disksize,
:memorysize => memorysize,
:cpucores => cpucores,
:hostname => hostname,
:bandwidth => bandwidth
}
data = service.edit(options)
else
requires :hostname, :rootpassword
options = {
:datacenter => datacenter || "Falkenberg",
:platform => platform || "OpenVz",
:hostname => hostname,
:templatename => templatename || "Debian 7.0 64-bit",
:disksize => disksize || "10",
:memorysize => memorysize || "512",
:cpucores => cpucores || "1",
:rootpassword => rootpassword,
:transfer => transfer || "500",
:bandwidth => bandwidth || "10",
}
options = {
:datacenter => datacenter || "Falkenberg",
:platform => platform || "OpenVz",
:hostname => hostname,
:templatename => templatename || "Debian 7.0 64-bit",
:disksize => disksize || "10",
:memorysize => memorysize || "512",
:cpucores => cpucores || "1",
:rootpassword => rootpassword,
:transfer => transfer || "500",
:bandwidth => bandwidth || "10",
}
# optional options when creating a server:
[:ip, :ipv6, :description].each do |k|
options[k] = attributes[k] if attributes[k]
# optional options when creating a server:
[:ip, :ipv6, :description].each do |k|
options[k] = attributes[k] if attributes[k]
end
data = service.create(options)
end
data = service.create(options)
merge_attributes(data.body['response']['server'])
data.status == 200 ? true : false
end

View File

@ -0,0 +1,11 @@
module Fog
module Compute
class Glesys
class Real
def edit(options = {})
request('server/edit/',options)
end
end
end
end
end

View File

@ -85,6 +85,18 @@ class Glesys
}
)
EDIT = DETAILS.merge(
'debug' => {
'input' => {
'serverid' => Fog::Nullable::String,
'disksize' => String,
'memorysize' => String,
'cpucores' => String,
'bandwidth' => String
}
}
)
STATUS = {
'debug' => {
'input' => {

View File

@ -94,11 +94,26 @@ Shindo.tests('Fog::Compute[:glesys] | server requests', ['glesys']) do
:transfer => "500",
:bandwidth => "10"
)
@serverid = vm.body['response']['server']['serverid']
vm.body['response']
end
unless Fog.mocking?
Fog::Compute[:glesys].servers.get(@serverid).wait_for { ready? }
end
tests("#edit #{@serverid}").formats(Glesys::Compute::Formats::Servers::EDIT) do
pending if Fog.mocking?
vm = Fog::Compute[:glesys].edit(
:serverid => @serverid,
:disksize => "10",
:memorysize => "512",
:cpucores => "1",
:bandwidth => "10"
)
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']