コード例 #1
0
ファイル: legacy_switch.py プロジェクト: oVirt/vdsm
def _del_broken_network(network, netAttr, configurator):
    """
    Adapts the network information of broken networks so that they can be
    deleted via _del_network.
    """
    iface = get_net_iface_from_config(network, netAttr)

    _netinfo = CachingNetInfo()
    _netinfo.networks[network] = {}
    _netinfo.networks[network]['iface'] = iface
    _netinfo.networks[network]['bridged'] = netAttr['bridged']
    _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/' + iface):
        # Bridgeless broken network without underlying device
        configurator.runningConfig.removeNetwork(network)
        return
    canonicalize_networks({network: _netinfo.networks[network]})
    _del_network(network, configurator, _netinfo, None, bypass_validation=True)
コード例 #2
0
ファイル: legacy_switch.py プロジェクト: minqf/vdsm
def _del_broken_network(network, netAttr, configurator):
    """
    Adapts the network information of broken networks so that they can be
    deleted via _del_network.
    """
    iface = get_net_iface_from_config(network, netAttr)

    _netinfo = CachingNetInfo()
    _netinfo.networks[network] = {}
    _netinfo.networks[network]['iface'] = iface
    _netinfo.networks[network]['bridged'] = netAttr['bridged']
    _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/' + iface):
        # Bridgeless broken network without underlying device
        configurator.runningConfig.removeNetwork(network)
        return
    canonicalize_networks({network: _netinfo.networks[network]})
    _del_network(network, configurator, _netinfo, None, bypass_validation=True)
コード例 #3
0
ファイル: configurator.py プロジェクト: minqf/vdsm
def net2northbound(network_name):
    nb_device = network_name

    # Using RunningConfig avoids the need to require root access.
    net_attr = RunningConfig().networks.get(network_name)
    is_legacy = net_attr['switch'] == legacy_switch.SWITCH_TYPE
    if not net_attr['bridged'] and is_legacy:
        nb_device = get_net_iface_from_config(network_name, net_attr)

    return nb_device
コード例 #4
0
ファイル: configurator.py プロジェクト: nirs/vdsm
def net2northbound(network_name):
    nb_device = network_name

    # Using RunningConfig avoids the need to require root access.
    net_attr = RunningConfig().networks.get(network_name)
    is_legacy = net_attr['switch'] == legacy_switch.SWITCH_TYPE
    if not net_attr['bridged'] and is_legacy:
        nb_device = get_net_iface_from_config(network_name, net_attr)

    return nb_device