Пример #1
0
def writeBonding(f, netcfg, ha_status, bonding, is_first=False):
    ordered_nets = tuple(bonding.nets)
    discard_services = any_ha(ha_status)
    autonomous = hasIPConfiguration(bonding, discard_services=discard_services)
    #autonomous=True:
    #always mark bonding auto
    writePreamble(f, netcfg, bonding, ordered_nets, autonomous=True)
    if is_first:
        addStatement(f, 'pre-up modprobe bonding')

    for statement in (
        'pre-up echo +%s > /sys/class/net/bonding_masters' % bonding.system_name,
        'pre-down echo -%s > /sys/class/net/bonding_masters' % bonding.system_name
    ):
        addStatement(f, statement)

    sorted_ethernets = list(bonding.ethernets)
    sorted_ethernets.sort()
    for ethernet in sorted_ethernets:
        for statement in (
            'up /sbin/ifenslave %s %s' % (bonding.system_name, ethernet.system_name),
            'down /sbin/ifenslave %s -d %s' % (bonding.system_name, ethernet.system_name)
        ):
            addStatement(f, statement)

    if autonomous:
        writeNets(f, ha_status, bonding, ordered_nets)
        writeRoutes(f, bonding)
    else:
        forceCreation(f, bonding)

    f.write('\n')
Пример #2
0
def isInterfaceSpecified(interface, ha_status=None):
    discard_services = active_ha(ha_status)
    return (
        isinstance(interface, Bonding)
        or
        isinstance(interface, Vlan)
        or
        hasIPConfiguration(interface, discard_services=discard_services)
        )
Пример #3
0
def writeEthernet(f, netcfg, ha_status, ethernet):
    ordered_nets = tuple(ethernet.nets)
    autonomous = hasIPConfiguration(ethernet)

    writePreamble(f, netcfg, ethernet, ordered_nets, autonomous=autonomous)
    if autonomous:
        writeNets(f, ha_status, ethernet, ordered_nets)
        writeRoutes(f, ethernet)
    f.write('\n')
Пример #4
0
    def mkEditMenu(self, interface):

        def deleteIntermediate(value):
            self.deleteInterface(interface)
            self.updateToolbar()

        def editIntermediate(value):
            self.editIface(interface)
            self.updateToolbar()

        edit_interface = QAction(QIcon(":icons/edit"), tr("Edit interface parameters"), self)
        self.connect(edit_interface, SIGNAL('triggered(bool)'), editIntermediate )

        actions = [edit_interface]

        if interface.freeForIp():
            def addNetIntermediate(value):
                self.newNet(interface)
                self.updateToolbar()

            add_net = QAction(QIcon(":icons/addnetwork"), tr("Add a network to this interface"), self)
            self.connect(add_net, SIGNAL('triggered(bool)'), addNetIntermediate )

            actions.append(add_net)

        propose_del_action = True
        if isinstance(interface, Ethernet):
            if hasIPConfiguration(interface):
                del_message = tr("Delete configuration")
            else:
                propose_del_action = False
        else:
            del_message = tr("Delete this interface")

        if interface.hasHA():
            propose_del_action = False

        if propose_del_action:
            del_interface = QAction(QIcon(":icons/delete"), del_message, self)
            self.connect(del_interface, SIGNAL('triggered(bool)'), deleteIntermediate)
            actions.append(del_interface)

        menu = QMenu(self)
        menu.setObjectName("menu_%s" % interface.fullName())
        for action in actions:
            menu.addAction(action)

        return menu
Пример #5
0
def writeVlan(f, netcfg, ha_status, vlan):
    ordered_nets = tuple(vlan.nets)

    discard_services = any_ha(ha_status)
    autonomous = hasIPConfiguration(vlan, discard_services=discard_services)

    # Always add preamble and vlan-raw-device
    writePreamble(f, netcfg, vlan, ordered_nets)
    if autonomous:
        writeNets(f, ha_status, vlan, ordered_nets)
        writeRoutes(f, vlan)
    else:
        forceCreation(f, vlan)
    addStatement(
        f,
        'vlan-raw-device %s' % vlan.raw_device,
        ignore_fail=True
        )
    f.write('\n')
Пример #6
0
def writePreamble(fd, netcfg, interface, ordered_nets, autonomous=True):
    if autonomous:
        method = 'static'
    else:
        method = 'manual'

    #auto up: normally all interfaces, but only lo and HA interfaces in a failover setup
    if EDENWALL:
        ha_iface = getHAInterface(netcfg)
    else:
        ha_iface = None

    #there are problems in HA when a bonding has vlans built on it that only have services IPs
    bonding_with_vlans = isinstance(interface, Bonding) and interface.vlans

    if interface is ha_iface or hasIPConfiguration(interface) or (bonding_with_vlans):
        fd.write('auto %s\n' % interface.system_name)

    #Prefix
    if len(ordered_nets) == 0 or ordered_nets[0].net.version() == 4:
        inet_string = 'inet'
    else:
        inet_string = 'inet6'
    fd.write('iface %s %s %s\n' % (interface.system_name, inet_string, method))