Files
virt-manager/virtManagerTui/changehost.py

68 lines
2.3 KiB
Python
Raw Normal View History

2011-05-03 14:57:35 -04:00
# changehost.py - Copyright (C) 2009 Red Hat, Inc.
# Written by Darryl L. Pierce <dpierce@redhat.com>
#
# This program is free software; you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation; version 2 of the License.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with this program; if not, write to the Free Software
# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston,
# MA 02110-1301, USA. A copy of the GNU General Public License is
# also available at http://www.gnu.org/copyleft/gpl.html.
2011-05-31 15:13:55 -04:00
import snack
2011-05-03 14:57:35 -04:00
import logging
from virtManagerTui.hostlistconfigscreen import HostListConfigScreen
2011-05-03 14:57:35 -04:00
CONNECTION_LIST_PAGE = 1
CONNECTED_PAGE = 2
2011-05-03 14:57:35 -04:00
class ChangeHostConfigScreen(HostListConfigScreen):
def __init__(self):
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:
2011-06-01 13:17:55 -04:00
return self.get_connection_list_page(screen)
elif page is CONNECTED_PAGE:
return self.get_connected_page(screen)
2011-05-03 14:57:35 -04:00
def process_input(self, page):
if page is CONNECTION_LIST_PAGE:
logging.info("Changing libvirt connection to %s",
self.get_selected_connection())
2011-05-03 14:57:35 -04:00
self.get_libvirt().open_connection(self.get_selected_connection())
2011-06-01 13:17:55 -04:00
elif page is CONNECTED_PAGE:
self.set_finished()
2011-05-03 14:57:35 -04:00
def page_has_next(self, page):
2011-06-01 13:17:55 -04:00
if page is CONNECTION_LIST_PAGE:
return self.has_selectable_connections()
2011-05-03 14:57:35 -04:00
return False
def page_has_back(self, page):
return page > CONNECTION_LIST_PAGE
def page_has_finish(self, page):
return page is CONNECTED_PAGE
def get_connected_page(self, screen):
ignore = screen
2011-05-31 15:13:55 -04:00
return [snack.Label("Connected to %s" % self.get_selected_connection())]
2011-05-03 14:57:35 -04:00
2011-05-03 14:57:35 -04:00
def ChangeHost():
screen = ChangeHostConfigScreen()
screen.start()