1
# changehost.py - Copyright (C) 2009 Red Hat, Inc.
2
# Written by Darryl L. Pierce <dpierce@redhat.com>
4
# This program is free software; you can redistribute it and/or modify
5
# it under the terms of the GNU General Public License as published by
6
# the Free Software Foundation; version 2 of the License.
8
# This program is distributed in the hope that it will be useful,
9
# but WITHOUT ANY WARRANTY; without even the implied warranty of
10
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
11
# GNU General Public License for more details.
13
# You should have received a copy of the GNU General Public License
14
# along with this program; if not, write to the Free Software
15
# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston,
16
# MA 02110-1301, USA. A copy of the GNU General Public License is
17
# also available at http://www.gnu.org/copyleft/gpl.html.
23
from configscreen import *
25
CONNECTION_LIST_PAGE = 1
28
class ChangeHostConfigScreen(HostListConfigScreen):
30
HostListConfigScreen.__init__(self, "")
33
return "Currently: %s" % self.get_libvirt().get_url()
35
def get_elements_for_page(self, screen, page):
36
if page is CONNECTION_LIST_PAGE: return self.get_connection_list_page(screen)
37
elif page is CONNECTED_PAGE: return self.get_connected_page(screen)
39
def process_input(self, page):
40
if page is CONNECTION_LIST_PAGE:
41
logging.info("Changing libvirt connection to %s" % self.get_selected_connection())
42
self.get_libvirt().open_connection(self.get_selected_connection())
43
elif page is CONNECTED_PAGE: self.set_finished()
45
def page_has_next(self, page):
46
if page is CONNECTION_LIST_PAGE: return self.has_selectable_connections()
49
def page_has_back(self, page):
50
return page > CONNECTION_LIST_PAGE
52
def page_has_finish(self, page):
53
return page is CONNECTED_PAGE
55
def get_connected_page(self, screen):
56
return [Label("Connected to %s" % self.get_selected_connection())]
59
screen = ChangeHostConfigScreen()