Skip to content

Commit 7992fe5

Browse files
authored
Merge pull request #9 from faucetsdn/os-ken-2.11.2
Import os-ken 2.11.2 source
2 parents afd5bdb + 230b293 commit 7992fe5

34 files changed

+157
-150
lines changed

.zuul.yaml

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,3 +12,7 @@
1212
gate:
1313
jobs:
1414
- neutron-ovs-tempest-dvr
15+
periodic-weekly:
16+
jobs:
17+
- openstack-tox-py311
18+
- openstack-tox-py312

doc/requirements.txt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
sphinx>=2.0.0,!=2.1.0 # BSD
1+
sphinx>2.2.0 # BSD
22
openstackdocstheme>=2.2.1 # Apache-2.0
33
# releasenotes
44
reno>=3.1.0 # Apache-2.0

os_ken/app/ofctl/service.py

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -21,8 +21,9 @@
2121
from os_ken.base import app_manager
2222

2323
from os_ken.controller import ofp_event
24-
from os_ken.controller.handler import CONFIG_DISPATCHER, MAIN_DISPATCHER,\
25-
DEAD_DISPATCHER
24+
from os_ken.controller.handler import CONFIG_DISPATCHER
25+
from os_ken.controller.handler import DEAD_DISPATCHER
26+
from os_ken.controller.handler import MAIN_DISPATCHER
2627
from os_ken.controller.handler import set_ev_cls
2728

2829
from . import event

os_ken/controller/controller.py

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -166,9 +166,8 @@ def stop_client_loop(self, addr):
166166

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

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

os_ken/controller/ofp_handler.py

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -29,8 +29,9 @@
2929
from os_ken.controller import ofp_event
3030
from os_ken.controller.controller import OpenFlowController
3131
from os_ken.controller.handler import set_ev_handler
32-
from os_ken.controller.handler import HANDSHAKE_DISPATCHER, CONFIG_DISPATCHER,\
33-
MAIN_DISPATCHER
32+
from os_ken.controller.handler import CONFIG_DISPATCHER
33+
from os_ken.controller.handler import HANDSHAKE_DISPATCHER
34+
from os_ken.controller.handler import MAIN_DISPATCHER
3435
from os_ken.ofproto import ofproto_parser
3536

3637

os_ken/lib/hub.py

Lines changed: 22 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -51,13 +51,6 @@
5151

5252
def patch(thread=True):
5353
eventlet.monkey_patch(thread=thread)
54-
if thread:
55-
# Monkey patch the original current_thread to use the up-to-date _active
56-
# global variable. See https://bugs.launchpad.net/bugs/1863021 and
57-
# https://github.com/eventlet/eventlet/issues/592
58-
import __original_module_threading as orig_threading # noqa
59-
import threading # noqa
60-
orig_threading.current_thread.__globals__['_active'] = threading._active
6154

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

138131
if ssl_args:
139132
ssl_args.setdefault('server_side', True)
140-
if 'ssl_ctx' in ssl_args:
141-
ctx = ssl_args.pop('ssl_ctx')
142-
ctx.load_cert_chain(ssl_args.pop('certfile'),
143-
ssl_args.pop('keyfile'))
144-
if 'cert_reqs' in ssl_args:
145-
ctx.verify_mode = ssl_args.pop('cert_reqs')
146-
if 'ca_certs' in ssl_args:
147-
ctx.load_verify_locations(ssl_args.pop('ca_certs'))
148-
149-
def wrap_and_handle_ctx(sock, addr):
150-
handle(ctx.wrap_socket(sock, **ssl_args), addr)
151-
152-
self.handle = wrap_and_handle_ctx
153-
else:
154-
def wrap_and_handle_ssl(sock, addr):
155-
handle(ssl.wrap_socket(sock, **ssl_args), addr)
156-
157-
self.handle = wrap_and_handle_ssl
133+
if 'ssl_ctx' not in ssl_args:
134+
raise RuntimeError("no SSLContext ssl_ctx in ssl_args")
135+
ctx = ssl_args.pop('ssl_ctx')
136+
ctx.load_cert_chain(ssl_args.pop('certfile'),
137+
ssl_args.pop('keyfile'))
138+
if 'cert_reqs' in ssl_args:
139+
ctx.verify_mode = ssl_args.pop('cert_reqs')
140+
if 'ca_certs' in ssl_args:
141+
ctx.load_verify_locations(ssl_args.pop('ca_certs'))
142+
143+
def wrap_and_handle_ctx(sock, addr):
144+
handle(ctx.wrap_socket(sock, **ssl_args), addr)
145+
146+
self.handle = wrap_and_handle_ctx
158147
else:
159148
self.handle = handle
160149

@@ -182,7 +171,14 @@ def connect(self):
182171
return None
183172

184173
if self.ssl_args:
185-
client = ssl.wrap_socket(client, **self.ssl_args)
174+
ctx = ssl.SSLContext(ssl.PROTOCOL_TLS_CLIENT)
175+
ctx.load_cert_chain(self.ssl_args.pop('certfile'),
176+
self.ssl_args.pop('keyfile'))
177+
if 'cert_reqs' in self.ssl_args:
178+
ctx.verify_mode = self.ssl_args.pop('cert_reqs')
179+
if 'ca_certs' in self.ssl_args:
180+
ctx.load_verify_location(self.ssl_args.pop('ca_certs'))
181+
client = ctx.wrap_socket(client, **self.ssl_args)
186182

187183
return client
188184

os_ken/lib/packet/tcp.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -115,8 +115,8 @@ def get_payload_type(src_port, dst_port):
115115
from os_ken.ofproto.ofproto_common import OFP_TCP_PORT, OFP_SSL_PORT_OLD
116116
if bgp.TCP_SERVER_PORT in [src_port, dst_port]:
117117
return bgp.BGPMessage
118-
elif(src_port in [OFP_TCP_PORT, OFP_SSL_PORT_OLD] or
119-
dst_port in [OFP_TCP_PORT, OFP_SSL_PORT_OLD]):
118+
elif (src_port in [OFP_TCP_PORT, OFP_SSL_PORT_OLD] or
119+
dst_port in [OFP_TCP_PORT, OFP_SSL_PORT_OLD]):
120120
return openflow.openflow
121121
elif src_port == zebra.ZEBRA_PORT:
122122
return zebra._ZebraMessageFromZebra

os_ken/lib/packet/vrrp.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -159,7 +159,7 @@ def vrrp_to_version_type(version, type_):
159159

160160

161161
def is_ipv6(ip_address):
162-
assert type(ip_address) == str
162+
assert isinstance(ip_address, str)
163163
try:
164164
addrconv.ipv4.text_to_bin(ip_address)
165165
except:
@@ -595,11 +595,11 @@ def parser(cls, buf):
595595
@staticmethod
596596
def serialize_static(vrrp_, prev):
597597
if isinstance(prev, ipv4.ipv4):
598-
assert type(vrrp_.ip_addresses[0]) == str
598+
assert isinstance(vrrp_.ip_addresses[0], str)
599599
conv = addrconv.ipv4.text_to_bin
600600
ip_address_pack_raw = vrrpv3._IPV4_ADDRESS_PACK_STR_RAW
601601
elif isinstance(prev, ipv6.ipv6):
602-
assert type(vrrp_.ip_addresses[0]) == str
602+
assert isinstance(vrrp_.ip_addresses[0], str)
603603
conv = addrconv.ipv6.text_to_bin
604604
ip_address_pack_raw = vrrpv3._IPV6_ADDRESS_PACK_STR_RAW
605605
else:

os_ken/lib/stplib.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -865,7 +865,7 @@ def _change_status(self, new_state, thread_switch=True):
865865
if new_state is not PORT_STATE_DISABLE:
866866
self.ofctl.set_port_status(self.ofport, new_state)
867867

868-
if(new_state is PORT_STATE_FORWARD
868+
if (new_state is PORT_STATE_FORWARD
869869
or (self.state is PORT_STATE_FORWARD
870870
and (new_state is PORT_STATE_DISABLE
871871
or new_state is PORT_STATE_BLOCK))):

os_ken/lib/stringify.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -370,7 +370,7 @@ def obj_python_attrs(msg_):
370370
# ofp parser implementations.
371371
if hasattr(msg_, '_fields'):
372372
for k in msg_._fields:
373-
yield(k, getattr(msg_, k))
373+
yield (k, getattr(msg_, k))
374374
return
375375
base = getattr(msg_, '_base_attributes', [])
376376
opt = getattr(msg_, '_opt_attributes', [])

0 commit comments

Comments
 (0)