def setupNetworks(self, networks, bonds, options): try: api.setupNetworks(networks, bonds, options) caps = api.network_caps() self.netinfo = CachingNetInfo(caps) self.config = RunningConfig() except errors.ConfigNetworkError as e: status = e.errCode msg = e.message else: status = SUCCESS msg = '' return status, msg
def list_networks(*args): """ list-nets List configured VDSM networks and mark the one with default route. """ caps = net_api.network_caps() output = '' for net, attrs in six.viewitems(caps['networks']): output += net if attrs['ipv4defaultroute']: output += ' (default route)\n' else: output += '\n' print(output, end='')
def clear_networks(*args): """ clear-nets [--exclude-net [network to keep [...]]] [--all] Remove networks configured by VDSM. Networks that should be kept could be listed with --exclude-net argument. In case no network is given, explicit --all is required to prevent accidental loss of connectivity. This command can be executed before VDSM removal to keep the host clean. """ parser = argparse.ArgumentParser() parser.add_argument( '-e', '--exclude-net', metavar='EXCLUDED_NETWORK', nargs='*', default=[], help='VDSM networks that should be kept' ) parser.add_argument( '-a', '--all', action='store_true', help='set this flag in case no network should be kept' ) arguments = parser.parse_args(args[1:]) if not arguments.exclude_net and not arguments.all: parser.error('Either --exclude-net with a network to be kept or ' '--all is required as an argument. Use vdsm-tool ' 'list-nets to list configured networks.') caps = net_api.network_caps() networks_request = { net: {'remove': True} for net in caps['networks'] if net not in arguments.exclude_net } net_api.setupNetworks(networks_request, {}, {'connectivityCheck': False}) net_api.setSafeNetworkConfig()
def ovn_config(*args): """ ovn-config IP-central [tunneling-IP|tunneling-network] Configures the ovn-controller on the host. Parameters: IP-central - the IP of the engine (the host where OVN central is located) tunneling-IP - the local IP which is to be used for OVN tunneling tunneling-network - the vdsm network name which is to be used for OVN tunneling """ if len(args) != 3: raise ExtraArgsError(n=2) if is_ipaddress(args[2]): ip_address = args[2] else: net_name = args[2] ip_address = get_ip_addr(get_network(network_caps(), net_name)) if not ip_address: raise IpAddressNotFoundError(net_name) cmd = [OVN_CONFIG_SCRIPT, args[1], ip_address] exec_ovn_config(cmd)
def clear_networks(*args): """ clear-nets [--exclude-net [network to keep [...]]] [--all] Remove networks configured by VDSM. Networks that should be kept could be listed with --exclude-net argument. In case no network is given, explicit --all is required to prevent accidental loss of connectivity. This command can be executed before VDSM removal to keep the host clean. """ parser = argparse.ArgumentParser() parser.add_argument('-e', '--exclude-net', metavar='EXCLUDED_NETWORK', nargs='*', default=[], help='VDSM networks that should be kept') parser.add_argument('-a', '--all', action='store_true', help='set this flag in case no network should be kept') arguments = parser.parse_args(args[1:]) if not arguments.exclude_net and not arguments.all: parser.error('Either --exclude-net with a network to be kept or ' '--all is required as an argument. Use vdsm-tool ' 'list-nets to list configured networks.') caps = net_api.network_caps() networks_request = { net: { 'remove': True } for net in caps['networks'] if net not in arguments.exclude_net } net_api.setupNetworks(networks_request, {}, {'connectivityCheck': False}) net_api.setSafeNetworkConfig()
def refreshNetworkCapabilities(self): caps = api.network_caps() self.netinfo = CachingNetInfo(caps)
def get_info(initial_ifaces_sample): capabilities = netapi.network_caps() new_ifaces_sample = InterfacesSample() statistics = stats._get_interfaces_stats(initial_ifaces_sample, new_ifaces_sample)['network'] return {'capabilities': capabilities, 'statistics': statistics}