def unified_restoration(): """ Builds a setupNetworks command from the persistent configuration to set it as running configuration. """ networkmanager.init() persistent_config = PersistentConfig() available_config = _filter_available(persistent_config) _verify_all_devices_are_up(list(_owned_ifcfg_files())) _wait_for_for_all_devices_up(available_config.networks.keys() + available_config.bonds.keys()) if ipv6_supported(): _restore_disable_ipv6() classified_conf = _classify_nets_bonds_config(available_config) setup_nets, setup_bonds, remove_nets, remove_bonds = classified_conf logging.info('Remove networks (%s) and bonds (%s).', remove_nets, remove_bonds) _greedy_setup_bonds(remove_bonds) _greedy_setup_nets(remove_nets) _restore_non_vdsm_net_devices() _convert_to_blocking_dhcp(setup_nets) logging.info('Setup networks (%s) and bonds (%s).', setup_nets, setup_bonds) _greedy_setup_bonds(setup_bonds) _greedy_setup_nets(setup_nets)
def unified_restoration(): """ Builds a setupNetworks command from the persistent configuration to set it as running configuration. """ networkmanager.init() persistent_config = PersistentConfig() available_config = _filter_available(persistent_config) _verify_all_devices_are_up(list(_owned_ifcfg_files())) _wait_for_for_all_devices_up( available_config.networks.keys() + available_config.bonds.keys()) if ipv6_supported(): _restore_disable_ipv6() classified_conf = _classify_nets_bonds_config(available_config) setup_nets, setup_bonds, remove_nets, remove_bonds = classified_conf logging.info( 'Remove networks (%s) and bonds (%s).', remove_nets, remove_bonds) _greedy_setup_bonds(remove_bonds) _greedy_setup_nets(remove_nets) _restore_non_vdsm_net_devices() _convert_to_blocking_dhcp(setup_nets) logging.info( 'Setup networks (%s) and bonds (%s).', setup_nets, setup_bonds) _greedy_setup_bonds(setup_bonds) _greedy_setup_nets(setup_nets)
def _get(vdsmnets=None): """ Generate a networking report for all devices. In case vdsmnets is provided, it is used in the report instead of retrieving data from the running config. :return: Dict of networking devices with all their details. """ ipaddrs = getIpAddrs() routes = get_routes() devices_info = _devices_report(ipaddrs, routes) nets_info = _networks_report(vdsmnets, routes, ipaddrs, devices_info) add_qos_info_to_devices(nets_info, devices_info) flat_devs_info = _get_flat_devs_info(devices_info) devices = _get_dev_names(nets_info, flat_devs_info) extra_info = {} if nmstate.is_nmstate_backend(): extra_info.update(_get_devices_info_from_nmstate(devices)) else: extra_info.update(dhclient.dhcp_info(devices)) _update_caps_info(nets_info, flat_devs_info, extra_info) networking_report = {'networks': nets_info} networking_report.update(devices_info) if nmstate.is_nmstate_backend(): networking_report['nameservers'] = nmstate.show_nameservers() else: networking_report['nameservers'] = dns.get_host_nameservers() networking_report['supportsIPv6'] = ipv6_supported() return networking_report
def _ipv6_is_unused(attrs): return ( 'ipv6addr' not in attrs and 'ipv6autoconf' not in attrs and 'dhcpv6' not in attrs and ipv6_supported() )
def _get(vdsmnets=None): """ Generate a networking report for all devices. In case vdsmnets is provided, it is used in the report instead of retrieving data from the running config. :return: Dict of networking devices with all their details. """ ipaddrs = getIpAddrs() routes = get_routes() devices_info = _devices_report(ipaddrs, routes) nets_info = _networks_report(vdsmnets, routes, ipaddrs, devices_info) add_qos_info_to_devices(nets_info, devices_info) flat_devs_info = _get_flat_devs_info(devices_info) devices = _get_dev_names(nets_info, flat_devs_info) extra_info = _create_default_extra_info(devices) current_state = nmstate.get_current_state() extra_info.update( _get_devices_info_from_nmstate( current_state.filtered_interfaces(devices))) _update_caps_info(nets_info, flat_devs_info, extra_info) networking_report = {'networks': nets_info} networking_report.update(devices_info) networking_report['nameservers'] = current_state.dns_state networking_report['supportsIPv6'] = ipv6_supported() return networking_report
def _get(vdsmnets=None): """ Generate a networking report for all devices, including data managed by libvirt. In case vdsmnets is provided, it is used in the report instead of retrieving data from libvirt. :return: Dict of networking devices with all their details. """ networking = { 'bondings': {}, 'bridges': {}, 'networks': {}, 'nics': {}, 'vlans': {}, 'nameservers': get_host_nameservers() } paddr = bonding.permanent_address() ipaddrs = getIpAddrs() routes = get_routes() if vdsmnets is None: libvirt_nets = libvirt.networks() networking['networks'] = libvirtNets2vdsm(libvirt_nets, routes, ipaddrs) else: networking['networks'] = vdsmnets for dev in (link for link in getLinks() if not link.isHidden()): if dev.isBRIDGE(): devinfo = networking['bridges'][dev.name] = bridges.info(dev) elif dev.isNICLike(): devinfo = networking['nics'][dev.name] = nics.info(dev, paddr) devinfo.update(bonding.get_bond_slave_agg_info(dev.name)) elif dev.isBOND(): devinfo = networking['bondings'][dev.name] = bonding.info(dev) devinfo.update(bonding.get_bond_agg_info(dev.name)) devinfo.update(LEGACY_SWITCH) elif dev.isVLAN(): devinfo = networking['vlans'][dev.name] = vlans.info(dev) else: continue devinfo.update(_devinfo(dev, routes, ipaddrs)) for network_name, network_info in six.iteritems(networking['networks']): set_netdev_dhcp_info(network_info, networking) networking['networks'][network_name].update(LEGACY_SWITCH) report_network_qos(networking) networking['supportsIPv6'] = ipv6_supported() return networking
def _get(vdsmnets=None): """ Generate a networking report for all devices, including data managed by libvirt. In case vdsmnets is provided, it is used in the report instead of retrieving data from libvirt. :return: Dict of networking devices with all their details. """ networking = {'bondings': {}, 'bridges': {}, 'networks': {}, 'nics': {}, 'vlans': {}, 'dnss': get_host_nameservers()} paddr = bonding.permanent_address() ipaddrs = getIpAddrs() routes = get_routes() if vdsmnets is None: libvirt_nets = libvirt.networks() networking['networks'] = libvirtNets2vdsm(libvirt_nets, routes, ipaddrs) else: networking['networks'] = vdsmnets for dev in (link for link in getLinks() if not link.isHidden()): if dev.isBRIDGE(): devinfo = networking['bridges'][dev.name] = bridges.info(dev) elif dev.isNICLike(): devinfo = networking['nics'][dev.name] = nics.info(dev, paddr) devinfo.update(bonding.get_bond_slave_agg_info(dev.name)) elif dev.isBOND(): devinfo = networking['bondings'][dev.name] = bonding.info(dev) devinfo.update(bonding.get_bond_agg_info(dev.name)) devinfo.update(LEGACY_SWITCH) elif dev.isVLAN(): devinfo = networking['vlans'][dev.name] = vlans.info(dev) else: continue devinfo.update(_devinfo(dev, routes, ipaddrs)) for network_name, network_info in six.iteritems(networking['networks']): updates = propose_updates_to_reported_dhcp(network_info, networking) update_reported_dhcp(updates, networking) networking['networks'][network_name].update(LEGACY_SWITCH) report_network_qos(networking) networking['supportsIPv6'] = ipv6_supported() return networking
def _get(vdsmnets=None): """ Generate a networking report for all devices. In case vdsmnets is provided, it is used in the report instead of retrieving data from the running config. :return: Dict of networking devices with all their details. """ ipaddrs = getIpAddrs() routes = get_routes() devices_info = _devices_report(ipaddrs, routes) nets_info = _networks_report(vdsmnets, routes, ipaddrs, devices_info) networking_report = {'networks': nets_info} networking_report.update(devices_info) networking_report['nameservers'] = get_host_nameservers() networking_report['supportsIPv6'] = ipv6_supported() return networking_report
def _get(vdsmnets=None): """ Generate a networking report for all devices, including data managed by libvirt. In case vdsmnets is provided, it is used in the report instead of retrieving data from libvirt. :return: Dict of networking devices with all their details. """ paddr = bonding.permanent_address() ipaddrs = getIpAddrs() routes = get_routes() devices_info = _devices_report(ipaddrs, routes, paddr) nets_info = _networks_report(vdsmnets, routes, ipaddrs, devices_info) networking_report = {"networks": nets_info} networking_report.update(devices_info) networking_report["nameservers"] = get_host_nameservers() networking_report["supportsIPv6"] = ipv6_supported() return networking_report
def _ipv6_is_unused(attrs): return ('ipv6addr' not in attrs and 'ipv6autoconf' not in attrs and 'dhcpv6' not in attrs and ipv6_supported())