Esempio n. 1
0
def _setup_nmstate(networks, bondings, options, in_rollback):
    """
    Setup the networks using nmstate as the backend provider.
    nmstate handles the rollback by itself in case of an error during the
    transaction or in case the resulted state does not include the desired one.

    In order to support the connectivity check, the "regular" rollback is
    used (the Transaction context).
    """
    logging.info('Processing setup through nmstate')
    desired_state = nmstate.generate_state(networks, bondings)
    logging.info('Desired state: %s', desired_state)
    _setup_dynamic_src_routing(networks)
    nmstate.setup(desired_state, verify_change=not in_rollback)
    net_info = NetInfo(netinfo_get())

    with Transaction(in_rollback=in_rollback, persistent=False) as config:
        _setup_qos(networks, net_info, config.networks)
        for net_name, net_attrs in six.viewitems(networks):
            if net_attrs.get('remove'):
                config.removeNetwork(net_name)
        for net_name, net_attrs in six.viewitems(networks):
            if not net_attrs.get('remove'):
                config.setNetwork(net_name, net_attrs)
        for bond_name, bond_attrs in six.viewitems(bondings):
            if bond_attrs.get('remove'):
                config.removeBonding(bond_name)
        for bond_name, bond_attrs in six.viewitems(bondings):
            if not bond_attrs.get('remove'):
                config.setBonding(bond_name, bond_attrs)
        _setup_static_src_routing(networks)
        config.save()
        link_setup.setup_custom_bridge_opts(networks)
        connectivity.check(options)
Esempio n. 2
0
def _setup_nmstate(networks, bondings, options, in_rollback):
    """
    Setup the networks using nmstate as the backend provider.
    nmstate handles the rollback by itself in case of an error during the
    transaction or in case the resulted state does not include the desired one.

    In order to support the connectivity check, the "regular" rollback is
    used (the Transaction context).
    """
    logging.info('Processing setup through nmstate')
    desired_state = nmstate.generate_state(networks, bondings)
    logging.info('Desired state: %s', desired_state)
    nmstate.setup(desired_state, verify_change=not in_rollback)
    with Transaction(in_rollback=in_rollback) as config:
        config.networks = {
            name: attrs
            for name, attrs in six.viewitems(networks)
            if not attrs.get('remove')
        }
        config.bonds = {
            name: attrs
            for name, attrs in six.viewitems(bondings)
            if not attrs.get('remove')
        }
        connectivity.check(options)
Esempio n. 3
0
def _setup_nmstate(networks, bondings, options, in_rollback):
    """
    Setup the networks using nmstate as the backend provider.
    nmstate handles the rollback by itself in case of an error during the
    transaction or in case the resulted state does not include the desired one.

    In order to support the connectivity check, the "regular" rollback is
    used (the Transaction context).
    """
    logging.info('Processing setup through nmstate')
    desired_state = nmstate.generate_state(networks, bondings)
    nmstate.setup(desired_state, verify_change=not in_rollback)
    with Transaction(in_rollback=in_rollback) as config:
        config.networks = {
            name: attrs for name, attrs in six.viewitems(networks)
            if not attrs.get('remove')
        }
        config.bonds = {
            name: attrs for name, attrs in six.viewitems(bondings)
            if not attrs.get('remove')
        }
        connectivity.check(options)
Esempio n. 4
0
def _setup_nmstate(networks, bondings, options, in_rollback, net_info):
    """
    Setup the networks using nmstate as the backend provider.
    nmstate handles the rollback by itself in case of an error during the
    transaction or in case the resulted state does not include the desired one.

    In order to support the connectivity check, the "regular" rollback is
    used (the Transaction context).
    """
    logging.info('Processing setup through nmstate')
    desired_state = nmstate.generate_state(networks, bondings)
    logging.info('Desired state: %s', desired_state)
    _setup_dynamic_src_routing(networks)

    vlan_ifaces_states = _generate_vlan_ifaces_states(desired_state, net_info)
    logging.info('Reapply VLANs desired state: %s', vlan_ifaces_states)

    nmstate.setup(desired_state, verify_change=not in_rollback)
    if vlan_ifaces_states:
        nmstate.setup({'interfaces': vlan_ifaces_states},
                      verify_change=not in_rollback)
    with Transaction(in_rollback=in_rollback) as config:
        for net_name, net_attrs in six.viewitems(networks):
            if net_attrs.get('remove'):
                config.removeNetwork(net_name)
        for net_name, net_attrs in six.viewitems(networks):
            if not net_attrs.get('remove'):
                config.setNetwork(net_name, net_attrs)
        for bond_name, bond_attrs in six.viewitems(bondings):
            if bond_attrs.get('remove'):
                config.removeBonding(bond_name)
        for bond_name, bond_attrs in six.viewitems(bondings):
            if not bond_attrs.get('remove'):
                config.setBonding(bond_name, bond_attrs)
        _setup_static_src_routing(networks)
        connectivity.check(options)