Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Import os-ken 2.11.2 source #9

Merged
merged 1 commit into from
Nov 20, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions .zuul.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -12,3 +12,7 @@
gate:
jobs:
- neutron-ovs-tempest-dvr
periodic-weekly:
jobs:
- openstack-tox-py311
- openstack-tox-py312
2 changes: 1 addition & 1 deletion doc/requirements.txt
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
sphinx>=2.0.0,!=2.1.0 # BSD
sphinx>2.2.0 # BSD
openstackdocstheme>=2.2.1 # Apache-2.0
# releasenotes
reno>=3.1.0 # Apache-2.0
5 changes: 3 additions & 2 deletions os_ken/app/ofctl/service.py
Original file line number Diff line number Diff line change
Expand Up @@ -21,8 +21,9 @@
from os_ken.base import app_manager

from os_ken.controller import ofp_event
from os_ken.controller.handler import CONFIG_DISPATCHER, MAIN_DISPATCHER,\
DEAD_DISPATCHER
from os_ken.controller.handler import CONFIG_DISPATCHER
from os_ken.controller.handler import DEAD_DISPATCHER
from os_ken.controller.handler import MAIN_DISPATCHER
from os_ken.controller.handler import set_ev_cls

from . import event
Expand Down
3 changes: 1 addition & 2 deletions os_ken/controller/controller.py
Original file line number Diff line number Diff line change
Expand Up @@ -166,9 +166,8 @@ def stop_client_loop(self, addr):

def server_loop(self, ofp_tcp_listen_port, ofp_ssl_listen_port):
if CONF.ctl_privkey is not None and CONF.ctl_cert is not None:
p = 'PROTOCOL_TLS'
ssl_args = {'ssl_ctx': ssl.SSLContext(ssl.PROTOCOL_TLS_SERVER)}

ssl_args = {'ssl_ctx': ssl.SSLContext(getattr(ssl, p))}
# Restrict non-safe versions
ssl_args['ssl_ctx'].options |= ssl.OP_NO_SSLv3 | ssl.OP_NO_SSLv2

Expand Down
5 changes: 3 additions & 2 deletions os_ken/controller/ofp_handler.py
Original file line number Diff line number Diff line change
Expand Up @@ -29,8 +29,9 @@
from os_ken.controller import ofp_event
from os_ken.controller.controller import OpenFlowController
from os_ken.controller.handler import set_ev_handler
from os_ken.controller.handler import HANDSHAKE_DISPATCHER, CONFIG_DISPATCHER,\
MAIN_DISPATCHER
from os_ken.controller.handler import CONFIG_DISPATCHER
from os_ken.controller.handler import HANDSHAKE_DISPATCHER
from os_ken.controller.handler import MAIN_DISPATCHER
from os_ken.ofproto import ofproto_parser


Expand Down
48 changes: 22 additions & 26 deletions os_ken/lib/hub.py
Original file line number Diff line number Diff line change
Expand Up @@ -51,13 +51,6 @@

def patch(thread=True):
eventlet.monkey_patch(thread=thread)
if thread:
# 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 # noqa
import threading # noqa
orig_threading.current_thread.__globals__['_active'] = threading._active

def spawn(*args, **kwargs):
raise_error = kwargs.pop('raise_error', False)
Expand Down Expand Up @@ -137,24 +130,20 @@ def __init__(self, listen_info, handle=None, backlog=None,

if ssl_args:
ssl_args.setdefault('server_side', True)
if 'ssl_ctx' in ssl_args:
ctx = ssl_args.pop('ssl_ctx')
ctx.load_cert_chain(ssl_args.pop('certfile'),
ssl_args.pop('keyfile'))
if 'cert_reqs' in ssl_args:
ctx.verify_mode = ssl_args.pop('cert_reqs')
if 'ca_certs' in ssl_args:
ctx.load_verify_locations(ssl_args.pop('ca_certs'))

def wrap_and_handle_ctx(sock, addr):
handle(ctx.wrap_socket(sock, **ssl_args), addr)

self.handle = wrap_and_handle_ctx
else:
def wrap_and_handle_ssl(sock, addr):
handle(ssl.wrap_socket(sock, **ssl_args), addr)

self.handle = wrap_and_handle_ssl
if 'ssl_ctx' not in ssl_args:
raise RuntimeError("no SSLContext ssl_ctx in ssl_args")
ctx = ssl_args.pop('ssl_ctx')
ctx.load_cert_chain(ssl_args.pop('certfile'),
ssl_args.pop('keyfile'))
if 'cert_reqs' in ssl_args:
ctx.verify_mode = ssl_args.pop('cert_reqs')
if 'ca_certs' in ssl_args:
ctx.load_verify_locations(ssl_args.pop('ca_certs'))

def wrap_and_handle_ctx(sock, addr):
handle(ctx.wrap_socket(sock, **ssl_args), addr)

self.handle = wrap_and_handle_ctx
else:
self.handle = handle

Expand Down Expand Up @@ -182,7 +171,14 @@ def connect(self):
return None

if self.ssl_args:
client = ssl.wrap_socket(client, **self.ssl_args)
ctx = ssl.SSLContext(ssl.PROTOCOL_TLS_CLIENT)
ctx.load_cert_chain(self.ssl_args.pop('certfile'),
self.ssl_args.pop('keyfile'))
if 'cert_reqs' in self.ssl_args:
ctx.verify_mode = self.ssl_args.pop('cert_reqs')
if 'ca_certs' in self.ssl_args:
ctx.load_verify_location(self.ssl_args.pop('ca_certs'))
client = ctx.wrap_socket(client, **self.ssl_args)

return client

Expand Down
4 changes: 2 additions & 2 deletions os_ken/lib/packet/tcp.py
Original file line number Diff line number Diff line change
Expand Up @@ -115,8 +115,8 @@ def get_payload_type(src_port, dst_port):
from os_ken.ofproto.ofproto_common import OFP_TCP_PORT, OFP_SSL_PORT_OLD
if bgp.TCP_SERVER_PORT in [src_port, dst_port]:
return bgp.BGPMessage
elif(src_port in [OFP_TCP_PORT, OFP_SSL_PORT_OLD] or
dst_port in [OFP_TCP_PORT, OFP_SSL_PORT_OLD]):
elif (src_port in [OFP_TCP_PORT, OFP_SSL_PORT_OLD] or
dst_port in [OFP_TCP_PORT, OFP_SSL_PORT_OLD]):
return openflow.openflow
elif src_port == zebra.ZEBRA_PORT:
return zebra._ZebraMessageFromZebra
Expand Down
6 changes: 3 additions & 3 deletions os_ken/lib/packet/vrrp.py
Original file line number Diff line number Diff line change
Expand Up @@ -159,7 +159,7 @@ def vrrp_to_version_type(version, type_):


def is_ipv6(ip_address):
assert type(ip_address) == str
assert isinstance(ip_address, str)
try:
addrconv.ipv4.text_to_bin(ip_address)
except:
Expand Down Expand Up @@ -595,11 +595,11 @@ def parser(cls, buf):
@staticmethod
def serialize_static(vrrp_, prev):
if isinstance(prev, ipv4.ipv4):
assert type(vrrp_.ip_addresses[0]) == str
assert isinstance(vrrp_.ip_addresses[0], str)
conv = addrconv.ipv4.text_to_bin
ip_address_pack_raw = vrrpv3._IPV4_ADDRESS_PACK_STR_RAW
elif isinstance(prev, ipv6.ipv6):
assert type(vrrp_.ip_addresses[0]) == str
assert isinstance(vrrp_.ip_addresses[0], str)
conv = addrconv.ipv6.text_to_bin
ip_address_pack_raw = vrrpv3._IPV6_ADDRESS_PACK_STR_RAW
else:
Expand Down
2 changes: 1 addition & 1 deletion os_ken/lib/stplib.py
Original file line number Diff line number Diff line change
Expand Up @@ -865,7 +865,7 @@ def _change_status(self, new_state, thread_switch=True):
if new_state is not PORT_STATE_DISABLE:
self.ofctl.set_port_status(self.ofport, new_state)

if(new_state is PORT_STATE_FORWARD
if (new_state is PORT_STATE_FORWARD
or (self.state is PORT_STATE_FORWARD
and (new_state is PORT_STATE_DISABLE
or new_state is PORT_STATE_BLOCK))):
Expand Down
2 changes: 1 addition & 1 deletion os_ken/lib/stringify.py
Original file line number Diff line number Diff line change
Expand Up @@ -370,7 +370,7 @@ def obj_python_attrs(msg_):
# ofp parser implementations.
if hasattr(msg_, '_fields'):
for k in msg_._fields:
yield(k, getattr(msg_, k))
yield (k, getattr(msg_, k))
return
base = getattr(msg_, '_base_attributes', [])
opt = getattr(msg_, '_opt_attributes', [])
Expand Down
12 changes: 6 additions & 6 deletions os_ken/ofproto/ofproto_v1_4.py
Original file line number Diff line number Diff line change
Expand Up @@ -160,20 +160,20 @@
# struct ofp_table_mod_prop_eviction
OFP_TABLE_MOD_PROP_EVICTION_PACK_STR = '!HHI'
OFP_TABLE_MOD_PROP_EVICTION_SIZE = 8
assert(calcsize(OFP_TABLE_MOD_PROP_EVICTION_PACK_STR) ==
OFP_TABLE_MOD_PROP_EVICTION_SIZE)
assert (calcsize(OFP_TABLE_MOD_PROP_EVICTION_PACK_STR) ==
OFP_TABLE_MOD_PROP_EVICTION_SIZE)

# struct ofp_table_mod_prop_vacancy
OFP_TABLE_MOD_PROP_VACANCY_PACK_STR = '!HHBBBx'
OFP_TABLE_MOD_PROP_VACANCY_SIZE = 8
assert(calcsize(OFP_TABLE_MOD_PROP_VACANCY_PACK_STR) ==
OFP_TABLE_MOD_PROP_VACANCY_SIZE)
assert (calcsize(OFP_TABLE_MOD_PROP_VACANCY_PACK_STR) ==
OFP_TABLE_MOD_PROP_VACANCY_SIZE)

# struct ofp_table_mod_prop_experimenter
OFP_TABLE_MOD_PROP_EXPERIMENTER_PACK_STR = '!HHII'
OFP_TABLE_MOD_PROP_EXPERIMENTER_SIZE = 12
assert(calcsize(OFP_TABLE_MOD_PROP_EXPERIMENTER_PACK_STR) ==
OFP_TABLE_MOD_PROP_EXPERIMENTER_SIZE)
assert (calcsize(OFP_TABLE_MOD_PROP_EXPERIMENTER_PACK_STR) ==
OFP_TABLE_MOD_PROP_EXPERIMENTER_SIZE)

# struct ofp_table_mod
OFP_TABLE_MOD_PACK_STR = '!B3xI'
Expand Down
12 changes: 6 additions & 6 deletions os_ken/ofproto/ofproto_v1_5.py
Original file line number Diff line number Diff line change
Expand Up @@ -162,20 +162,20 @@
# struct ofp_table_mod_prop_eviction
OFP_TABLE_MOD_PROP_EVICTION_PACK_STR = '!HHI'
OFP_TABLE_MOD_PROP_EVICTION_SIZE = 8
assert(calcsize(OFP_TABLE_MOD_PROP_EVICTION_PACK_STR) ==
OFP_TABLE_MOD_PROP_EVICTION_SIZE)
assert (calcsize(OFP_TABLE_MOD_PROP_EVICTION_PACK_STR) ==
OFP_TABLE_MOD_PROP_EVICTION_SIZE)

# struct ofp_table_mod_prop_vacancy
OFP_TABLE_MOD_PROP_VACANCY_PACK_STR = '!HHBBBx'
OFP_TABLE_MOD_PROP_VACANCY_SIZE = 8
assert(calcsize(OFP_TABLE_MOD_PROP_VACANCY_PACK_STR) ==
OFP_TABLE_MOD_PROP_VACANCY_SIZE)
assert (calcsize(OFP_TABLE_MOD_PROP_VACANCY_PACK_STR) ==
OFP_TABLE_MOD_PROP_VACANCY_SIZE)

# struct ofp_table_mod_prop_experimenter
OFP_TABLE_MOD_PROP_EXPERIMENTER_PACK_STR = '!HHII'
OFP_TABLE_MOD_PROP_EXPERIMENTER_SIZE = 12
assert(calcsize(OFP_TABLE_MOD_PROP_EXPERIMENTER_PACK_STR) ==
OFP_TABLE_MOD_PROP_EXPERIMENTER_SIZE)
assert (calcsize(OFP_TABLE_MOD_PROP_EXPERIMENTER_PACK_STR) ==
OFP_TABLE_MOD_PROP_EXPERIMENTER_SIZE)

# struct ofp_table_mod
OFP_TABLE_MOD_PACK_STR = '!B3xI'
Expand Down
4 changes: 2 additions & 2 deletions os_ken/services/protocols/bgp/api/prefix.py
Original file line number Diff line number Diff line change
Expand Up @@ -368,8 +368,8 @@ def add_evpn_local(route_type, route_dist, next_hop, **kwargs):
"""Adds EVPN route from VRF identified by *route_dist*.
"""

if(route_type in [EVPN_ETH_AUTO_DISCOVERY, EVPN_ETH_SEGMENT]
and kwargs['esi'] == 0):
if (route_type in [EVPN_ETH_AUTO_DISCOVERY, EVPN_ETH_SEGMENT]
and kwargs['esi'] == 0):
raise ConfigValueError(conf_name=EVPN_ESI,
conf_value=kwargs['esi'])

Expand Down
12 changes: 6 additions & 6 deletions os_ken/services/protocols/bgp/info_base/base.py
Original file line number Diff line number Diff line change
Expand Up @@ -428,7 +428,7 @@ def remove_old_paths_from_source(self, source):
Returns *True* if any of the known paths were found to be old and
removed/deleted.
"""
assert(source and hasattr(source, 'version_num'))
assert (source and hasattr(source, 'version_num'))
removed_paths = []
# Iterate over the paths in reverse order as we want to delete paths
# whose source is this peer.
Expand All @@ -438,7 +438,7 @@ def remove_old_paths_from_source(self, source):
if (path.source == source and
path.source_version_num < source_ver_num):
# If this peer is source of any paths, remove those path.
del(self._known_path_list[path_idx])
del self._known_path_list[path_idx]
removed_paths.append(path)
return removed_paths

Expand Down Expand Up @@ -485,7 +485,7 @@ def _process_paths(self):
# If we do not have any old but one new path
# it becomes best path.
self._known_path_list.append(self._new_path_list[0])
del(self._new_path_list[0])
del self._new_path_list[0]
return self._known_path_list[0], BPR_ONLY_PATH

# If we have a new version of old/known path we use it and delete old
Expand All @@ -496,7 +496,7 @@ def _process_paths(self):
self._known_path_list.extend(self._new_path_list)

# Clear new paths as we copied them.
del(self._new_path_list[:])
del self._new_path_list[:]

# If we do not have any paths to this destination, then we do not have
# new best path.
Expand Down Expand Up @@ -528,7 +528,7 @@ def _remove_withdrawals(self):
if not self._known_path_list:
LOG.debug('Found %s withdrawals for path(s) that did not get'
' installed.', len(self._withdraw_list))
del(self._withdraw_list[:])
del self._withdraw_list[:]
return

# If we have some known paths and some withdrawals, we find matches and
Expand Down Expand Up @@ -1193,7 +1193,7 @@ class AttributeMap(object):

def __init__(self, filters, attr_type, attr_value):

assert all(isinstance(f, Filter) for f in filters),\
assert all(isinstance(f, Filter) for f in filters), \
'all the items in filters must be an instance of Filter sub-class'
self.filters = filters
self.attr_type = attr_type
Expand Down
6 changes: 3 additions & 3 deletions os_ken/services/protocols/bgp/model.py
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@ class OutgoingRoute(object):
'next_sink_out_route', 'prev_sink_out_route')

def __init__(self, path, for_route_refresh=False):
assert(path)
assert path

self.sink = None

Expand Down Expand Up @@ -145,7 +145,7 @@ class SentRoute(object):
"""

def __init__(self, path, peer, filtered=None, timestamp=None):
assert(path and hasattr(peer, 'version_num'))
assert (path and hasattr(peer, 'version_num'))

self.path = path

Expand Down Expand Up @@ -175,7 +175,7 @@ class ReceivedRoute(object):
"""

def __init__(self, path, peer, filtered=None, timestamp=None):
assert(path and hasattr(peer, 'version_num'))
assert (path and hasattr(peer, 'version_num'))

self.path = path

Expand Down
Loading