compute: Adds shelve-offload support
Change-Id: I74979ded4ded26382629611b5990229c9936e247
This commit is contained in:
parent
692b7f39e3
commit
6d04b0c3ce
@ -1135,6 +1135,25 @@ class Proxy(proxy.Proxy):
|
||||
server = self._get_resource(_server.Server, server)
|
||||
server.shelve(self)
|
||||
|
||||
def shelve_offload_server(self, server):
|
||||
"""Shelve-offloads, or removes, a server
|
||||
|
||||
Data and resource associations are deleted.
|
||||
|
||||
Policy defaults enable only users with administrative role or the owner
|
||||
of the server to perform this operation. Cloud provides could change
|
||||
this permission though.
|
||||
|
||||
Note that in some clouds, shelved servers are automatically offloaded,
|
||||
sometimes after a certain time period.
|
||||
|
||||
:param server: Either the ID of a server or a
|
||||
:class:`~openstack.compute.v2.server.Server` instance.
|
||||
:returns: None
|
||||
"""
|
||||
server = self._get_resource(_server.Server, server)
|
||||
server.shelve_offload(self)
|
||||
|
||||
def unshelve_server(self, server):
|
||||
"""Unshelves or restores a shelved server.
|
||||
|
||||
|
@ -537,6 +537,10 @@ class Server(resource.Resource, metadata.MetadataMixin, tag.TagMixin):
|
||||
body = {"shelve": None}
|
||||
self._action(session, body)
|
||||
|
||||
def shelve_offload(self, session):
|
||||
body = {"shelveOffload": None}
|
||||
self._action(session, body)
|
||||
|
||||
def unshelve(self, session, availability_zone=_sentinel, host=None):
|
||||
"""
|
||||
Unshelve -- Unshelve the server.
|
||||
|
@ -1224,6 +1224,14 @@ class TestCompute(TestComputeProxy):
|
||||
expected_args=[self.proxy],
|
||||
)
|
||||
|
||||
def test_server_shelve_offload(self):
|
||||
self._verify(
|
||||
"openstack.compute.v2.server.Server.shelve_offload",
|
||||
self.proxy.shelve_offload_server,
|
||||
method_args=["value"],
|
||||
expected_args=[self.proxy],
|
||||
)
|
||||
|
||||
def test_server_unshelve(self):
|
||||
self._verify(
|
||||
"openstack.compute.v2.server.Server.unshelve",
|
||||
|
@ -461,6 +461,21 @@ class TestServer(base.TestCase):
|
||||
microversion=self.sess.default_microversion,
|
||||
)
|
||||
|
||||
def test_shelve_offload(self):
|
||||
sot = server.Server(**EXAMPLE)
|
||||
|
||||
self.assertIsNone(sot.shelve_offload(self.sess))
|
||||
|
||||
url = 'servers/IDENTIFIER/action'
|
||||
body = {"shelveOffload": None}
|
||||
headers = {'Accept': ''}
|
||||
self.sess.post.assert_called_with(
|
||||
url,
|
||||
json=body,
|
||||
headers=headers,
|
||||
microversion=self.sess.default_microversion,
|
||||
)
|
||||
|
||||
def test_create_image_header(self):
|
||||
sot = server.Server(**EXAMPLE)
|
||||
name = 'noo'
|
||||
|
@ -0,0 +1,4 @@
|
||||
---
|
||||
features:
|
||||
- |
|
||||
Adds shelve_offload_server method to the compute proxy
|
Loading…
Reference in New Issue
Block a user