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 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 setSafeNetworkConfig(self): api.setSafeNetworkConfig()
sys.path.append('/usr/share/vdsm/') FORMAT = '%(asctime)-15s::%(message)s' logging.basicConfig( filename='/var/log/vdsm/setup-vdsm-net.log', format=FORMAT, level=logging.DEBUG ) NOCHK = {'connectivityCheck': False} NET = 'ovirtmgmt' NIC = 'dummy_0' res = api.setupNetworks( { NET: { 'nic': NIC, 'ipaddr': '10.0.0.1', 'netmask': '255.255.255.0', 'gateway': '10.0.0.1' } }, {}, NOCHK ) logging.debug('setupNetworks: %s', res) res = api.setSafeNetworkConfig() logging.debug('setSafeNetworkConfig: %s', res)
import logging import sys from vdsm.network import api sys.path.append('/usr/share/vdsm/') FORMAT = '%(asctime)-15s::%(message)s' logging.basicConfig(filename='/var/log/vdsm/setup-vdsm-net.log', format=FORMAT, level=logging.DEBUG) NOCHK = {'connectivityCheck': False} NET = 'ovirtmgmt' NIC = 'dummy_0' res = api.setupNetworks( { NET: { 'nic': NIC, 'ipaddr': '10.0.0.1', 'netmask': '255.255.255.0', 'gateway': '10.0.0.1' } }, {}, NOCHK) logging.debug('setupNetworks: %s', res) res = api.setSafeNetworkConfig() logging.debug('setSafeNetworkConfig: %s', res)