Change-Id: I5c886a6fc02ed06553f9ef3583aba27091a0a21dchanges/10/104810/1
parent
d0fd540c3c
commit
b5607354c0
@ -1,38 +0,0 @@
|
||||
# vim: tabstop=4 shiftwidth=4 softtabstop=4
|
||||
|
||||
# Copyright (c) 2014 OpenStack Foundation.
|
||||
# All Rights Reserved.
|
||||
#
|
||||
# Licensed under the Apache License, Version 2.0 (the "License"); you may
|
||||
# not use this file except in compliance with the License. You may obtain
|
||||
# a copy of the License at
|
||||
#
|
||||
# http://www.apache.org/licenses/LICENSE-2.0
|
||||
#
|
||||
# Unless required by applicable law or agreed to in writing, software
|
||||
# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
|
||||
# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
|
||||
# License for the specific language governing permissions and limitations
|
||||
# under the License.
|
||||
|
||||
from neutron.agent.linux import ovs_lib
|
||||
from neutron.common import utils
|
||||
from neutron.plugins.common import constants as const
|
||||
from neutron.plugins.openvswitch.common import constants as ovs_const
|
||||
|
||||
|
||||
def vxlan_supported(root_helper, from_ip='192.0.2.1', to_ip='192.0.2.2'):
|
||||
name = "vxlantest-" + utils.get_random_string(6)
|
||||
with ovs_lib.OVSBridge(name, root_helper) as br:
|
||||
port = br.add_tunnel_port(from_ip, to_ip, const.TYPE_VXLAN)
|
||||
return port != ovs_const.INVALID_OFPORT
|
||||
|
||||
|
||||
def patch_supported(root_helper):
|
||||
seed = utils.get_random_string(6)
|
||||
name = "patchtest-" + seed
|
||||
peer_name = "peertest0-" + seed
|
||||
patch_name = "peertest1-" + seed
|
||||
with ovs_lib.OVSBridge(name, root_helper) as br:
|
||||
port = br.add_patch_port(patch_name, peer_name)
|
||||
return port != ovs_const.INVALID_OFPORT
|
@ -1,93 +0,0 @@
|
||||
# vim: tabstop=4 shiftwidth=4 softtabstop=4
|
||||
|
||||
# Copyright (c) 2014 OpenStack Foundation.
|
||||
# All Rights Reserved.
|
||||
#
|
||||
# Licensed under the Apache License, Version 2.0 (the "License"); you may
|
||||
# not use this file except in compliance with the License. You may obtain
|
||||
# a copy of the License at
|
||||
#
|
||||
# http://www.apache.org/licenses/LICENSE-2.0
|
||||
#
|
||||
# Unless required by applicable law or agreed to in writing, software
|
||||
# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
|
||||
# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
|
||||
# License for the specific language governing permissions and limitations
|
||||
# under the License.
|
||||
|
||||
import sys
|
||||
|
||||
from neutron.cmd.sanity import checks
|
||||
from neutron.common import config
|
||||
from neutron.openstack.common import log as logging
|
||||
from oslo.config import cfg
|
||||
|
||||
|
||||
LOG = logging.getLogger(__name__)
|
||||
cfg.CONF.import_group('AGENT', 'neutron.plugins.openvswitch.common.config')
|
||||
|
||||
|
||||
class BoolOptCallback(cfg.BoolOpt):
|
||||
def __init__(self, name, callback, **kwargs):
|
||||
self.callback = callback
|
||||
super(BoolOptCallback, self).__init__(name, **kwargs)
|
||||
|
||||
|
||||
def check_ovs_vxlan():
|
||||
result = checks.vxlan_supported(root_helper=cfg.CONF.AGENT.root_helper)
|
||||
if not result:
|
||||
LOG.error(_('Check for Open vSwitch VXLAN support failed. '
|
||||
'Please ensure that the version of openvswitch '
|
||||
'being used has VXLAN support.'))
|
||||
return result
|
||||
|
||||
|
||||
def check_ovs_patch():
|
||||
result = checks.patch_supported(root_helper=cfg.CONF.AGENT.root_helper)
|
||||
if not result:
|
||||
LOG.error(_('Check for Open vSwitch patch port support failed. '
|
||||
'Please ensure that the version of openvswitch '
|
||||
'being used has patch port support or disable features '
|
||||
'requiring patch ports (gre/vxlan, etc.).'))
|
||||
return result
|
||||
|
||||
|
||||
# Define CLI opts to test specific features, with a calback for the test
|
||||
OPTS = [
|
||||
BoolOptCallback('ovs_vxlan', check_ovs_vxlan, default=False,
|
||||
help=_('Check for vxlan support')),
|
||||
BoolOptCallback('ovs_patch', check_ovs_patch, default=False,
|
||||
help=_('Check for patch port support')),
|
||||
]
|
||||
|
||||
|
||||
def enable_tests_from_config():
|
||||
"""If a test can depend on configuration, use this function to set the
|
||||
appropriate CLI option to enable that test. It will then be possible to
|
||||
run all necessary tests, just by passing in the appropriate configs.
|
||||
"""
|
||||
|
||||
if 'vxlan' in cfg.CONF.AGENT.tunnel_types:
|
||||
cfg.CONF.set_override('ovs_vxlan', True)
|
||||
if cfg.CONF.AGENT.tunnel_types:
|
||||
cfg.CONF.set_override('ovs_patch', True)
|
||||
|
||||
|
||||
def all_tests_passed():
|
||||
res = True
|
||||
for opt in OPTS:
|
||||
if cfg.CONF.get(opt.name):
|
||||
res &= opt.callback()
|
||||
return res
|
||||
|
||||
|
||||
def main():
|
||||
cfg.CONF.register_cli_opts(OPTS)
|
||||
cfg.CONF.set_override('use_stderr', True)
|
||||
config.setup_logging(cfg.CONF)
|
||||
config.init(sys.argv[1:], default_config_files=[])
|
||||
|
||||
if cfg.CONF.config_file:
|
||||
enable_tests_from_config()
|
||||
|
||||
return 0 if all_tests_passed() else 1
|
@ -1,50 +0,0 @@
|
||||
#!/usr/bin/env python
|
||||
# vim: tabstop=4 shiftwidth=4 softtabstop=4
|
||||
|
||||
# Copyright (c) 2012 New Dream Network, LLC (DreamHost)
|
||||
# Author: Julien Danjou <julien@danjou.info>
|
||||
# All Rights Reserved.
|
||||
#
|
||||
# Licensed under the Apache License, Version 2.0 (the "License"); you may
|
||||
# not use this file except in compliance with the License. You may obtain
|
||||
# a copy of the License at
|
||||
#
|
||||
# http://www.apache.org/licenses/LICENSE-2.0
|
||||
#
|
||||
# Unless required by applicable law or agreed to in writing, software
|
||||
# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
|
||||
# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
|
||||
# License for the specific language governing permissions and limitations
|
||||
# under the License.
|
||||
"""Cron script to generate usage notifications for networks, ports and
|
||||
subnets.
|
||||
|
||||
"""
|
||||
|
||||
import sys
|
||||
|
||||
from oslo.config import cfg
|
||||
|
||||
from neutron.common import config
|
||||
from neutron.common import rpc as n_rpc
|
||||
from neutron import context
|
||||
from neutron import manager
|
||||
|
||||
|
||||
def main():
|
||||
config.init(sys.argv[1:])
|
||||
config.setup_logging(cfg.CONF)
|
||||
|
||||
cxt = context.get_admin_context()
|
||||
plugin = manager.NeutronManager.get_plugin()
|
||||
notifier = n_rpc.get_notifier('network')
|
||||
for network in plugin.get_networks(cxt):
|
||||
notifier.info(cxt, 'network.exists', {'network': network})
|
||||
for subnet in plugin.get_subnets(cxt):
|
||||
notifier.info(cxt, 'subnet.exists', {'subnet': subnet})
|
||||
for port in plugin.get_ports(cxt):
|
||||
notifier.info(cxt, 'port.exists', {'port': port})
|
||||
for router in plugin.get_routers(cxt):
|
||||
notifier.info(cxt, 'router.exists', {'router': router})
|
||||
for floatingip in plugin.get_floatingips(cxt):
|
||||
notifier.info(cxt, 'floatingip.exists', {'floatingip': floatingip})
|
@ -1,39 +0,0 @@
|
||||
# Copyright 2013 IBM Corp.
|
||||
# All Rights Reserved.
|
||||
#
|
||||
# Licensed under the Apache License, Version 2.0 (the "License"); you may
|
||||
# not use this file except in compliance with the License. You may obtain
|
||||
# a copy of the License at
|
||||
#
|
||||
# http://www.apache.org/licenses/LICENSE-2.0
|
||||
#
|
||||
# Unless required by applicable law or agreed to in writing, software
|
||||
# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
|
||||
# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
|
||||
# License for the specific language governing permissions and limitations
|
||||
# under the License.
|
||||
|
||||
"""
|
||||
IPv6-related utilities and helper functions.
|
||||
"""
|
||||
|
||||
import netaddr
|
||||
|
||||
|
||||
def get_ipv6_addr_by_EUI64(prefix, mac):
|
||||
# Check if the prefix is IPv4 address
|
||||
isIPv4 = netaddr.valid_ipv4(prefix)
|
||||
if isIPv4:
|
||||
msg = _("Unable to generate IP address by EUI64 for IPv4 prefix")
|
||||
raise TypeError(msg)
|
||||
try:
|
||||
eui64 = int(netaddr.EUI(mac).eui64())
|
||||
prefix = netaddr.IPNetwork(prefix)
|
||||
return netaddr.IPAddress(prefix.first + eui64 ^ (1 << 57))
|
||||
except (ValueError, netaddr.AddrFormatError):
|
||||
raise TypeError(_('Bad prefix or mac format for generating IPv6 '
|
||||
'address by EUI-64: %(prefix)s, %(mac)s:')
|
||||
% {'prefix': prefix, 'mac': mac})
|
||||
except TypeError:
|
||||
raise TypeError(_('Bad prefix type for generate IPv6 address by '
|
||||
'EUI-64: %s') % prefix)
|
Loading…
Reference in new issue