Ejemplo n.º 1
0
    def _ifup_vlan_with_slave_bond_hwaddr_sync(vlan):
        """
        When NM is active and the network includes a vlan on top of a bond, the
        following scenario may occur:
        - VLAN over a bond with slaves is already defined in the system and
          VDSM is about to acquire it to define on it a network.
        - The VLAN iface is re-created while the bond slaves are temporary
          detached, causing the vlan to be created with the bond temporary
          mac address, which is different from the original existing address.
        Therefore, following the VLAN ifup command, its mac address is compared
        with the first bond slave. In case they differ, the vlan device is
        recreated.
        Bond mode 5 & 6 is excluded from the mac sync check.
        """
        bond = vlan.device
        bond_mode = Ifcfg._get_bond_mode(bond)
        if not bond.slaves or bond_mode == '5' or bond_mode == '6':
            _ifup(vlan)
            return

        blocking = _blocking_action_required(vlan)
        for attempt in range(5):
            if blocking:
                _ifup(vlan, blocking=blocking)
            else:
                with waitfor.waitfor_link_exists(vlan.name):
                    _ifup(vlan, blocking=blocking)

            vlan_hwaddr = link_iface.iface(vlan.name).address()
            slaves_hwaddr = [
                link_iface.iface(slave.name).address() for slave in bond.slaves
            ]
            if slaves_hwaddr[0] == vlan_hwaddr:
                return

            bond_hwaddr = link_iface.iface(bond.name).address()
            logging.info(
                '%s. vlan@bond hwaddr is not in sync (v/b/[s]): %s/%s/%s',
                attempt,
                vlan_hwaddr,
                bond_hwaddr,
                slaves_hwaddr,
            )

            ifdown(vlan.name)

        raise ConfigNetworkError(
            ERR_BAD_BONDING,
            'While adding vlan {} over bond {}, '
            'the bond hwaddr was not in sync '
            'whith its slaves.'.format(vlan.name, vlan.device.name),
        )
Ejemplo n.º 2
0
Archivo: ifcfg.py Proyecto: oVirt/vdsm
    def _ifup_vlan_with_slave_bond_hwaddr_sync(vlan):
        """
        When NM is active and the network includes a vlan on top of a bond, the
        following scenario may occur:
        - VLAN over a bond with slaves is already defined in the system and
          VDSM is about to acquire it to define on it a network.
        - The VLAN iface is re-created while the bond slaves are temporary
          detached, causing the vlan to be created with the bond temporary
          mac address, which is different from the original existing address.
        Therefore, following the VLAN ifup command, its mac address is compared
        with the first bond slave. In case they differ, the vlan device is
        recreated.
        Bond mode 5 & 6 is excluded from the mac sync check.
        """
        bond = vlan.device
        bond_mode = Ifcfg._get_bond_mode(bond)
        if not bond.slaves or bond_mode == '5' or bond_mode == '6':
            _ifup(vlan)
            return

        blocking = _blocking_action_required(vlan)
        for attempt in range(5):
            if blocking:
                _ifup(vlan, blocking=blocking)
            else:
                with waitfor.waitfor_link_exists(vlan.name):
                    _ifup(vlan, blocking=blocking)

            vlan_hwaddr = link_iface.iface(vlan.name).address()
            slaves_hwaddr = [link_iface.iface(slave.name).address()
                             for slave in bond.slaves]
            if slaves_hwaddr[0] == vlan_hwaddr:
                return

            bond_hwaddr = link_iface.iface(bond.name).address()
            logging.info(
                '%s. vlan@bond hwaddr is not in sync (v/b/[s]): %s/%s/%s',
                attempt, vlan_hwaddr, bond_hwaddr, slaves_hwaddr)

            ifdown(vlan.name)

        raise ConfigNetworkError(
            ERR_BAD_BONDING,
            'While adding vlan {} over bond {}, '
            'the bond hwaddr was not in sync '
            'whith its slaves.'.format(vlan.name, vlan.device.name))
Ejemplo n.º 3
0
    def _ifup_vlan_with_slave_bond_hwaddr_sync(vlan):
        """
        When NM is active and the network includes a vlan on top of a bond, the
        following scenario may occur:
        - VLAN over a bond with slaves is already defined in the system and
          VDSM is about to acquire it to define on it a network.
        - The VLAN iface is re-created while the bond slaves are temporary
          detached, causing the vlan to be created with the bond temporary
          mac address, which is different from the original existing address.
        Therefore, following the VLAN ifup command, its mac address is compared
        with the first bond slave. In case they differ, the vlan device is
        recreated.
        """
        bond = vlan.device
        if not bond.slaves:
            _ifup(vlan)
            return

        blocking = _blocking_action_required(vlan)
        for attempt in range(5):
            if blocking:
                _ifup(vlan, blocking=blocking)
            else:
                with waitfor.waitfor_link_exists(vlan.name):
                    _ifup(vlan, blocking=blocking)

            if (link_iface.mac_address(bond.slaves[0].name) ==
                    link_iface.mac_address(vlan.name)):
                return

            logging.info('Config vlan@bond: hwaddr not in sync (%s)', attempt)
            ifdown(vlan.name)

        raise ConfigNetworkError(
            ERR_BAD_BONDING,
            'While adding vlan {} over bond {}, '
            'the bond hwaddr was not in sync '
            'whith its slaves.'.format(vlan.name, vlan.device.name))