mirror of
https://github.com/virt-manager/virt-manager.git
synced 2025-02-14 01:13:38 -06:00
engine: Don't rewrite connection list when we read stored URIs
This commit is contained in:
parent
d057cce292
commit
179e94fda5
@ -195,7 +195,7 @@ def show_engine(engine, show, uri, uuid, no_conn_auto):
|
|||||||
engine.show_manager()
|
engine.show_manager()
|
||||||
|
|
||||||
if uri:
|
if uri:
|
||||||
conn = engine.add_conn(uri)
|
conn = engine.add_conn_to_ui(uri)
|
||||||
|
|
||||||
if conn and show:
|
if conn and show:
|
||||||
conn.connect_opt_out("state-changed",
|
conn.connect_opt_out("state-changed",
|
||||||
|
@ -203,10 +203,11 @@ class vmmEngine(vmmGObject):
|
|||||||
|
|
||||||
def load_stored_uris(self):
|
def load_stored_uris(self):
|
||||||
uris = self.config.get_conn_uris()
|
uris = self.config.get_conn_uris()
|
||||||
if uris != None:
|
if not uris:
|
||||||
logging.debug("About to connect to uris %s", uris)
|
return
|
||||||
for uri in uris:
|
logging.debug("About to connect to uris %s", uris)
|
||||||
self.add_conn(uri)
|
for uri in uris:
|
||||||
|
self.add_conn_to_ui(uri)
|
||||||
|
|
||||||
def autostart_conns(self):
|
def autostart_conns(self):
|
||||||
for uri in self.conns:
|
for uri in self.conns:
|
||||||
@ -214,31 +215,6 @@ class vmmEngine(vmmGObject):
|
|||||||
if conn.get_autoconnect():
|
if conn.get_autoconnect():
|
||||||
self.connect_to_uri(uri)
|
self.connect_to_uri(uri)
|
||||||
|
|
||||||
def connect_to_uri(self, uri, autoconnect=None, do_start=True):
|
|
||||||
try:
|
|
||||||
conn = self._check_conn(uri)
|
|
||||||
if not conn:
|
|
||||||
# Unknown connection, add it
|
|
||||||
conn = self.add_conn(uri)
|
|
||||||
|
|
||||||
if autoconnect is not None:
|
|
||||||
conn.set_autoconnect(bool(autoconnect))
|
|
||||||
|
|
||||||
self.show_manager()
|
|
||||||
if do_start:
|
|
||||||
conn.open()
|
|
||||||
return conn
|
|
||||||
except Exception:
|
|
||||||
logging.exception("Error connecting to %s", uri)
|
|
||||||
return None
|
|
||||||
|
|
||||||
def _do_connect(self, src_ignore, uri):
|
|
||||||
return self.connect_to_uri(uri)
|
|
||||||
|
|
||||||
def _connect_cancelled(self, src):
|
|
||||||
if len(self.conns.keys()) == 0:
|
|
||||||
self.exit_app(src)
|
|
||||||
|
|
||||||
|
|
||||||
def _do_vm_removed(self, conn, vmuuid):
|
def _do_vm_removed(self, conn, vmuuid):
|
||||||
hvuri = conn.get_uri()
|
hvuri = conn.get_uri()
|
||||||
@ -424,7 +400,9 @@ class vmmEngine(vmmGObject):
|
|||||||
self.connect("conn-removed", self.inspection.conn_removed)
|
self.connect("conn-removed", self.inspection.conn_removed)
|
||||||
return
|
return
|
||||||
|
|
||||||
def add_conn(self, uri):
|
|
||||||
|
def add_conn_to_ui(self, uri):
|
||||||
|
# Public method called from virt-manager.py
|
||||||
conn = self._check_conn(uri)
|
conn = self._check_conn(uri)
|
||||||
if conn:
|
if conn:
|
||||||
return conn
|
return conn
|
||||||
@ -441,10 +419,30 @@ class vmmEngine(vmmGObject):
|
|||||||
conn.connect("state-changed", self._do_conn_changed)
|
conn.connect("state-changed", self._do_conn_changed)
|
||||||
conn.tick()
|
conn.tick()
|
||||||
self.emit("conn-added", conn)
|
self.emit("conn-added", conn)
|
||||||
self.config.add_conn(conn.get_uri())
|
|
||||||
|
|
||||||
return conn
|
return conn
|
||||||
|
|
||||||
|
|
||||||
|
def connect_to_uri(self, uri, autoconnect=None, do_start=True):
|
||||||
|
# Public method called from virt-manager.py
|
||||||
|
try:
|
||||||
|
conn = self.add_conn_to_ui(uri)
|
||||||
|
|
||||||
|
if conn.get_uri() not in (self.config.get_conn_uris() or []):
|
||||||
|
self.config.add_conn(conn.get_uri())
|
||||||
|
|
||||||
|
if autoconnect is not None:
|
||||||
|
conn.set_autoconnect(bool(autoconnect))
|
||||||
|
|
||||||
|
self.show_manager()
|
||||||
|
if do_start:
|
||||||
|
conn.open()
|
||||||
|
return conn
|
||||||
|
except Exception:
|
||||||
|
logging.exception("Error connecting to %s", uri)
|
||||||
|
return None
|
||||||
|
|
||||||
|
|
||||||
def cleanup_conn(self, uri):
|
def cleanup_conn(self, uri):
|
||||||
try:
|
try:
|
||||||
if self.conns[uri]["windowHost"]:
|
if self.conns[uri]["windowHost"]:
|
||||||
@ -552,20 +550,26 @@ class vmmEngine(vmmGObject):
|
|||||||
except Exception, e:
|
except Exception, e:
|
||||||
src.err.show_err(_("Error launching host dialog: %s") % str(e))
|
src.err.show_err(_("Error launching host dialog: %s") % str(e))
|
||||||
|
|
||||||
|
|
||||||
def _get_connect_dialog(self):
|
def _get_connect_dialog(self):
|
||||||
if self.windowConnect:
|
if self.windowConnect:
|
||||||
return self.windowConnect
|
return self.windowConnect
|
||||||
|
|
||||||
def connect_wrap(src, uri, autoconnect):
|
def completed(src, uri, autoconnect):
|
||||||
ignore = src
|
ignore = src
|
||||||
return self.connect_to_uri(uri, autoconnect)
|
return self.connect_to_uri(uri, autoconnect)
|
||||||
|
|
||||||
|
def cancelled(src):
|
||||||
|
if len(self.conns.keys()) == 0:
|
||||||
|
self.exit_app(src)
|
||||||
|
|
||||||
obj = vmmConnect()
|
obj = vmmConnect()
|
||||||
obj.connect("completed", connect_wrap)
|
obj.connect("completed", completed)
|
||||||
obj.connect("cancelled", self._connect_cancelled)
|
obj.connect("cancelled", cancelled)
|
||||||
self.windowConnect = obj
|
self.windowConnect = obj
|
||||||
return self.windowConnect
|
return self.windowConnect
|
||||||
|
|
||||||
|
|
||||||
def _do_show_connect(self, src):
|
def _do_show_connect(self, src):
|
||||||
try:
|
try:
|
||||||
self._get_connect_dialog().show(src.topwin)
|
self._get_connect_dialog().show(src.topwin)
|
||||||
@ -642,7 +646,6 @@ class vmmEngine(vmmGObject):
|
|||||||
obj.connect("action-show-about", self._do_show_about)
|
obj.connect("action-show-about", self._do_show_about)
|
||||||
obj.connect("action-show-host", self._do_show_host)
|
obj.connect("action-show-host", self._do_show_host)
|
||||||
obj.connect("action-show-connect", self._do_show_connect)
|
obj.connect("action-show-connect", self._do_show_connect)
|
||||||
obj.connect("action-connect", self._do_connect)
|
|
||||||
obj.connect("action-exit-app", self.exit_app)
|
obj.connect("action-exit-app", self.exit_app)
|
||||||
obj.connect("manager-opened", self.increment_window_counter)
|
obj.connect("manager-opened", self.increment_window_counter)
|
||||||
obj.connect("manager-closed", self.decrement_window_counter)
|
obj.connect("manager-closed", self.decrement_window_counter)
|
||||||
|
@ -91,7 +91,6 @@ class vmmManager(vmmGObjectUI):
|
|||||||
"action-reboot-domain": (GObject.SignalFlags.RUN_FIRST, None, [str, str]),
|
"action-reboot-domain": (GObject.SignalFlags.RUN_FIRST, None, [str, str]),
|
||||||
"action-destroy-domain": (GObject.SignalFlags.RUN_FIRST, None, [str, str]),
|
"action-destroy-domain": (GObject.SignalFlags.RUN_FIRST, None, [str, str]),
|
||||||
"action-save-domain": (GObject.SignalFlags.RUN_FIRST, None, [str, str]),
|
"action-save-domain": (GObject.SignalFlags.RUN_FIRST, None, [str, str]),
|
||||||
"action-connect": (GObject.SignalFlags.RUN_FIRST, None, [str]),
|
|
||||||
"action-show-help": (GObject.SignalFlags.RUN_FIRST, None, [str]),
|
"action-show-help": (GObject.SignalFlags.RUN_FIRST, None, [str]),
|
||||||
"action-migrate-domain": (GObject.SignalFlags.RUN_FIRST, None, [str, str]),
|
"action-migrate-domain": (GObject.SignalFlags.RUN_FIRST, None, [str, str]),
|
||||||
"action-clone-domain": (GObject.SignalFlags.RUN_FIRST, None, [str, str]),
|
"action-clone-domain": (GObject.SignalFlags.RUN_FIRST, None, [str, str]),
|
||||||
|
Loading…
Reference in New Issue
Block a user