Darryl L. Pierce
2009-Dec-21 16:49 UTC
[Ovirt-devel] [PATCH] Fixed errors when the user selects a different remove libvirt host.
Now the app will show the current connection. When the user selects a different host then any connection exception is caught and the previous connection restored. Signed-off-by: Darryl L. Pierce <dpierce at redhat.com> --- nodeadmin/changehost.py | 6 ++++-- nodeadmin/configscreen.py | 5 ++++- nodeadmin/libvirtworker.py | 16 +++++++++++++++- 3 files changed, 23 insertions(+), 4 deletions(-) diff --git a/nodeadmin/changehost.py b/nodeadmin/changehost.py index 23e6854..f604c03 100644 --- a/nodeadmin/changehost.py +++ b/nodeadmin/changehost.py @@ -27,7 +27,10 @@ CONNECTED_PAGE = 2 class ChangeHostConfigScreen(HostListConfigScreen): def __init__(self): - HostListConfigScreen.__init__(self, "Change Host") + HostListConfigScreen.__init__(self, "") + + def get_title(self): + return "Currently: %s" % self.get_libvirt().get_url() def get_elements_for_page(self, screen, page): if page is CONNECTION_LIST_PAGE: return self.get_connection_list_page(screen) @@ -36,7 +39,6 @@ class ChangeHostConfigScreen(HostListConfigScreen): def process_input(self, page): if page is CONNECTION_LIST_PAGE: logging.info("Changing libvirt connection to %s" % self.get_selected_connection()) - libvirtworker.set_default_url(self.get_selected_connection()) self.get_libvirt().open_connection(self.get_selected_connection()) elif page is CONNECTED_PAGE: self.set_finished() diff --git a/nodeadmin/configscreen.py b/nodeadmin/configscreen.py index 02ab5b4..7a23325 100644 --- a/nodeadmin/configscreen.py +++ b/nodeadmin/configscreen.py @@ -37,6 +37,9 @@ class ConfigScreen: self.__libvirt = LibvirtWorker() self.__vm_config = VirtManagerConfig() + def get_title(self): + return self.__title + def get_hal(self): return self.__hal @@ -83,7 +86,7 @@ class ConfigScreen: screen = SnackScreen() elements = self.get_elements_for_page(screen, self.__current_page) # TODO: need to set the form height to the number of elements on the page - gridform = GridForm(screen, self.__title, 1, 10) + gridform = GridForm(screen, self.get_title(), 1, 10) current_element = 0 for element in elements: gridform.add(element, 0, current_element) diff --git a/nodeadmin/libvirtworker.py b/nodeadmin/libvirtworker.py index b35509f..3338f80 100644 --- a/nodeadmin/libvirtworker.py +++ b/nodeadmin/libvirtworker.py @@ -74,6 +74,8 @@ class LibvirtWorker: def __init__(self, url = None): if url is None: url = get_default_url() logging.info("Connecting to libvirt: %s" % url) + self.__url = None + self.__conn = None self.open_connection(url) self.__capabilities = virtinst.CapabilitiesParser.parse(self.__conn.getCapabilities()) self.__net = virtinst.VirtualNetworkInterface(conn = self.__conn) @@ -84,9 +86,21 @@ class LibvirtWorker: '''Returns the underlying connection.''' return self.__conn + def get_url(self): + return self.__url + def open_connection(self, url): '''Lets the user change the url for the connection.''' - self.__conn = libvirt.open(url) + old_conn = self.__conn + old_url = self.__url + try: + self.__conn = libvirt.open(url) + self.__url = url + set_default_url(url) + except Exception, error: + self.__conn = old_conn + self.__url = old_url + raise error def list_domains(self, defined = True, started = True): '''Lists all domains.''' -- 1.6.5.2
Darryl L. Pierce
2010-Jan-04 16:01 UTC
[Ovirt-devel] [PATCH] Fixed errors when the user selects a different remove libvirt host.
On Mon, Dec 21, 2009 at 11:49:47AM -0500, Darryl L. Pierce wrote:> Now the app will show the current connection. When the user selects > a different host then any connection exception is caught and the > previous connection restored. > > Signed-off-by: Darryl L. Pierce <dpierce at redhat.com> > ---Can I get an ACK or feedback on this? -- Darryl L. Pierce, Sr. Software Engineer @ Red Hat, Inc. Delivering value year after year. Red Hat ranks #1 in value among software vendors. http://www.redhat.com/promo/vendor/ -------------- next part -------------- A non-text attachment was scrubbed... Name: not available Type: application/pgp-signature Size: 198 bytes Desc: not available URL: <http://listman.redhat.com/archives/ovirt-devel/attachments/20100104/21a8a8fc/attachment.sig>
Mike Burns
2010-Mar-24 17:59 UTC
[Ovirt-devel] [PATCH] Fixed errors when the user selects a different remove libvirt host.
On Mon, 2009-12-21 at 11:49 -0500, Darryl L. Pierce wrote:> Now the app will show the current connection. When the user selects > a different host then any connection exception is caught and the > previous connection restored. > > Signed-off-by: Darryl L. Pierce <dpierce at redhat.com> > --- > nodeadmin/changehost.py | 6 ++++-- > nodeadmin/configscreen.py | 5 ++++- > nodeadmin/libvirtworker.py | 16 +++++++++++++++- > 3 files changed, 23 insertions(+), 4 deletions(-) > > diff --git a/nodeadmin/changehost.py b/nodeadmin/changehost.py > index 23e6854..f604c03 100644 > --- a/nodeadmin/changehost.py > +++ b/nodeadmin/changehost.py > @@ -27,7 +27,10 @@ CONNECTED_PAGE = 2 > > class ChangeHostConfigScreen(HostListConfigScreen): > def __init__(self): > - HostListConfigScreen.__init__(self, "Change Host") > + HostListConfigScreen.__init__(self, "") > + > + def get_title(self): > + return "Currently: %s" % self.get_libvirt().get_url() > > def get_elements_for_page(self, screen, page): > if page is CONNECTION_LIST_PAGE: return self.get_connection_list_page(screen) > @@ -36,7 +39,6 @@ class ChangeHostConfigScreen(HostListConfigScreen): > def process_input(self, page): > if page is CONNECTION_LIST_PAGE: > logging.info("Changing libvirt connection to %s" % self.get_selected_connection()) > - libvirtworker.set_default_url(self.get_selected_connection()) > self.get_libvirt().open_connection(self.get_selected_connection()) > elif page is CONNECTED_PAGE: self.set_finished() > > diff --git a/nodeadmin/configscreen.py b/nodeadmin/configscreen.py > index 02ab5b4..7a23325 100644 > --- a/nodeadmin/configscreen.py > +++ b/nodeadmin/configscreen.py > @@ -37,6 +37,9 @@ class ConfigScreen: > self.__libvirt = LibvirtWorker() > self.__vm_config = VirtManagerConfig() > > + def get_title(self): > + return self.__title > + > def get_hal(self): > return self.__hal > > @@ -83,7 +86,7 @@ class ConfigScreen: > screen = SnackScreen() > elements = self.get_elements_for_page(screen, self.__current_page) > # TODO: need to set the form height to the number of elements on the page > - gridform = GridForm(screen, self.__title, 1, 10) > + gridform = GridForm(screen, self.get_title(), 1, 10) > current_element = 0 > for element in elements: > gridform.add(element, 0, current_element) > diff --git a/nodeadmin/libvirtworker.py b/nodeadmin/libvirtworker.py > index b35509f..3338f80 100644 > --- a/nodeadmin/libvirtworker.py > +++ b/nodeadmin/libvirtworker.py > @@ -74,6 +74,8 @@ class LibvirtWorker: > def __init__(self, url = None): > if url is None: url = get_default_url() > logging.info("Connecting to libvirt: %s" % url) > + self.__url = None > + self.__conn = None > self.open_connection(url) > self.__capabilities = virtinst.CapabilitiesParser.parse(self.__conn.getCapabilities()) > self.__net = virtinst.VirtualNetworkInterface(conn = self.__conn) > @@ -84,9 +86,21 @@ class LibvirtWorker: > '''Returns the underlying connection.''' > return self.__conn > > + def get_url(self): > + return self.__url > + > def open_connection(self, url): > '''Lets the user change the url for the connection.''' > - self.__conn = libvirt.open(url) > + old_conn = self.__conn > + old_url = self.__url > + try: > + self.__conn = libvirt.open(url) > + self.__url = url > + set_default_url(url) > + except Exception, error: > + self.__conn = old_conn > + self.__url = old_url > + raise error > > def list_domains(self, defined = True, started = True): > '''Lists all domains.'''Ack, pushed with modified message (s/remove/remote)