summaryrefslogtreecommitdiff
path: root/novaclient/v2
diff options
context:
space:
mode:
authorRené Ribaud <rribaud@redhat.com>2022-03-03 11:18:59 +0100
committerRené Ribaud <rribaud@redhat.com>2022-07-28 14:49:46 +0200
commitee9b277c5f442f299b853118c900c3ee2996c67a (patch)
treebf4dc5e298c820c37f7994921cc1d435e11dcc38 /novaclient/v2
parent63d368168c87bc0b9a9b7928b42553c609e46089 (diff)
downloadpython-novaclient-ee9b277c5f442f299b853118c900c3ee2996c67a.tar.gz
Microversion 2.91: Support specifying destination host to unshelve
This patch adds ``host`` to novaclient api. This can help administrators to specify a ``host`` to unshelve a shelve offloaded server from 2.91 microversion. Depends-On: https://review.opendev.org/c/openstack/nova/+/831507 Implements: blueprint unshelve-to-host Change-Id: I7efc8f0b0ef159e16cefee761bff5d7e90d0c427
Diffstat (limited to 'novaclient/v2')
-rw-r--r--novaclient/v2/servers.py65
1 files changed, 63 insertions, 2 deletions
diff --git a/novaclient/v2/servers.py b/novaclient/v2/servers.py
index 76709ec5..8a9301f6 100644
--- a/novaclient/v2/servers.py
+++ b/novaclient/v2/servers.py
@@ -314,7 +314,7 @@ class Server(base.Resource):
"""
return self.manager.unshelve(self)
- @api_versions.wraps("2.77")
+ @api_versions.wraps("2.77", "2.90")
def unshelve(self, availability_zone=None):
"""
Unshelve -- Unshelve the server.
@@ -326,6 +326,37 @@ class Server(base.Resource):
return self.manager.unshelve(self,
availability_zone=availability_zone)
+ @api_versions.wraps("2.91")
+ def unshelve(self, availability_zone=object(), host=None):
+ """
+ Unshelve -- Unshelve the server.
+
+ :param availability_zone: If specified the instance will be unshelved
+ to the availability_zone.
+ If None is passed the instance defined
+ availability_zone is unpin and the instance
+ will be scheduled to any availability_zone
+ (free scheduling).
+ If not specified the instance will be
+ unshelved to either its defined
+ availability_zone or any
+ availability_zone (free scheduling).
+ :param host: The specified host
+ (Optional)
+ :returns: An instance of novaclient.base.TupleWithMeta
+ """
+ if (
+ availability_zone is None or isinstance(availability_zone, str)
+ ) and host:
+ return self.manager.unshelve(
+ self, availability_zone=availability_zone, host=host)
+ if availability_zone is None or isinstance(availability_zone, str):
+ return self.manager.unshelve(
+ self, availability_zone=availability_zone)
+ if host:
+ return self.manager.unshelve(self, host=host)
+ return self.manager.unshelve(self)
+
def diagnostics(self):
"""Diagnostics -- Retrieve server diagnostics."""
return self.manager.diagnostics(self)
@@ -1266,7 +1297,7 @@ class ServerManager(base.BootingManagerWithFind):
"""
return self._action('unshelve', server, None)
- @api_versions.wraps("2.77")
+ @api_versions.wraps("2.77", "2.90")
def unshelve(self, server, availability_zone=None):
"""
Unshelve the server.
@@ -1281,6 +1312,36 @@ class ServerManager(base.BootingManagerWithFind):
info = {'availability_zone': availability_zone}
return self._action('unshelve', server, info)
+ @api_versions.wraps("2.91")
+ def unshelve(self, server, availability_zone=object(), host=None):
+ """
+ Unshelve the server.
+
+ :param availability_zone: If specified the instance will be unshelved
+ to the availability_zone.
+ If None is passed the instance defined
+ availability_zone is unpin and the instance
+ will be scheduled to any availability_zone
+ (free scheduling).
+ If not specified the instance will be
+ unshelved to either its defined
+ availability_zone or any
+ availability_zone (free scheduling).
+ :param host: The specified host
+ (Optional)
+ :returns: An instance of novaclient.base.TupleWithMeta
+ """
+ info = None
+
+ if availability_zone is None or isinstance(availability_zone, str):
+ info = {'availability_zone': availability_zone}
+ if host:
+ if info:
+ info['host'] = host
+ else:
+ info = {'host': host}
+ return self._action('unshelve', server, info)
+
def ips(self, server):
"""
Return IP Addresses associated with the server.