Enable hacking to be run

Ensure that Neuteron hacking is run when doing pep8

Ensures the following:
1. oslo.whatever => oslo_whatever
2. LOG messages should have cortrect translations
3. using jsonutils instead of json

Change-Id: I85cf69d483fd5d624ed3876ec9bacd83f7b7b70b
This commit is contained in:
Gary Kotton 2015-03-08 05:55:26 -07:00
parent 313542ccd6
commit bf7b098788
63 changed files with 176 additions and 183 deletions

View File

@ -82,3 +82,4 @@ commands =
[hacking]
import_exceptions = neutron.i18n
local-check-factory = neutron.hacking.checks.factory

View File

@ -19,7 +19,7 @@ import httplib
import six
import time
from oslo.config import cfg
from oslo_config import cfg
from oslo_log import log as logging
from neutron.i18n import _LE, _LI, _LW

View File

@ -18,8 +18,8 @@ import httplib
import urllib
import eventlet
from oslo.serialization import jsonutils
from oslo_log import log as logging
from oslo_serialization import jsonutils
from neutron.i18n import _LI, _LW
from vmware_nsx.neutron.plugins.vmware.api_client import request

View File

@ -21,8 +21,8 @@ import httplib
import time
import eventlet
from oslo.utils import excutils
from oslo_log import log as logging
from oslo_utils import excutils
import six
import six.moves.urllib.parse as urlparse

View File

@ -17,7 +17,7 @@ from __future__ import print_function
import sys
from oslo.config import cfg
from oslo_config import cfg
from neutron.common import config
from vmware_nsx.neutron.plugins.vmware.common import config as nsx_config # noqa

View File

@ -14,9 +14,9 @@
import logging
from neutron.i18n import _LW
from oslo.config import cfg
from oslo_config import cfg
from neutron.i18n import _LW
from vmware_nsx.neutron.plugins.vmware.common import exceptions as nsx_exc
LOG = logging.getLogger(__name__)

View File

@ -15,6 +15,10 @@
import random
from oslo_log import log
from oslo_serialization import jsonutils
from oslo_utils import timeutils
from neutron.common import constants
from neutron.common import exceptions
from neutron import context
@ -24,10 +28,6 @@ from neutron.db import models_v2
from neutron.extensions import l3
from neutron.i18n import _LE, _LI, _LW
from neutron.openstack.common import loopingcall
from oslo.serialization import jsonutils
from oslo.utils import timeutils
from oslo_log import log
from vmware_nsx.neutron.plugins.vmware.api_client import exception as api_exc
from vmware_nsx.neutron.plugins.vmware.common import exceptions as nsx_exc
from vmware_nsx.neutron.plugins.vmware.common import nsx_utils

View File

@ -14,9 +14,9 @@
# License for the specific language governing permissions and limitations
# under the License.
from oslo.db import exception as db_exc
from oslo.utils import excutils
from oslo_db import exception as db_exc
from oslo_log import log as logging
from oslo_utils import excutils
from sqlalchemy.orm import exc
import neutron.db.api as db

View File

@ -15,11 +15,11 @@
# under the License.
#
from neutron.plugins.vmware.dbexts import nsx_models
from oslo.db import exception as d_exc
from oslo_db import exception as d_exc
from oslo_log import log as logging
from sqlalchemy import orm
from neutron.plugins.vmware.dbexts import nsx_models
from vmware_nsx.neutron.plugins.vmware.common import exceptions as p_exc

View File

@ -14,9 +14,9 @@
# License for the specific language governing permissions and limitations
# under the License.
from oslo.db import exception as db_exc
from oslo.utils import excutils
from oslo_db import exception as db_exc
from oslo_log import log as logging
from oslo_utils import excutils
from sqlalchemy.orm import exc
from sqlalchemy.sql import expression as expr

View File

@ -15,13 +15,13 @@
# under the License.
#
from oslo_config import cfg
from oslo_db import exception as db_exc
from oslo_log import log as logging
from oslo_utils import excutils
from neutron.common import exceptions as n_exc
from neutron.i18n import _LE, _LW
from oslo.config import cfg
from oslo.db import exception as db_exc
from oslo.utils import excutils
from oslo_log import log as logging
from vmware_nsx.neutron.plugins.vmware.api_client import exception as api_exc
from vmware_nsx.neutron.plugins.vmware.common import exceptions as p_exc
from vmware_nsx.neutron.plugins.vmware.common import nsx_utils

View File

@ -15,6 +15,10 @@
# under the License.
#
from oslo_config import cfg
from oslo_log import log as logging
from oslo_utils import excutils
from neutron.api.v2 import attributes as attr
from neutron.common import constants as const
from neutron.common import exceptions as n_exc
@ -22,10 +26,6 @@ from neutron.db import db_base_plugin_v2
from neutron.db import l3_db
from neutron.extensions import external_net
from neutron.i18n import _LE, _LI
from oslo.config import cfg
from oslo.utils import excutils
from oslo_log import log as logging
from vmware_nsx.neutron.plugins.vmware.common import exceptions as p_exc
from vmware_nsx.neutron.plugins.vmware.dhcp_meta import constants as d_const
from vmware_nsx.neutron.plugins.vmware.nsxlib import lsn as lsn_api

View File

@ -16,6 +16,9 @@
from eventlet import greenthread
import netaddr
from oslo_config import cfg
from oslo_log import log as logging
from neutron.api.rpc.agentnotifiers import dhcp_rpc_agent_api
from neutron.api.v2 import attributes
from neutron.common import constants as const
@ -24,9 +27,6 @@ from neutron.db import db_base_plugin_v2
from neutron.db import l3_db
from neutron.db import models_v2
from neutron.i18n import _LE, _LI, _LW
from oslo.config import cfg
from oslo_log import log as logging
from vmware_nsx.neutron.plugins.vmware.api_client import exception as api_exc
from vmware_nsx.neutron.plugins.vmware.common import config
from vmware_nsx.neutron.plugins.vmware.common import exceptions as nsx_exc

View File

@ -15,9 +15,9 @@
# under the License.
#
from oslo.concurrency import lockutils
from oslo.config import cfg
from oslo.utils import importutils
from oslo_concurrency import lockutils
from oslo_config import cfg
from oslo_utils import importutils
from neutron.api.rpc.agentnotifiers import dhcp_rpc_agent_api
from neutron.api.rpc.handlers import dhcp_rpc

View File

@ -12,11 +12,11 @@
# License for the specific language governing permissions and limitations
# under the License.
from oslo.utils import excutils
from oslo.vmware import vim_util
from oslo_utils import excutils
from oslo_vmware import vim_util
from neutron.common import exceptions
from neutron.i18n import _LE, _LI
from neutron.openstack.common import log as logging
from vmware_nsx.neutron.plugins.vmware.common import exceptions as nsx_exc
from vmware_nsx.neutron.plugins.vmware.dvs import dvs_utils
@ -87,10 +87,10 @@ class DvsManager(object):
except Exception:
# NOTE(garyk): handle more specific exceptions
with excutils.save_and_reraise_exception():
LOG.exception(_('Failed to create port group for '
'%(net_id)s with tag %(tag)s.'),
LOG.exception(_LE('Failed to create port group for '
'%(net_id)s with tag %(tag)s.'),
{'net_id': net_id, 'tag': vlan_tag})
LOG.info("%(net_id)s with tag %(vlan_tag)s created on %(dvs)s.",
LOG.info(_LI("%(net_id)s with tag %(vlan_tag)s created on %(dvs)s."),
{'net_id': net_id,
'vlan_tag': vlan_tag,
'dvs': dvs_utils.dvs_name_get()})
@ -129,7 +129,8 @@ class DvsManager(object):
except Exception:
# NOTE(garyk): handle more specific exceptions
with excutils.save_and_reraise_exception():
LOG.exception(_('Failed to delete port group for %s.'), net_id)
LOG.info("%(net_id)s delete from %(dvs)s.",
LOG.exception(_LE('Failed to delete port group for %s.'),
net_id)
LOG.info(_LI("%(net_id)s delete from %(dvs)s."),
{'net_id': net_id,
'dvs': dvs_utils.dvs_name_get()})

View File

@ -12,8 +12,8 @@
# License for the specific language governing permissions and limitations
# under the License.
from oslo.config import cfg
from oslo.vmware import api
from oslo_config import cfg
from oslo_vmware import api
dvs_opts = [
cfg.StrOpt('host_ip',

View File

@ -13,10 +13,10 @@
# License for the specific language governing permissions and limitations
# under the License.
from neutron.i18n import _LI
from oslo.config import cfg
from oslo_config import cfg
from oslo_log import log as logging
from neutron.i18n import _LI
from vmware_nsx.neutron.plugins.vmware.common import exceptions
LOG = logging.getLogger(__name__)

View File

@ -13,11 +13,11 @@
# License for the specific language governing permissions and limitations
# under the License.
from oslo_log import log
from oslo_serialization import jsonutils
from neutron.common import exceptions as exception
from neutron import version
from oslo.serialization import jsonutils
from oslo_log import log
from vmware_nsx.neutron.plugins.vmware.api_client import exception as api_exc
from vmware_nsx.neutron.plugins.vmware.common import exceptions as nsx_exc

View File

@ -14,8 +14,8 @@
# under the License.
#
from oslo.serialization import jsonutils
from oslo_log import log
from oslo_serialization import jsonutils
from vmware_nsx.neutron.plugins.vmware.api_client import exception as api_exc
from vmware_nsx.neutron.plugins.vmware.common import exceptions as nsx_exc

View File

@ -13,10 +13,10 @@
# License for the specific language governing permissions and limitations
# under the License.
from neutron.common import exceptions as exception
from oslo.serialization import jsonutils
from oslo_log import log
from oslo_serialization import jsonutils
from neutron.common import exceptions as exception
from vmware_nsx.neutron.plugins.vmware.api_client import exception as api_exc
from vmware_nsx.neutron.plugins.vmware.common import exceptions as nsx_exc
from vmware_nsx.neutron.plugins.vmware.common import utils

View File

@ -13,13 +13,12 @@
# License for the specific language governing permissions and limitations
# under the License.
from oslo.serialization import jsonutils
from oslo.utils import excutils
from oslo_log import log
from oslo_serialization import jsonutils
from oslo_utils import excutils
from neutron.api.v2 import attributes as attr
from neutron.common import exceptions as exception
from vmware_nsx.neutron.plugins.vmware.api_client import exception as api_exc
from vmware_nsx.neutron.plugins.vmware.common import utils
from vmware_nsx.neutron.plugins.vmware import nsxlib

View File

@ -13,14 +13,13 @@
# License for the specific language governing permissions and limitations
# under the License.
from oslo.config import cfg
from oslo.serialization import jsonutils
from oslo.utils import excutils
from oslo_config import cfg
from oslo_log import log
from oslo_serialization import jsonutils
from oslo_utils import excutils
from neutron.common import exceptions as exception
from neutron.i18n import _LE, _LI, _LW
from vmware_nsx.neutron.plugins.vmware.api_client import exception as api_exc
from vmware_nsx.neutron.plugins.vmware.common import exceptions as nsx_exc
from vmware_nsx.neutron.plugins.vmware.common import utils

View File

@ -13,13 +13,13 @@
# License for the specific language governing permissions and limitations
# under the License.
from oslo_log import log
from oslo_serialization import jsonutils
from oslo_utils import excutils
from neutron.common import constants
from neutron.common import exceptions
from neutron.i18n import _LW
from oslo.serialization import jsonutils
from oslo.utils import excutils
from oslo_log import log
from vmware_nsx.neutron.plugins.vmware.common import utils
from vmware_nsx.neutron.plugins.vmware import nsxlib

View File

@ -14,13 +14,13 @@
# under the License.
#
from oslo_config import cfg
from oslo_log import log
from oslo_serialization import jsonutils
from neutron.common import constants
from neutron.common import exceptions as exception
from neutron.i18n import _LE, _LI, _LW
from oslo.config import cfg
from oslo.serialization import jsonutils
from oslo_log import log
from vmware_nsx.neutron.plugins.vmware.api_client import exception as api_exc
from vmware_nsx.neutron.plugins.vmware.common import exceptions as nsx_exc
from vmware_nsx.neutron.plugins.vmware.common import utils

View File

@ -15,11 +15,11 @@
import uuid
from oslo.config import cfg
from oslo.db import exception as db_exc
from oslo.utils import excutils
from oslo_concurrency import lockutils
from oslo_config import cfg
from oslo_db import exception as db_exc
from oslo_log import log as logging
from oslo_utils import excutils
from sqlalchemy import exc as sql_exc
from sqlalchemy.orm import exc as sa_exc
import webob.exc

View File

@ -15,8 +15,8 @@
import uuid
from oslo.utils import excutils
from oslo_log import log as logging
from oslo_utils import excutils
from neutron.api import extensions as neutron_extensions
from neutron.api.v2 import attributes as attr
@ -32,7 +32,7 @@ from neutron.extensions import multiprovidernet as mpnet
from neutron.extensions import portbindings as pbin
from neutron.extensions import portsecurity as psec
from neutron.extensions import providernet as pnet
from neutron.i18n import _LE, _LW
from vmware_nsx.neutron.plugins import vmware
from vmware_nsx.neutron.plugins.vmware.common import config # noqa
from vmware_nsx.neutron.plugins.vmware.common import exceptions as nsx_exc
@ -119,9 +119,9 @@ class NsxDvsV2(addr_pair_db.AllowedAddressPairsMixin,
def _dvs_create_network(self, context, network):
net_data = network['network']
if net_data['admin_state_up'] is False:
LOG.warning(_("Network with admin_state_up=False are not yet "
"supported by this plugin. Ignoring setting for "
"network %s"), net_data.get('name', '<unknown>'))
LOG.warning(_LW("Network with admin_state_up=False are not yet "
"supported by this plugin. Ignoring setting for "
"network %s"), net_data.get('name', '<unknown>'))
net_data['id'] = str(uuid.uuid4())
vlan_tag = 0
if net_data.get(pnet.NETWORK_TYPE) == c_utils.NetworkTypes.VLAN:
@ -144,7 +144,7 @@ class NsxDvsV2(addr_pair_db.AllowedAddressPairsMixin,
vlan_tag)
except Exception:
with excutils.save_and_reraise_exception():
LOG.exception(_('Failed to create network'))
LOG.exception(_LE('Failed to create network'))
self._dvs.delete_port_group(dvs_id)
new_net[pnet.NETWORK_TYPE] = net_data.get(pnet.NETWORK_TYPE)
@ -164,7 +164,7 @@ class NsxDvsV2(addr_pair_db.AllowedAddressPairsMixin,
try:
self._dvs.delete_port_group(dvs_id)
except Exception:
LOG.exception(_('Unable to delete DVS port group %s'), id)
LOG.exception(_LE('Unable to delete DVS port group %s'), id)
self.handle_network_dhcp_access(context, id, action='delete_network')
def delete_network(self, context, id):
@ -232,8 +232,8 @@ class NsxDvsV2(addr_pair_db.AllowedAddressPairsMixin,
# remove ATTR_NOT_SPECIFIED
port_data[addr_pair.ADDRESS_PAIRS] = []
LOG.debug(_("create_port completed on NSX for tenant "
"%(tenant_id)s: (%(id)s)"), port_data)
LOG.debug("create_port completed on NSX for tenant "
"%(tenant_id)s: (%(id)s)", port_data)
self._process_portbindings_create_and_update(context,
port['port'],
@ -289,7 +289,7 @@ class NsxDvsV2(addr_pair_db.AllowedAddressPairsMixin,
self._process_port_port_security_update(
context, port['port'], ret_port)
LOG.debug(_("Updating port: %s"), port)
LOG.debug("Updating port: %s", port)
self._process_portbindings_create_and_update(context,
port['port'],
ret_port)

View File

@ -13,11 +13,12 @@
# License for the specific language governing permissions and limitations
# under the License.
from oslo.config import cfg
from oslo_config import cfg
import stevedore
from oslo_log import log
from neutron.i18n import _LE, _LI
from vmware_nsx.neutron.plugins.vmware.common import exceptions as nsx_exc
@ -32,14 +33,14 @@ class RouterTypeManager(stevedore.named.NamedExtensionManager):
# Mapping from type name to DriverManager
self.drivers = {}
LOG.info(_("Configured router type driver names: %s"),
LOG.info(_LI("Configured router type driver names: %s"),
ROUTER_TYPE_DRIVERS)
super(RouterTypeManager, self).__init__(
'vmware_nsx.neutron.nsxv.router_type_drivers',
ROUTER_TYPE_DRIVERS,
invoke_on_load=True,
invoke_args=(plugin,))
LOG.info(_("Loaded type driver names: %s"), self.names())
LOG.info(_LI("Loaded type driver names: %s"), self.names())
self._register_types()
self._check_tenant_router_types(cfg.CONF.nsxv.tenant_router_types)
@ -47,15 +48,15 @@ class RouterTypeManager(stevedore.named.NamedExtensionManager):
for ext in self:
router_type = ext.obj.get_type()
if router_type in self.drivers:
LOG.error(_("Type driver '%(new_driver)s' ignored because "
"type driver '%(old_driver)s' is already "
"registered for type '%(type)s'"),
LOG.error(_LE("Type driver '%(new_driver)s' ignored because "
"type driver '%(old_driver)s' is already "
"registered for type '%(type)s'"),
{'new_driver': ext.name,
'old_driver': self.drivers[router_type].name,
'type': router_type})
else:
self.drivers[router_type] = ext
LOG.info(_("Registered types: %s"), self.drivers.keys())
LOG.info(_LI("Registered types: %s"), self.drivers.keys())
def _check_tenant_router_types(self, types):
self.tenant_router_types = []
@ -67,7 +68,7 @@ class RouterTypeManager(stevedore.named.NamedExtensionManager):
"Service terminated!") % router_type
LOG.error(msg)
raise SystemExit(msg)
LOG.info(_("Tenant router_types: %s"), self.tenant_router_types)
LOG.info(_LI("Tenant router_types: %s"), self.tenant_router_types)
def get_tenant_router_driver(self, context, router_type):
driver = self.drivers.get(router_type)

View File

@ -16,10 +16,10 @@
import uuid
import netaddr
from oslo.config import cfg
from oslo.utils import excutils
from oslo_concurrency import lockutils
from oslo_config import cfg
from oslo_log import log as logging
from oslo_utils import excutils
from sqlalchemy.orm import exc as sa_exc
from neutron.api import extensions as neutron_extensions
@ -46,13 +46,12 @@ from neutron.extensions import portbindings as pbin
from neutron.extensions import portsecurity as psec
from neutron.extensions import providernet as pnet
from neutron.extensions import securitygroup as ext_sg
from neutron.i18n import _LE, _LW
from neutron.i18n import _LE, _LI, _LW
from neutron.openstack.common import uuidutils
from neutron.plugins.vmware.extensions import (
advancedserviceproviders as as_providers)
from neutron.plugins.vmware.extensions import (
vnicindex as ext_vnic_idx)
from vmware_nsx.neutron.plugins import vmware
from vmware_nsx.neutron.plugins.vmware.common import config # noqa
from vmware_nsx.neutron.plugins.vmware.common import exceptions as nsx_exc
@ -457,8 +456,8 @@ class NsxVPluginV2(agents_db.AgentDbMixin,
try:
h, c = self.nsx_v.vcns.add_member_to_security_group(
sg_id, vnic_id)
LOG.info(_("Added %s(sg_id)s member to NSX security "
"group %(vnic_id)s"),
LOG.info(_LI("Added %s(sg_id)s member to NSX security "
"group %(vnic_id)s"),
{'sg_id': sg_id, 'vnic_id': vnic_id})
except Exception as e:
LOG.debug("NSX security group %(sg_id)s member add "
@ -693,7 +692,7 @@ class NsxVPluginV2(agents_db.AgentDbMixin,
self._delete_dhcp_edge_service(context, id)
except Exception:
with excutils.save_and_reraise_exception():
LOG.exception(_('Failed to delete network'))
LOG.exception(_LE('Failed to delete network'))
with context.session.begin(subtransactions=True):
self._process_l3_delete(context, id)
@ -752,10 +751,10 @@ class NsxVPluginV2(agents_db.AgentDbMixin,
original_network[psec.PORTSECURITY] !=
net_attrs[psec.PORTSECURITY])
if psec_update and not net_attrs[psec.PORTSECURITY]:
LOG.warning(_("Disabling port-security on network %s would "
"require instance in the network to have VM tools "
"installed in order for security-groups to "
"function properly."))
LOG.warning(_LW("Disabling port-security on network %s would "
"require instance in the network to have VM tools "
"installed in order for security-groups to "
"function properly."))
with context.session.begin(subtransactions=True):
net_res = super(NsxVPluginV2, self).update_network(context, id,
@ -848,10 +847,10 @@ class NsxVPluginV2(agents_db.AgentDbMixin,
self._update_vnic_assigned_addresses(
context.session, original_port, vnic_id)
else:
LOG.warning(_("port-security is disabled on port %(id)s, "
"VM tools must be installed on instance "
"%(device_id)s for security-groups to function "
"properly "),
LOG.warning(_LW("port-security is disabled on port %(id)s, "
"VM tools must be installed on instance "
"%(device_id)s for security-groups to "
"function properly."),
{'id': id,
'device_id': original_port['device_id']})
@ -921,10 +920,11 @@ class NsxVPluginV2(agents_db.AgentDbMixin,
self._update_vnic_assigned_addresses(
context.session, ret_port, vnic_id)
if not has_port_security and has_security_groups:
LOG.warning(_("port-security is disabled on port %(id)s, "
"VM tools must be installed on instance "
"%(device_id)s for security-groups to "
"function properly "),
LOG.warning(_LW("port-security is disabled on "
"port %(id)s, "
"VM tools must be installed on instance "
"%(device_id)s for security-groups to "
"function properly "),
{'id': id,
'device_id': original_port['device_id']})
if delete_security_groups or has_security_groups:
@ -1846,7 +1846,7 @@ class NsxVPluginV2(agents_db.AgentDbMixin,
try:
self.nsx_v.vcns.edges_lock_operation()
except Exception:
LOG.info(_("Unable to set manager lock operation"))
LOG.info(_LI("Unable to set manager lock operation"))
def _validate_config(self):
if not self.nsx_v.vcns.validate_dvs(cfg.CONF.nsxv.dvs_id):

View File

@ -12,7 +12,7 @@
# License for the specific language governing permissions and limitations
# under the License.
from oslo.utils import excutils
from oslo_utils import excutils
from neutron.common import exceptions as n_exc

View File

@ -12,14 +12,13 @@
# License for the specific language governing permissions and limitations
# under the License.
from oslo.config import cfg
from oslo_concurrency import lockutils
from oslo_config import cfg
from neutron import context as neutron_context
from neutron.db import l3_db
from neutron.db import models_v2
from neutron.openstack.common import log as logging
from vmware_nsx.neutron.plugins.vmware.common import exceptions as nsx_exc
from vmware_nsx.neutron.plugins.vmware.dbexts import nsxv_db
from vmware_nsx.neutron.plugins.vmware.plugins import nsx_v

View File

@ -19,14 +19,15 @@ import hmac
import time
import netaddr
from oslo.config import cfg
from oslo.db import exception as db_exc
from oslo_config import cfg
from oslo_db import exception as db_exc
from oslo_log import log as logging
from oslo_utils import excutils
from neutron.api.v2 import attributes as attr
from neutron.common import constants
from neutron import context as neutron_context
from oslo_log import log as logging
from neutron.i18n import _LE
from vmware_nsx.neutron.plugins.vmware.common import exceptions as nsxv_exc
from vmware_nsx.neutron.plugins.vmware.common import nsxv_constants
from vmware_nsx.neutron.plugins.vmware.dbexts import nsxv_db
@ -155,8 +156,8 @@ class NsxVMetadataProxyHandler:
if internal_net:
self.nsxv_plugin.delete_network(self.context, internal_net)
LOG.exception(_("Exception %s while creating internal network "
"for metadata service"), e)
LOG.exception(_LE("Exception %s while creating internal "
"network for metadata service"), e)
# Update the new network_id in DB
nsxv_db.update_nsxv_internal_network(
@ -307,8 +308,8 @@ class NsxVMetadataProxyHandler:
if rtr_id:
self.nsxv_plugin.delete_router(self.context, rtr_id)
LOG.exception(_("Exception %s while creating internal edge "
"for metadata service"), e)
LOG.exception(_LE("Exception %s while creating internal edge "
"for metadata service"), e)
def _get_address_groups(self, context, network_id, device_id, is_proxy):

View File

@ -15,7 +15,7 @@
import base64
import eventlet
from oslo.serialization import jsonutils
from oslo_serialization import jsonutils
from vmware_nsx.neutron.plugins.vmware.vshield.common import exceptions

View File

@ -13,7 +13,7 @@
# License for the specific language governing permissions and limitations
# under the License.
from oslo.config import cfg
from oslo_config import cfg
from vmware_nsx.neutron.plugins.vmware.common import nsxv_constants

View File

@ -16,10 +16,10 @@
import time
from oslo.config import cfg
from oslo.serialization import jsonutils
from oslo.utils import excutils
from oslo_config import cfg
from oslo_log import log as logging
from oslo_serialization import jsonutils
from oslo_utils import excutils
from neutron.i18n import _LE, _LI, _LW
from vmware_nsx.neutron.plugins.vmware.common import nsxv_constants
@ -497,7 +497,7 @@ class EdgeApplianceDriver(object):
header = self.vcns.deploy_edge(edge,
async=False)[0]
edge_id = header['location'].split('/')[-1]
LOG.debug(_("VCNS: deploying edge %s"), edge_id)
LOG.debug("VCNS: deploying edge %s", edge_id)
self.callbacks.edge_deploy_started_sync(
jobdata['context'], edge_id, name,
@ -512,7 +512,7 @@ class EdgeApplianceDriver(object):
jobdata['context'], edge_id, name, jobdata['router_id'],
dist, False)
with excutils.save_and_reraise_exception():
LOG.exception(_("NSXv: deploy edge failed."))
LOG.exception(_LE("NSXv: deploy edge failed."))
def update_edge(self, router_id, edge_id, name, internal_network,
jobdata=None, dist=False, loadbalancer_enable=True,

View File

@ -12,7 +12,7 @@
# License for the specific language governing permissions and limitations
# under the License.
from oslo.utils import excutils
from oslo_utils import excutils
from neutron.db import db_base_plugin_v2
from neutron.i18n import _, _LE

View File

@ -12,7 +12,7 @@
# License for the specific language governing permissions and limitations
# under the License.
from oslo.utils import excutils
from oslo_utils import excutils
from neutron.i18n import _LE, _LW
from neutron.openstack.common import log as logging

View File

@ -12,7 +12,7 @@
# License for the specific language governing permissions and limitations
# under the License.
from oslo.utils import excutils
from oslo_utils import excutils
from neutron.i18n import _LE
from neutron.openstack.common import log as logging

View File

@ -16,10 +16,10 @@
import eventlet
import time
from oslo.config import cfg
from oslo.utils import excutils
from oslo_concurrency import lockutils
from oslo_config import cfg
from oslo_log import log as logging
from oslo_utils import excutils
from sqlalchemy.orm import exc as sa_exc
from neutron.common import exceptions as n_exc
@ -702,9 +702,9 @@ class EdgeManager(object):
except Exception:
with excutils.save_and_reraise_exception():
LOG.exception(
_('Failed to delete vnic %(vnic_index)d '
'tunnel %(tunnel_index)d on edge '
'%(edge_id)s'),
_LE('Failed to delete vnic %(vnic_index)d '
'tunnel %(tunnel_index)d on edge '
'%(edge_id)s'),
{'vnic_index': old_vnic_index,
'tunnel_index': old_tunnel_index,
'edge_id': edge_id})
@ -1361,8 +1361,8 @@ def delete_interface(nsxv_manager, context, router_id, network_id,
edge_vnic_binding = nsxv_db.get_edge_vnic_binding(
context.session, edge_id, network_id)
if not edge_vnic_binding:
LOG.warning(_("Failed to find the network %(net_id)s "
"corresponding vnic index on edge %(edge_id)s"),
LOG.warning(_LW("Failed to find the network %(net_id)s "
"corresponding vnic index on edge %(edge_id)s"),
{'net_id': network_id,
'edge_id': edge_id})
@ -1429,8 +1429,8 @@ def check_network_in_use_at_backend(context, network_id):
context.session, network_id)
if not edge_vnic_bindings:
return
LOG.warning(_('NSXv: network is still in use at the backend'))
LOG.error(_('NSXv: network is still in use at the backend'))
LOG.warning(_LW('NSXv: network is still in use at the backend'))
LOG.error(_LE('NSXv: network is still in use at the backend'))
class NsxVCallbacks(object):

View File

@ -15,7 +15,7 @@
import abc
from oslo.serialization import jsonutils
from oslo_serialization import jsonutils
import six
from vmware_nsx.neutron.plugins.vmware.vshield import vcns

View File

@ -14,9 +14,9 @@
# License for the specific language governing permissions and limitations
# under the License.
from oslo.config import cfg
from oslo.serialization import jsonutils
from oslo_config import cfg
from oslo_log import log as logging
from oslo_serialization import jsonutils
import retrying
import xml.etree.ElementTree as et

View File

@ -14,7 +14,7 @@
# License for the specific language governing permissions and limitations
# under the License.
from oslo.config import cfg
from oslo_config import cfg
from oslo_log import log as logging
from vmware_nsx.neutron.plugins.vmware.common import config # noqa

View File

@ -13,7 +13,7 @@
# License for the specific language governing permissions and limitations
# under the License.
from oslo.config import cfg
from oslo_config import cfg
cfg.CONF.use_stderr = False

View File

@ -12,11 +12,11 @@
# License for the specific language governing permissions and limitations
# under the License.
from neutron.openstack.common import uuidutils
from oslo.serialization import jsonutils
from oslo_log import log as logging
from oslo_serialization import jsonutils
import six.moves.urllib.parse as urlparse
from neutron.openstack.common import uuidutils
from vmware_nsx.neutron.plugins.vmware.api_client import exception as api_exc

View File

@ -13,7 +13,7 @@
# See the License for the specific language governing permissions and
# limitations under the License.
from oslo.db import exception as d_exc
from oslo_db import exception as d_exc
from neutron import context
from neutron.db import models_v2

View File

@ -15,8 +15,7 @@
import contextlib
import mock
from oslo.config import cfg
from oslo_config import cfg
from neutron.api.v2 import attributes
from neutron.common import test_lib

View File

@ -15,7 +15,7 @@
import contextlib
import mock
from oslo.config import cfg
from oslo_config import cfg
from webob import exc
import webtest
@ -33,7 +33,6 @@ from neutron.tests.unit import test_api_v2
from neutron.tests.unit import test_db_plugin
from neutron.tests.unit import test_extensions
from neutron.tests.unit import testlib_plugin
from vmware_nsx.neutron.plugins.vmware.api_client import exception as api_exc
from vmware_nsx.neutron.plugins.vmware.common import exceptions as nsx_exc
from vmware_nsx.neutron.plugins.vmware.dbexts import networkgw_db

View File

@ -13,7 +13,7 @@
# License for the specific language governing permissions and limitations
# under the License.
from oslo.config import cfg
from oslo_config import cfg
import webob.exc
from neutron.extensions import multiprovidernet as mpnet

View File

@ -16,13 +16,12 @@
import contextlib
import mock
from oslo.config import cfg
from oslo_config import cfg
import webob.exc
from neutron import context
from neutron.plugins.vmware.extensions import qos as ext_qos
from neutron.tests.unit import test_extensions
from vmware_nsx.neutron.plugins.vmware.dbexts import qos_db
from vmware_nsx.neutron.plugins.vmware import nsxlib
from vmware_nsx.neutron.tests.unit import vmware

View File

@ -13,8 +13,8 @@
# License for the specific language governing permissions and limitations
# under the License.
from oslo.config import cfg
from oslo.db import exception as d_exc
from oslo_config import cfg
from oslo_db import exception as d_exc
from neutron.api.v2 import attributes as attr
from neutron import context as neutron_context

View File

@ -13,9 +13,8 @@
# License for the specific language governing permissions and limitations
# under the License.
import json
import mock
from oslo_serialization import jsonutils
from neutron.tests import base
from vmware_nsx.neutron.plugins.vmware.vshield import nsxv_loadbalancer
@ -79,7 +78,7 @@ class NsxvLoadbalancerTestCase(base.BaseTestCase):
def test_get_edge_loadbalancer(self):
h = None
v = json.loads(self.EDGE_OBJ_JSON)
v = jsonutils.loads(self.EDGE_OBJ_JSON)
with mock.patch.object(self._vcns, 'do_request',
return_value=(h, v)) as mock_do_request:

View File

@ -15,9 +15,9 @@
#
import mock
from neutron.tests.unit import test_api_v2
from oslo.serialization import jsonutils
from oslo_serialization import jsonutils
from neutron.tests.unit import test_api_v2
from vmware_nsx.neutron.plugins.vmware.api_client import exception
from vmware_nsx.neutron.plugins.vmware.common import utils as nsx_utils
from vmware_nsx.neutron.plugins.vmware import nsxlib

View File

@ -14,9 +14,10 @@
# limitations under the License.
import mock
from oslo_serialization import jsonutils
from neutron.common import exceptions
from neutron.tests import base
from oslo.serialization import jsonutils
from vmware_nsx.neutron.plugins.vmware.api_client import exception as api_exc
from vmware_nsx.neutron.plugins.vmware.common import exceptions as nsx_exc

View File

@ -16,7 +16,7 @@
import mock
from oslo.config import cfg
from oslo_config import cfg
from neutron.common import exceptions
from neutron.openstack.common import uuidutils

View File

@ -14,7 +14,7 @@
# under the License.
import mock
from oslo.config import cfg
from oslo_config import cfg
from neutron.common import constants
from neutron.common import test_lib

View File

@ -14,12 +14,13 @@
# limitations under the License.
import mock
from oslo_config import cfg
from neutron.common import constants as n_consts
from neutron.common import exceptions as n_exc
from neutron import context
from neutron.tests import base
from neutron.tests.unit import testlib_api
from oslo.config import cfg
from vmware_nsx.neutron.plugins.vmware.api_client import exception
from vmware_nsx.neutron.plugins.vmware.common import exceptions as p_exc

View File

@ -15,7 +15,7 @@
import contextlib
import mock
from oslo.config import cfg
from oslo_config import cfg
from neutron.common import exceptions as exp
from neutron import context

View File

@ -14,8 +14,8 @@
# limitations under the License.
import mock
from oslo.config import cfg
from oslo.vmware import api
from oslo_config import cfg
from oslo_vmware import api
from neutron.tests import base
from vmware_nsx.neutron.plugins.vmware.dvs import dvs_utils

View File

@ -16,12 +16,11 @@
import fixtures
import mock
from oslo.config import cfg
from oslo_config import cfg
from neutron import manager
from neutron.openstack.common import uuidutils
from neutron.tests import base
from vmware_nsx.neutron.plugins.vmware.api_client import client
from vmware_nsx.neutron.plugins.vmware.api_client import version
from vmware_nsx.neutron.plugins.vmware.common import config # noqa

View File

@ -18,8 +18,8 @@ import uuid
import mock
import netaddr
from oslo.config import cfg
from oslo.db import exception as db_exc
from oslo_config import cfg
from oslo_db import exception as db_exc
from oslo_log import log
from sqlalchemy import exc as sql_exc
import webob.exc

View File

@ -18,9 +18,9 @@ import contextlib
import time
import mock
from oslo.config import cfg
from oslo.serialization import jsonutils
from oslo_config import cfg
from oslo_log import log
from oslo_serialization import jsonutils
from neutron.api.v2 import attributes as attr
from neutron.common import constants

View File

@ -16,7 +16,7 @@
import contextlib
from eventlet import greenthread
import mock
from oslo.config import cfg
from oslo_config import cfg
import webob.exc
from neutron.api.v2 import attributes
@ -443,12 +443,10 @@ class TestPortsV2(NsxVPluginV2TestCase,
instance with existing port.
"""
with self.port() as port:
with mock.patch(PLUGIN_NAME + '._create_dhcp_static_binding') as (
_create_dhcp_static_binding_mock):
with mock.patch(PLUGIN_NAME + '._create_dhcp_static_binding'):
update = {'port': {'device_owner'}}
self.new_update_request('ports',
update, port['port']['id'])
_create_dhcp_static_binding_mock.assert_called_once()
def test_create_port_public_network_with_ip(self):
with self.network(shared=True) as network:
@ -1307,15 +1305,13 @@ class TestExclusiveRouterTestCase(L3NatTest,
p1_id = p1['port']['id']
p2_id = p2['port']['id']
with self.floatingip_with_assoc(port_id=p1_id) as fip:
with self._mock_edge_router_update_with_exception() as (
update_edge):
with self._mock_edge_router_update_with_exception():
self.assertRaises(object,
p.update_floatingip,
context.get_admin_context(),
fip['floatingip']['id'],
floatingip={'floatingip':
{'port_id': p2_id}})
update_edge.assert_called_once()
res = self._list(
'floatingips', query_params="port_id=%s" % p1_id)
self.assertEqual(len(res['floatingips']), 1)
@ -1345,13 +1341,11 @@ class TestExclusiveRouterTestCase(L3NatTest,
'floating_network_id': public_network_id,
'port_id': port_id}}
with self._mock_edge_router_update_with_exception() as (
update_edge):
with self._mock_edge_router_update_with_exception():
self.assertRaises(object,
p.create_floatingip,
context.get_admin_context(),
floatingip=floatingip)
update_edge.assert_called_once()
res = self._list(
'floatingips', query_params="port_id=%s" % port_id)
self.assertEqual(len(res['floatingips']), 0)

View File

@ -14,7 +14,7 @@
import copy
from oslo.serialization import jsonutils as json
from oslo_serialization import jsonutils
import xml.etree.ElementTree as ET
from neutron.openstack.common import uuidutils
@ -100,7 +100,7 @@ class FakeVcns(object):
'moduleName': 'vShield Edge',
'errorData': None
}
return (header, json.dumps(response))
return (header, jsonutils.dumps(response))
self._job_idx = self._job_idx + 1
job_id = "jobdata-%d" % self._job_idx
@ -382,7 +382,8 @@ class FakeVcns(object):
# The lswitch is created via VCNS API so the fake nsx_api will not
# see it. Added to fake nsx_api here.
if self._fake_nsx_api:
lswitch = self._fake_nsx_api._add_lswitch(json.dumps(lsconfig))
lswitch = self._fake_nsx_api._add_lswitch(
jsonutils.dumps(lsconfig))
else:
lswitch = lsconfig
lswitch['uuid'] = uuidutils.generate_uuid()

View File

@ -14,7 +14,7 @@
#
import mock
from oslo.config import cfg
from oslo_config import cfg
from neutron.common import exceptions as n_exc
from neutron import context