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

« back to all changes in this revision

Viewing changes to src/virtManagerTui/networkconfig.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
# networkconfig.py - Copyright (C) 2009 Red Hat, Inc.
 
2
# Written by Darryl L. Pierce <dpierce@redhat.com>
 
3
#
 
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.
 
7
#
 
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.
 
12
#
 
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.
 
18
 
 
19
from IPy import IP
 
20
import logging
 
21
 
 
22
class NetworkConfig:
 
23
    def __init__(self):
 
24
        self.__name = ""
 
25
        self.set_ipv4_address("192.168.100.0/24")
 
26
        self.__isolated_network = True
 
27
        self.__physical_device = ""
 
28
 
 
29
    def set_name(self, name):
 
30
        self.__name = name
 
31
 
 
32
    def get_name(self):
 
33
        return self.__name
 
34
 
 
35
    def set_ipv4_address(self, address):
 
36
        self.__ipv4_address = IP(address)
 
37
        start = int(self.__ipv4_address.len() / 2)
 
38
        end   = self.__ipv4_address.len() - 2
 
39
        self.__ipv4_start = str(self.__ipv4_address[start])
 
40
        self.__ipv4_end   = str(self.__ipv4_address[end])
 
41
 
 
42
    def get_ipv4_address(self):
 
43
        return self.__ipv4_address.strNormal()
 
44
 
 
45
    def get_ipv4_address_raw(self):
 
46
        return self.__ipv4_address
 
47
 
 
48
    def get_ipv4_netmask(self):
 
49
        return self.__ipv4_address.netmask().strNormal()
 
50
 
 
51
    def get_ipv4_broadcast(self):
 
52
        return self.__ipv4_address.broadcast().strNormal()
 
53
 
 
54
    def get_ipv4_gateway(self):
 
55
        return str(self.__ipv4_address[1])
 
56
 
 
57
    def get_ipv4_max_addresses(self):
 
58
        return self.__ipv4_address.len()
 
59
 
 
60
    def get_ipv4_network_type(self):
 
61
        return self.__ipv4_address.iptype()
 
62
 
 
63
    def is_public_ipv4_network(self):
 
64
        if self.__ipv4_address.iptype() is "PUBLIC":
 
65
            return True
 
66
        return False
 
67
 
 
68
    def set_ipv4_start_address(self, address):
 
69
        self.__ipv4_start = address
 
70
 
 
71
    def get_ipv4_start_address(self):
 
72
        return self.__ipv4_start
 
73
 
 
74
    def set_ipv4_end_address(self, address):
 
75
        self.__ipv4_end = address
 
76
 
 
77
    def get_ipv4_end_address(self):
 
78
        return self.__ipv4_end
 
79
 
 
80
    def is_bad_address(self, address):
 
81
        return not self.__ipv4_address.overlaps(address)
 
82
 
 
83
    def set_isolated_network(self, isolated):
 
84
        self.__isolated_network = isolated
 
85
 
 
86
    def is_isolated_network(self):
 
87
        return self.__isolated_network
 
88
 
 
89
    def set_physical_device(self, device):
 
90
        self.__physical_device = device
 
91
 
 
92
    def get_physical_device(self):
 
93
        return self.__physical_device
 
94
 
 
95
    def get_physical_device_text(self):
 
96
        if self.__physical_device == "":
 
97
            return "any physical device"
 
98
        else:
 
99
            return "physical device %s" % self.__physical_device