Ejemplo n.º 1
0
    def test_ovs_info_with_sb_nic(self):
        with dummy_device() as nic:
            with _setup_ovs_network(self.ovsdb, nic):
                expected_bridges = {
                    TEST_BRIDGE: {
                        'stp': False,
                        'dpdk_enabled': False,
                        'ports': {
                            nic: {
                                'level': info.SOUTHBOUND,
                                'tag': None
                            },
                            TEST_VLANED_NETWORK: {
                                'level': info.NORTHBOUND,
                                'tag': TEST_VLAN,
                            },
                            TEST_BRIDGE: {
                                'level': None,
                                'tag': None
                            },
                        },
                    }
                }

                ovs_info = info.OvsInfo()

                obtained_bridges = ovs_info.bridges
                self.assertEqual(obtained_bridges, expected_bridges)

                obtained_bridges_by_sb = ovs_info.bridges_by_sb
                self.assertEqual(obtained_bridges_by_sb, {nic: TEST_BRIDGE})
Ejemplo n.º 2
0
    def test_ovs_info_with_sb_bond(self):
        with dummy_device() as nic:
            with bond_device([nic]) as bond:
                with _setup_ovs_network(self.ovsdb, bond):
                    expected_bridges = {
                        TEST_BRIDGE: {
                            'stp': False,
                            'ports': {
                                TEST_VLANED_NETWORK: {
                                    'level': info.NORTHBOUND,
                                    'tag': TEST_VLAN
                                },
                                TEST_BRIDGE: {
                                    'level': None,
                                    'tag': None
                                },
                                bond: {
                                    'level': info.SOUTHBOUND,
                                    'tag': None
                                }
                            }
                        }
                    }

                    ovs_info = info.OvsInfo()

                    obtained_bridges = ovs_info.bridges
                    self.assertEqual(obtained_bridges, expected_bridges)

                    obtained_bridges_by_sb = ovs_info.bridges_by_sb
                    self.assertEqual(obtained_bridges_by_sb,
                                     {bond: TEST_BRIDGE})
Ejemplo n.º 3
0
def _setup_ovs(networks, bondings, options, net_info, in_rollback):
    _ovs_info = ovs_info.OvsInfo()
    ovs_nets = ovs_info.create_netinfo(_ovs_info)['networks']

    nets2add, nets2edit, nets2remove = _split_setup_actions(networks, ovs_nets)
    bonds2add, bonds2edit, bonds2remove = _split_setup_actions(
        bondings, net_info['bondings'])

    # TODO: If a nework is to be edited, we remove it and recreate again.
    # We should implement editation.
    nets2add.update(nets2edit)
    nets2remove.update(nets2edit)

    # FIXME: we are not able to move a nic from bond to network in one setup
    with Transaction(in_rollback=in_rollback) as config:
        setup_bonds = SetupBonds(bonds2add, bonds2edit, bonds2remove, config)
        with ifacquire.Transaction(ovs_nets) as acq:
            _remove_networks(nets2remove, _ovs_info, config)

            setup_bonds.remove_bonds()

            # Post removal of nets, update ovs_nets.
            ovs_nets = ovs_info.create_netinfo(_ovs_info)['networks']
            kernel_bonds = bond.Bond.bonds()
            validator.validate_nic_usage(
                nets2add,
                bonds2add,
                _get_kernel_nets_nics(ovs_nets, kernel_bonds),
                _get_kernel_bonds_slaves(kernel_bonds),
            )

            acq.acquire(setup_bonds.ifaces_for_acquirement)
            setup_bonds.edit_bonds()
            setup_bonds.add_bonds()

            _add_networks(nets2add, _ovs_info, config, acq)

            ovs_switch.update_network_to_bridge_mappings(ovs_info.OvsInfo())

            setup_ipv6autoconf(networks)
            set_ovs_links_up(nets2add, bonds2add, bonds2edit)
            setup_ovs_ip_config(nets2add, nets2remove)

            _setup_ovs_dns(nets2add)

            connectivity.check(options)
Ejemplo n.º 4
0
    def test_ovs_info(self):
        with dummy_device() as nic1, dummy_device() as nic2:
            with _setup_ovs_network(self.ovsdb, nic1, nic2):
                expected_bridges = {
                    TEST_BRIDGE: {
                        'stp': False,
                        'ports': {
                            TEST_BOND: {
                                'bond': {
                                    'active_slave': None,
                                    'fake_iface': False,
                                    'lacp': None,
                                    'bond_mode': 'active-backup',
                                    'other_config:bond-detect-mode': 'carrier',
                                    'other_config:bond-miimon-interval': None,
                                    'slaves': sorted([nic1, nic2])
                                },
                                'level': info.SOUTHBOUND,
                                'tag': None
                            },
                            TEST_VLANED_NETWORK: {
                                'bond': None,
                                'level': info.NORTHBOUND,
                                'tag': TEST_VLAN
                            },
                            TEST_BRIDGE: {
                                'bond': None,
                                'level': None,
                                'tag': None
                            }
                        }
                    }
                }
                expected_bridges_by_sb = {TEST_BOND: TEST_BRIDGE}

                ovs_info = info.OvsInfo()

                obtained_bridges = ovs_info.bridges
                self.assertEqual(obtained_bridges, expected_bridges)

                obtained_bridges_by_sb = ovs_info.bridges_by_sb
                self.assertEqual(obtained_bridges_by_sb,
                                 expected_bridges_by_sb)
Ejemplo n.º 5
0
def upgrade():
    rconfig = RunningConfig()
    pconfig = PersistentConfig()

    libvirt_networks = libvirtnetwork.networks()

    _upgrade_volatile_running_config(rconfig)

    if rconfig.config_exists() or pconfig.config_exists():
        _upgrade_unified_configuration(rconfig)
        _upgrade_unified_configuration(pconfig)
    else:
        # In case unified config has not existed before, it is assumed that
        # the networks existance have been persisted in libvirt db.
        vdsmnets = libvirt_vdsm_nets(libvirt_networks)
        _create_unified_configuration(rconfig, NetInfo(netinfo(vdsmnets)))

    _cleanup_libvirt_networks(libvirt_networks)

    if ovs_info.is_ovs_service_running():
        ovs_switch.update_network_to_bridge_mappings(ovs_info.OvsInfo())