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

« back to all changes in this revision

Viewing changes to src/virtManager/network.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:
18
18
# MA 02110-1301 USA.
19
19
#
20
20
 
21
 
import gobject
22
21
import virtinst.util as util
23
22
 
24
23
from virtManager.IPy import IP
25
 
 
26
 
class vmmNetwork(gobject.GObject):
27
 
    __gsignals__ = { }
28
 
 
 
24
from virtManager.libvirtobject import vmmLibvirtObject
 
25
 
 
26
class vmmNetwork(vmmLibvirtObject):
29
27
    @staticmethod
30
28
    def pretty_desc(forward, forwardDev):
31
29
        if forward or forwardDev:
49
47
 
50
48
        return desc
51
49
 
52
 
    def __init__(self, config, connection, net, uuid, active):
53
 
        self.__gobject_init__()
54
 
        self.config = config
55
 
        self.connection = connection
 
50
    def __init__(self, connection, net, uuid, active):
 
51
        vmmLibvirtObject.__init__(self, connection)
56
52
        self.net = net
57
53
        self.uuid = uuid
58
54
        self.active = active
59
 
        self._xml = self.net.XMLDesc(0)
 
55
 
 
56
    # Required class methods
 
57
    def get_name(self):
 
58
        return self.net.name()
 
59
    def _XMLDesc(self, flags):
 
60
        return self.net.XMLDesc(flags)
 
61
    def _define(self, xml):
 
62
        return self.get_connection().vmm.networkDefineXML(xml)
 
63
 
60
64
 
61
65
    def set_handle(self, net):
62
66
        self.net = net
64
68
    def set_active(self, state):
65
69
        self.active = state
66
70
 
67
 
    def get_xml(self):
68
 
        if not self._xml:
69
 
            self._update_xml()
70
 
        return self._xml
71
 
 
72
 
    def _update_xml(self):
73
 
        self._xml = self.net.XMLDesc(0)
74
 
 
75
71
    def is_active(self):
76
72
        return self.active
77
73
 
78
 
    def get_connection(self):
79
 
        return self.connection
80
 
 
81
 
    def get_name(self):
82
 
        return self.net.name()
83
 
 
84
74
    def get_label(self):
85
75
        return self.get_name()
86
76
 
119
109
        gateway = IP(addrStr)
120
110
 
121
111
        network = IP(gateway.int() & netmask.int())
122
 
        return IP(str(network)+ "/" + netmaskStr)
 
112
        return IP(str(network) + "/" + netmaskStr)
123
113
 
124
114
    def get_ipv4_forward(self):
125
115
        xml = self.get_xml()
140
130
        forward, forwardDev = self.get_ipv4_forward()
141
131
        return vmmNetwork.pretty_desc(forward, forwardDev)
142
132
 
143
 
    def is_read_only(self):
144
 
        if self.connection.is_read_only():
 
133
    def can_pxe(self):
 
134
        xml = self.get_xml()
 
135
        forward = self.get_ipv4_forward()[0]
 
136
        if forward and forward != "nat":
145
137
            return True
146
 
        return False
 
138
        return bool(util.get_xml_path(xml, "/network/ip/dhcp/bootp/@file"))
147
139
 
148
 
gobject.type_register(vmmNetwork)
 
140
vmmLibvirtObject.type_register(vmmNetwork)