summaryrefslogtreecommitdiff
path: root/nova/network
diff options
context:
space:
mode:
authorArnaud Morin <arnaud.morin@ovhcloud.com>2022-08-18 17:52:58 +0200
committerArnaud Morin <arnaud.morin@ovhcloud.com>2022-11-29 17:06:46 +0100
commit4eef0fe6354304b4639a3b635e4955457188e4ce (patch)
treedd6b22b5c58730b869f1e488bc62b3f502672921 /nova/network
parentb1958b7cfa6b8aca5b76b3f133627bb733d29f00 (diff)
downloadnova-4eef0fe6354304b4639a3b635e4955457188e4ce.tar.gz
Unbind port when offloading a shelved instance
When offloading a shelved instance, the compute needs to remove the binding so the port will appear as "unbound" in neutron. Closes-Bug: 1983471 Change-Id: Ia49271b126870c7936c84527a4c39ab96b6c5ea7 Signed-off-by: Arnaud Morin <arnaud.morin@ovhcloud.com>
Diffstat (limited to 'nova/network')
-rw-r--r--nova/network/neutron.py21
1 files changed, 17 insertions, 4 deletions
diff --git a/nova/network/neutron.py b/nova/network/neutron.py
index 27e7d06455..6c9f19f010 100644
--- a/nova/network/neutron.py
+++ b/nova/network/neutron.py
@@ -612,10 +612,22 @@ class API:
raise exception.ExternalNetworkAttachForbidden(
network_uuid=net['id'])
+ def unbind_ports(self, context, ports, detach=True):
+ """Unbind and detach the given ports by clearing their
+ device_owner and dns_name.
+ The device_id will also be cleaned if detach=True.
+
+ :param context: The request context.
+ :param ports: list of port IDs.
+ """
+ neutron = get_client(context)
+ self._unbind_ports(context, ports, neutron, detach=detach)
+
def _unbind_ports(self, context, ports,
- neutron, port_client=None):
- """Unbind the given ports by clearing their device_id,
+ neutron, port_client=None, detach=True):
+ """Unbind and detach the given ports by clearing their
device_owner and dns_name.
+ The device_id will also be cleaned if detach=True.
:param context: The request context.
:param ports: list of port IDs.
@@ -638,11 +650,12 @@ class API:
port_req_body: ty.Dict[str, ty.Any] = {
'port': {
- 'device_id': '',
- 'device_owner': '',
constants.BINDING_HOST_ID: None,
}
}
+ if detach:
+ port_req_body['port']['device_id'] = ''
+ port_req_body['port']['device_owner'] = ''
try:
port = self._show_port(
context, port_id, neutron_client=neutron,