compute: Add support for targeting host during migrate

Current setup of the migrate command does not support targeting a
specific compute node. With this change I want to introduce the
possibility to target specific compute nodes.

Change-Id: I7ae40d4513d685e4e93ab4120058a53a849a2d19
This commit is contained in:
Tomas Rinblad 2024-06-01 14:23:11 +02:00 committed by Stephen Finucane
parent 4eea48a48a
commit 6910a4e1d5
3 changed files with 19 additions and 4 deletions

@ -2095,15 +2095,16 @@ class Proxy(proxy.Proxy):
# ========== Server Migrations ==========
def migrate_server(self, server):
def migrate_server(self, server, *, host=None):
"""Migrate a server from one host to another
:param server: Either the ID of a server or a
:class:`~openstack.compute.v2.server.Server` instance.
:param str host: The host to which to migrate the server.
:returns: None
"""
server = self._get_resource(_server.Server, server)
server.migrate(self)
server.migrate(self, host=host)
def live_migrate_server(
self,

@ -841,13 +841,22 @@ class Server(resource.Resource, metadata.MetadataMixin, tag.TagMixin):
body = {'unshelve': data or None}
self._action(session, body)
def migrate(self, session):
def migrate(self, session, *, host=None):
"""Migrate the server.
:param session: The session to use for making this request.
:param host: The host to migrate the server to. (Optional)
:returns: None
"""
body = {"migrate": None}
if host and not utils.supports_microversion(session, '2.56'):
raise ValueError(
"The 'host' option is only supported on microversion 2.56 or "
"greater."
)
body: ty.Dict[str, ty.Any] = {"migrate": None}
if host:
body["migrate"] = {"host": host}
self._action(session, body)
def trigger_crash_dump(self, session):

@ -0,0 +1,5 @@
---
features:
- |
The ``migrate_server`` compute proxy API and the ``Server.migrate`` API now
accept a ``host`` parameter to migrate to a given host.