1
0
Fork 0
mirror of https://github.com/retspen/webvirtcloud synced 2026-12-03 17:36:05 +00:00

fix(computes): a changed compute does not use or list its old host

A compute saved with another address, login or password, or deleted, left
its connection open in the panel: saved back to the old credentials, the
panel used it again although the host no longer took them. A VM list that
read the host before such a change could then save that listing over the
VMs of the new one.

The old connection is retired when a compute's connection changes or the
compute is deleted, and a listing is saved only when the compute's
connection is still the one it was read with.
This commit is contained in:
catborise 2026-11-12 08:44:34 +03:00
parent 29ec20682b
commit d682c4bc82
5 changed files with 81 additions and 2 deletions

View file

@ -432,6 +432,13 @@ class wvmConnectionManager(object):
return connection
return None
def retire_connection(self, host, login, passwd, conn):
"""The connection with these credentials, of a compute changed or
deleted, is not used again: asked again, it connects anew."""
connection = self._search_connection(str(host), str(login), str(passwd) if passwd is not None else None, conn)
if connection is not None:
connection.retire()
def get_connection(self, host, login, passwd, conn):
"""
returns a connection object (as returned by the libvirt.open* methods) for the given host and credentials

View file

@ -177,6 +177,17 @@ class BoundedOpenTestCase(unittest.TestCase):
self.assertIsNone(entry.connection)
self.assertEqual(entry.last_error, {"text": "Connection closed (keepalive timeout)", "values": {}})
def test_a_retired_connection_of_a_changed_compute_is_opened_anew(self):
self.release.set()
old, new = alive_connection(), alive_connection()
with self.open_auth(old):
self.get()
self.manager.retire_connection("h", "u", "p", CONN_TCP)
self.manager.retire_connection("other", "u", "p", CONN_TCP) # none: nothing to do
with self.open_auth(new):
self.assertIs(self.get()[0], new)
self.assertEqual(self.calls, 2)
def test_an_rpc_error_opens_new_connections(self):
self.release.set()
old, new = alive_connection(), alive_connection()