1
0
Fork 0
mirror of https://github.com/fog/fog.git synced 2022-11-09 13:51:43 -05:00

Merge pull request #3647 from Ladas/openstack_compute_add_shelve_related_actions

OpenStack compute add shelve related actions
This commit is contained in:
Wesley Beary 2015-08-07 15:20:23 -05:00
commit e7cf7d4810
6 changed files with 102 additions and 0 deletions

View file

@ -96,6 +96,9 @@ module Fog
request :reset_server_state
request :add_security_group
request :remove_security_group
request :shelve_server
request :unshelve_server
request :shelve_offload_server
# Server Extenstions
request :get_console_output

View file

@ -257,6 +257,21 @@ module Fog
end
end
def shelve
requires :id
service.shelve_server(id)
end
def unshelve
requires :id
service.unshelve_server(id)
end
def shelve_offload
requires :id
service.shelve_offload_server(id)
end
def create_image(name, metadata={})
requires :id
service.create_image(id, name, metadata)

View file

@ -0,0 +1,24 @@
module Fog
module Compute
class OpenStack
class Real
# Shelve Off load the server. Data and resource associations are deleted.
#
# === Parameters
# * server_id <~String> - The ID of the server to be shelve off loaded
# === Returns
# * success <~Boolean>
def shelve_offload_server(server_id)
body = { 'shelveOffload' => nil }
server_action(server_id, body).status == 202
end # def shelve_off_load_server
end # class Real
class Mock
def shelve_offload_server(server_id)
true
end # def shelve_off_load_server
end # class Mock
end # class OpenStack
end # module Compute
end # module Fog

View file

@ -0,0 +1,24 @@
module Fog
module Compute
class OpenStack
class Real
# Shelve the server.
#
# === Parameters
# * server_id <~String> - The ID of the server to be shelved
# === Returns
# * success <~Boolean>
def shelve_server(server_id)
body = { 'shelve' => nil }
server_action(server_id, body).status == 202
end # def shelve_server
end # class Real
class Mock
def shelve_server(server_id)
true
end # def shelve_server
end # class Mock
end # class OpenStack
end # module Compute
end # module Fog

View file

@ -0,0 +1,24 @@
module Fog
module Compute
class OpenStack
class Real
# Unshelve the server.
#
# === Parameters
# * server_id <~String> - The ID of the server to be unshelved
# === Returns
# * success <~Boolean>
def unshelve_server(server_id)
body = { 'unshelve' => nil }
server_action(server_id, body).status == 202
end # def unshelve_server
end # class Real
class Mock
def unshelve_server(server_id)
true
end # def unshelve_server
end # class Mock
end # class OpenStack
end # module Compute
end # module Fog

View file

@ -232,6 +232,18 @@ Shindo.tests('Fog::Compute[:openstack] | server requests', ['openstack']) do
Fog::Compute[:openstack].servers.get(@server_id).wait_for { ready? } if not Fog.mocking?
tests("#shelve_server(#{@server_id})").succeeds do
Fog::Compute[:openstack].shelve_server(@server_id)
end
Fog::Compute[:openstack].servers.get(@server_id).wait_for { ready? } if not Fog.mocking?
tests("#unshelve_server(#{@server_id})").succeeds do
Fog::Compute[:openstack].unshelve_server(@server_id)
end
Fog::Compute[:openstack].servers.get(@server_id).wait_for { ready? } if not Fog.mocking?
#DELETE
tests("#delete_server(#{@server_id})").succeeds do
Fog::Compute[:openstack].delete_server(@server_id)