Beispiel #1
0
def _greedy_setup_bonds(setup_bonds):
    for bond, bond_attr in six.iteritems(setup_bonds):
        try:
            setupNetworks(
                {}, {bond: bond_attr},
                {'connectivityCheck': False, '_inRollback': True})
        except Exception:
            logging.exception('Failed to setup {}'.format(bond))
Beispiel #2
0
def _greedy_setup_nets(setup_nets):
    for net, net_attr in six.iteritems(setup_nets):
        try:
            setupNetworks(
                {net: net_attr}, {},
                {'connectivityCheck': False, '_inRollback': True})
        except Exception:
            logging.exception('Failed to setup {}'.format(net))
Beispiel #3
0
def _greedy_setup_bonds(setup_bonds):
    for bond, bond_attr in six.iteritems(setup_bonds):
        try:
            setupNetworks({}, {bond: bond_attr}, {
                'connectivityCheck': False,
                '_inRollback': True
            })
        except Exception:
            logging.exception('Failed to setup {}'.format(bond))
Beispiel #4
0
def _greedy_setup_nets(setup_nets):
    for net, net_attr in six.iteritems(setup_nets):
        try:
            setupNetworks({net: net_attr}, {}, {
                'connectivityCheck': False,
                '_inRollback': True
            })
        except Exception:
            logging.exception('Failed to setup {}'.format(net))
Beispiel #5
0
    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
Beispiel #6
0
    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
Beispiel #7
0
def setup(networks, bondings, ping_fn):
    logging.info('Running VDSM setup of desired config: %s %s', networks,
                 bondings)
    canonicalize.canonicalize_networks(networks)
    canonicalize.canonicalize_bondings(bondings)
    _southbound_to_nic_or_bond(networks, bondings)
    _canonicalize_bondings(bondings)
    desired = BaseConfig(networks, bondings)
    diff = desired.diffFrom(RunningConfig())
    logging.info('Configuration difference to be applied: %s %s',
                 diff.networks, diff.bonds)

    if diff:
        _run_ping_check_thread(ping_fn, _CONNECTIVITY_TIMEOUT)
        netapi.setupNetworks(
            diff.networks, diff.bonds, {
                'connectivityCheck': True,
                'connectivityTimeout': _CONNECTIVITY_TIMEOUT
            })

    logging.info('Setup is now complete.')
Beispiel #8
0
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()
Beispiel #9
0
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()
Beispiel #10
0
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)
Beispiel #11
0
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)
Beispiel #12
0
#!/usr/bin/python

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 = "dummy0"

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)