Ejemplo n.º 1
0
def _del_broken_network(network, netAttr, configurator):
    """
    Adapts the network information of broken networks so that they can be
    deleted via _del_network.
    """
    _netinfo = CachingNetInfo()
    _netinfo.networks[network] = netAttr
    _netinfo.networks[network]['dhcpv4'] = False

    if _netinfo.networks[network]['bridged']:
        try:
            nets = configurator.runningConfig.networks
        except AttributeError:
            nets = {}  # ifcfg does not need net definitions
        _netinfo.networks[network]['ports'] = _persistence.configuredPorts(
            nets, network)
    elif not os.path.exists('/sys/class/net/' + netAttr['iface']):
        # Bridgeless broken network without underlying device
        libvirt.removeNetwork(network)
        if config.get('vars', 'net_persistence') == 'unified':
            configurator.runningConfig.removeNetwork(network)
        return
    canonicalize_networks({network: _netinfo.networks[network]})
    _del_network(network, configurator, bypass_validation=True,
                 _netinfo=_netinfo)
Ejemplo n.º 2
0
def _del_broken_network(network, netAttr, configurator):
    """
    Adapts the network information of broken networks so that they can be
    deleted via _del_network.
    """
    _netinfo = CachingNetInfo()
    _netinfo.networks[network] = netAttr
    _netinfo.networks[network]['dhcpv4'] = False

    if _netinfo.networks[network]['bridged']:
        try:
            nets = configurator.runningConfig.networks
        except AttributeError:
            nets = {}  # ifcfg does not need net definitions
        _netinfo.networks[network]['ports'] = _persistence.configuredPorts(
            nets, network)
    elif not os.path.exists('/sys/class/net/' + netAttr['iface']):
        # Bridgeless broken network without underlying device
        libvirt.removeNetwork(network)
        if config.get('vars', 'net_persistence') == 'unified':
            configurator.runningConfig.removeNetwork(network)
        return
    canonicalize_networks({network: _netinfo.networks[network]})
    _del_network(network, configurator, bypass_validation=True,
                 _netinfo=_netinfo)
Ejemplo n.º 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()
Ejemplo n.º 4
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()
Ejemplo n.º 5
0
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
Ejemplo n.º 6
0
Archivo: ifcfg.py Proyecto: nirs/vdsm
    def restoreAtomicNetworkBackup(self):
        logging.info("Rolling back logical networks configuration " "(restoring atomic logical networks backup)")
        for network, content in six.iteritems(self._networksBackups):
            # Networks with content None should be removed.
            # Networks with real content should be recreated.
            # To avoid libvirt errors during recreation we need
            # to remove the old network first
            try:
                libvirt.removeNetwork(network)
            except libvirtError as e:
                if e.get_error_code() == VIR_ERR_NO_NETWORK:
                    pass

            if content:
                libvirt.createNetwork(content)

            logging.info("Restored %s", network)
Ejemplo n.º 7
0
    def restoreAtomicNetworkBackup(self):
        logging.info("Rolling back logical networks configuration "
                     "(restoring atomic logical networks backup)")
        for network, content in six.iteritems(self._networksBackups):
            # Networks with content None should be removed.
            # Networks with real content should be recreated.
            # To avoid libvirt errors during recreation we need
            # to remove the old network first
            try:
                libvirt.removeNetwork(network)
            except libvirtError as e:
                if e.get_error_code() == VIR_ERR_NO_NETWORK:
                    pass

            if content:
                libvirt.createNetwork(content)

            logging.info('Restored %s', network)
Ejemplo n.º 8
0
 def removeLibvirtNetwork(self, network):
     libvirt.removeNetwork(network)
Ejemplo n.º 9
0
 def removeLibvirtNetwork(self, network, skipBackup=False):
     if not skipBackup:
         self._networkBackup(network)
     libvirt.removeNetwork(network)
Ejemplo n.º 10
0
Archivo: ifcfg.py Proyecto: nirs/vdsm
 def removeLibvirtNetwork(self, network, skipBackup=False):
     if not skipBackup:
         self._networkBackup(network)
     libvirt.removeNetwork(network)
Ejemplo n.º 11
0
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)