Skip to content

Commit

Permalink
OSP-250: Add support for python3
Browse files Browse the repository at this point in the history
This PR did a few changes that are mostly related to Python3:

- Convert iterators to lists as needed
- Separate most mock paths and store in an individual file
- Use http.client for py3 (handled by six)
- Use upstream HTTPS Connection directly, instead of a customed one
- Update requirements and project configs
- Fix various compatibility issues
- Oranization/Refactor
- Use explicted calls for super
- Other minor fix/improvements

Change-Id: I186f182de82cb9da2ea8215da374bd42eaf1767a
  • Loading branch information
Weifan Fu authored and wolverineav committed Nov 20, 2018
1 parent 8874df5 commit 206be47
Show file tree
Hide file tree
Showing 29 changed files with 509 additions and 533 deletions.
12 changes: 12 additions & 0 deletions .zuul.yaml
Expand Up @@ -20,6 +20,14 @@
required-projects:
- name: openstack/neutron
- name: openstack/tap-as-a-service
- openstack-tox-py35:
required-projects:
- name: openstack/neutron
- name: openstack/tap-as-a-service
- openstack-tox-py36:
required-projects:
- name: openstack/neutron
- name: openstack/tap-as-a-service
gate:
jobs:
- openstack-tox-pep8:
Expand All @@ -30,3 +38,7 @@
required-projects:
- name: openstack/neutron
- name: openstack/tap-as-a-service
- openstack-tox-py35:
required-projects:
- name: openstack/neutron
- name: openstack/tap-as-a-service
2 changes: 1 addition & 1 deletion networking_bigswitch/__init__.py
Expand Up @@ -14,8 +14,8 @@
# under the License.

import gettext
import six

import six

if six.PY2:
# E1123: unexpected keyword argument
Expand Down
Expand Up @@ -92,13 +92,13 @@ def get_port_name_list(self):
try:
resp = self.run_vsctl(['list-ports'], True,
log_fail_as_error=False).strip().splitlines()
port_names = map(lambda x: x.strip(), resp)
port_names = [x.strip() for x in resp]
except RuntimeError:
resp = self.run_vsctl(['show'], True)
# get rid of stats and blank lines
lines = resp.split('ivs:')[1].split('ports:')[1].splitlines()
ports = [x for x in lines if 'packets=' not in x and x.strip()]
port_names = map(lambda x: x.strip().split(' ')[1], ports)
port_names = [x.strip().split(' ')[1] for x in ports]
LOG.debug("Ports on IVS: %s", port_names)
return port_names

Expand Down Expand Up @@ -174,7 +174,7 @@ def prepare_devices_filter(self, device_ids):
self.firewall.prepare_port_filter(device)
if self.use_enhanced_rpc:
LOG.debug("Update security group information for ports %s",
devices.keys())
list(devices.keys()))
self._update_security_group_info(
security_groups, security_group_member_ips)

Expand Down
3 changes: 1 addition & 2 deletions networking_bigswitch/plugins/bigswitch/config.py
Expand Up @@ -17,11 +17,10 @@
This module manages configuration options
"""

from oslo_config import cfg

from neutron.conf.agent import common as agconfig
from neutron_lib.api.definitions import portbindings
from neutron_lib.utils import net
from oslo_config import cfg

restproxy_opts = [
cfg.ListOpt('servers', default=['localhost:8800'],
Expand Down
11 changes: 4 additions & 7 deletions networking_bigswitch/plugins/bigswitch/l3_router_plugin.py
Expand Up @@ -22,16 +22,9 @@
"""
import copy

from oslo_log import helpers as log_helper
from oslo_log import log as logging
from oslo_utils import excutils
from oslo_utils import uuidutils

from neutron.api import extensions as neutron_extensions
from neutron.db import dns_db
from neutron.db import l3_db


from neutron_lib.api.definitions import l3 as l3_apidef
from neutron_lib.callbacks import events
from neutron_lib.callbacks import registry
Expand All @@ -41,6 +34,10 @@
from neutron_lib import exceptions
from neutron_lib.plugins import constants as plugin_constants
from neutron_lib.plugins import directory
from oslo_log import helpers as log_helper
from oslo_log import log as logging
from oslo_utils import excutils
from oslo_utils import uuidutils

from networking_bigswitch.plugins.bigswitch.db import tenant_policy_db
from networking_bigswitch.plugins.bigswitch import extensions
Expand Down
4 changes: 2 additions & 2 deletions networking_bigswitch/plugins/bigswitch/plugin.py
Expand Up @@ -42,14 +42,14 @@

import copy
import functools
import httplib
import re

import eventlet
from oslo_config import cfg
from oslo_log import log as logging
import oslo_messaging
from oslo_utils import importutils
from six.moves import http_client
from sqlalchemy.orm import exc as sqlexc

from neutron.agent import rpc as agent_rpc
Expand Down Expand Up @@ -928,7 +928,7 @@ def async_port_create(self, tenant_id, net_id, port, update_status=True):
# and the data in the backend.
# Run a sync to get it consistent.
if (cfg.CONF.RESTPROXY.auto_sync_on_failure and
e.status == httplib.NOT_FOUND and
e.status == http_client.NOT_FOUND and
servermanager.NXNETWORK in e.reason):
LOG.error("Inconsistency with backend controller "
"triggering full synchronization.")
Expand Down

0 comments on commit 206be47

Please sign in to comment.