def _destroy_ovs_libvirt_nets(initial_config, running_config):
    log('Removing OVS and libvirt networks: %s %s' %
        (initial_config, running_config))
    for libvirt_ovs_nets in (iter_ovs_nets(running_config.networks),
                             iter_ovs_nets(initial_config.networks)):
        for net, attrs in libvirt_ovs_nets:
            with suppress(libvirtError):  # network not found
                libvirt.removeNetwork(net)

    destroy_ovs_bridge()
def _destroy_ovs_libvirt_nets(initial_config, running_config):
    log('Removing OVS and libvirt networks: %s %s' % (initial_config,
                                                      running_config))
    for libvirt_ovs_nets in (iter_ovs_nets(running_config.networks),
                             iter_ovs_nets(initial_config.networks)):
        for net, attrs in libvirt_ovs_nets:
            with suppress(libvirtError):  # network not found
                libvirt.removeNetwork(net)

    destroy_ovs_bridge()
def _remove_ovs_network(net, running_config, nets_by_nic):
    commands = []
    net_conf = running_config.networks.get(net)
    if 'vlan' in net_conf:
        commands.extend(['--', 'del-br', net])
    if 'nic' in net_conf:
        commands.extend(_del_nic_port(net, net_conf.get('nic'), nets_by_nic))
    running_config.removeNetwork(net)
    with suppress():
        libvirt.removeNetwork(net)
    return commands
def _remove_ovs_network(net, running_config, nets_by_nic):
    commands = []
    net_conf = running_config.networks.get(net)
    if 'vlan' in net_conf:
        commands.extend(['--', 'del-br', net])
    if 'nic' in net_conf:
        commands.extend(_del_nic_port(net, net_conf.get('nic'), nets_by_nic))
    running_config.removeNetwork(net)
    with suppress():
        libvirt.removeNetwork(net)
    return commands
示例#5
0
def rollback(running_config, initial_config):
    diff = running_config.diffFrom(initial_config)
    if diff:
        for libvirt_ovs_nets in (iter_ovs_nets(running_config.networks),
                                 iter_ovs_nets(initial_config.networks)):
            for net, attrs in libvirt_ovs_nets:
                with suppress(libvirtError):  # network not found
                    libvirt.removeNetwork(net)

        destroy_ovs_bridge()
        for net, attrs in running_config.networks.items():
            if is_ovs_network(attrs):
                running_config.networks.pop(net)
        for bond, attrs in running_config.bonds.items():
            if is_ovs_bond(attrs):
                running_config.bonds.pop(bond)
        running_config.save()

        supervdsm.getProxy().setupNetworks(
            initial_config.networks, initial_config.bonds,
            {'connectivityCheck': False, '_inRollback': True})
def _remove_libvirt_nets(libvirt_remove):
    for net in libvirt_remove:
        with suppress():
            libvirt.removeNetwork(net)
示例#7
0
def remove_libvirt_nets(libvirt_remove):
    for net in libvirt_remove:
        with suppress(libvirtError):
            libvirt.removeNetwork(net)