def _remove_ip_config(iface, ipv4, ipv6):
    net_dev = NetDevice(iface, iproute2, ipv4=ipv4, ipv6=ipv6)
    DynamicSourceRoute.addInterfaceTracking(net_dev)
    DhcpClient(iface).shutdown()
    iproute2._removeSourceRoute(net_dev, DynamicSourceRoute)
    if ipv4.address or ipv6.address:
        with suppress(ipwrapper.IPRoute2Error):  # device does not exist
            ipwrapper.addrFlush(iface)
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()
示例#3
0
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
def _remove_ip_config(ip_config):
    iface = ip_config.top_dev
    ipv4 = ip_config.ipv4
    ipv6 = ip_config.ipv6

    net_dev = NetDevice(iface, iproute2, ipv4=ipv4, ipv6=ipv6)
    DynamicSourceRoute.addInterfaceTracking(net_dev)
    DhcpClient(iface).shutdown()
    iproute2._removeSourceRoute(net_dev, DynamicSourceRoute)
    if ipv4.address or ipv6.address:
        with suppress(ipwrapper.IPRoute2Error):  # device does not exist
            ipwrapper.addrFlush(iface)
def _remove_network_ip_config(ip_config):
    """Remove IP configuration from Vdsm controlled OVS network"""
    iface = ip_config.top_dev
    ipv4 = ip_config.ipv4
    ipv6 = ip_config.ipv6

    net_dev = NetDevice(iface, iproute2, ipv4=ipv4, ipv6=ipv6)
    DynamicSourceRoute.addInterfaceTracking(net_dev)
    DhcpClient(iface).shutdown()
    iproute2._removeSourceRoute(net_dev, DynamicSourceRoute)
    if ipv4.address or ipv6.address:
        with suppress(ipwrapper.IPRoute2Error):  # device does not exist
            ipwrapper.addrFlush(iface)
def remove_libvirt_nets(libvirt_remove):
    for net in libvirt_remove:
        with suppress(libvirtError):
            libvirt.removeNetwork(net)
def remove_libvirt_nets(libvirt_remove):
    for net in libvirt_remove:
        with suppress(libvirtError):
            libvirt.removeNetwork(net)