Browse Source

Merge "Switch to hacking 3.0.1"

master
Zuul 2 weeks ago
committed by Gerrit Code Review
parent
commit
d27919f356
15 changed files with 62 additions and 50 deletions
  1. +4
    -4
      networking_bagpipe/agent/bagpipe_bgp_agent.py
  2. +15
    -14
      networking_bagpipe/agent/bagpipe_ml2/agent_extension.py
  3. +4
    -5
      networking_bagpipe/agent/bgpvpn/rpc_client.py
  4. +1
    -0
      networking_bagpipe/bagpipe_bgp/cli/impex2dot.py
  5. +2
    -2
      networking_bagpipe/bagpipe_bgp/cli/rest_attach.py
  6. +8
    -2
      networking_bagpipe/bagpipe_bgp/common/dataplane_utils.py
  7. +1
    -0
      networking_bagpipe/bagpipe_bgp/constants.py
  8. +6
    -18
      networking_bagpipe/bagpipe_bgp/engine/exabgp_peer_worker.py
  9. +2
    -0
      networking_bagpipe/bagpipe_bgp/fakerr.py
  10. +1
    -0
      networking_bagpipe/bagpipe_bgp/vpn/dataplane_drivers.py
  11. +4
    -2
      networking_bagpipe/bagpipe_bgp/vpn/ipvpn/mpls_ovs_dataplane.py
  12. +2
    -1
      networking_bagpipe/bagpipe_bgp/vpn/vpn_instance.py
  13. +1
    -1
      networking_bagpipe/tests/fullstack/test_bgpvpn_connectivity.py
  14. +1
    -1
      test-requirements.txt
  15. +10
    -0
      tox.ini

+ 4
- 4
networking_bagpipe/agent/bagpipe_bgp_agent.py View File

@@ -23,7 +23,7 @@ from oslo_log import helpers as log_helpers
from oslo_log import log as logging

from oslo_concurrency import lockutils
from oslo_serialization import jsonutils
from oslo_service import loopingcall

from networking_bagpipe._i18n import _
@@ -71,7 +71,7 @@ class BaGPipeBGPException(n_exc.NeutronException):
REST service: %(reason)s"


class SetJSONEncoder(json.JSONEncoder):
class SetJSONEncoder(jsonutils.JSONEncoder):
# JSON encoder that encodes set like a list, this
# allows to store list of RTs as sets and simplify the code
# in many places
@@ -102,7 +102,7 @@ class HTTPClientBase(object):
{'method': method, 'action': action, 'body': str(body)})

if isinstance(body, dict):
body = json.dumps(body, cls=SetJSONEncoder)
body = jsonutils.dumps(body, cls=SetJSONEncoder)
try:
headers = {'User-Agent': self.client_name,
"Content-Type": "application/json",
@@ -116,7 +116,7 @@ class HTTPClientBase(object):

if response.status == 200:
if content and len(content) > 1:
return json.loads(content)
return jsonutils.loads(content)
else:
reason = (
"An HTTP operation has failed on bagpipe-bgp."


+ 15
- 14
networking_bagpipe/agent/bagpipe_ml2/agent_extension.py View File

@@ -20,27 +20,28 @@ eventlet.monkey_patch()
# Monkey patch the original current_thread to use the up-to-date _active
# global variable. See https://bugs.launchpad.net/bugs/1863021 and
# https://github.com/eventlet/eventlet/issues/592
import __original_module_threading as orig_threading # pylint: disable=E0401
import __original_module_threading as orig_threading # noqa pylint: disable=import-error
import threading # noqa
orig_threading.current_thread.__globals__['_active'] = threading._active

from oslo_concurrency import lockutils
from oslo_config import cfg
from oslo_config import types
from oslo_log import helpers as log_helpers
from oslo_log import log as logging
from oslo_concurrency import lockutils # noqa: E402
from oslo_config import cfg # noqa: E402
from oslo_config import types # noqa: E402
from oslo_log import helpers as log_helpers # noqa: E402
from oslo_log import log as logging # noqa: E402

from networking_bagpipe.agent import agent_base_info
from networking_bagpipe.agent import bagpipe_bgp_agent
from networking_bagpipe.bagpipe_bgp import constants as bbgp_const
from networking_bagpipe.agent import agent_base_info # noqa: E402
from networking_bagpipe.agent import bagpipe_bgp_agent # noqa: E402
from networking_bagpipe.bagpipe_bgp import \
constants as bbgp_const # noqa: E402

from neutron.agent.linux import ip_lib
from neutron.common import config as common_config
from neutron.agent.linux import ip_lib # noqa: E402
from neutron.common import config as common_config # noqa: E402
from neutron.plugins.ml2.drivers.linuxbridge.agent import \
linuxbridge_neutron_agent as lnx_agt
linuxbridge_neutron_agent as lnx_agt # noqa: E402

from neutron_lib.agent import l2_extension
from neutron_lib import constants as n_const
from neutron_lib.agent import l2_extension # noqa: E402
from neutron_lib import constants as n_const # noqa: E402


LOG = logging.getLogger(__name__)


+ 4
- 5
networking_bagpipe/agent/bgpvpn/rpc_client.py View File

@@ -19,7 +19,6 @@ from neutron_lib.agent import topics
from neutron_lib import rpc as n_rpc
from oslo_log import log as logging

from networking_bagpipe._i18n import _

LOG = logging.getLogger(__name__)

@@ -44,8 +43,8 @@ class BGPVPNAgentNotifyApi(object):
# BGP VPN CRUD notifications
# --------------------------------------
def _notification_fanout(self, context, method, bgpvpn):
LOG.debug(_('Fanout notify BGP VPN agents at %(topic)s '
'the message %(method)s with %(bgpvpn)s'),
LOG.debug('Fanout notify BGP VPN agents at %(topic)s '
'the message %(method)s with %(bgpvpn)s',
{'topic': self.topic_bgpvpn_update,
'method': method,
'bgpvpn': bgpvpn})
@@ -72,8 +71,8 @@ class BGPVPNAgentNotifyApi(object):
# Port attach/detach on/from BGP VPN notifications
# ---------------------------------------------------------
def _notification_host(self, context, method, port_bgpvpn_info, host):
LOG.debug(_('Notify BGP VPN agent %(host)s at %(topic)s '
'the message %(method)s with %(port_bgpvpn_info)s'),
LOG.debug('Notify BGP VPN agent %(host)s at %(topic)s '
'the message %(method)s with %(port_bgpvpn_info)s',
{'host': host,
'topic': self.topic_bgpvpn_update,
'method': method,


+ 1
- 0
networking_bagpipe/bagpipe_bgp/cli/impex2dot.py View File

@@ -54,6 +54,7 @@ def normalize(string):
.replace("-", "_")
.replace(".", "_"))


RT_TXT_STYLE = 'color="orange",fontcolor="orange"'
RT_STYLE = 'color="orange",fontcolor="orange",arrowhead=onormal'
RT_STYLE_REDIR_FROM_RT = ('color="orange",fontcolor="orange",style=dashed,'


+ 2
- 2
networking_bagpipe/bagpipe_bgp/cli/rest_attach.py View File

@@ -262,7 +262,7 @@ def main():
default=None,
type="int",
help="BGP LOCAL PREF attribute (optional)")
(options, _) = parser.parse_args()
(options, _unused) = parser.parse_args()

if not(options.operation):
parser.error("Need to specify --attach or --detach")
@@ -310,7 +310,7 @@ def main():
options.netns = options.vpn_instance_id

try:
(_, options.if2netns) = options.port.split(":")
(_unused, options.if2netns) = options.port.split(":")
except Exception:
options.if2netns = get_vpn2ns_if_name(options.netns)



+ 8
- 2
networking_bagpipe/bagpipe_bgp/common/dataplane_utils.py View File

@@ -134,7 +134,11 @@ def _build_group_expr_str(group_dict, cmd):

class OVSExtendedBridge(ovs_lib.OVSBridge):

def add_flow_extended(self, flow_matches=[], actions=[]):
def add_flow_extended(self, flow_matches=None, actions=None):
if flow_matches is None:
flow_matches = []
if actions is None:
actions = []
flow_args = {}
for match in flow_matches:
flow_args.update(match)
@@ -144,7 +148,9 @@ class OVSExtendedBridge(ovs_lib.OVSBridge):

self.add_flow(**flow_args)

def delete_flows_extended(self, flow_matches=[]):
def delete_flows_extended(self, flow_matches=None):
if flow_matches is None:
flow_matches = []
flow_args = {}
for match in flow_matches:
flow_args.update(match)


+ 1
- 0
networking_bagpipe/bagpipe_bgp/constants.py View File

@@ -34,6 +34,7 @@ ALL_DIRECTIONS = (BOTH, TO_PORT, FROM_PORT)
def config_group(vpn_type):
return "DATAPLANE_DRIVER_%s" % vpn_type.upper()


# maximum length for a linux network device name
# grep 'define.*IFNAMSIZ' /usr/src/linux/include/uapi/linux/if.h
# define IFNAMSIZ 16


+ 6
- 18
networking_bagpipe/bagpipe_bgp/engine/exabgp_peer_worker.py View File

@@ -17,7 +17,6 @@

import collections
import functools
import inspect
import logging as python_logging
import select
import time
@@ -78,21 +77,10 @@ def setup_exabgp_env():
exa_logger.Logger._syslog.addHandler = noop
exa_logger.Logger._syslog.removeHandler = noop

# patch the exabgp logging method, to avoid formating all the
# information twice
# we have to use different signature for exabgp (change betweeen
# 4.0.1 and 4.0.2)
FORMAT_SIG_401 = ['timestamp', 'level', 'source', 'message']
if inspect.getargspec(exa_logger.Logger._format).args == FORMAT_SIG_401:
def patched_format(self, timestamp, level, source, message):
if self.short:
return message
return "%-13s %s" % (source, message)
else: # 4.0.2 or higher
def patched_format(self, message, source, level, timestamp=None):
if self.short:
return message
return "%-13s %s" % (source, message)
def patched_format(self, message, source, level, timestamp=None):
if self.short:
return message
return "%-13s %s" % (source, message)

exa_logger.Logger._format = patched_format

@@ -237,7 +225,7 @@ class ExaBGPPeerWorker(bgp_peer_worker.BGPPeerWorker, lg.LookingGlassMixin):
raise bgp_peer_worker.OpenWaitTimeout(str(e))
else:
raise Exception("Notify received: %s" % e)
except exa_reactor.network.error.LostConnection as e:
except exa_reactor.network.error.LostConnection:
raise

# check the capabilities of the session just established...
@@ -369,7 +357,7 @@ class ExaBGPPeerWorker(bgp_peer_worker.BGPPeerWorker, lg.LookingGlassMixin):
self.log.debug("Sending %d bytes on socket to peer %s",
len(data), self.peer_address)
try:
for _ in self.protocol.connection.writer(data):
for _unused in self.protocol.connection.writer(data):
pass
except Exception:
self.log.exception("Was not able to send data")


+ 2
- 0
networking_bagpipe/bagpipe_bgp/fakerr.py View File

@@ -111,6 +111,7 @@ class FakeRR(basic.LineReceiver):
self.factory.buffer = []
self.factory.buffer.append(data)


factory = protocol.ServerFactory()
factory.protocol = FakeRR
factory.clients = []
@@ -129,6 +130,7 @@ def main():
endpoints.serverFromString(reactor, "tcp:179").listen(factory)
reactor.run()


if __name__ == '__main__':
main()



+ 1
- 0
networking_bagpipe/bagpipe_bgp/vpn/dataplane_drivers.py View File

@@ -58,6 +58,7 @@ for vpn_type in constants.VPN_TYPES:
def register_driver_opts(vpn_type, driver_opts):
cfg.CONF.register_opts(driver_opts, constants.config_group(vpn_type))


# prefix for setuptools entry points for dataplane drivers
DATAPLANE_DRIVER_ENTRY_POINT_PFX = "bagpipe.dataplane"



+ 4
- 2
networking_bagpipe/bagpipe_bgp/vpn/ipvpn/mpls_ovs_dataplane.py View File

@@ -233,7 +233,7 @@ class MPLSOVSVRFDataplane(dp_drivers.VPNInstanceDataplane):
try:
try:
port_name = localport['ovs']['port_name']
except KeyError as e:
except KeyError:
port_name = localport['linuxif']
except Exception:
raise Exception("Trying to find which port to plug, but no"
@@ -767,7 +767,9 @@ class NextHopGroupManagerProxy(dataplane_utils.ObjectLifecycleManagerProxy):
selection_method_param=self.manager.hash_method_param,
buckets=','.join(buckets))

def new_nexthop(self, prefix, nexthop, actions=[]):
def new_nexthop(self, prefix, nexthop, actions=None):
if actions is None:
actions = []
bucket_allocator = self.bucket_allocators[prefix]
bucket_id = bucket_allocator.get_new_id(
"Bucket ID for prefix %s and nexthop %s" % (str(prefix), nexthop),


+ 2
- 1
networking_bagpipe/bagpipe_bgp/vpn/vpn_instance.py View File

@@ -884,7 +884,8 @@ class VPNInstance(tracker_worker.TrackerWorker,

if linuxif in self.localport_2_endpoints:
# Parse address/mask
(ip_prefix, _) = self._parse_ipaddress_prefix(ip_address_prefix)
(ip_prefix, _unused) = self._parse_ipaddress_prefix(
ip_address_prefix)

self.log.info("Withdrawing BGP route for VIF %s endpoint %s",
linuxif, endpoint)


+ 1
- 1
networking_bagpipe/tests/fullstack/test_bgpvpn_connectivity.py View File

@@ -153,7 +153,7 @@ class TestConnectivitySameBGPVPN(base.BaGPipeBaseFullStackTestCase):
# still works *inside* a given network, both locally on a compute
# node, and across different compute nodes

if self.evpn_driver is 'dummy':
if self.evpn_driver == 'dummy':
self.skipTest("L2VPN unsupported for this scenario")

tenant_uuid = uuidutils.generate_uuid()


+ 1
- 1
test-requirements.txt View File

@@ -2,7 +2,7 @@
# of appearance. Changing the order has an impact on the overall integration
# process, which may cause wedges in the gate later.

hacking!=0.13.0,<0.14,>=0.12.0 # Apache-2.0
hacking>=3.0.0,<3.1 # Apache-2.0

coverage!=4.4,>=4.0 # Apache-2.0
python-subunit>=1.0.0 # Apache-2.0/BSD


+ 10
- 0
tox.ini View File

@@ -102,6 +102,16 @@ enable-extensions = H203,H904
builtins = _
exclude=.venv,.git,.tox,dist,doc,*lib/python*,*egg,build,tools,.tmp,bagpipe-bgp/*

[flake8:local-plugins]
extension =
# Checks from neutron-lib
N521 = neutron_lib.hacking.checks:use_jsonutils
N524 = neutron_lib.hacking.checks:check_no_contextlib_nested
N529 = neutron_lib.hacking.checks:no_mutable_default_args
N532 = neutron_lib.hacking.translation_checks:check_log_warn_deprecated
N536 = neutron_lib.hacking.checks:assert_equal_none
N537 = neutron_lib.hacking.translation_checks:no_translate_logs

[testenv:lower-constraints]
deps =
-c{toxinidir}/lower-constraints.txt


Loading…
Cancel
Save