コード例 #1
0
ファイル: defaults.py プロジェクト: oVirt/Node
            def commit(self):
                if bond["options"]:
                    cfg = NicConfig(bond["name"])
                    cfg.device = bond["name"]
                    cfg.onboot = "yes"
                    cfg.bonding_opts = bond["options"]

                    cfg.save()
コード例 #2
0
ファイル: defaults.py プロジェクト: oVirt/Node
            def commit(self):
                m = Network().retrieve()
                if m["iface"] in bond["slaves"]:
                    raise RuntimeError("Bond slave can not be used as " +
                                       "primary device")

                for slave in bond["slaves"]:
                    slave_cfg = NicConfig(slave)
                    slave_cfg.device = slave
                    slave_cfg.slave = "yes"
                    slave_cfg.master = bond["name"]
                    slave_cfg.onboot = "yes"
                    slave_cfg.save()
コード例 #3
0
ファイル: defaults.py プロジェクト: oVirt/Node
            def _remove_devices(self):
                process.call(["killall", "dhclient"])

                vlans = utils.network.Vlans()
                vifs = vlans.all_vlan_devices()
                self.logger.debug("Attempting to delete all vlans: %s" % vifs)
                for vifname in vifs:
                    vlans.delete(vifname)
                    if NicConfig(vifname).exists():
                        NicConfig(vifname).delete()

                # FIXME we are removing ALL bridges
                bridges = Bridges()
                for bifname in bridges.ifnames():
                    bridges.delete(bifname)
                    if NicConfig(bifname).exists():
                        NicConfig(bifname).delete()

                bonds = Bonds()
                bonds.delete_all()
コード例 #4
0
ファイル: defaults.py プロジェクト: oVirt/Node
            def commit(self):
                net = Network()
                mnet = net.retrieve()
                if mnet["iface"] and mnet["iface"].startswith("bond"):
                    net.configure_no_networking()

                for ifname in NicConfig.list():
                    cfg = NicConfig(ifname)
                    if cfg.master:
                        self.logger.debug("Removing master from %s" % ifname)
                        cfg.master = None
                        cfg.slave = None
                        cfg.save()
                    elif ifname.startswith("bond"):
                        self.logger.debug("Removing master %s" % ifname)
                        cfg.delete()

                Bonds().delete_all()
コード例 #5
0
    def __init__(self, ifname):
        super(NIC, self).__init__()
        self.ifname = ifname

        self._udevinfo = UdevNICInfo(self.ifname)
        self.vendor = self._udevinfo.vendor

        self._sysfsinfo = SysfsNICInfo(self.ifname)
        self.driver = self._sysfsinfo.driver
        self.hwaddr = self._sysfsinfo.hwaddr

        self.config = NicConfig(ifname)
        self.typ = self._udevinfo.devtype or self._sysfsinfo.systype
コード例 #6
0
ファイル: defaults.py プロジェクト: oVirt/Node
            def __write_direct_config(self):
                m = Network().retrieve()

                nic_ifname_vlan = "%s.%s" % (m["iface"],
                                             m["vlanid"])
                nic_ifname = nic_ifname_vlan if m["vlanid"] \
                    else m["iface"]
                nic_cfg = NicConfig(nic_ifname)
                nic_cfg.device = nic_ifname
                self.__assign_common(nic_cfg)
                nic_cfg.hwaddr = NIC(m["iface"]).hwaddr

                nic_cfg.save()
コード例 #7
0
ファイル: defaults.py プロジェクト: oVirt/Node
            def __write_bridged_config(self):
                m = Network().retrieve()

                # Bridge
                bridge_ifname = "br%s" % m["iface"]
                bridge_cfg = NicConfig(bridge_ifname)
                self.__assign_common(bridge_cfg)
                bridge_cfg.device = bridge_ifname
                bridge_cfg.delay = "0"
                bridge_cfg.type = "Bridge"

                # Now the slave
                slave_ifname_vlan = "%s.%s" % (m["iface"],
                                               m["vlanid"])
                slave_ifname = slave_ifname_vlan if m["vlanid"] else m["iface"]
                slave_cfg = NicConfig(slave_ifname)
                slave_cfg.device = m["iface"]
                slave_cfg.device = slave_ifname
                slave_cfg.bridge = bridge_ifname
                slave_cfg.hwaddr = NIC(m["iface"]).hwaddr
                slave_cfg.vlan = "yes" if m["vlanid"] else None
                slave_cfg.onboot = "yes"

                # save()includes persisting
                bridge_cfg.save()
                slave_cfg.save()