mirror of
https://github.com/fog/fog.git
synced 2022-11-09 13:51:43 -05:00
Merge pull request #3474 from Artmann/glesys-add-ability-to-persist-changes-on-existing-server
[GleSYS] Add ability to persist changes on existing server
This commit is contained in:
commit
9a9068e16d
5 changed files with 70 additions and 20 deletions
|
@ -19,6 +19,7 @@ module Fog
|
|||
|
||||
# Server
|
||||
request :create
|
||||
request :edit
|
||||
request :destroy
|
||||
request :list_servers
|
||||
request :server_details
|
||||
|
|
|
@ -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
|
||||
|
|
11
lib/fog/glesys/requests/compute/edit.rb
Normal file
11
lib/fog/glesys/requests/compute/edit.rb
Normal 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
|
|
@ -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' => {
|
||||
|
|
|
@ -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']
|
||||
|
|
Loading…
Reference in a new issue