~ubuntu-branches/ubuntu/precise/virt-manager/precise-proposed

« back to all changes in this revision

Viewing changes to src/virtManagerTui/undefinenetwork.py

  • Committer: Bazaar Package Importer
  • Author(s): Marc Deslauriers
  • Date: 2011-02-03 10:35:22 UTC
  • mfrom: (2.3.3 experimental)
  • Revision ID: james.westby@ubuntu.com-20110203103522-j8and6dsy3taczbj
Tags: 0.8.6-1ubuntu1
* Merge from debian experimental. Remaining changes:
  - Depend on python-appindicator for appindicator support.
  - Add a /usr/share/pixmaps/virt-manager-icon.svg symlink to link icon to
    where the Application Indicator can find it.
  - Add patch da_l10n.patch since it is not integrated. (refreshed)
  - Add patch show_session_or_system_in_console to make the overview
    screen show which local qemu session you're connected to. (refreshed)
  - Add patch more_helpful_error_message to explain to the user why he
    can't connect to qemu:///system and what he can do fix it.
  - Add patch qemu-system-by-default to automatically add qemu:///system
    to the list of hypervisors if the user has write access to the UNIX
    socket.
  - Drop patchsys-quilt include since dpkg-source does the quilt dance for
    us.
  - debian/control: lower libvirt-bin from Recommends to Suggests; seems
    some users (like netbooks) want to manage VMs, but not host them; see
    meta packages (ubuntu-virt, ubuntu-virt-server, ubuntu-virt-mgmt) for
    group installation of virt package sets.
* Removed patches:
  - debian/patches/custom-icon-installation.patch: Upstream.
  - debian/patches/remove-appindicator-workarounds.patch: Upstream.
  - debian/patches/fix-nc-with-zsh.patch: Upstream
* Removed python-ipy dependency as it is in universe:
  - debian/control: remove python-ipy from Depends
  - debian/series: disable 0002-Use-IPy-from-python-ipy.patch patch so
    we use the one that's included in the virt-manager source.
  - debian/rules: don't delete the IPy file.
* debian/patches/fix-cpu-wrong-types.patch: fix "value is of wrong type
  for this column" error by making sure we are using strings in
  src/virtManager/details.py.
* debian/patches/dont-always-launch-consoles.patch: Don't always launch
  consoles for running domains in src/virtManager/manager.py.

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
#!/usr/bin/env python
 
2
#
 
3
# undefinenetwork.py - Copyright (C) 2009 Red Hat, Inc.
 
4
# Written by Darryl L. Pierce <dpierce@redhat.com>
 
5
#
 
6
# This program is free software; you can redistribute it and/or modify
 
7
# it under the terms of the GNU General Public License as published by
 
8
# the Free Software Foundation; version 2 of the License.
 
9
#
 
10
# This program is distributed in the hope that it will be useful,
 
11
# but WITHOUT ANY WARRANTY; without even the implied warranty of
 
12
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 
13
# GNU General Public License for more details.
 
14
#
 
15
# You should have received a copy of the GNU General Public License
 
16
# along with this program; if not, write to the Free Software
 
17
# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston,
 
18
# MA  02110-1301, USA.  A copy of the GNU General Public License is
 
19
# also available at http://www.gnu.org/copyleft/gpl.html.
 
20
 
 
21
from snack import *
 
22
from configscreen import *
 
23
 
 
24
LIST_PAGE     = 1
 
25
CONFIRM_PAGE  = 2
 
26
UNDEFINE_PAGE = 3
 
27
 
 
28
class UndefineNetworkConfigScreen(NetworkListConfigScreen):
 
29
    def __init__(self):
 
30
        NetworkListConfigScreen.__init__(self, "Undefine A Network")
 
31
 
 
32
    def get_elements_for_page(self, screen, page):
 
33
        if   page is LIST_PAGE:     return self.get_network_list_page(screen, created = False)
 
34
        elif page is CONFIRM_PAGE:  return self.get_confirm_page(screen)
 
35
        elif page is UNDEFINE_PAGE: return self.get_undefine_network_page(screen)
 
36
 
 
37
    def process_input(self, page, errors):
 
38
        if page is LIST_PAGE:
 
39
            network = self.get_selected_network()
 
40
            self.get_libvirt().undefine_network(network)
 
41
            return True
 
42
 
 
43
    def page_has_next(self, page):
 
44
        if page is LIST_PAGE:    return self.has_selectable_networks()
 
45
        if page is CONFIRM_PAGE: return True
 
46
        return False
 
47
 
 
48
    def page_has_back(self, page):
 
49
        if page is CONFIRM_PAGE: return True
 
50
        if page is UNDEFINE_PAGE: return True
 
51
        return False
 
52
 
 
53
    def get_back_page(self, page):
 
54
        if   page is CONFIRM_PAGE: return LIST_PAGE
 
55
        elif page is UNDEFINE_PAGE: return LIST_PAGE
 
56
 
 
57
    def validate_input(self, page, errors):
 
58
        if   page is LIST_PAGE: return True
 
59
        elif page is CONFIRM_PAGE:
 
60
            if self.__confirm_undefine.value():
 
61
                return True
 
62
            else:
 
63
                errors.append("You must confirm undefining %s." % self.get_selected_network())
 
64
        elif page is UNDEFINE_PAGE: return True
 
65
        return False
 
66
 
 
67
    def process_input(self, page):
 
68
        if   page is LIST_PAGE:     return True
 
69
        elif page is CONFIRM_PAGE:
 
70
            network = self.get_selected_network()
 
71
            self.get_libvirt().undefine_network(network)
 
72
            return True
 
73
        elif page is UNDEFINE_PAGE: return True
 
74
        return False
 
75
 
 
76
    def get_confirm_page(self, screen):
 
77
        self.__confirm_undefine = Checkbox("Check here to confirm undefining %s." % self.get_selected_network(), 0)
 
78
        grid = Grid(1, 1)
 
79
        grid.setField(self.__confirm_undefine, 0, 0)
 
80
        return [grid]
 
81
 
 
82
    def get_undefine_network_page(self, screen):
 
83
        return [Label("Network Is Undefined"),
 
84
                Label("Network has been undefined: %s" % self.get_selected_network())]
 
85
 
 
86
def UndefineNetwork():
 
87
    screen = UndefineNetworkConfigScreen()
 
88
    screen.start()