Drop log translations

Log messages are no longer being translated. This removes all use of
the _LE, _LI, and _LW translation markers to simplify logging and to
avoid confusion with new contributions.

See:
http://lists.openstack.org/pipermail/openstack-i18n/2016-November/002574.html
http://lists.openstack.org/pipermail/openstack-dev/2017-March/113365.html

Change-Id: I9d37ae28a3fecbe910e60dc7f22e229a7b65940c
This commit is contained in:
Gary Kotton
2017-03-26 04:41:58 -07:00
parent 72af9f1b34
commit 6228a06399
100 changed files with 1229 additions and 1333 deletions

View File

@@ -97,7 +97,8 @@ commands = sphinx-build -W -b html doc/source doc/build/html
# H904 Wrap long lines in parentheses instead of a backslash
# TODO(dougwig) -- uncomment this to test for remaining linkages
# N530 direct neutron imports not allowed
ignore = E125,E126,E128,E129,E265,H305,H307,H404,H405,H904,N530
# N531 translations hints
ignore = E125,E126,E128,E129,E265,H305,H307,H404,H405,H904,N530,N531
show-source = true
builtins = _
exclude = .venv,.git,.tox,dist,doc,*lib/python*,*egg,build,.ropeproject

View File

@@ -27,16 +27,6 @@ _C = _translators.contextual_form
# The plural translation function using the name "_P"
_P = _translators.plural_form
# Translators for log levels.
#
# The abbreviated names are meant to reflect the usual use of a short
# name like '_'. The "L" is for "log" and the other letter comes from
# the level.
_LI = _translators.log_info
_LW = _translators.log_warning
_LE = _translators.log_error
_LC = _translators.log_critical
def get_available_languages():
return oslo_i18n.get_available_languages(DOMAIN)

View File

@@ -22,7 +22,6 @@ from oslo_log import log as logging
import six
from six.moves import http_client as httplib
from vmware_nsx._i18n import _LE, _LI, _LW
from vmware_nsx import api_client
LOG = logging.getLogger(__name__)
@@ -101,15 +100,15 @@ class ApiClientBase(object):
api_providers are configured.
'''
if not self._api_providers:
LOG.warning(_LW("[%d] no API providers currently available."), rid)
LOG.warning("[%d] no API providers currently available.", rid)
return None
if self._conn_pool.empty():
LOG.debug("[%d] Waiting to acquire API client connection.", rid)
priority, conn = self._conn_pool.get()
now = time.time()
if getattr(conn, 'last_used', now) < now - cfg.CONF.conn_idle_timeout:
LOG.info(_LI("[%(rid)d] Connection %(conn)s idle for %(sec)0.2f "
"seconds; reconnecting."),
LOG.info("[%(rid)d] Connection %(conn)s idle for %(sec)0.2f "
"seconds; reconnecting.",
{'rid': rid, 'conn': api_client.ctrl_conn_to_str(conn),
'sec': now - conn.last_used})
conn = self._create_connection(*self._conn_params(conn))
@@ -149,8 +148,8 @@ class ApiClientBase(object):
priority = http_conn.priority
if bad_state:
# Reconnect to provider.
LOG.warning(_LW("[%(rid)d] Connection returned in bad state, "
"reconnecting to %(conn)s"),
LOG.warning("[%(rid)d] Connection returned in bad state, "
"reconnecting to %(conn)s",
{'rid': rid,
'conn': api_client.ctrl_conn_to_str(http_conn)})
http_conn = self._create_connection(*self._conn_params(http_conn))
@@ -181,7 +180,7 @@ class ApiClientBase(object):
data = self._get_provider_data(conn)
if data is None:
LOG.error(_LE("Login request for an invalid connection: '%s'"),
LOG.error("Login request for an invalid connection: '%s'",
api_client.ctrl_conn_to_str(conn))
return
provider_sem = data[0]

View File

@@ -19,7 +19,6 @@
from oslo_log import log as logging
from six.moves import http_client as httplib
from vmware_nsx._i18n import _LE
from vmware_nsx.api_client import base
from vmware_nsx.api_client import eventlet_client
from vmware_nsx.api_client import eventlet_request
@@ -101,7 +100,7 @@ class NsxApiClient(eventlet_client.EventletApiClient):
if response is None:
# Timeout.
LOG.error(_LE('Request timed out: %(method)s to %(url)s'),
LOG.error('Request timed out: %(method)s to %(url)s',
{'method': method, 'url': url})
raise exception.RequestTimeout()
@@ -112,15 +111,15 @@ class NsxApiClient(eventlet_client.EventletApiClient):
# Fail-fast: Check for exception conditions and raise the
# appropriate exceptions for known error codes.
if status in exception.ERROR_MAPPINGS:
LOG.error(_LE("Received error code: %s"), status)
LOG.error(_LE("Server Error Message: %s"), response.body)
LOG.error("Received error code: %s", status)
LOG.error("Server Error Message: %s", response.body)
exception.ERROR_MAPPINGS[status](response)
# Continue processing for non-error condition.
if (status != httplib.OK and status != httplib.CREATED
and status != httplib.NO_CONTENT):
LOG.error(_LE("%(method)s to %(url)s, unexpected response code: "
"%(status)d (content = '%(body)s')"),
LOG.error("%(method)s to %(url)s, unexpected response code: "
"%(status)d (content = '%(body)s')",
{'method': method, 'url': url,
'status': response.status, 'body': response.body})
return None
@@ -136,6 +135,6 @@ class NsxApiClient(eventlet_client.EventletApiClient):
# one of the server that responds.
self.request('GET', '/ws.v1/control-cluster/node')
if not self._version:
LOG.error(_LE('Unable to determine NSX version. '
'Plugin might not work as expected.'))
LOG.error('Unable to determine NSX version. '
'Plugin might not work as expected.')
return self._version

View File

@@ -21,7 +21,6 @@ import eventlet
eventlet.monkey_patch()
from oslo_log import log as logging
from vmware_nsx._i18n import _LE
from vmware_nsx.api_client import base
from vmware_nsx.api_client import eventlet_request
@@ -143,7 +142,7 @@ class EventletApiClient(base.ApiClientBase):
ret = g.join()
if ret:
if isinstance(ret, Exception):
LOG.error(_LE('Login error "%s"'), ret)
LOG.error('Login error "%s"', ret)
raise ret
cookie = ret.getheader("Set-Cookie")

View File

@@ -21,7 +21,7 @@ from oslo_serialization import jsonutils
from six.moves import http_client as httplib
from six.moves.urllib import parse
from vmware_nsx._i18n import _, _LI, _LW
from vmware_nsx._i18n import _
from vmware_nsx.api_client import request
LOG = logging.getLogger(__name__)
@@ -119,7 +119,7 @@ class EventletApiRequest(request.ApiRequest):
with eventlet.timeout.Timeout(self._request_timeout, False):
return self._handle_request()
LOG.info(_LI('[%d] Request timeout.'), self._rid())
LOG.info('[%d] Request timeout.', self._rid())
self._request_error = Exception(_('Request timeout'))
return None
else:
@@ -153,8 +153,8 @@ class EventletApiRequest(request.ApiRequest):
self._request_error = None
response = req
else:
LOG.info(_LI('[%(rid)d] Error while handling request: '
'%(req)s'),
LOG.info('[%(rid)d] Error while handling request: '
'%(req)s',
{'rid': self._rid(), 'req': req})
self._request_error = req
response = None
@@ -210,7 +210,7 @@ class GetApiProvidersRequestEventlet(EventletApiRequest):
ret.append(_provider_from_listen_addr(addr))
return ret
except Exception as e:
LOG.warning(_LW("[%(rid)d] Failed to parse API provider: %(e)s"),
LOG.warning("[%(rid)d] Failed to parse API provider: %(e)s",
{'rid': self._rid(), 'e': e})
# intentionally fall through
return None

View File

@@ -27,7 +27,7 @@ import six
from six.moves import http_client as httplib
import six.moves.urllib.parse as urlparse
from vmware_nsx._i18n import _, _LI, _LW
from vmware_nsx._i18n import _
from vmware_nsx import api_client
LOG = logging.getLogger(__name__)
@@ -122,8 +122,8 @@ class ApiRequest(object):
conn.request(self._method, url, self._body, headers)
except Exception as e:
with excutils.save_and_reraise_exception():
LOG.warning(_LW("[%(rid)d] Exception issuing request: "
"%(e)s"),
LOG.warning("[%(rid)d] Exception issuing request: "
"%(e)s",
{'rid': self._rid(), 'e': e})
response = conn.getresponse()
@@ -158,8 +158,8 @@ class ApiRequest(object):
httplib.TEMPORARY_REDIRECT]:
break
elif redirects >= self._redirects:
LOG.info(_LI("[%d] Maximum redirects exceeded, aborting "
"request"), self._rid())
LOG.info("[%d] Maximum redirects exceeded, aborting "
"request", self._rid())
break
redirects += 1
@@ -168,7 +168,7 @@ class ApiRequest(object):
if url is None:
response.status = httplib.INTERNAL_SERVER_ERROR
break
LOG.info(_LI("[%(rid)d] Redirecting request to: %(conn)s"),
LOG.info("[%(rid)d] Redirecting request to: %(conn)s",
{'rid': self._rid(),
'conn': self._request_str(conn, url)})
# yield here, just in case we are not out of the loop yet
@@ -181,8 +181,8 @@ class ApiRequest(object):
# queue.
if (response.status == httplib.INTERNAL_SERVER_ERROR and
response.status > httplib.NOT_IMPLEMENTED):
LOG.warning(_LW("[%(rid)d] Request '%(method)s %(url)s' "
"received: %(status)s"),
LOG.warning("[%(rid)d] Request '%(method)s %(url)s' "
"received: %(status)s",
{'rid': self._rid(), 'method': self._method,
'url': self._url, 'status': response.status})
raise Exception(_('Server error return: %s'), response.status)
@@ -197,8 +197,8 @@ class ApiRequest(object):
msg = str(e)
if response is None:
elapsed_time = time.time() - issued_time
LOG.warning(_LW("[%(rid)d] Failed request '%(conn)s': '%(msg)s' "
"(%(elapsed)s seconds)"),
LOG.warning("[%(rid)d] Failed request '%(conn)s': '%(msg)s' "
"(%(elapsed)s seconds)",
{'rid': self._rid(),
'conn': self._request_str(conn, url),
'msg': msg, 'elapsed': elapsed_time})
@@ -232,8 +232,8 @@ class ApiRequest(object):
url = value
break
if not url:
LOG.warning(_LW("[%d] Received redirect status without location "
"header field"), self._rid())
LOG.warning("[%d] Received redirect status without location "
"header field", self._rid())
return (conn, None)
# Accept location with the following format:
# 1. /path, redirect to same node
@@ -249,13 +249,13 @@ class ApiRequest(object):
url = result.path
return (conn, url) # case 1
else:
LOG.warning(_LW("[%(rid)d] Received invalid redirect "
"location: '%(url)s'"),
LOG.warning("[%(rid)d] Received invalid redirect "
"location: '%(url)s'",
{'rid': self._rid(), 'url': url})
return (conn, None) # case 3
elif result.scheme not in ["http", "https"] or not result.hostname:
LOG.warning(_LW("[%(rid)d] Received malformed redirect "
"location: %(url)s"),
LOG.warning("[%(rid)d] Received malformed redirect "
"location: %(url)s",
{'rid': self._rid(), 'url': url})
return (conn, None) # case 3
# case 2, redirect location includes a scheme

View File

@@ -17,9 +17,6 @@
from oslo_log import log as logging
from vmware_nsx._i18n import _LW
LOG = logging.getLogger(__name__)
@@ -30,8 +27,8 @@ def find_version(headers):
if header_name == 'server':
return Version(header_value.split('/')[1])
except IndexError:
LOG.warning(_LW("Unable to fetch NSX version from response "
"headers :%s"), headers)
LOG.warning("Unable to fetch NSX version from response "
"headers :%s", headers)
class Version(object):

View File

@@ -18,7 +18,7 @@ from oslo_log import log as logging
from neutron.db import l3_hamode_db
from vmware_nsx._i18n import _, _LW
from vmware_nsx._i18n import _
from vmware_nsx.common import exceptions as nsx_exc
from vmware_nsx.dvs import dvs_utils
from vmware_nsx.extensions import routersize
@@ -843,9 +843,9 @@ def validate_nsxv_config_options():
error = _("manager_uri, user, and password must be configured!")
raise nsx_exc.NsxPluginException(err_msg=error)
if cfg.CONF.nsxv.dvs_id is None:
LOG.warning(_LW("dvs_id must be configured to support VLANs!"))
LOG.warning("dvs_id must be configured to support VLANs!")
if cfg.CONF.nsxv.vdn_scope_id is None:
LOG.warning(_LW("vdn_scope_id must be configured to support VXLANs!"))
LOG.warning("vdn_scope_id must be configured to support VXLANs!")
if cfg.CONF.nsxv.use_dvs_features and not dvs_utils.dvs_is_enabled(
dvs_id=cfg.CONF.nsxv.dvs_id):
error = _("dvs host/vcenter credentials must be defined to use "

View File

@@ -18,8 +18,6 @@ from oslo_log import log
from oslo_utils import excutils
import stevedore
from vmware_nsx._i18n import _LE, _LI
LOG = log.getLogger(__name__)
@@ -31,13 +29,13 @@ class ExtensionManager(stevedore.named.NamedExtensionManager):
# the order in which the drivers are called.
self.ordered_ext_drivers = []
LOG.info(_LI("Configured extension driver names: %s"),
LOG.info("Configured extension driver names: %s",
cfg.CONF.nsx_extension_drivers)
super(ExtensionManager, self).__init__('vmware_nsx.extension_drivers',
cfg.CONF.nsx_extension_drivers,
invoke_on_load=True,
name_order=True)
LOG.info(_LI("Loaded extension driver names: %s"), self.names())
LOG.info("Loaded extension driver names: %s", self.names())
self._register_drivers()
def _register_drivers(self):
@@ -48,13 +46,13 @@ class ExtensionManager(stevedore.named.NamedExtensionManager):
"""
for ext in self:
self.ordered_ext_drivers.append(ext)
LOG.info(_LI("Registered extension drivers: %s"),
LOG.info("Registered extension drivers: %s",
[driver.name for driver in self.ordered_ext_drivers])
def initialize(self):
# Initialize each driver in the list.
for driver in self.ordered_ext_drivers:
LOG.info(_LI("Initializing extension driver '%s'"), driver.name)
LOG.info("Initializing extension driver '%s'", driver.name)
driver.obj.initialize()
def extension_aliases(self):
@@ -63,7 +61,7 @@ class ExtensionManager(stevedore.named.NamedExtensionManager):
alias = driver.obj.extension_alias
if alias:
exts.append(alias)
LOG.info(_LI("Got %(alias)s extension from driver '%(drv)s'"),
LOG.info("Got %(alias)s extension from driver '%(drv)s'",
{'alias': alias, 'drv': driver.name})
return exts
@@ -74,8 +72,8 @@ class ExtensionManager(stevedore.named.NamedExtensionManager):
getattr(driver.obj, method_name)(plugin_context, data, result)
except Exception:
with excutils.save_and_reraise_exception():
LOG.info(_LI("Extension driver '%(name)s' failed in "
"%(method)s"),
LOG.info("Extension driver '%(name)s' failed in "
"%(method)s",
{'name': driver.name, 'method': method_name})
def process_create_network(self, plugin_context, data, result):
@@ -113,8 +111,8 @@ class ExtensionManager(stevedore.named.NamedExtensionManager):
try:
getattr(driver.obj, method_name)(session, base_model, result)
except Exception:
LOG.error(_LE("Extension driver '%(name)s' failed in "
"%(method)s"),
LOG.error("Extension driver '%(name)s' failed in "
"%(method)s",
{'name': driver.name, 'method': method_name})
raise

View File

@@ -21,7 +21,6 @@ from neutron_lib import exceptions as n_exc
from oslo_log import log
import six
from vmware_nsx._i18n import _LW
from vmware_nsx.api_client import client
from vmware_nsx.api_client import exception as api_exc
from vmware_nsx.common import utils as vmw_utils
@@ -68,8 +67,8 @@ def get_nsx_switch_ids(session, cluster, neutron_network_id):
# more than once for each network in Neutron's lifetime
nsx_switches = switchlib.get_lswitches(cluster, neutron_network_id)
if not nsx_switches:
LOG.warning(_LW("Unable to find NSX switches for Neutron network "
"%s"), neutron_network_id)
LOG.warning("Unable to find NSX switches for Neutron network "
"%s", neutron_network_id)
return
nsx_switch_ids = []
with session.begin(subtransactions=True):
@@ -115,7 +114,7 @@ def get_nsx_switch_and_port_id(session, cluster, neutron_port_id):
# NOTE(salv-orlando): Not handling the case where more than one
# port is found with the same neutron port tag
if not nsx_ports:
LOG.warning(_LW("Unable to find NSX port for Neutron port %s"),
LOG.warning("Unable to find NSX port for Neutron port %s",
neutron_port_id)
# This method is supposed to return a tuple
return None, None
@@ -155,12 +154,12 @@ def get_nsx_security_group_id(session, cluster, neutron_id):
# NOTE(salv-orlando): Not handling the case where more than one
# security profile is found with the same neutron port tag
if not nsx_sec_profiles:
LOG.warning(_LW("Unable to find NSX security profile for Neutron "
"security group %s"), neutron_id)
LOG.warning("Unable to find NSX security profile for Neutron "
"security group %s", neutron_id)
return
elif len(nsx_sec_profiles) > 1:
LOG.warning(_LW("Multiple NSX security profiles found for Neutron "
"security group %s"), neutron_id)
LOG.warning("Multiple NSX security profiles found for Neutron "
"security group %s", neutron_id)
nsx_sec_profile = nsx_sec_profiles[0]
nsx_id = nsx_sec_profile['uuid']
with session.begin(subtransactions=True):
@@ -192,7 +191,7 @@ def get_nsx_router_id(session, cluster, neutron_router_id):
# NOTE(salv-orlando): Not handling the case where more than one
# port is found with the same neutron port tag
if not nsx_routers:
LOG.warning(_LW("Unable to find NSX router for Neutron router %s"),
LOG.warning("Unable to find NSX router for Neutron router %s",
neutron_router_id)
return
nsx_router = nsx_routers[0]
@@ -249,12 +248,12 @@ def get_nsx_device_statuses(cluster, tenant_id):
except api_exc.NsxApiException:
# Do not make a NSX API exception fatal
if tenant_id:
LOG.warning(_LW("Unable to retrieve operational status for "
"gateway devices belonging to tenant: %s"),
LOG.warning("Unable to retrieve operational status for "
"gateway devices belonging to tenant: %s",
tenant_id)
else:
LOG.warning(_LW("Unable to retrieve operational status for "
"gateway devices"))
LOG.warning("Unable to retrieve operational status for "
"gateway devices")
def _convert_bindings_to_nsx_transport_zones(bindings):

View File

@@ -30,7 +30,7 @@ from neutron.db.models import l3 as l3_db
from neutron.db import models_v2
from neutron.extensions import l3
from vmware_nsx._i18n import _, _LE, _LI, _LW
from vmware_nsx._i18n import _
from vmware_nsx.api_client import exception as api_exc
from vmware_nsx.common import exceptions as nsx_exc
from vmware_nsx.common import nsx_utils
@@ -273,8 +273,8 @@ class NsxSynchronizer(object):
# TODO(salv-orlando): We should be catching
# api_exc.ResourceNotFound here
# The logical switch was not found
LOG.warning(_LW("Logical switch for neutron network %s not "
"found on NSX."), neutron_network_data['id'])
LOG.warning("Logical switch for neutron network %s not "
"found on NSX.", neutron_network_data['id'])
lswitches = []
else:
for lswitch in lswitches:
@@ -360,8 +360,8 @@ class NsxSynchronizer(object):
# NOTE(salv-orlando): We should be catching
# api_exc.ResourceNotFound here
# The logical router was not found
LOG.warning(_LW("Logical router for neutron router %s not "
"found on NSX."), neutron_router_data['id'])
LOG.warning("Logical router for neutron router %s not "
"found on NSX.", neutron_router_data['id'])
if lrouter:
# Update the cache
self._nsx_cache.update_lrouter(lrouter)
@@ -410,8 +410,8 @@ class NsxSynchronizer(object):
neutron_router_mappings[neutron_router_id] = (
self._nsx_cache[lr_uuid])
else:
LOG.warning(_LW("Unable to find Neutron router id for "
"NSX logical router: %s"), lr_uuid)
LOG.warning("Unable to find Neutron router id for "
"NSX logical router: %s", lr_uuid)
# Fetch neutron routers from database
filters = ({} if scan_missing else
{'id': neutron_router_mappings.keys()})
@@ -452,8 +452,8 @@ class NsxSynchronizer(object):
# api_exc.ResourceNotFound here instead
# of PortNotFoundOnNetwork when the id exists but
# the logical switch port was not found
LOG.warning(_LW("Logical switch port for neutron port %s "
"not found on NSX."), neutron_port_data['id'])
LOG.warning("Logical switch port for neutron port %s "
"not found on NSX.", neutron_port_data['id'])
lswitchport = None
else:
# If lswitchport is not None, update the cache.
@@ -545,11 +545,11 @@ class NsxSynchronizer(object):
# be emitted.
num_requests = page_size // (MAX_PAGE_SIZE + 1) + 1
if num_requests > 1:
LOG.warning(_LW("Requested page size is %(cur_chunk_size)d. "
"It might be necessary to do %(num_requests)d "
"round-trips to NSX for fetching data. Please "
"tune sync parameters to ensure chunk size "
"is less than %(max_page_size)d"),
LOG.warning("Requested page size is %(cur_chunk_size)d. "
"It might be necessary to do %(num_requests)d "
"round-trips to NSX for fetching data. Please "
"tune sync parameters to ensure chunk size "
"is less than %(max_page_size)d",
{'cur_chunk_size': page_size,
'num_requests': num_requests,
'max_page_size': MAX_PAGE_SIZE})
@@ -578,8 +578,8 @@ class NsxSynchronizer(object):
def _fetch_nsx_data_chunk(self, sp):
base_chunk_size = sp.chunk_size
chunk_size = base_chunk_size + sp.extra_chunk_size
LOG.info(_LI("Fetching up to %s resources "
"from NSX backend"), chunk_size)
LOG.info("Fetching up to %s resources "
"from NSX backend", chunk_size)
fetched = ls_count = lr_count = lp_count = 0
lswitches = lrouters = lswitchports = []
if sp.ls_cursor or sp.ls_cursor == 'start':
@@ -618,7 +618,7 @@ class NsxSynchronizer(object):
# Reset page cursor variables if necessary
if sp.current_chunk == 0:
sp.ls_cursor = sp.lr_cursor = sp.lp_cursor = 'start'
LOG.info(_LI("Running state synchronization task. Chunk: %s"),
LOG.info("Running state synchronization task. Chunk: %s",
sp.current_chunk)
# Fetch chunk_size data from NSX
try:
@@ -628,9 +628,9 @@ class NsxSynchronizer(object):
sleep_interval = self._sync_backoff
# Cap max back off to 64 seconds
self._sync_backoff = min(self._sync_backoff * 2, 64)
LOG.exception(_LE("An error occurred while communicating with "
"NSX backend. Will retry synchronization "
"in %d seconds"), sleep_interval)
LOG.exception("An error occurred while communicating with "
"NSX backend. Will retry synchronization "
"in %d seconds", sleep_interval)
return sleep_interval
LOG.debug("Time elapsed querying NSX: %s",
timeutils.utcnow() - start)
@@ -669,8 +669,8 @@ class NsxSynchronizer(object):
self._synchronize_lswitchports(ctx, lp_uuids,
scan_missing=scan_missing)
# Increase chunk counter
LOG.info(_LI("Synchronization for chunk %(chunk_num)d of "
"%(total_chunks)d performed"),
LOG.info("Synchronization for chunk %(chunk_num)d of "
"%(total_chunks)d performed",
{'chunk_num': sp.current_chunk + 1,
'total_chunks': num_chunks})
sp.current_chunk = (sp.current_chunk + 1) % num_chunks

View File

@@ -28,8 +28,6 @@ from neutron_lib import constants
from oslo_context import context as common_context
from oslo_log import log
from vmware_nsx._i18n import _LE
LOG = log.getLogger(__name__)
MAX_DISPLAY_NAME_LEN = 40
@@ -162,8 +160,8 @@ def read_file(path):
with open(path) as file:
return file.read().strip()
except IOError as e:
LOG.error(_LE("Error while opening file "
"%(path)s: %(err)s"), {'path': path, 'err': str(e)})
LOG.error("Error while opening file "
"%(path)s: %(err)s", {'path': path, 'err': str(e)})
def get_name_and_uuid(name, uuid, tag=None, maxlen=80):

View File

@@ -34,7 +34,6 @@ from neutron_lib import constants as n_constants
from neutron_lib.db import model_base
from neutron_lib.utils import helpers
from vmware_nsx._i18n import _LW
from vmware_nsx.extensions import providersecuritygroup as provider_sg
from vmware_nsx.extensions import securitygrouplogging as sg_logging
from vmware_nsx.extensions import securitygrouppolicy as sg_policy
@@ -204,8 +203,8 @@ class ExtendedSecurityGroupPropertiesMixin(object):
if self._is_provider_security_group(context, sg):
if only_warn:
LOG.warning(
_LW("Ignored provider security group %(sg)s in "
"security groups list for port %(id)s"),
"Ignored provider security group %(sg)s in "
"security groups list for port %(id)s",
{'sg': sg, 'id': port['id']})
else:
raise provider_sg.SecurityGroupIsProvider(id=sg)

View File

@@ -27,7 +27,7 @@ from sqlalchemy import func
from sqlalchemy.orm import exc
from sqlalchemy.sql import expression as expr
from vmware_nsx._i18n import _, _LE, _LW
from vmware_nsx._i18n import _
from vmware_nsx.common import exceptions as nsx_exc
from vmware_nsx.common import nsxv_constants
from vmware_nsx.db import db as nsx_db
@@ -70,10 +70,10 @@ def warn_on_binding_status_error(f, *args, **kwargs):
for binding in bindings:
if binding and binding['status'] == neutron_const.ERROR:
LOG.warning(_LW("Found NSXV router binding entry with status "
"%(status)s: router %(router)s, "
"edge %(edge)s, lswitch %(lswitch)s, "
"status description: %(desc)s "),
LOG.warning("Found NSXV router binding entry with status "
"%(status)s: router %(router)s, "
"edge %(edge)s, lswitch %(lswitch)s, "
"status description: %(desc)s ",
{'status': binding['status'],
'router': binding['router_id'],
'edge': binding['edge_id'],
@@ -318,8 +318,8 @@ def create_edge_dhcp_static_binding(session, edge_id, mac_address, binding_id):
return _create_edge_dhcp_static_binding(session, edge_id, mac_address,
binding_id)
except db_exc.DBDuplicateEntry:
LOG.warning(_LW('Conflicting DHCP binding entry for '
'%(edge_id)s:%(mac_address)s. Overwriting!'),
LOG.warning('Conflicting DHCP binding entry for '
'%(edge_id)s:%(mac_address)s. Overwriting!',
{'edge_id': edge_id, 'mac_address': mac_address})
delete_edge_dhcp_static_binding(session, edge_id, mac_address)
return _create_edge_dhcp_static_binding(session, edge_id, mac_address,
@@ -373,8 +373,8 @@ def create_nsxv_internal_network(session, network_purpose,
session.add(network)
except db_exc.DBDuplicateEntry:
with excutils.save_and_reraise_exception():
LOG.exception(_LE("Duplicate internal network for purpose "
"%(p)s and availabiltiy zone %(az)s"),
LOG.exception("Duplicate internal network for purpose "
"%(p)s and availabiltiy zone %(az)s",
{'p': network_purpose,
'az': availability_zone})
@@ -412,7 +412,7 @@ def create_nsxv_internal_edge(session, ext_ip_address, purpose, router_id):
session.add(internal_edge)
except db_exc.DBDuplicateEntry:
with excutils.save_and_reraise_exception():
LOG.exception(_LE("Duplicate internal Edge IP %s"),
LOG.exception("Duplicate internal Edge IP %s",
ext_ip_address)

View File

@@ -23,7 +23,6 @@ from neutron.db import models_v2
from oslo_log import log
from oslo_utils import uuidutils
from vmware_nsx._i18n import _LI
from vmware_nsx.db import nsx_models
from vmware_nsx.extensions import qos_queue as qos
@@ -254,8 +253,8 @@ class QoSDbMixin(qos.QueuePluginBase):
if dscp:
# must raise because a non-zero dscp was provided
raise qos.QueueInvalidMarking()
LOG.info(_LI("DSCP value (%s) will be ignored with 'trusted' "
"marking"), dscp)
LOG.info("DSCP value (%s) will be ignored with 'trusted' "
"marking", dscp)
max = qos_queue.get('max')
min = qos_queue.get('min')
# Max can be None

View File

@@ -21,7 +21,7 @@ from oslo_db import exception as db_exc
from oslo_log import log as logging
from oslo_utils import excutils
from vmware_nsx._i18n import _, _LE, _LW
from vmware_nsx._i18n import _
from vmware_nsx.api_client import exception as api_exc
from vmware_nsx.common import exceptions as p_exc
from vmware_nsx.common import nsx_utils
@@ -69,14 +69,14 @@ class LsnManager(object):
return lsn_api.lsn_for_network_get(self.cluster, network_id)
except (n_exc.NotFound, api_exc.NsxApiException):
if raise_on_err:
LOG.error(_LE('Unable to find Logical Service Node for '
'network %s.'),
LOG.error('Unable to find Logical Service Node for '
'network %s.',
network_id)
raise p_exc.LsnNotFound(entity='network',
entity_id=network_id)
else:
LOG.warning(_LW('Unable to find Logical Service Node for '
'the requested network %s.'),
LOG.warning('Unable to find Logical Service Node for '
'the requested network %s.',
network_id)
def lsn_create(self, context, network_id):
@@ -92,7 +92,7 @@ class LsnManager(object):
try:
lsn_api.lsn_delete(self.cluster, lsn_id)
except (n_exc.NotFound, api_exc.NsxApiException):
LOG.warning(_LW('Unable to delete Logical Service Node %s'),
LOG.warning('Unable to delete Logical Service Node %s',
lsn_id)
def lsn_delete_by_network(self, context, network_id):
@@ -110,17 +110,17 @@ class LsnManager(object):
self.cluster, lsn_id, subnet_id)
except (n_exc.NotFound, api_exc.NsxApiException):
if raise_on_err:
LOG.error(_LE('Unable to find Logical Service Node Port '
'for LSN %(lsn_id)s and subnet '
'%(subnet_id)s'),
LOG.error('Unable to find Logical Service Node Port '
'for LSN %(lsn_id)s and subnet '
'%(subnet_id)s',
{'lsn_id': lsn_id, 'subnet_id': subnet_id})
raise p_exc.LsnPortNotFound(lsn_id=lsn_id,
entity='subnet',
entity_id=subnet_id)
else:
LOG.warning(_LW('Unable to find Logical Service Node Port '
'for LSN %(lsn_id)s and subnet '
'%(subnet_id)s'),
LOG.warning('Unable to find Logical Service Node Port '
'for LSN %(lsn_id)s and subnet '
'%(subnet_id)s',
{'lsn_id': lsn_id, 'subnet_id': subnet_id})
return (lsn_id, None)
else:
@@ -137,17 +137,17 @@ class LsnManager(object):
self.cluster, lsn_id, mac)
except (n_exc.NotFound, api_exc.NsxApiException):
if raise_on_err:
LOG.error(_LE('Unable to find Logical Service Node Port '
'for LSN %(lsn_id)s and mac address '
'%(mac)s'),
LOG.error('Unable to find Logical Service Node Port '
'for LSN %(lsn_id)s and mac address '
'%(mac)s',
{'lsn_id': lsn_id, 'mac': mac})
raise p_exc.LsnPortNotFound(lsn_id=lsn_id,
entity='MAC',
entity_id=mac)
else:
LOG.warning(_LW('Unable to find Logical Service Node '
'Port for LSN %(lsn_id)s and mac address '
'%(mac)s'),
LOG.warning('Unable to find Logical Service Node '
'Port for LSN %(lsn_id)s and mac address '
'%(mac)s',
{'lsn_id': lsn_id, 'mac': mac})
return (lsn_id, None)
else:
@@ -170,7 +170,7 @@ class LsnManager(object):
try:
lsn_api.lsn_port_delete(self.cluster, lsn_id, lsn_port_id)
except (n_exc.NotFound, api_exc.NsxApiException):
LOG.warning(_LW('Unable to delete LSN Port %s'), lsn_port_id)
LOG.warning('Unable to delete LSN Port %s', lsn_port_id)
def lsn_port_dispose(self, context, network_id, mac_address):
"""Delete a LSN port given the network and the mac address."""
@@ -187,12 +187,12 @@ class LsnManager(object):
self.cluster, network_id, lswitch_port_id)
except (n_exc.PortNotFoundOnNetwork,
api_exc.NsxApiException):
LOG.warning(_LW("Metadata port not found while attempting "
"to delete it from network %s"),
LOG.warning("Metadata port not found while attempting "
"to delete it from network %s",
network_id)
else:
LOG.warning(_LW("Unable to find Logical Services Node "
"Port with MAC %s"), mac_address)
LOG.warning("Unable to find Logical Services Node "
"Port with MAC %s", mac_address)
def lsn_port_dhcp_setup(
self, context, network_id, port_id, port_data, subnet_config=None):
@@ -319,8 +319,8 @@ class LsnManager(object):
if lsn_id and lsn_port_id:
hdlr(self.cluster, lsn_id, lsn_port_id, data)
except (n_exc.NotFound, api_exc.NsxApiException):
LOG.error(_LE('Error while configuring LSN '
'port %s'), lsn_port_id)
LOG.error('Error while configuring LSN '
'port %s', lsn_port_id)
raise p_exc.PortConfigurationError(
net_id=network_id, lsn_id=lsn_id, port_id=lsn_port_id)

View File

@@ -20,7 +20,7 @@ from neutron_lib import constants as const
from neutron_lib import exceptions as n_exc
from oslo_log import log as logging
from vmware_nsx._i18n import _, _LE
from vmware_nsx._i18n import _
from vmware_nsx.common import exceptions as p_exc
from vmware_nsx.dhcp_meta import nsx
from vmware_nsx.dhcp_meta import rpc
@@ -80,7 +80,7 @@ class DhcpMetadataBuilder(object):
try:
self.plugin.delete_port(context, port['id'])
except n_exc.PortNotFound:
LOG.error(_LE('Port %s is already gone'), port['id'])
LOG.error('Port %s is already gone', port['id'])
def dhcp_allocate(self, context, network_id, subnet):
"""Allocate dhcp resources for the subnet."""

View File

@@ -28,7 +28,7 @@ from neutron.common import rpc as n_rpc
from neutron.common import topics
from neutron.db import agents_db
from vmware_nsx._i18n import _, _LW
from vmware_nsx._i18n import _
from vmware_nsx.common import config
from vmware_nsx.common import exceptions as nsx_exc
from vmware_nsx.dhcp_meta import combined
@@ -121,7 +121,7 @@ class DhcpMetadataAccess(object):
# This becomes ineffective, as all new networks creations
# are handled by Logical Services Nodes in NSX
cfg.CONF.set_override('network_auto_schedule', False)
LOG.warning(_LW('network_auto_schedule has been disabled'))
LOG.warning('network_auto_schedule has been disabled')
notifier = combined.DhcpAgentNotifyAPI(self.safe_reference,
lsn_manager)
self.supported_extension_aliases.append(lsn.EXT_ALIAS)

View File

@@ -25,7 +25,7 @@ from neutron.db import db_base_plugin_v2
from neutron.db import l3_db
from neutron.extensions import external_net
from vmware_nsx._i18n import _, _LE, _LI
from vmware_nsx._i18n import _
from vmware_nsx.common import exceptions as p_exc
from vmware_nsx.dhcp_meta import constants as d_const
from vmware_nsx.nsxlib.mh import lsn as lsn_api
@@ -138,9 +138,9 @@ class DhcpAgentNotifyAPI(object):
# down below as well as handle_port_metadata_access
self.plugin.create_port(context, {'port': dhcp_port})
except p_exc.PortConfigurationError as e:
LOG.error(_LE("Error while creating subnet %(cidr)s for "
"network %(network)s. Please, contact "
"administrator"),
LOG.error("Error while creating subnet %(cidr)s for "
"network %(network)s. Please, contact "
"administrator",
{"cidr": subnet["cidr"],
"network": network_id})
db_base_plugin_v2.NeutronDbPluginV2.delete_port(
@@ -207,12 +207,12 @@ def check_services_requirements(cluster):
def handle_network_dhcp_access(plugin, context, network, action):
LOG.info(_LI("Performing DHCP %(action)s for resource: %(resource)s"),
LOG.info("Performing DHCP %(action)s for resource: %(resource)s",
{"action": action, "resource": network})
if action == 'create_network':
network_id = network['id']
if network.get(external_net.EXTERNAL):
LOG.info(_LI("Network %s is external: no LSN to create"),
LOG.info("Network %s is external: no LSN to create",
network_id)
return
plugin.lsn_manager.lsn_create(context, network_id)
@@ -221,12 +221,12 @@ def handle_network_dhcp_access(plugin, context, network, action):
# is just the network id
network_id = network
plugin.lsn_manager.lsn_delete_by_network(context, network_id)
LOG.info(_LI("Logical Services Node for network "
"%s configured successfully"), network_id)
LOG.info("Logical Services Node for network "
"%s configured successfully", network_id)
def handle_port_dhcp_access(plugin, context, port, action):
LOG.info(_LI("Performing DHCP %(action)s for resource: %(resource)s"),
LOG.info("Performing DHCP %(action)s for resource: %(resource)s",
{"action": action, "resource": port})
if port["device_owner"] == const.DEVICE_OWNER_DHCP:
network_id = port["network_id"]
@@ -243,8 +243,8 @@ def handle_port_dhcp_access(plugin, context, port, action):
plugin.lsn_manager.lsn_port_dhcp_setup(
context, network_id, port['id'], subnet_data, subnet)
except p_exc.PortConfigurationError:
LOG.error(_LE("Error while configuring DHCP for "
"port %s"), port['id'])
LOG.error("Error while configuring DHCP for "
"port %s", port['id'])
raise n_exc.NeutronException()
elif action == "delete_port":
plugin.lsn_manager.lsn_port_dispose(context, network_id,
@@ -254,8 +254,8 @@ def handle_port_dhcp_access(plugin, context, port, action):
# do something only if there are IP's and dhcp is enabled
subnet_id = port["fixed_ips"][0]['subnet_id']
if not plugin.get_subnet(context, subnet_id)['enable_dhcp']:
LOG.info(_LI("DHCP is disabled for subnet %s: nothing "
"to do"), subnet_id)
LOG.info("DHCP is disabled for subnet %s: nothing "
"to do", subnet_id)
return
host_data = {
"mac_address": port["mac_address"],
@@ -273,7 +273,7 @@ def handle_port_dhcp_access(plugin, context, port, action):
if action == 'create_port':
db_base_plugin_v2.NeutronDbPluginV2.delete_port(
plugin, context, port['id'])
LOG.info(_LI("DHCP for port %s configured successfully"), port['id'])
LOG.info("DHCP for port %s configured successfully", port['id'])
def handle_port_metadata_access(plugin, context, port, is_delete=False):
@@ -281,7 +281,7 @@ def handle_port_metadata_access(plugin, context, port, is_delete=False):
network_id = port["network_id"]
network = plugin.get_network(context, network_id)
if network[external_net.EXTERNAL]:
LOG.info(_LI("Network %s is external: nothing to do"),
LOG.info("Network %s is external: nothing to do",
network_id)
return
subnet_id = port["fixed_ips"][0]['subnet_id']
@@ -290,7 +290,7 @@ def handle_port_metadata_access(plugin, context, port, is_delete=False):
"tenant_id": port["tenant_id"],
"ip_address": port["fixed_ips"][0]['ip_address']
}
LOG.info(_LI("Configuring metadata entry for port %s"), port)
LOG.info("Configuring metadata entry for port %s", port)
if not is_delete:
handler = plugin.lsn_manager.lsn_port_meta_host_add
else:
@@ -302,13 +302,13 @@ def handle_port_metadata_access(plugin, context, port, is_delete=False):
if not is_delete:
db_base_plugin_v2.NeutronDbPluginV2.delete_port(
plugin, context, port['id'])
LOG.info(_LI("Metadata for port %s configured successfully"),
LOG.info("Metadata for port %s configured successfully",
port['id'])
def handle_router_metadata_access(plugin, context, router_id, interface=None):
LOG.info(_LI("Handle metadata access via router: %(r)s and "
"interface %(i)s"), {'r': router_id, 'i': interface})
LOG.info("Handle metadata access via router: %(r)s and "
"interface %(i)s", {'r': router_id, 'i': interface})
if interface:
try:
plugin.get_port(context, interface['port_id'])
@@ -324,4 +324,4 @@ def handle_router_metadata_access(plugin, context, router_id, interface=None):
if is_enabled:
l3_db.L3_NAT_db_mixin.remove_router_interface(
plugin, context, router_id, interface)
LOG.info(_LI("Metadata for router %s handled successfully"), router_id)
LOG.info("Metadata for router %s handled successfully", router_id)

View File

@@ -24,7 +24,6 @@ from neutron.api.rpc.agentnotifiers import dhcp_rpc_agent_api
from neutron.db import db_base_plugin_v2
from neutron.db import models_v2
from vmware_nsx._i18n import _LE, _LI, _LW
from vmware_nsx.api_client import exception as api_exc
from vmware_nsx.common import config
from vmware_nsx.common import exceptions as nsx_exc
@@ -55,7 +54,7 @@ def handle_port_metadata_access(plugin, context, port, is_delete=False):
if not port.get('fixed_ips'):
# If port does not have an IP, the associated subnet is in
# deleting state.
LOG.info(_LI('Port %s has no IP due to subnet in deleting state'),
LOG.info('Port %s has no IP due to subnet in deleting state',
port['id'])
return
fixed_ip = port['fixed_ips'][0]
@@ -66,8 +65,8 @@ def handle_port_metadata_access(plugin, context, port, is_delete=False):
# route. This is done via the enable_isolated_metadata
# option if desired.
if not subnet.get('gateway_ip'):
LOG.info(_LI('Subnet %s does not have a gateway, the '
'metadata route will not be created'),
LOG.info('Subnet %s does not have a gateway, the '
'metadata route will not be created',
subnet['id'])
return
metadata_routes = [r for r in subnet.routes
@@ -99,8 +98,8 @@ def handle_router_metadata_access(plugin, context, router_id, interface=None):
LOG.debug("Metadata access network is disabled")
return
if not cfg.CONF.allow_overlapping_ips:
LOG.warning(_LW("Overlapping IPs must be enabled in order to setup "
"the metadata access network"))
LOG.warning("Overlapping IPs must be enabled in order to setup "
"the metadata access network")
return
ctx_elevated = context.elevated()
on_demand = getattr(plugin_cfg, 'metadata_on_demand', False)
@@ -138,8 +137,8 @@ def handle_router_metadata_access(plugin, context, router_id, interface=None):
except (ntn_exc.NeutronException, nsx_exc.NsxPluginException,
api_exc.NsxApiException):
# Any exception here should be regarded as non-fatal
LOG.exception(_LE("An error occurred while operating on the "
"metadata access network for router:'%s'"),
LOG.exception("An error occurred while operating on the "
"metadata access network for router:'%s'",
router_id)

View File

@@ -17,7 +17,6 @@ from oslo_log import log as logging
from oslo_utils import excutils
from oslo_vmware import vim_util
from vmware_nsx._i18n import _LE, _LI
from vmware_nsx.common import exceptions as nsx_exc
from vmware_nsx.dvs import dvs_utils
@@ -154,10 +153,10 @@ class DvsManager(VCManagerBase):
except Exception:
# NOTE(garyk): handle more specific exceptions
with excutils.save_and_reraise_exception():
LOG.exception(_LE('Failed to create port group for '
'%(net_id)s with tag %(tag)s.'),
LOG.exception('Failed to create port group for '
'%(net_id)s with tag %(tag)s.',
{'net_id': net_id, 'tag': vlan_tag})
LOG.info(_LI("%(net_id)s with tag %(vlan_tag)s created on %(dvs)s."),
LOG.info("%(net_id)s with tag %(vlan_tag)s created on %(dvs)s.",
{'net_id': net_id,
'vlan_tag': vlan_tag,
'dvs': dvs_moref.value})
@@ -282,7 +281,7 @@ class DvsManager(VCManagerBase):
self._session.vim,
pg_moref, ['config'])
if len(pg_spec) == 0 or len(pg_spec[0].propSet[0]) == 0:
LOG.error(_LE('Failed to get object properties of %s'), pg_moref)
LOG.error('Failed to get object properties of %s', pg_moref)
raise nsx_exc.DvsNotFound(dvs=pg_moref)
# Convert the extracted config to DVPortgroupConfigSpec
@@ -298,7 +297,7 @@ class DvsManager(VCManagerBase):
try:
self._session.wait_for_task(task)
except Exception:
LOG.error(_LE('Failed to reconfigure DVPortGroup %s'), pg_moref)
LOG.error('Failed to reconfigure DVPortGroup %s', pg_moref)
raise nsx_exc.DvsNotFound(dvs=pg_moref)
# Update the dvs port groups config for a vxlan/vlan network
@@ -376,9 +375,9 @@ class DvsManager(VCManagerBase):
except Exception:
# NOTE(garyk): handle more specific exceptions
with excutils.save_and_reraise_exception():
LOG.exception(_LE('Failed to delete port group for %s.'),
LOG.exception('Failed to delete port group for %s.',
net_id)
LOG.info(_LI("%(net_id)s delete from %(dvs)s."),
LOG.info("%(net_id)s delete from %(dvs)s.",
{'net_id': net_id,
'dvs': dvs_moref.value})
@@ -514,11 +513,11 @@ class VMManager(VCManagerBase):
spec=new_spec)
try:
self._session.wait_for_task(task)
LOG.info(_LI("Updated VM moref %(moref)s spec - "
"attached an interface"),
LOG.info("Updated VM moref %(moref)s spec - "
"attached an interface",
{'moref': vm_moref.value})
except Exception as e:
LOG.error(_LE("Failed to reconfigure VM %(moref)s spec: %(e)s"),
LOG.error("Failed to reconfigure VM %(moref)s spec: %(e)s",
{'moref': vm_moref.value, 'e': e})
def _build_vm_spec_detach(self, device):
@@ -541,10 +540,10 @@ class VMManager(VCManagerBase):
spec=new_spec)
try:
self._session.wait_for_task(task)
LOG.info(_LI("Updated VM %(moref)s spec - detached an interface"),
LOG.info("Updated VM %(moref)s spec - detached an interface",
{'moref': vm_moref.value})
except Exception as e:
LOG.error(_LE("Failed to reconfigure vm moref %(moref)s: %(e)s"),
LOG.error("Failed to reconfigure vm moref %(moref)s: %(e)s",
{'moref': vm_moref.value, 'e': e})
def get_vm_interfaces_info(self, vm_moref):
@@ -566,7 +565,7 @@ class ClusterManager(VCManagerBase):
session.vim, "ReconfigureComputeResource_Task",
cluster, spec=config_spec, modify=True)
except Exception as excep:
LOG.exception(_LE('Failed to reconfigure cluster %s'), excep)
LOG.exception('Failed to reconfigure cluster %s', excep)
session.wait_for_task(reconfig_task)
def _create_vm_group_spec(self, client_factory, name, vm_refs,
@@ -702,7 +701,7 @@ class ClusterManager(VCManagerBase):
found = True
break
if not found:
LOG.error(_LE("%s does not exist"), host_group_name)
LOG.error("%s does not exist", host_group_name)
raise exceptions.NotFound()
update_cluster = False
num_host_groups = len(host_group_names)
@@ -745,7 +744,7 @@ class ClusterManager(VCManagerBase):
try:
self._reconfigure_cluster(session, cluster, config_spec)
except Exception as e:
LOG.error(_LE('Unable to update cluster for host groups %s'),
LOG.error('Unable to update cluster for host groups %s',
e)
def _delete_vm_group_spec(self, client_factory, name):

View File

@@ -26,7 +26,6 @@ from neutron.objects import network as net_obj
from neutron.objects import ports as port_obj
from neutron.services.externaldns import driver
from vmware_nsx._i18n import _LE, _LI
from vmware_nsx.common import driver_api
from vmware_nsx.plugins.nsx_v3 import availability_zones as nsx_az
@@ -272,7 +271,7 @@ class DNSExtensionDriver(driver_api.ExtensionDriver):
class DNSExtensionDriverNSXv(DNSExtensionDriver):
def initialize(self):
LOG.info(_LI("DNSExtensionDriverNSXv initialization complete"))
LOG.info("DNSExtensionDriverNSXv initialization complete")
def external_dns_not_needed(self, context, network):
dns_driver = _get_dns_driver()
@@ -287,7 +286,7 @@ class DNSExtensionDriverNSXv3(DNSExtensionDriver):
def initialize(self):
self._availability_zones = nsx_az.NsxV3AvailabilityZones()
LOG.info(_LI("DNSExtensionDriverNSXv3 initialization complete"))
LOG.info("DNSExtensionDriverNSXv3 initialization complete")
def _get_network_az(self, network_id):
context = n_context.get_admin_context()
@@ -337,7 +336,7 @@ def _get_dns_driver():
cfg.CONF.external_dns_driver)
return DNS_DRIVER
except ImportError:
LOG.exception(_LE("ImportError exception occurred while loading "
"the external DNS service driver"))
LOG.exception("ImportError exception occurred while loading "
"the external DNS service driver")
raise dns.ExternalDNSDriverNotFound(
driver=cfg.CONF.external_dns_driver)

View File

@@ -17,7 +17,7 @@ from oslo_config import cfg
from oslo_log import log as logging
import six
from vmware_nsx._i18n import _, _LI
from vmware_nsx._i18n import _
from vmware_nsx.common import exceptions
LOG = logging.getLogger(__name__)
@@ -60,8 +60,8 @@ class NSXCluster(object):
raise exceptions.InvalidClusterConfiguration(
invalid_attrs=self._required_attributes)
if self._important_attributes:
LOG.info(_LI("The following cluster attributes were "
"not specified: %s'"), self._important_attributes)
LOG.info("The following cluster attributes were "
"not specified: %s'", self._important_attributes)
# The API client will be explicitly created by users of this class
self.api_client = None

View File

@@ -17,7 +17,6 @@
from oslo_log import log
from oslo_serialization import jsonutils
from vmware_nsx._i18n import _LE
from vmware_nsx.api_client import exception as api_exc
from vmware_nsx.common import exceptions as nsx_exc
from vmware_nsx.common import utils
@@ -127,7 +126,7 @@ def _build_gateway_device_body(tenant_id, display_name, neutron_id,
'ipsec_%s' % utils.NetworkTypes.GRE: "IPsecGRE"}
nsx_connector_type = connector_type_mappings.get(connector_type)
if connector_type and not nsx_connector_type:
LOG.error(_LE("There is no NSX mapping for connector type %s"),
LOG.error("There is no NSX mapping for connector type %s",
connector_type)
raise nsx_exc.InvalidTransportType(transport_type=connector_type)

View File

@@ -20,7 +20,7 @@ from oslo_serialization import jsonutils
from oslo_utils import excutils
import six
from vmware_nsx._i18n import _, _LE, _LI, _LW
from vmware_nsx._i18n import _
from vmware_nsx.api_client import exception as api_exc
from vmware_nsx.common import exceptions as nsx_exc
from vmware_nsx.common import utils
@@ -255,8 +255,8 @@ def update_explicit_routes_lrouter(cluster, router_id, routes):
router_id, route)
added_routes.append(uuid)
except api_exc.NsxApiException:
LOG.exception(_LE('Cannot update NSX routes %(routes)s for '
'router %(router_id)s'),
LOG.exception('Cannot update NSX routes %(routes)s for '
'router %(router_id)s',
{'routes': routes, 'router_id': router_id})
# Roll back to keep NSX in consistent state
with excutils.save_and_reraise_exception():
@@ -473,13 +473,13 @@ def _build_snat_rule_obj(min_src_ip, max_src_ip, nat_match_obj):
def create_lrouter_nosnat_rule_v2(cluster, _router_id, _match_criteria=None):
LOG.info(_LI("No SNAT rules cannot be applied as they are not available "
"in this version of the NSX platform"))
LOG.info("No SNAT rules cannot be applied as they are not available "
"in this version of the NSX platform")
def create_lrouter_nodnat_rule_v2(cluster, _router_id, _match_criteria=None):
LOG.info(_LI("No DNAT rules cannot be applied as they are not available "
"in this version of the NSX platform"))
LOG.info("No DNAT rules cannot be applied as they are not available "
"in this version of the NSX platform")
def create_lrouter_snat_rule_v2(cluster, router_id,
@@ -579,9 +579,9 @@ def delete_nat_rules_by_match(cluster, router_id, rule_type,
min_rules=min_num_expected,
max_rules=max_num_expected)
else:
LOG.warning(_LW("Found %(actual_rule_num)d matching NAT rules, "
"which is not in the expected range "
"(%(min_exp_rule_num)d,%(max_exp_rule_num)d)"),
LOG.warning("Found %(actual_rule_num)d matching NAT rules, "
"which is not in the expected range "
"(%(min_exp_rule_num)d,%(max_exp_rule_num)d)",
{'actual_rule_num': num_rules_to_delete,
'min_exp_rule_num': min_num_expected,
'max_exp_rule_num': max_num_expected})

View File

@@ -19,7 +19,6 @@ from oslo_log import log
from oslo_serialization import jsonutils
from oslo_utils import excutils
from vmware_nsx._i18n import _LW
from vmware_nsx.common import utils
from vmware_nsx.nsxlib import mh as nsxlib
@@ -141,8 +140,8 @@ def delete_security_profile(cluster, spid):
except exceptions.NotFound:
with excutils.save_and_reraise_exception():
# This is not necessarily an error condition
LOG.warning(_LW("Unable to find security profile %s on NSX "
"backend"), spid)
LOG.warning("Unable to find security profile %s on NSX "
"backend", spid)
def summarize_security_group_rules(logical_port_rules):

View File

@@ -20,7 +20,7 @@ from oslo_config import cfg
from oslo_log import log
from oslo_serialization import jsonutils
from vmware_nsx._i18n import _, _LE, _LI, _LW
from vmware_nsx._i18n import _
from vmware_nsx.api_client import exception as api_exc
from vmware_nsx.common import exceptions as nsx_exc
from vmware_nsx.common import utils
@@ -148,7 +148,7 @@ def update_lswitch(cluster, lswitch_id, display_name,
return nsxlib.do_request(HTTP_PUT, uri, jsonutils.dumps(lswitch_obj),
cluster=cluster)
except exception.NotFound as e:
LOG.error(_LE("Network not found, Error: %s"), str(e))
LOG.error("Network not found, Error: %s", str(e))
raise exception.NetworkNotFound(net_id=lswitch_id)
@@ -163,7 +163,7 @@ def delete_networks(cluster, net_id, lswitch_ids):
try:
nsxlib.do_request(HTTP_DELETE, path, cluster=cluster)
except exception.NotFound as e:
LOG.error(_LE("Network not found, Error: %s"), str(e))
LOG.error("Network not found, Error: %s", str(e))
raise exception.NetworkNotFound(net_id=ls_id)
@@ -186,7 +186,7 @@ def delete_port(cluster, switch, port):
try:
nsxlib.do_request(HTTP_DELETE, uri, cluster=cluster)
except exception.NotFound as e:
LOG.error(_LE("Port or Network not found, Error: %s"), str(e))
LOG.error("Port or Network not found, Error: %s", str(e))
raise exception.PortNotFoundOnNetwork(
net_id=switch, port_id=port)
except api_exc.NsxApiException:
@@ -245,7 +245,7 @@ def get_ports(cluster, networks=None, devices=None, tenants=None):
if not ports:
ports = nsxlib.get_all_query_pages(lport_query_path, cluster)
except exception.NotFound:
LOG.warning(_LW("Lswitch %s not found in NSX"), lswitch)
LOG.warning("Lswitch %s not found in NSX", lswitch)
ports = None
if ports:
@@ -279,16 +279,16 @@ def get_port_by_neutron_tag(cluster, lswitch_uuid, neutron_port_id):
num_results = len(res["results"])
if num_results >= 1:
if num_results > 1:
LOG.warning(_LW("Found '%(num_ports)d' ports with "
"q_port_id tag: '%(neutron_port_id)s'. "
"Only 1 was expected."),
LOG.warning("Found '%(num_ports)d' ports with "
"q_port_id tag: '%(neutron_port_id)s'. "
"Only 1 was expected.",
{'num_ports': num_results,
'neutron_port_id': neutron_port_id})
return res["results"][0]
def get_port(cluster, network, port, relations=None):
LOG.info(_LI("get_port() %(network)s %(port)s"),
LOG.info("get_port() %(network)s %(port)s",
{'network': network, 'port': port})
uri = "/ws.v1/lswitch/" + network + "/lport/" + port + "?"
if relations:
@@ -296,7 +296,7 @@ def get_port(cluster, network, port, relations=None):
try:
return nsxlib.do_request(HTTP_GET, uri, cluster=cluster)
except exception.NotFound as e:
LOG.error(_LE("Port or Network not found, Error: %s"), str(e))
LOG.error("Port or Network not found, Error: %s", str(e))
raise exception.PortNotFoundOnNetwork(
port_id=port, net_id=network)
@@ -327,7 +327,7 @@ def update_port(cluster, lswitch_uuid, lport_uuid, neutron_port_id, tenant_id,
{'result': result['uuid'], 'uuid': lswitch_uuid})
return result
except exception.NotFound as e:
LOG.error(_LE("Port or Network not found, Error: %s"), str(e))
LOG.error("Port or Network not found, Error: %s", str(e))
raise exception.PortNotFoundOnNetwork(
port_id=lport_uuid, net_id=lswitch_uuid)
@@ -369,7 +369,7 @@ def get_port_status(cluster, lswitch_id, port_id):
"/ws.v1/lswitch/%s/lport/%s/status" %
(lswitch_id, port_id), cluster=cluster)
except exception.NotFound as e:
LOG.error(_LE("Port not found, Error: %s"), str(e))
LOG.error("Port not found, Error: %s", str(e))
raise exception.PortNotFoundOnNetwork(
port_id=port_id, net_id=lswitch_id)
if r['link_status_up'] is True:

View File

@@ -49,7 +49,7 @@ from neutron_lib.api import validators
from neutron_lib import exceptions as n_exc
import vmware_nsx
from vmware_nsx._i18n import _, _LE, _LW
from vmware_nsx._i18n import _
from vmware_nsx.common import config # noqa
from vmware_nsx.common import nsx_constants
from vmware_nsx.common import utils as c_utils
@@ -162,9 +162,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(_LW("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("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:
@@ -211,7 +211,7 @@ class NsxDvsV2(addr_pair_db.AllowedAddressPairsMixin,
vlan_tag)
except Exception:
with excutils.save_and_reraise_exception():
LOG.exception(_LE('Failed to create network'))
LOG.exception('Failed to create network')
if (net_data.get(pnet.NETWORK_TYPE) !=
c_utils.NetworkTypes.PORTGROUP):
self._dvs.delete_port_group(dvs_id)
@@ -278,7 +278,7 @@ class NsxDvsV2(addr_pair_db.AllowedAddressPairsMixin,
bindings[0].binding_type != c_utils.NetworkTypes.PORTGROUP):
self._dvs.delete_port_group(dvs_id)
except Exception:
LOG.exception(_LE('Unable to delete DVS port group %s'), id)
LOG.exception('Unable to delete DVS port group %s', id)
self.handle_network_dhcp_access(context, id, action='delete_network')
def delete_network(self, context, id):

View File

@@ -67,7 +67,7 @@ from neutron_lib.api.definitions import portbindings as pbin
from neutron_lib.api.definitions import provider_net as pnet
import vmware_nsx
from vmware_nsx._i18n import _, _LE, _LI, _LW
from vmware_nsx._i18n import _
from vmware_nsx.api_client import exception as api_exc
from vmware_nsx.common import config # noqa
from vmware_nsx.common import exceptions as nsx_exc
@@ -150,8 +150,8 @@ class NsxPluginV2(addr_pair_db.AllowedAddressPairsMixin,
router=l3_db_models.Router,
floatingip=l3_db_models.FloatingIP)
def __init__(self):
LOG.warning(_LW("The NSX-MH plugin is deprecated and may be removed "
"in the O or the P cycle"))
LOG.warning("The NSX-MH plugin is deprecated and may be removed "
"in the O or the P cycle")
super(NsxPluginV2, self).__init__()
# TODO(salv-orlando): Replace These dicts with
# collections.defaultdict for better handling of default values
@@ -242,8 +242,8 @@ class NsxPluginV2(addr_pair_db.AllowedAddressPairsMixin,
self._is_default_net_gw_in_sync = True
except Exception:
with excutils.save_and_reraise_exception():
LOG.exception(_LE("Unable to process default l2 gw service: "
"%s"),
LOG.exception("Unable to process default l2 gw service: "
"%s",
def_l2_gw_uuid)
def _build_ip_address_list(self, context, fixed_ips, subnet_ids=None):
@@ -280,8 +280,8 @@ class NsxPluginV2(addr_pair_db.AllowedAddressPairsMixin,
port_data.get('mac_address'))
LOG.debug("Created NSX router port:%s", lrouter_port['uuid'])
except api_exc.NsxApiException:
LOG.exception(_LE("Unable to create port on NSX logical router "
"%s"),
LOG.exception("Unable to create port on NSX logical router "
"%s",
nsx_router_id)
raise nsx_exc.NsxPluginException(
err_msg=_("Unable to create logical router port for neutron "
@@ -369,9 +369,9 @@ class NsxPluginV2(addr_pair_db.AllowedAddressPairsMixin,
# Must remove NSX logical port
routerlib.delete_router_lport(cluster, nsx_router_id,
nsx_router_port_id)
LOG.exception(_LE("Unable to plug attachment in NSX logical "
"router port %(r_port_id)s, associated with "
"Neutron %(q_port_id)s"),
LOG.exception("Unable to plug attachment in NSX logical "
"router port %(r_port_id)s, associated with "
"Neutron %(q_port_id)s",
{'r_port_id': nsx_router_port_id,
'q_port_id': port_data.get('id')})
raise nsx_exc.NsxPluginException(
@@ -444,8 +444,8 @@ class NsxPluginV2(addr_pair_db.AllowedAddressPairsMixin,
# rollback the neutron-nsx port mapping
nsx_db.delete_neutron_nsx_port_mapping(context.session,
port_id)
LOG.exception(_LE("An exception occurred while creating the "
"neutron port %s on the NSX plaform"), port_id)
LOG.exception("An exception occurred while creating the "
"neutron port %s on the NSX plaform", port_id)
def _nsx_create_port(self, context, port_data):
"""Driver for creating a logical switch port on NSX platform."""
@@ -455,8 +455,8 @@ class NsxPluginV2(addr_pair_db.AllowedAddressPairsMixin,
# However, in order to not break unit tests, we need to still create
# the DB object and return success
if self._network_is_external(context, port_data['network_id']):
LOG.info(_LI("NSX plugin does not support regular VIF ports on "
"external networks. Port %s will be down."),
LOG.info("NSX plugin does not support regular VIF ports on "
"external networks. Port %s will be down.",
port_data['network_id'])
# No need to actually update the DB state - the default is down
return port_data
@@ -488,9 +488,9 @@ class NsxPluginV2(addr_pair_db.AllowedAddressPairsMixin,
if (port_data['device_owner'] == constants.DEVICE_OWNER_DHCP and
isinstance(e.inner_exception, sql_exc.IntegrityError)):
LOG.warning(
_LW("Concurrent network deletion detected; Back-end "
"Port %(nsx_id)s creation to be rolled back for "
"Neutron port: %(neutron_id)s"),
"Concurrent network deletion detected; Back-end "
"Port %(nsx_id)s creation to be rolled back for "
"Neutron port: %(neutron_id)s",
{'nsx_id': lport['uuid'],
'neutron_id': port_data['id']})
if selected_lswitch and lport:
@@ -507,8 +507,8 @@ class NsxPluginV2(addr_pair_db.AllowedAddressPairsMixin,
# does not make sense. However we cannot raise as this would break
# unit tests.
if self._network_is_external(context, port_data['network_id']):
LOG.info(_LI("NSX plugin does not support regular VIF ports on "
"external networks. Port %s will be down."),
LOG.info("NSX plugin does not support regular VIF ports on "
"external networks. Port %s will be down.",
port_data['network_id'])
return
nsx_switch_id, nsx_port_id = nsx_utils.get_nsx_switch_and_port_id(
@@ -526,7 +526,7 @@ class NsxPluginV2(addr_pair_db.AllowedAddressPairsMixin,
{'port_id': port_data['id'],
'net_id': port_data['network_id']})
except n_exc.NotFound:
LOG.warning(_LW("Port %s not found in NSX"), port_data['id'])
LOG.warning("Port %s not found in NSX", port_data['id'])
def _nsx_delete_router_port(self, context, port_data):
# Delete logical router port
@@ -536,9 +536,9 @@ class NsxPluginV2(addr_pair_db.AllowedAddressPairsMixin,
context.session, self.cluster, port_data['id'])
if not nsx_port_id:
LOG.warning(
_LW("Neutron port %(port_id)s not found on NSX backend. "
"Terminating delete operation. A dangling router port "
"might have been left on router %(router_id)s"),
"Neutron port %(port_id)s not found on NSX backend. "
"Terminating delete operation. A dangling router port "
"might have been left on router %(router_id)s",
{'port_id': port_data['id'],
'router_id': nsx_router_id})
return
@@ -551,8 +551,8 @@ class NsxPluginV2(addr_pair_db.AllowedAddressPairsMixin,
# Do not raise because the issue might as well be that the
# router has already been deleted, so there would be nothing
# to do here
LOG.exception(_LE("Ignoring exception as this means the peer "
"for port '%s' has already been deleted."),
LOG.exception("Ignoring exception as this means the peer "
"for port '%s' has already been deleted.",
nsx_port_id)
# Delete logical switch port
@@ -714,8 +714,8 @@ class NsxPluginV2(addr_pair_db.AllowedAddressPairsMixin,
# However, in order to not break unit tests, we need to still create
# the DB object and return success
if self._network_is_external(context, port_data['network_id']):
LOG.info(_LI("NSX plugin does not support regular VIF ports on "
"external networks. Port %s will be down."),
LOG.info("NSX plugin does not support regular VIF ports on "
"external networks. Port %s will be down.",
port_data['network_id'])
# No need to actually update the DB state - the default is down
return port_data
@@ -941,9 +941,9 @@ class NsxPluginV2(addr_pair_db.AllowedAddressPairsMixin,
net_data[key] = None
# FIXME(arosen) implement admin_state_up = False in NSX
if net_data['admin_state_up'] is False:
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>'))
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>'))
transport_zone_config = self._convert_to_nsx_transport_zones(
self.cluster, net_data)
external = net_data.get(ext_net_extn.EXTERNAL)
@@ -1026,8 +1026,8 @@ class NsxPluginV2(addr_pair_db.AllowedAddressPairsMixin,
try:
switchlib.delete_networks(self.cluster, id, lswitch_ids)
except n_exc.NotFound:
LOG.warning(_LW("The following logical switches were not "
"found on the NSX backend:%s"), lswitch_ids)
LOG.warning("The following logical switches were not "
"found on the NSX backend:%s", lswitch_ids)
self.handle_network_dhcp_access(context, id, action='delete_network')
LOG.debug("Delete network complete for network: %s", id)
@@ -1086,17 +1086,17 @@ class NsxPluginV2(addr_pair_db.AllowedAddressPairsMixin,
nsx_switch_ids = nsx_utils.get_nsx_switch_ids(
context.session, self.cluster, id)
if not nsx_switch_ids or len(nsx_switch_ids) < 1:
LOG.warning(_LW("Unable to find NSX mappings for neutron "
"network:%s"), id)
LOG.warning("Unable to find NSX mappings for neutron "
"network:%s", id)
try:
switchlib.update_lswitch(self.cluster,
nsx_switch_ids[0],
network['network']['name'])
except api_exc.NsxApiException as e:
LOG.warning(_LW("Logical switch update on NSX backend failed. "
"Neutron network id:%(net_id)s; "
"NSX lswitch id:%(lswitch_id)s;"
"Error:%(error)s"),
LOG.warning("Logical switch update on NSX backend failed. "
"Neutron network id:%(net_id)s; "
"NSX lswitch id:%(lswitch_id)s;"
"Error:%(error)s",
{'net_id': id, 'lswitch_id': nsx_switch_ids[0],
'error': e})
@@ -1179,8 +1179,8 @@ class NsxPluginV2(addr_pair_db.AllowedAddressPairsMixin,
LOG.debug("port created on NSX backend for tenant "
"%(tenant_id)s: (%(id)s)", port_data)
except n_exc.NotFound:
LOG.warning(_LW("Logical switch for network %s was not "
"found in NSX."), port_data['network_id'])
LOG.warning("Logical switch for network %s was not "
"found in NSX.", port_data['network_id'])
# Put port in error on neutron DB
with context.session.begin(subtransactions=True):
port = self._get_port(context, neutron_port_id)
@@ -1190,8 +1190,8 @@ class NsxPluginV2(addr_pair_db.AllowedAddressPairsMixin,
except Exception:
# Port must be removed from neutron DB
with excutils.save_and_reraise_exception():
LOG.error(_LE("Unable to create port or set port "
"attachment in NSX."))
LOG.error("Unable to create port or set port "
"attachment in NSX.")
with context.session.begin(subtransactions=True):
self.ipam.delete_port(context, neutron_port_id)
# this extra lookup is necessary to get the
@@ -1322,7 +1322,7 @@ class NsxPluginV2(addr_pair_db.AllowedAddressPairsMixin,
# FIXME(arosen) improve exception handling.
except Exception:
ret_port['status'] = constants.PORT_STATUS_ERROR
LOG.exception(_LE("Unable to update port id: %s."),
LOG.exception("Unable to update port id: %s.",
nsx_port_id)
# If nsx_port_id is not in database or in nsx put in error state.
@@ -1419,10 +1419,10 @@ class NsxPluginV2(addr_pair_db.AllowedAddressPairsMixin,
"L3GatewayAttachment",
self.cluster.default_l3_gw_service_uuid)
except nsx_exc.NsxPluginException:
LOG.exception(_LE("Unable to create L3GW port on logical router "
"%(router_uuid)s. Verify Default Layer-3 "
"Gateway service %(def_l3_gw_svc)s id is "
"correct"),
LOG.exception("Unable to create L3GW port on logical router "
"%(router_uuid)s. Verify Default Layer-3 "
"Gateway service %(def_l3_gw_svc)s id is "
"correct",
{'router_uuid': lrouter['uuid'],
'def_l3_gw_svc':
self.cluster.default_l3_gw_service_uuid})
@@ -1513,13 +1513,13 @@ class NsxPluginV2(addr_pair_db.AllowedAddressPairsMixin,
# As setting gateway failed, the router must be deleted
# in order to ensure atomicity
router_id = router_db['id']
LOG.warning(_LW("Failed to set gateway info for router "
"being created:%s - removing router"),
LOG.warning("Failed to set gateway info for router "
"being created:%s - removing router",
router_id)
self.delete_router(context, router_id)
LOG.info(_LI("Create router failed while setting external "
"gateway. Router:%s has been removed from "
"DB and backend"),
LOG.info("Create router failed while setting external "
"gateway. Router:%s has been removed from "
"DB and backend",
router_id)
return self._make_router_dict(router_db)
@@ -1624,8 +1624,8 @@ class NsxPluginV2(addr_pair_db.AllowedAddressPairsMixin,
self._delete_lrouter(context, router_id, nsx_router_id)
except n_exc.NotFound:
# This is not a fatal error, but needs to be logged
LOG.warning(_LW("Logical router '%s' not found "
"on NSX Platform"), router_id)
LOG.warning("Logical router '%s' not found "
"on NSX Platform", router_id)
except api_exc.NsxApiException:
raise nsx_exc.NsxPluginException(
err_msg=(_("Unable to delete logical router '%s' "
@@ -1635,8 +1635,8 @@ class NsxPluginV2(addr_pair_db.AllowedAddressPairsMixin,
# not exist anymore in the backend. This is not a fatal condition,
# but will result in an exception is "None" is passed to
# _delete_lrouter
LOG.warning(_LW("No mapping found for logical router '%s' "
"on NSX Platform"), router_id)
LOG.warning("No mapping found for logical router '%s' "
"on NSX Platform", router_id)
# Remove the NSX mapping first in order to ensure a mapping to
# a non-existent NSX router is not left in the DB in case of
@@ -1646,10 +1646,10 @@ class NsxPluginV2(addr_pair_db.AllowedAddressPairsMixin,
context.session, router_id)
except db_exc.DBError as d_exc:
# Do not make this error fatal
LOG.warning(_LW("Unable to remove NSX mapping for Neutron router "
"%(router_id)s because of the following exception:"
"%(d_exc)s"), {'router_id': router_id,
'd_exc': str(d_exc)})
LOG.warning("Unable to remove NSX mapping for Neutron router "
"%(router_id)s because of the following exception:"
"%(d_exc)s", {'router_id': router_id,
'd_exc': str(d_exc)})
# Perform the actual delete on the Neutron DB
super(NsxPluginV2, self).delete_router(context, router_id)
@@ -1805,8 +1805,8 @@ class NsxPluginV2(addr_pair_db.AllowedAddressPairsMixin,
raise_on_len_mismatch=False,
destination_ip_addresses=subnet['cidr'])
except n_exc.NotFound:
LOG.error(_LE("Logical router resource %s not found "
"on NSX platform"), router_id)
LOG.error("Logical router resource %s not found "
"on NSX platform", router_id)
except api_exc.NsxApiException:
raise nsx_exc.NsxPluginException(
err_msg=(_("Unable to update logical router"
@@ -1841,13 +1841,13 @@ class NsxPluginV2(addr_pair_db.AllowedAddressPairsMixin,
except api_exc.NsxApiException:
with excutils.save_and_reraise_exception():
LOG.exception(_LE("An error occurred while removing NAT rules "
"on the NSX platform for floating ip:%s"),
LOG.exception("An error occurred while removing NAT rules "
"on the NSX platform for floating ip:%s",
floating_ip_address)
except nsx_exc.NatRuleMismatch:
# Do not surface to the user
LOG.warning(_LW("An incorrect number of matching NAT rules "
"was found on the NSX platform"))
LOG.warning("An incorrect number of matching NAT rules "
"was found on the NSX platform")
def _remove_floatingip_address(self, context, fip_db):
# Remove floating IP address from logical router port
@@ -1960,10 +1960,10 @@ class NsxPluginV2(addr_pair_db.AllowedAddressPairsMixin,
self.cluster, nsx_router_id, nsx_gw_port_id,
ips_to_add=nsx_floating_ips, ips_to_remove=[])
except api_exc.NsxApiException:
LOG.exception(_LE("An error occurred while creating NAT "
"rules on the NSX platform for floating "
"ip:%(floating_ip)s mapped to "
"internal ip:%(internal_ip)s"),
LOG.exception("An error occurred while creating NAT "
"rules on the NSX platform for floating "
"ip:%(floating_ip)s mapped to "
"internal ip:%(internal_ip)s",
{'floating_ip': floating_ip,
'internal_ip': internal_ip})
msg = _("Failed to update NAT rules for floatingip update")
@@ -2020,7 +2020,7 @@ class NsxPluginV2(addr_pair_db.AllowedAddressPairsMixin,
LOG.debug("The port '%s' is not associated with floating IPs",
port_id)
except n_exc.NotFound:
LOG.warning(_LW("Nat rules not found in nsx for port: %s"), id)
LOG.warning("Nat rules not found in nsx for port: %s", id)
# NOTE(ihrachys): L3 agent notifications don't make sense for
# NSX VMWare plugin since there is no L3 agent in such setup, so
@@ -2085,8 +2085,8 @@ class NsxPluginV2(addr_pair_db.AllowedAddressPairsMixin,
except api_exc.ResourceNotFound:
# Do not cause a 500 to be returned to the user if
# the corresponding NSX resource does not exist
LOG.exception(_LE("Unable to remove gateway service from "
"NSX plaform - the resource was not found"))
LOG.exception("Unable to remove gateway service from "
"NSX plaform - the resource was not found")
def get_network_gateway(self, context, id, fields=None):
# Ensure the default gateway in the config file is in sync with the db
@@ -2114,8 +2114,8 @@ class NsxPluginV2(addr_pair_db.AllowedAddressPairsMixin,
except api_exc.NsxApiException:
# Consider backend failures as non-fatal, but still warn
# because this might indicate something dodgy is going on
LOG.warning(_LW("Unable to update name on NSX backend "
"for network gateway: %s"), id)
LOG.warning("Unable to update name on NSX backend "
"for network gateway: %s", id)
return super(NsxPluginV2, self).update_network_gateway(
context, id, network_gateway)
@@ -2141,8 +2141,8 @@ class NsxPluginV2(addr_pair_db.AllowedAddressPairsMixin,
def _rollback_gw_device(self, context, device_id, gw_data=None,
new_status=None, is_create=False):
LOG.error(_LE("Rolling back database changes for gateway device %s "
"because of an error in the NSX backend"), device_id)
LOG.error("Rolling back database changes for gateway device %s "
"because of an error in the NSX backend", device_id)
with context.session.begin(subtransactions=True):
query = self._model_query(
context, nsx_models.NetworkGatewayDevice).filter(
@@ -2321,16 +2321,16 @@ class NsxPluginV2(addr_pair_db.AllowedAddressPairsMixin,
try:
l2gwlib.delete_gateway_device(self.cluster, nsx_device_id)
except n_exc.NotFound:
LOG.warning(_LW("Removal of gateway device: %(neutron_id)s failed "
"on NSX backend (NSX id:%(nsx_id)s) because the "
"NSX resource was not found"),
LOG.warning("Removal of gateway device: %(neutron_id)s failed "
"on NSX backend (NSX id:%(nsx_id)s) because the "
"NSX resource was not found",
{'neutron_id': device_id, 'nsx_id': nsx_device_id})
except api_exc.NsxApiException:
with excutils.save_and_reraise_exception():
# In this case a 500 should be returned
LOG.exception(_LE("Removal of gateway device: %(neutron_id)s "
"failed on NSX backend (NSX id:%(nsx_id)s). "
"Neutron and NSX states have diverged."),
LOG.exception("Removal of gateway device: %(neutron_id)s "
"failed on NSX backend (NSX id:%(nsx_id)s). "
"Neutron and NSX states have diverged.",
{'neutron_id': device_id,
'nsx_id': nsx_device_id})
@@ -2376,8 +2376,8 @@ class NsxPluginV2(addr_pair_db.AllowedAddressPairsMixin,
# Reverting the DB change is not really worthwhile
# for a mismatch between names. It's the rules that
# we care about.
LOG.error(_LE('Error while updating security profile '
'%(uuid)s with name %(name)s: %(error)s.'),
LOG.error('Error while updating security profile '
'%(uuid)s with name %(name)s: %(error)s.',
{'uuid': secgroup_id, 'name': name, 'error': e})
return secgroup
@@ -2408,19 +2408,19 @@ class NsxPluginV2(addr_pair_db.AllowedAddressPairsMixin,
except n_exc.NotFound:
# The security profile was not found on the backend
# do not fail in this case.
LOG.warning(_LW("The NSX security profile %(sec_profile_id)s, "
"associated with the Neutron security group "
"%(sec_group_id)s was not found on the "
"backend"),
LOG.warning("The NSX security profile %(sec_profile_id)s, "
"associated with the Neutron security group "
"%(sec_group_id)s was not found on the "
"backend",
{'sec_profile_id': nsx_sec_profile_id,
'sec_group_id': security_group_id})
except api_exc.NsxApiException:
# Raise and fail the operation, as there is a problem which
# prevented the sec group from being removed from the backend
LOG.exception(_LE("An exception occurred while removing the "
"NSX security profile %(sec_profile_id)s, "
"associated with Netron security group "
"%(sec_group_id)s"),
LOG.exception("An exception occurred while removing the "
"NSX security profile %(sec_profile_id)s, "
"associated with Netron security group "
"%(sec_group_id)s",
{'sec_profile_id': nsx_sec_profile_id,
'sec_group_id': security_group_id})
raise nsx_exc.NsxPluginException(

View File

@@ -20,7 +20,6 @@ from neutron.db import l3_db
from neutron_lib import constants
from neutron_lib import exceptions as n_exc
from vmware_nsx._i18n import _LE, _LW
from vmware_nsx.common import locking
from vmware_nsx.db import nsxv_db
from vmware_nsx.plugins.nsx_v.drivers import (
@@ -127,8 +126,8 @@ class RouterDistributedDriver(router_driver.RouterBaseDriver):
# This should address cases where the binding remains due to breakage
if nsxv_db.get_vdr_dhcp_binding_by_vdr(context.session, router_id):
LOG.warning(_LW("DHCP bind wasn't cleaned for router %s. "
"Cleaning up entry"), router_id)
LOG.warning("DHCP bind wasn't cleaned for router %s. "
"Cleaning up entry", router_id)
nsxv_db.delete_vdr_dhcp_binding(context.session, router_id)
def update_routes(self, context, router_id, newnexthop,
@@ -476,7 +475,7 @@ class RouterDistributedDriver(router_driver.RouterBaseDriver):
self.edge_manager.remove_network_from_dhcp_edge(
context, network_id, vdr_dhcp_binding['dhcp_edge_id'])
else:
LOG.error(_LE('VDR DHCP binding is missing for %s'),
LOG.error('VDR DHCP binding is missing for %s',
router_id)
# Reattach to regular DHCP Edge

View File

@@ -24,7 +24,6 @@ from neutron_lib import exceptions as n_exc
from oslo_log import log as logging
from vmware_nsx._i18n import _
from vmware_nsx._i18n import _LE
from vmware_nsx.common import exceptions as nsx_exc
from vmware_nsx.common import locking
from vmware_nsx.db import nsxv_db
@@ -398,7 +397,7 @@ class RouterSharedDriver(router_driver.RouterBaseDriver):
router_dict['gateway'] = (
gwp['fixed_ips'][0]['subnet_id'])
except IndexError:
LOG.error(_LE("Skipping GW port %s with no fixed IP"),
LOG.error("Skipping GW port %s with no fixed IP",
gwp['id'])
subnet_ids = [p['fixed_ips'][0]['subnet_id'] for p in
intf_ports if p['device_id'] == r['id']]

View File

@@ -18,7 +18,7 @@ import stevedore
from oslo_log import log
from vmware_nsx._i18n import _, _LE, _LI
from vmware_nsx._i18n import _
from vmware_nsx.common import exceptions as nsx_exc
LOG = log.getLogger(__name__)
@@ -32,14 +32,14 @@ class RouterTypeManager(stevedore.named.NamedExtensionManager):
# Mapping from type name to DriverManager
self.drivers = {}
LOG.info(_LI("Configured router type driver names: %s"),
LOG.info("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(_LI("Loaded type driver names: %s"), self.names())
LOG.info("Loaded type driver names: %s", self.names())
self._register_types()
self._check_tenant_router_types(cfg.CONF.nsxv.tenant_router_types)
@@ -47,15 +47,15 @@ class RouterTypeManager(stevedore.named.NamedExtensionManager):
for ext in self:
router_type = ext.obj.get_type()
if router_type in self.drivers:
LOG.error(_LE("Type driver '%(new_driver)s' ignored because "
"type driver '%(old_driver)s' is already "
"registered for type '%(type)s'"),
LOG.error("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(_LI("Registered types: %s"), self.drivers.keys())
LOG.info("Registered types: %s", self.drivers.keys())
def _check_tenant_router_types(self, types):
self.tenant_router_types = []
@@ -67,7 +67,7 @@ class RouterTypeManager(stevedore.named.NamedExtensionManager):
"Service terminated!") % router_type
LOG.error(msg)
raise SystemExit(msg)
LOG.info(_LI("Tenant router_types: %s"), self.tenant_router_types)
LOG.info("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

@@ -23,7 +23,7 @@ from neutron_lib import context as neutron_context
from oslo_config import cfg
from oslo_log import log as logging
from vmware_nsx._i18n import _, _LE, _LW
from vmware_nsx._i18n import _
from vmware_nsx.common import exceptions as nsxv_exc
from vmware_nsx.common import locking
from vmware_nsx.common import nsxv_constants
@@ -192,8 +192,8 @@ class NsxVMetadataProxyHandler(object):
self.nsxv_plugin.delete_network(context,
internal_net)
LOG.exception(_LE("Exception %s while creating internal "
"network for metadata service"), e)
LOG.exception("Exception %s while creating internal "
"network for metadata service", e)
return
# Update the new network_id in DB
@@ -217,7 +217,7 @@ class NsxVMetadataProxyHandler(object):
if ports:
return ports[0]['fixed_ips'][0]['ip_address']
else:
LOG.error(_LE("No port found for metadata for %s"), rtr_id)
LOG.error("No port found for metadata for %s", rtr_id)
def _get_edge_rtr_id_by_ext_ip(self, context, edge_ip):
rtr_list = nsxv_db.get_nsxv_internal_edge(
@@ -299,8 +299,8 @@ class NsxVMetadataProxyHandler(object):
edge_id = self._get_edge_id_by_rtr_id(context, rtr_id)
if not rtr_id or not edge_id:
# log this error and return without the ip, but don't fail
LOG.error(_LE("Failed find edge for router %(rtr_id)s with ip "
"%(rtr_ext_ip)s"),
LOG.error("Failed find edge for router %(rtr_id)s with ip "
"%(rtr_ext_ip)s",
{'rtr_id': rtr_id, 'rtr_ext_ip': rtr_ext_ip})
return
@@ -310,8 +310,8 @@ class NsxVMetadataProxyHandler(object):
h, routes = self.nsxv_plugin.nsx_v.vcns.get_routes(edge_id)
except exceptions.ResourceNotFound as e:
# log this error and return without the ip, but don't fail
LOG.error(_LE("Failed to get routes for metadata proxy edge "
"%(edge)s: %(err)s"),
LOG.error("Failed to get routes for metadata proxy edge "
"%(edge)s: %(err)s",
{'edge': edge_id, 'err': e})
return
@@ -381,8 +381,8 @@ class NsxVMetadataProxyHandler(object):
lb_obj.submit_to_backend(self.nsxv_plugin.nsx_v.vcns, edge_id)
except exceptions.RequestBad as e:
# log the error and continue
LOG.error(_LE("Failed to update load balancer on metadata "
"proxy edge %(edge)s: %(err)s"),
LOG.error("Failed to update load balancer on metadata "
"proxy edge %(edge)s: %(err)s",
{'edge': edge_id, 'err': e})
edge_ip = self._get_edge_internal_ip(context, rtr_id)
@@ -504,8 +504,8 @@ class NsxVMetadataProxyHandler(object):
return edge_ip
except Exception as e:
LOG.exception(_LE("Exception %s while creating internal edge "
"for metadata service"), e)
LOG.exception("Exception %s while creating internal edge "
"for metadata service", e)
ports = self.nsxv_plugin.get_ports(
context, filters={'device_id': [rtr_id]})
@@ -721,13 +721,13 @@ class NsxVMetadataProxyHandler(object):
if ports:
if warn:
LOG.warning(_LW("cleanup_router_edge found port %(port)s for "
"router %(router)s - deleting it now."),
LOG.warning("cleanup_router_edge found port %(port)s for "
"router %(router)s - deleting it now.",
{'port': ports[0]['id'], 'router': rtr_id})
try:
self.nsxv_plugin.delete_port(
ctx, ports[0]['id'],
l3_port_check=False)
except Exception as e:
LOG.error(_LE("Failed to delete md_proxy port %(port)s: "
"%(e)s"), {'port': ports[0]['id'], 'e': e})
LOG.error("Failed to delete md_proxy port %(port)s: "
"%(e)s", {'port': ports[0]['id'], 'e': e})

View File

@@ -85,7 +85,7 @@ from vmware_nsx.services.qos.common import utils as qos_com_utils
from vmware_nsx.services.qos.nsx_v import utils as qos_utils
import vmware_nsx
from vmware_nsx._i18n import _, _LE, _LI, _LW
from vmware_nsx._i18n import _
from vmware_nsx.common import availability_zones as nsx_com_az
from vmware_nsx.common import config # noqa
from vmware_nsx.common import exceptions as nsx_exc
@@ -341,9 +341,9 @@ class NsxVPluginV2(addr_pair_db.AllowedAddressPairsMixin,
vnic_id = self._get_port_vnic_id(vnic_idx, device_id)
self._add_member_to_security_group(sg_id, vnic_id)
except Exception as e:
LOG.info(_LI('Could not add port %(port)s to service '
'insertion security group. Exception '
'%(err)s'),
LOG.info('Could not add port %(port)s to service '
'insertion security group. Exception '
'%(err)s',
{'port': port['id'], 'err': e})
# Doing this in a separate thread to not slow down the init process
@@ -355,7 +355,7 @@ class NsxVPluginV2(addr_pair_db.AllowedAddressPairsMixin,
# If called more than once - we should not create it again
return self.conn.consume_in_threads()
LOG.info(_LI("NSXV plugin: starting RPC listeners"))
LOG.info("NSXV plugin: starting RPC listeners")
self.endpoints = [agents_db.AgentExtRpcCallback()]
self.topic = topics.PLUGIN
@@ -533,8 +533,8 @@ class NsxVPluginV2(addr_pair_db.AllowedAddressPairsMixin,
section_uri,
self.nsx_sg_utils.to_xml_string(section), h)
except Exception as exc:
LOG.error(_LE('Unable to update security group %(sg)s '
'section for logging. %(e)s'),
LOG.error('Unable to update security group %(sg)s '
'section for logging. %(e)s',
{'e': exc, 'sg': sg['id']})
c_utils.spawn_n(process_security_groups_rules_logging)
@@ -557,8 +557,8 @@ class NsxVPluginV2(addr_pair_db.AllowedAddressPairsMixin,
context, neutron_port_db['id'], network_id,
neutron_port_db['mac_address'])
except Exception as e:
LOG.error(_LE('Unable to delete static bindings for %(id)s. '
'Error: %(e)s'),
LOG.error('Unable to delete static bindings for %(id)s. '
'Error: %(e)s',
{'id': neutron_port_db['id'], 'e': e})
def _validate_network_qos(self, network, backend_network):
@@ -844,8 +844,8 @@ class NsxVPluginV2(addr_pair_db.AllowedAddressPairsMixin,
self._vcm.update_port_group_spec_teaming,
switch)
except Exception as e:
LOG.error(_LE('Unable to update teaming information for '
'net %(net_id)s. Error: %(e)s'),
LOG.error('Unable to update teaming information for '
'net %(net_id)s. Error: %(e)s',
{'net_id': net_id, 'e': e})
def _create_vlan_network_at_backend(self, net_data, dvs_id):
@@ -889,13 +889,13 @@ class NsxVPluginV2(addr_pair_db.AllowedAddressPairsMixin,
try:
self.nsx_v.vcns.add_member_to_security_group(
sg_id, vnic_id)
LOG.info(_LI("Added %(sg_id)s member to NSX security "
"group %(vnic_id)s"),
LOG.info("Added %(sg_id)s member to NSX security "
"group %(vnic_id)s",
{'sg_id': sg_id, 'vnic_id': vnic_id})
except Exception:
with excutils.save_and_reraise_exception():
LOG.error(_LE("NSX security group %(sg_id)s member add "
"failed %(vnic_id)s."),
LOG.error("NSX security group %(sg_id)s member add "
"failed %(vnic_id)s.",
{'sg_id': sg_id,
'vnic_id': vnic_id})
@@ -906,7 +906,7 @@ class NsxVPluginV2(addr_pair_db.AllowedAddressPairsMixin,
for add_sg in added_sgids:
nsx_sg_id = nsx_db.get_nsx_security_group_id(session, add_sg)
if nsx_sg_id is None:
LOG.warning(_LW("NSX security group not found for %s"), add_sg)
LOG.warning("NSX security group not found for %s", add_sg)
else:
self._add_member_to_security_group(nsx_sg_id, vnic_id)
@@ -929,7 +929,7 @@ class NsxVPluginV2(addr_pair_db.AllowedAddressPairsMixin,
for del_sg in deleted_sgids:
nsx_sg_id = nsx_db.get_nsx_security_group_id(session, del_sg)
if nsx_sg_id is None:
LOG.warning(_LW("NSX security group not found for %s"), del_sg)
LOG.warning("NSX security group not found for %s", del_sg)
else:
self._remove_member_from_security_group(nsx_sg_id, vnic_id)
@@ -1211,7 +1211,7 @@ class NsxVPluginV2(addr_pair_db.AllowedAddressPairsMixin,
elif network_type != c_utils.NsxVNetworkTypes.PORTGROUP:
for dvsmrf, netmrf in six.iteritems(dvs_pg_mappings):
self._delete_backend_network(netmrf, dvsmrf)
LOG.exception(_LE('Failed to create network'))
LOG.exception('Failed to create network')
# If init is incomplete calling _update_qos_network() will result a
# deadlock.
@@ -1300,7 +1300,7 @@ class NsxVPluginV2(addr_pair_db.AllowedAddressPairsMixin,
try:
policy = self.nsx_v.vcns.get_spoofguard_policy(policy_id)[1]
except Exception:
LOG.error(_LE("Policy does not exists for %s"), policy_id)
LOG.error("Policy does not exists for %s", policy_id)
# We will not attempt to delete a policy that does not exist
return False
if policy:
@@ -1333,14 +1333,14 @@ class NsxVPluginV2(addr_pair_db.AllowedAddressPairsMixin,
is_dhcp_backend_deleted = True
except Exception:
with excutils.save_and_reraise_exception():
LOG.exception(_LE('Failed to delete network'))
LOG.exception('Failed to delete network')
for port_id in auto_del:
try:
self.delete_port(context.elevated(), port_id,
force_delete_dhcp=True)
except Exception as e:
LOG.warning(_LW('Unable to delete port %(port_id)s. '
'Reason: %(e)s'),
LOG.warning('Unable to delete port %(port_id)s. '
'Reason: %(e)s',
{'port_id': port_id, 'e': e})
with context.session.begin(subtransactions=True):
@@ -1491,10 +1491,10 @@ class NsxVPluginV2(addr_pair_db.AllowedAddressPairsMixin,
orig_net[psec.PORTSECURITY] !=
net_attrs[psec.PORTSECURITY])
if psec_update and not net_attrs[psec.PORTSECURITY]:
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."))
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.")
# Check if the physical network of a vlan provider network was updated
updated_morefs = False
@@ -1701,7 +1701,7 @@ class NsxVPluginV2(addr_pair_db.AllowedAddressPairsMixin,
self._create_dhcp_static_binding(context, neutron_db)
except Exception:
with excutils.save_and_reraise_exception():
LOG.exception(_LE('Failed to create port'))
LOG.exception('Failed to create port')
# Revert what we have created and raise the exception
self.delete_port(context, port_data['id'])
@@ -1744,20 +1744,20 @@ class NsxVPluginV2(addr_pair_db.AllowedAddressPairsMixin,
vm_moref = self._vcm.get_vm_moref(device_id)
if vm_moref is not None:
try:
LOG.info(_LI("Add VM %(dev)s to exclude list on "
"behalf of port %(port)s: added to "
"list"),
LOG.info("Add VM %(dev)s to exclude list on "
"behalf of port %(port)s: added to "
"list",
{"dev": device_id, "port": port_id})
self.nsx_v.vcns.add_vm_to_exclude_list(vm_moref)
except vsh_exc.RequestBad as e:
LOG.error(_LE("Failed to add vm %(device)s "
"moref %(moref)s to exclude list: "
"%(err)s"),
LOG.error("Failed to add vm %(device)s "
"moref %(moref)s to exclude list: "
"%(err)s",
{'device': device_id, 'moref': vm_moref,
'err': e})
else:
LOG.info(_LI("Add VM %(dev)s to exclude list on behalf of "
"port %(port)s: already in list"),
LOG.info("Add VM %(dev)s to exclude list on behalf of "
"port %(port)s: already in list",
{"dev": device_id, "port": port_id})
def _remove_vm_from_exclude_list(self, context, device_id, port_id,
@@ -1772,20 +1772,20 @@ class NsxVPluginV2(addr_pair_db.AllowedAddressPairsMixin,
vm_moref = self._vcm.get_vm_moref(device_id)
if vm_moref is not None:
try:
LOG.info(_LI("Remove VM %(dev)s from exclude list on "
"behalf of port %(port)s: removed from "
"list"),
LOG.info("Remove VM %(dev)s from exclude list on "
"behalf of port %(port)s: removed from "
"list",
{"dev": device_id, "port": port_id})
self.nsx_v.vcns.delete_vm_from_exclude_list(vm_moref)
except vsh_exc.RequestBad as e:
LOG.error(_LE("Failed to delete vm %(device)s "
"moref %(moref)s from exclude list: "
"%(err)s"),
LOG.error("Failed to delete vm %(device)s "
"moref %(moref)s from exclude list: "
"%(err)s",
{'device': device_id, 'moref': vm_moref,
'err': e})
else:
LOG.info(_LI("Remove VM %(dev)s from exclude list on behalf "
"of port %(port)s: other ports still in list"),
LOG.info("Remove VM %(dev)s from exclude list on behalf "
"of port %(port)s: other ports still in list",
{"dev": device_id, "port": port_id})
def update_port(self, context, id, port):
@@ -1961,8 +1961,8 @@ class NsxVPluginV2(addr_pair_db.AllowedAddressPairsMixin,
ret_port['network_id'],
old_ip, new_ip, sub_mask)
else:
LOG.info(_LI('Not updating fixed IP on backend for '
'device owner [%(dev_own)s] and port %(pid)s'),
LOG.info('Not updating fixed IP on backend for '
'device owner [%(dev_own)s] and port %(pid)s',
{'dev_own': owner, 'pid': original_port['id']})
# update port security in DB if changed
@@ -1990,8 +1990,8 @@ class NsxVPluginV2(addr_pair_db.AllowedAddressPairsMixin,
original_port['network_id'],
vnic_id)
except Exception as e:
LOG.error(_LE('Could not delete the spoofguard '
'policy. Exception %s'), e)
LOG.error('Could not delete the spoofguard '
'policy. Exception %s', e)
# remove vm from the exclusion list when it is detached
# from the device if it has no port security
if not original_port[psec.PORTSECURITY]:
@@ -2030,8 +2030,8 @@ class NsxVPluginV2(addr_pair_db.AllowedAddressPairsMixin,
context.session, original_port['network_id'],
vnic_id)
except Exception as e:
LOG.error(_LE('Could not delete the spoofguard '
'policy. Exception %s'), e)
LOG.error('Could not delete the spoofguard '
'policy. Exception %s', e)
# Add vm to the exclusion list, since it has no port
# security now
self._add_vm_to_exclude_list(context, device_id, id)
@@ -2049,11 +2049,11 @@ class NsxVPluginV2(addr_pair_db.AllowedAddressPairsMixin,
self._update_vnic_assigned_addresses(
context.session, ret_port, vnic_id)
if not has_port_security and has_security_groups:
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 "),
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 ",
{'id': id,
'device_id': original_port['device_id']})
if (delete_security_groups
@@ -2131,8 +2131,8 @@ class NsxVPluginV2(addr_pair_db.AllowedAddressPairsMixin,
context.session, neutron_db_port['network_id'],
vnic_id)
except Exception as e:
LOG.error(_LE('Could not delete the spoofguard policy. '
'Exception %s'), e)
LOG.error('Could not delete the spoofguard policy. '
'Exception %s', e)
if (cfg.CONF.nsxv.spoofguard_enabled and
not neutron_db_port[psec.PORTSECURITY] and
@@ -2270,15 +2270,15 @@ class NsxVPluginV2(addr_pair_db.AllowedAddressPairsMixin,
s = self.create_subnet(context, item)
new_subnets.append(s)
except Exception as e:
LOG.error(_LE('Unable to create bulk subnets. Failed to '
'create item %(item)s. Rolling back. '
'Error: %(e)s'), {'item': item, 'e': e})
LOG.error('Unable to create bulk subnets. Failed to '
'create item %(item)s. Rolling back. '
'Error: %(e)s', {'item': item, 'e': e})
for subnet in new_subnets:
s_id = subnet['id']
try:
self.delete_subnet(context, s_id)
except Exception:
LOG.error(_LE('Unable to delete subnet %s'), s_id)
LOG.error('Unable to delete subnet %s', s_id)
raise
return new_subnets
@@ -2455,7 +2455,7 @@ class NsxVPluginV2(addr_pair_db.AllowedAddressPairsMixin,
if vdr_dhcp_binding:
pass
else:
LOG.error(_LE('VDR DHCP binding not found for router %s'),
LOG.error('VDR DHCP binding not found for router %s',
vdr_id)
sids = self.get_subnets(context,
filters={'network_id': [network_id],
@@ -2629,7 +2629,7 @@ class NsxVPluginV2(addr_pair_db.AllowedAddressPairsMixin,
except Exception:
with excutils.save_and_reraise_exception():
LOG.exception(_LE("Failed to update DHCP for subnet %s"),
LOG.exception("Failed to update DHCP for subnet %s",
subnet['id'])
def setup_dhcp_edge_fw_rules(self, context, plugin, router_id):
@@ -2650,7 +2650,7 @@ class NsxVPluginV2(addr_pair_db.AllowedAddressPairsMixin,
except Exception as e:
LOG.error(
_LE('Could not find ICMP Echo application. Exception %s'),
'Could not find ICMP Echo application. Exception %s',
e)
else:
# For newer versions, we can use the raw icmp rule
@@ -2671,7 +2671,7 @@ class NsxVPluginV2(addr_pair_db.AllowedAddressPairsMixin,
# On failure, log that we couldn't configure the firewall on the
# Edge appliance. This won't break the DHCP functionality
LOG.error(
_LE('Could not set up DHCP Edge firewall. Exception %s'), e)
'Could not set up DHCP Edge firewall. Exception %s', e)
def _create_network_dhcp_address_group(self, context, network_id):
"""Create dhcp address group for subnets attached to the network."""
@@ -2778,14 +2778,14 @@ class NsxVPluginV2(addr_pair_db.AllowedAddressPairsMixin,
try:
metainfo = jsonutils.loads(metainfo_string)
if not isinstance(metainfo, dict):
LOG.warning(_LW("Skipping router flavor %(flavor)s metainfo "
"[%(metainfo)s]: expected a dictionary"),
LOG.warning("Skipping router flavor %(flavor)s metainfo "
"[%(metainfo)s]: expected a dictionary",
{'flavor': flavor_id,
'metainfo': metainfo_string})
metainfo = {}
except ValueError as e:
LOG.warning(_LW("Error reading router flavor %(flavor)s metainfo "
"[%(metainfo)s]: %(error)s"),
LOG.warning("Error reading router flavor %(flavor)s metainfo "
"[%(metainfo)s]: %(error)s",
{'flavor': flavor_id,
'metainfo': metainfo_string,
'error': e})
@@ -2836,8 +2836,8 @@ class NsxVPluginV2(addr_pair_db.AllowedAddressPairsMixin,
elif k in future_use_keys:
pass
else:
LOG.warning(_LW("Skipping router flavor metainfo [%(k)s:%(v)s]"
":unsupported field"),
LOG.warning("Skipping router flavor metainfo [%(k)s:%(v)s]"
":unsupported field",
{'k': k, 'v': v})
def _process_extra_attr_router_create(self, context, router_db, r):
@@ -3049,7 +3049,7 @@ class NsxVPluginV2(addr_pair_db.AllowedAddressPairsMixin,
if binding:
router[ROUTER_SIZE] = binding.get("appliance_size")
else:
LOG.error(_LE("No binding for router %s"), id)
LOG.error("No binding for router %s", id)
return router
def _get_external_attachment_info(self, context, router):
@@ -3157,16 +3157,16 @@ class NsxVPluginV2(addr_pair_db.AllowedAddressPairsMixin,
is_routes_update=is_routes_update)
except n_exc.IpAddressGenerationFailure:
del info['external_fixed_ips']
LOG.warning(_LW("Cannot get one subnet with gateway "
"to allocate one available gw ip"))
LOG.warning("Cannot get one subnet with gateway "
"to allocate one available gw ip")
router_driver._update_router_gw_info(
context, router_id, info,
is_routes_update=is_routes_update,
force_update=force_update)
except vsh_exc.VcnsApiException:
with excutils.save_and_reraise_exception():
LOG.error(_LE("Failed to update gw_info %(info)s on "
"router %(router_id)s"),
LOG.error("Failed to update gw_info %(info)s on "
"router %(router_id)s",
{'info': str(info),
'router_id': router_id})
router_driver._update_router_gw_info(
@@ -3338,8 +3338,8 @@ class NsxVPluginV2(addr_pair_db.AllowedAddressPairsMixin,
context, router_id, interface_info)
except vsh_exc.VcnsApiException:
with excutils.save_and_reraise_exception():
LOG.error(_LE("Failed to add interface_info %(info)s on "
"router %(router_id)s"),
LOG.error("Failed to add interface_info %(info)s on "
"router %(router_id)s",
{'info': str(interface_info),
'router_id': router_id})
router_driver.remove_router_interface(
@@ -3389,7 +3389,7 @@ class NsxVPluginV2(addr_pair_db.AllowedAddressPairsMixin,
self._update_edge_router(context, router_id)
except Exception:
with excutils.save_and_reraise_exception():
LOG.exception(_LE("Failed to update edge router"))
LOG.exception("Failed to update edge router")
super(NsxVPluginV2, self).delete_floatingip(context,
fip_db['id'])
self._set_floatingip_status(context, fip_db)
@@ -3411,7 +3411,7 @@ class NsxVPluginV2(addr_pair_db.AllowedAddressPairsMixin,
self._update_edge_router(context, router_id)
except Exception:
with excutils.save_and_reraise_exception():
LOG.exception(_LE("Failed to update edge router"))
LOG.exception("Failed to update edge router")
super(NsxVPluginV2, self).update_floatingip(
context, id, {'floatingip': {'port_id': old_port_id}})
self._set_floatingip_status(context, fip_db)
@@ -3498,7 +3498,7 @@ class NsxVPluginV2(addr_pair_db.AllowedAddressPairsMixin,
edge_utils.update_firewall(self.nsx_v, context, router_id, fake_fw,
allow_external=allow_external)
except vsh_exc.ResourceNotFound:
LOG.error(_LE("Failed to update firewall for router %s"),
LOG.error("Failed to update firewall for router %s",
router_id)
def _delete_nsx_security_group(self, nsx_sg_id, nsx_policy):
@@ -3513,8 +3513,8 @@ class NsxVPluginV2(addr_pair_db.AllowedAddressPairsMixin,
self.nsx_sg_utils.del_nsx_security_group_from_policy(
nsx_policy, nsx_sg_id)
except Exception as e:
LOG.warning(_LW("Failed to remove nsx security group "
"%(id)s from policy %(pol)s : %(e)s"),
LOG.warning("Failed to remove nsx security group "
"%(id)s from policy %(pol)s : %(e)s",
{'id': nsx_sg_id, 'pol': nsx_policy, 'e': e})
self.nsx_v.vcns.delete_security_group(nsx_sg_id)
@@ -3699,7 +3699,7 @@ class NsxVPluginV2(addr_pair_db.AllowedAddressPairsMixin,
if default_sg:
context = context.elevated()
super(NsxVPluginV2, self).delete_security_group(context, sg_id)
LOG.exception(_LE('Failed to create security group'))
LOG.exception('Failed to create security group')
return new_sg
@@ -3818,7 +3818,7 @@ class NsxVPluginV2(addr_pair_db.AllowedAddressPairsMixin,
except Exception:
with excutils.save_and_reraise_exception():
LOG.exception(_LE("Failed to delete security group"))
LOG.exception("Failed to delete security group")
def _create_nsx_rule(self, context, rule,
nsx_sg_id=None, logged=False, action='allow'):
@@ -3962,7 +3962,7 @@ class NsxVPluginV2(addr_pair_db.AllowedAddressPairsMixin,
if p['neutron_id'] in ruleids]:
self.nsx_v.vcns.remove_rule_from_section(
section_uri, nsx_rule_id)
LOG.exception(_LE("Failed to create security group rule"))
LOG.exception("Failed to create security group rule")
return new_rule_list
def delete_security_group_rule(self, context, id):
@@ -4019,13 +4019,13 @@ class NsxVPluginV2(addr_pair_db.AllowedAddressPairsMixin,
try:
self.nsx_v.vcns.edges_lock_operation()
except Exception:
LOG.info(_LI("Unable to set manager lock operation"))
LOG.info("Unable to set manager lock operation")
def _aggregate_publishing(self):
try:
self.nsx_v.vcns.configure_aggregate_publishing()
except Exception:
LOG.info(_LI("Unable to configure aggregate publishing"))
LOG.info("Unable to configure aggregate publishing")
def _configure_reservations(self):
ver = self.nsx_v.vcns.get_version()
@@ -4036,7 +4036,7 @@ class NsxVPluginV2(addr_pair_db.AllowedAddressPairsMixin,
try:
self.nsx_v.vcns.configure_reservations()
except Exception:
LOG.info(_LI("Unable to configure edge reservations"))
LOG.info("Unable to configure edge reservations")
def _validate_config(self):
if (cfg.CONF.nsxv.dvs_id and
@@ -4071,7 +4071,7 @@ class NsxVPluginV2(addr_pair_db.AllowedAddressPairsMixin,
ver = self.nsx_v.vcns.get_version()
if version.LooseVersion(ver) < version.LooseVersion('6.2.0'):
LOG.warning(_LW("Skipping validations. Not supported by version."))
LOG.warning("Skipping validations. Not supported by version.")
return
# Validate the host_groups for each AZ

View File

@@ -23,7 +23,7 @@ from oslo_serialization import jsonutils
from oslo_utils import excutils
from sqlalchemy.orm import exc as sa_exc
from vmware_nsx._i18n import _, _LE, _LI, _LW
from vmware_nsx._i18n import _
from vmware_nsx.common import exceptions as nsxv_exc
from vmware_nsx.common import nsxv_constants
from vmware_nsx.common import utils
@@ -248,8 +248,8 @@ class EdgeApplianceDriver(object):
status_level = self._edge_status_to_level(
response['edgeStatus'])
except exceptions.VcnsApiException as e:
LOG.error(_LE("VCNS: Failed to get edge %(edge_id)s status: "
"Reason: %(reason)s"),
LOG.error("VCNS: Failed to get edge %(edge_id)s status: "
"Reason: %(reason)s",
{'edge_id': edge_id, 'reason': e.response})
status_level = constants.RouterStatus.ROUTER_STATUS_ERROR
try:
@@ -258,7 +258,7 @@ class EdgeApplianceDriver(object):
constants.VCNS_ERROR_CODE_EDGE_NOT_RUNNING):
status_level = constants.RouterStatus.ROUTER_STATUS_DOWN
except ValueError:
LOG.error(_LE('Error code not present. %s'), e.response)
LOG.error('Error code not present. %s', e.response)
return status_level
@@ -278,7 +278,7 @@ class EdgeApplianceDriver(object):
return self.vcns.query_interface(edge_id, vnic_index)
except exceptions.VcnsApiException:
with excutils.save_and_reraise_exception():
LOG.exception(_LE("NSXv: Failed to query vnic %s"), vnic_index)
LOG.exception("NSXv: Failed to query vnic %s", vnic_index)
def update_interface(self, router_id, edge_id, index, network,
tunnel_index=-1, address=None, netmask=None,
@@ -338,8 +338,8 @@ class EdgeApplianceDriver(object):
edge_id, index, interface_req)
except exceptions.VcnsApiException:
with excutils.save_and_reraise_exception():
LOG.exception(_LE("Failed to update vdr interface on edge: "
"%s"), edge_id)
LOG.exception("Failed to update vdr interface on edge: "
"%s", edge_id)
def delete_vdr_internal_interface(self, edge_id, interface_index):
LOG.debug("Delete VDR interface on edge: %s", edge_id)
@@ -348,8 +348,8 @@ class EdgeApplianceDriver(object):
edge_id, interface_index)
except exceptions.VcnsApiException:
with excutils.save_and_reraise_exception():
LOG.exception(_LE("Failed to delete vdr interface on edge: "
"%s"),
LOG.exception("Failed to delete vdr interface on edge: "
"%s",
edge_id)
def delete_interface(self, router_id, edge_id, index):
@@ -358,14 +358,14 @@ class EdgeApplianceDriver(object):
try:
self.vcns.delete_interface(edge_id, index)
except exceptions.ResourceNotFound:
LOG.error(_LE('Failed to delete vnic %(vnic_index)s on edge '
'%(edge_id)s: edge was not found'),
LOG.error('Failed to delete vnic %(vnic_index)s on edge '
'%(edge_id)s: edge was not found',
{'vnic_index': index,
'edge_id': edge_id})
except exceptions.VcnsApiException:
with excutils.save_and_reraise_exception():
LOG.exception(_LE("Failed to delete vnic %(vnic_index)s: "
"on edge %(edge_id)s"),
LOG.exception("Failed to delete vnic %(vnic_index)s: "
"on edge %(edge_id)s",
{'vnic_index': index,
'edge_id': edge_id})
@@ -376,7 +376,7 @@ class EdgeApplianceDriver(object):
try:
return self.vcns.get_edges()[1]
except exceptions.VcnsApiException as e:
LOG.exception(_LE("VCNS: Failed to get edges:\n%s"), e.response)
LOG.exception("VCNS: Failed to get edges:\n%s", e.response)
raise e
def deploy_edge(self, context, router_id, name, internal_network,
@@ -450,7 +450,7 @@ class EdgeApplianceDriver(object):
self.callbacks.complete_edge_creation(
context, edge_id, name, router_id, dist, False)
with excutils.save_and_reraise_exception():
LOG.exception(_LE("NSXv: deploy edge failed."))
LOG.exception("NSXv: deploy edge failed.")
return edge_id
def update_edge(self, context, router_id, edge_id, name, internal_network,
@@ -494,7 +494,7 @@ class EdgeApplianceDriver(object):
self.callbacks.complete_edge_update(
context, edge_id, router_id, True, set_errors)
except exceptions.VcnsApiException as e:
LOG.error(_LE("Failed to update edge: %s"),
LOG.error("Failed to update edge: %s",
e.response)
self.callbacks.complete_edge_update(
context, edge_id, router_id, False, set_errors)
@@ -518,7 +518,7 @@ class EdgeApplianceDriver(object):
# update the edge
self.vcns.update_edge(edge_id, edge)
except exceptions.VcnsApiException as e:
LOG.error(_LE("Failed to rename edge: %s"),
LOG.error("Failed to rename edge: %s",
e.response)
def resize_edge(self, edge_id, size):
@@ -542,7 +542,7 @@ class EdgeApplianceDriver(object):
# update the edge
self.vcns.update_edge(edge_id, edge)
except exceptions.VcnsApiException as e:
LOG.error(_LE("Failed to resize edge: %s"), e.response)
LOG.error("Failed to resize edge: %s", e.response)
def delete_edge(self, context, router_id, edge_id, dist=False):
try:
@@ -550,7 +550,7 @@ class EdgeApplianceDriver(object):
if not dist:
nsxv_db.clean_edge_vnic_binding(context.session, edge_id)
except sa_exc.NoResultFound:
LOG.warning(_LW("Router Binding for %s not found"), router_id)
LOG.warning("Router Binding for %s not found", router_id)
if edge_id:
try:
@@ -559,12 +559,12 @@ class EdgeApplianceDriver(object):
except exceptions.ResourceNotFound:
return True
except exceptions.VcnsApiException as e:
LOG.exception(_LE("VCNS: Failed to delete %(edge_id)s:\n"
"%(response)s"),
LOG.exception("VCNS: Failed to delete %(edge_id)s:\n"
"%(response)s",
{'edge_id': edge_id, 'response': e.response})
return False
except Exception:
LOG.exception(_LE("VCNS: Failed to delete %s"), edge_id)
LOG.exception("VCNS: Failed to delete %s", edge_id)
return False
def _assemble_nat_rule(self, action, original_address,
@@ -591,7 +591,7 @@ class EdgeApplianceDriver(object):
try:
return self.vcns.get_nat_config(edge_id)[1]
except exceptions.VcnsApiException as e:
LOG.exception(_LE("VCNS: Failed to get nat config:\n%s"),
LOG.exception("VCNS: Failed to get nat config:\n%s",
e.response)
raise e
@@ -658,7 +658,7 @@ class EdgeApplianceDriver(object):
self.vcns.update_nat_config(edge_id, nat)
return True
except exceptions.VcnsApiException as e:
LOG.exception(_LE("VCNS: Failed to create snat rule:\n%s"),
LOG.exception("VCNS: Failed to create snat rule:\n%s",
e.response)
return False
@@ -696,7 +696,7 @@ class EdgeApplianceDriver(object):
self.vcns.update_routes(edge_id, request)
return True
except exceptions.VcnsApiException as e:
LOG.exception(_LE("VCNS: Failed to update routes:\n%s"),
LOG.exception("VCNS: Failed to update routes:\n%s",
e.response)
return False
@@ -726,7 +726,7 @@ class EdgeApplianceDriver(object):
edge_id)
except exceptions.VcnsApiException:
with excutils.save_and_reraise_exception():
LOG.exception(_LE("Failed to get service config"))
LOG.exception("Failed to get service config")
return response
def enable_service_loadbalancer(self, edge_id):
@@ -738,8 +738,8 @@ class EdgeApplianceDriver(object):
self.vcns.enable_service_loadbalancer(edge_id, config)
except exceptions.VcnsApiException:
with excutils.save_and_reraise_exception():
LOG.exception(_LE("Failed to enable loadbalancer "
"service config"))
LOG.exception("Failed to enable loadbalancer "
"service config")
def _delete_port_group(self, task):
try:
@@ -747,7 +747,7 @@ class EdgeApplianceDriver(object):
task.userdata['dvs_id'],
task.userdata['port_group_id'])
except Exception as e:
LOG.error(_LE('Unable to delete %(pg)s exception %(ex)s'),
LOG.error('Unable to delete %(pg)s exception %(ex)s',
{'pg': task.userdata['port_group_id'],
'ex': e})
return task_constants.TaskStatus.ERROR
@@ -770,14 +770,14 @@ class EdgeApplianceDriver(object):
retry_number += 1
if retry_number > max_retries:
with excutils.save_and_reraise_exception():
LOG.exception(_LE("Failed to %s"), task.name)
LOG.exception("Failed to %s", task.name)
else:
task.userdata['retry_number'] = retry_number
# Sleep twice as long as the previous retry
tts = (2 ** (retry_number - 1)) * delay
time.sleep(min(tts, 60))
return task_constants.TaskStatus.PENDING
LOG.info(_LI("Task %(name)s completed."), {'name': task.name})
LOG.info("Task %(name)s completed.", {'name': task.name})
return task_constants.TaskStatus.COMPLETED
def delete_port_group(self, dvs_id, port_group_id):
@@ -807,14 +807,14 @@ class EdgeApplianceDriver(object):
self.vcns.create_bridge(device_name, bridge)
except exceptions.VcnsApiException:
with excutils.save_and_reraise_exception():
LOG.exception(_LE("Failed to create bridge in the %s"),
LOG.exception("Failed to create bridge in the %s",
device_name)
def delete_bridge(self, device_name):
try:
self.vcns.delete_bridge(device_name)
except exceptions.VcnsApiException:
LOG.exception(_LE("Failed to delete bridge in the %s"),
LOG.exception("Failed to delete bridge in the %s",
device_name)
def update_edge_ha(self, edge_id):
@@ -825,19 +825,19 @@ class EdgeApplianceDriver(object):
def update_edge_syslog(self, edge_id, syslog_config, router_id):
if 'server_ip' not in syslog_config:
LOG.warning(_LW("Server IP missing in syslog config for %s"),
LOG.warning("Server IP missing in syslog config for %s",
router_id)
return
protocol = syslog_config.get('protocol', 'tcp')
if protocol not in ['tcp', 'udp']:
LOG.warning(_LW("Invalid protocol in syslog config for %s"),
LOG.warning("Invalid protocol in syslog config for %s",
router_id)
return
loglevel = syslog_config.get('log_level')
if loglevel and loglevel not in edge_utils.SUPPORTED_EDGE_LOG_LEVELS:
LOG.warning(_LW("Invalid loglevel in syslog config for %s"),
LOG.warning("Invalid loglevel in syslog config for %s",
router_id)
return

View File

@@ -15,7 +15,7 @@
from oslo_log import log as logging
from oslo_utils import excutils
from vmware_nsx._i18n import _, _LE
from vmware_nsx._i18n import _
from vmware_nsx.common import exceptions as nsx_exc
from vmware_nsx.db import nsxv_db
from vmware_nsx.plugins.nsx_v.vshield.common import (
@@ -224,8 +224,8 @@ class EdgeFirewallDriver(object):
try:
return self.vcns.get_firewall(edge_id)[1]
except vcns_exc.VcnsApiException as e:
LOG.exception(_LE("Failed to get firewall with edge "
"id: %s"), edge_id)
LOG.exception("Failed to get firewall with edge "
"id: %s", edge_id)
raise e
def _get_firewall_rule_next(self, context, edge_id, rule_vseid):
@@ -252,8 +252,8 @@ class EdgeFirewallDriver(object):
response = self.vcns.get_firewall_rule(
edge_id, vcns_rule_id)[1]
except vcns_exc.VcnsApiException as e:
LOG.exception(_LE("Failed to get firewall rule: %(rule_id)s "
"with edge_id: %(edge_id)s"), {
LOG.exception("Failed to get firewall rule: %(rule_id)s "
"with edge_id: %(edge_id)s", {
'rule_id': id,
'edge_id': edge_id})
raise e
@@ -267,8 +267,8 @@ class EdgeFirewallDriver(object):
try:
self.vcns.delete_firewall(edge_id)
except vcns_exc.VcnsApiException as e:
LOG.exception(_LE("Failed to delete firewall "
"with edge_id:%s"), edge_id)
LOG.exception("Failed to delete firewall "
"with edge_id:%s", edge_id)
raise e
nsxv_db.cleanup_nsxv_edge_firewallrule_binding(
context.session, edge_id)
@@ -282,9 +282,9 @@ class EdgeFirewallDriver(object):
self.vcns.update_firewall_rule(edge_id, vcns_rule_id, fwr_req)
except vcns_exc.VcnsApiException:
with excutils.save_and_reraise_exception():
LOG.exception(_LE("Failed to update firewall rule: "
"%(rule_id)s "
"with edge_id: %(edge_id)s"),
LOG.exception("Failed to update firewall rule: "
"%(rule_id)s "
"with edge_id: %(edge_id)s",
{'rule_id': id,
'edge_id': edge_id})
@@ -296,9 +296,9 @@ class EdgeFirewallDriver(object):
self.vcns.delete_firewall_rule(edge_id, vcns_rule_id)
except vcns_exc.VcnsApiException:
with excutils.save_and_reraise_exception():
LOG.exception(_LE("Failed to delete firewall rule: "
"%(rule_id)s "
"with edge_id: %(edge_id)s"),
LOG.exception("Failed to delete firewall rule: "
"%(rule_id)s "
"with edge_id: %(edge_id)s",
{'rule_id': id,
'edge_id': edge_id})
nsxv_db.delete_nsxv_edge_firewallrule_binding(
@@ -314,8 +314,8 @@ class EdgeFirewallDriver(object):
edge_id, ref_vcns_rule_id, fwr_req)[0]
except vcns_exc.VcnsApiException:
with excutils.save_and_reraise_exception():
LOG.exception(_LE("Failed to add firewall rule above: "
"%(rule_id)s with edge_id: %(edge_id)s"),
LOG.exception("Failed to add firewall rule above: "
"%(rule_id)s with edge_id: %(edge_id)s",
{'rule_id': ref_vcns_rule_id,
'edge_id': edge_id})
@@ -342,8 +342,8 @@ class EdgeFirewallDriver(object):
edge_id, int(ref_vcns_rule_id), fwr_req)[0]
except vcns_exc.VcnsApiException:
with excutils.save_and_reraise_exception():
LOG.exception(_LE("Failed to add firewall rule above: "
"%(rule_id)s with edge_id: %(edge_id)s"),
LOG.exception("Failed to add firewall rule above: "
"%(rule_id)s with edge_id: %(edge_id)s",
{'rule_id': ref_vcns_rule_id,
'edge_id': edge_id})
else:
@@ -353,8 +353,8 @@ class EdgeFirewallDriver(object):
edge_id, fwr_req)[0]
except vcns_exc.VcnsApiException:
with excutils.save_and_reraise_exception():
LOG.exception(_LE("Failed to append a firewall rule"
"with edge_id: %s"), edge_id)
LOG.exception("Failed to append a firewall rule"
"with edge_id: %s", edge_id)
objuri = header['location']
fwr_vseid = objuri[objuri.rfind("/") + 1:]
@@ -386,8 +386,8 @@ class EdgeFirewallDriver(object):
self.vcns.update_firewall(edge_id, config)
except vcns_exc.VcnsApiException:
with excutils.save_and_reraise_exception():
LOG.exception(_LE("Failed to update firewall "
"with edge_id: %s"), edge_id)
LOG.exception("Failed to update firewall "
"with edge_id: %s", edge_id)
vcns_fw_config = self._get_firewall(edge_id)
nsxv_db.cleanup_nsxv_edge_firewallrule_binding(

View File

@@ -15,7 +15,7 @@
from oslo_log import log as logging
from oslo_utils import excutils
from vmware_nsx._i18n import _, _LE, _LW
from vmware_nsx._i18n import _
from vmware_nsx.plugins.nsx_v.vshield.common import (
exceptions as vcns_exc)
@@ -63,9 +63,9 @@ class EdgeIPsecVpnDriver(object):
ikepolicy['encryption_algorithm'] != ipsecpolicy[
'encryption_algorithm'] or
ikepolicy['pfs'] != ipsecpolicy['pfs']):
LOG.warning(_LW(
LOG.warning(
"IKEPolicy and IPsecPolicy should have consistent "
"auth_algorithm, encryption_algorithm and pfs for VSE!"))
"auth_algorithm, encryption_algorithm and pfs for VSE!")
# Check whether encryption_algorithm is allowed.
encryption_algorithm = ENCRYPTION_ALGORITHM_MAP.get(
@@ -135,19 +135,19 @@ class EdgeIPsecVpnDriver(object):
self.vcns.update_ipsec_config(edge_id, ipsec_config)
except vcns_exc.VcnsApiException:
with excutils.save_and_reraise_exception():
LOG.exception(_LE("Failed to update ipsec vpn "
"configuration with edge_id: %s"),
LOG.exception("Failed to update ipsec vpn "
"configuration with edge_id: %s",
edge_id)
def delete_ipsec_config(self, edge_id):
try:
self.vcns.delete_ipsec_config(edge_id)
except vcns_exc.ResourceNotFound:
LOG.warning(_LW("IPsec config not found on edge: %s"), edge_id)
LOG.warning("IPsec config not found on edge: %s", edge_id)
except vcns_exc.VcnsApiException:
with excutils.save_and_reraise_exception():
LOG.exception(_LE("Failed to delete ipsec vpn configuration "
"with edge_id: %s"), edge_id)
LOG.exception("Failed to delete ipsec vpn configuration "
"with edge_id: %s", edge_id)
def get_ipsec_config(self, edge_id):
return self.vcns.get_ipsec_config(edge_id)

View File

@@ -38,7 +38,7 @@ from neutron.plugins.common import constants as plugin_const
from neutron_lib.api import validators
from neutron_lib import exceptions as n_exc
from vmware_nsx._i18n import _, _LE, _LI, _LW
from vmware_nsx._i18n import _
from vmware_nsx.common import config as conf
from vmware_nsx.common import exceptions as nsx_exc
from vmware_nsx.common import locking
@@ -218,9 +218,9 @@ class EdgeManager(object):
if version.LooseVersion(ver) >= version.LooseVersion('6.2.3'):
self.is_dhcp_opt_enabled = True
elif cfg.CONF.nsxv.dhcp_force_metadata:
LOG.warning(_LW("Skipping dhcp_force_metadata param since dhcp "
"option feature can only be supported at version "
"6.2.3 or higher"))
LOG.warning("Skipping dhcp_force_metadata param since dhcp "
"option feature can only be supported at version "
"6.2.3 or higher")
self.is_dhcp_opt_enabled = False
def _get_per_edge_rp_filter_state(self):
@@ -235,9 +235,9 @@ class EdgeManager(object):
context.session, edge_id):
if binding['status'] == plugin_const.ERROR:
continue
LOG.error(_LE('Mark router binding ERROR for resource '
'%(res_id)s on edge %(edge_id)s due to '
'%(reason)s'),
LOG.error('Mark router binding ERROR for resource '
'%(res_id)s on edge %(edge_id)s due to '
'%(reason)s',
{'res_id': binding['router_id'],
'edge_id': edge_id,
'reason': error_reason})
@@ -297,8 +297,8 @@ class EdgeManager(object):
def _delete_edge(self, context, router_binding):
if router_binding['status'] == plugin_const.ERROR:
LOG.warning(_LW("Start deleting %(router_id)s corresponding"
"edge: %(edge_id)s due to status error"),
LOG.warning("Start deleting %(router_id)s corresponding "
"edge: %(edge_id)s due to status error",
{'router_id': router_binding['router_id'],
'edge_id': router_binding['edge_id']})
nsxv_db.update_nsxv_router_binding(
@@ -539,9 +539,9 @@ class EdgeManager(object):
else:
self.nsxv_manager.vcns.update_interface(edge_id, vnic_config)
except nsxapi_exc.VcnsApiException:
LOG.exception(_LE('Failed to delete vnic %(vnic_index)d '
'tunnel %(tunnel_index)d on edge %(edge_id)s '
'for network %(net_id)s'),
LOG.exception('Failed to delete vnic %(vnic_index)d '
'tunnel %(tunnel_index)d on edge %(edge_id)s '
'for network %(net_id)s',
{'vnic_index': vnic_index,
'tunnel_index': tunnel_index,
'net_id': network_id,
@@ -610,8 +610,8 @@ class EdgeManager(object):
net_ids = nsx_db.get_net_ids(context.session, ls_id)
if net_ids:
# Here should never happen, else one bug occurs
LOG.error(_LE("net %(id)s on edge %(edge_id)s "
"overlaps with new net %(net_id)s"),
LOG.error("net %(id)s on edge %(edge_id)s "
"overlaps with new net %(net_id)s",
{'id': net_ids[0],
'edge_id': edge_id,
'net_id': network_id})
@@ -621,10 +621,10 @@ class EdgeManager(object):
else:
# Occurs when there are DB inconsistency
sb["is_overlapped"] = True
LOG.error(_LE("unexpected sub intf %(id)s on edge "
"%(edge_id)s overlaps with new net "
"%(net_id)s. we would update with "
"deleting it for DB consistency"),
LOG.error("unexpected sub intf %(id)s on edge "
"%(edge_id)s overlaps with new net "
"%(net_id)s. we would update with "
"deleting it for DB consistency",
{'id': ls_id,
'edge_id': edge_id,
'net_id': network_id})
@@ -725,7 +725,7 @@ class EdgeManager(object):
try:
self.nsxv_manager.rename_edge(edge_id, name)
except nsxapi_exc.VcnsApiException as e:
LOG.error(_LE("Failed to update edge: %s"),
LOG.error("Failed to update edge: %s",
e.response)
self.nsxv_manager.callbacks.complete_edge_update(
context, edge_id, resource_id, False, set_errors=True)
@@ -748,8 +748,8 @@ class EdgeManager(object):
"""Try to collect one edge to pool."""
binding = nsxv_db.get_nsxv_router_binding(context.session, router_id)
if not binding:
LOG.warning(_LW("router binding for router: %s "
"not found"), router_id)
LOG.warning("router binding for router: %s "
"not found", router_id)
return
dist = (binding['edge_type'] == nsxv_constants.VDR_EDGE)
edge_id = binding['edge_id']
@@ -893,8 +893,8 @@ class EdgeManager(object):
def rename_lrouter(self, context, router_id, new_name):
binding = nsxv_db.get_nsxv_router_binding(context.session, router_id)
if not binding or not binding['edge_id']:
LOG.warning(_LW("router binding for router: %s "
"not found"), router_id)
LOG.warning("router binding for router: %s "
"not found", router_id)
return
edge_id = binding['edge_id']
with locking.LockManager.get_lock(str(edge_id)):
@@ -905,8 +905,8 @@ class EdgeManager(object):
# get the router edge-id
binding = nsxv_db.get_nsxv_router_binding(context.session, router_id)
if not binding or not binding['edge_id']:
LOG.warning(_LW("router binding for router: %s "
"not found"), router_id)
LOG.warning("router binding for router: %s "
"not found", router_id)
return
edge_id = binding['edge_id']
with locking.LockManager.get_lock(str(edge_id)):
@@ -1041,8 +1041,8 @@ class EdgeManager(object):
'169.254.169.254/32',
dhcp_ip)
else:
LOG.error(_LE("Failed to find the dhcp port on subnet "
"%s to do metadata host route insertion"),
LOG.error("Failed to find the dhcp port on subnet "
"%s to do metadata host route insertion",
subnet_id)
def update_dhcp_service_config(self, context, edge_id):
@@ -1096,8 +1096,8 @@ class EdgeManager(object):
if not self.check_edge_active_at_backend(new_id):
# Remove edge_id from available edges pool.
available_edge_ids.remove(new_id)
LOG.warning(_LW("Skipping edge: %s due to inactive status on "
"the backend."), new_id)
LOG.warning("Skipping edge: %s due to inactive status on "
"the backend.", new_id)
else:
return new_id
@@ -1159,8 +1159,8 @@ class EdgeManager(object):
old_binding = nsxv_db.get_edge_vnic_binding(
context.session, edge_id, network_id)
if not old_binding:
LOG.error(_LE("Remove network %(id)s failed since no binding "
"found on edge %(edge_id)s"),
LOG.error("Remove network %(id)s failed since no binding "
"found on edge %(edge_id)s",
{'id': network_id,
'edge_id': edge_id})
self._delete_dhcp_router_binding(context, network_id, edge_id)
@@ -1176,8 +1176,8 @@ class EdgeManager(object):
self.update_dhcp_service_config(context, edge_id)
except nsxapi_exc.VcnsApiException:
LOG.exception(_LE('Failed to delete vnic %(vnic_index)d '
'tunnel %(tunnel_index)d on edge %(edge_id)s'),
LOG.exception('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})
@@ -1185,8 +1185,8 @@ class EdgeManager(object):
context, edge_id,
error_reason="remove network from dhcp edge failure")
except Exception:
LOG.exception(_LE('Failed to delete vnic %(vnic_index)d '
'tunnel %(tunnel_index)d on edge %(edge_id)s'),
LOG.exception('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})
@@ -1339,7 +1339,7 @@ class EdgeManager(object):
edge_binding = nsxv_db.get_nsxv_router_binding(context.session,
resource_id)
if not edge_binding:
LOG.warning(_LW('Edge binding does not exist for network %s'),
LOG.warning('Edge binding does not exist for network %s',
network_id)
return
dhcp_binding = nsxv_db.get_edge_vnic_binding(context.session,
@@ -1368,9 +1368,9 @@ class EdgeManager(object):
except nsxapi_exc.VcnsApiException:
with excutils.save_and_reraise_exception():
LOG.exception(
_LE('Failed to update the dhcp service for '
'%(edge_id)s on vnic %(vnic_index)d '
'tunnel %(tunnel_index)d'),
'Failed to update the dhcp service for '
'%(edge_id)s on vnic %(vnic_index)d '
'tunnel %(tunnel_index)d',
{'edge_id': edge_id,
'vnic_index': vnic_index,
'tunnel_index': tunnel_index})
@@ -1380,9 +1380,9 @@ class EdgeManager(object):
except Exception:
with excutils.save_and_reraise_exception():
LOG.exception(
_LE('Failed to update the dhcp service for '
'%(edge_id)s on vnic %(vnic_index)d '
'tunnel %(tunnel_index)d'),
'Failed to update the dhcp service for '
'%(edge_id)s on vnic %(vnic_index)d '
'tunnel %(tunnel_index)d',
{'edge_id': edge_id,
'vnic_index': vnic_index,
'tunnel_index': tunnel_index})
@@ -1413,10 +1413,10 @@ class EdgeManager(object):
network_id)
except Exception:
with excutils.save_and_reraise_exception():
LOG.exception(_LE('Failed to delete the tunnel '
'%(tunnel_index)d on vnic '
'%(vnic_index)d'
'from DHCP Edge %(edge_id)s'),
LOG.exception('Failed to delete the tunnel '
'%(tunnel_index)d on vnic '
'%(vnic_index)d'
'from DHCP Edge %(edge_id)s',
{'tunnel_index': tunnel_index,
'vnic_index': vnic_index,
'edge_id': edge_id})
@@ -1470,13 +1470,13 @@ class EdgeManager(object):
except db_exc.DBDuplicateEntry as e:
# Could have garbage binding in the DB - warn and overwrite
if 'PRIMARY' in e.columns:
LOG.warning(_LW('Conflict found in VDR DHCP bindings - '
'router %s was already bound'),
LOG.warning('Conflict found in VDR DHCP bindings - '
'router %s was already bound',
vdr_router_id)
del_vdr = vdr_router_id
else:
LOG.warning(_LW('Conflict found in VDR DHCP bindings - '
'DHCP edge %s was already bound'),
LOG.warning('Conflict found in VDR DHCP bindings - '
'DHCP edge %s was already bound',
dhcp_edge_id)
bind = nsxv_db.get_vdr_dhcp_binding_by_edge(
context.session, dhcp_edge_id)
@@ -1491,8 +1491,8 @@ class EdgeManager(object):
nsxv_db.add_vdr_dhcp_binding(context.session,
vdr_router_id, dhcp_edge_id)
else:
LOG.error(_LE('Database conflict could not be recovered '
'for VDR %(vdr)s DHCP edge %(dhcp)s'),
LOG.error('Database conflict could not be recovered '
'for VDR %(vdr)s DHCP edge %(dhcp)s',
{'vdr': vdr_router_id, 'dhcp': dhcp_edge_id})
address_groups = self.plugin._create_network_dhcp_address_group(
@@ -1735,14 +1735,14 @@ class EdgeManager(object):
context.session, plr_id)
if router_binding is None:
LOG.error(_LE("Router binding not found for router: %s"),
LOG.error("Router binding not found for router: %s",
router_id)
else:
plr_edge_id = router_binding.edge_id
vnic_binding = nsxv_db.get_edge_vnic_binding(
context.session, plr_edge_id, lswitch_id)
if vnic_binding is None:
LOG.error(_LE("Vnic binding not found for router: %s"),
LOG.error("Vnic binding not found for router: %s",
router_id)
else:
# Clear static routes before delete internal vnic
@@ -1764,7 +1764,7 @@ class EdgeManager(object):
tlr_vnic_binding = nsxv_db.get_edge_vnic_binding(
context.session, tlr_edge_id, lswitch_id)
if tlr_vnic_binding is None:
LOG.error(_LE("Vnic binding not found for router: %s"), router_id)
LOG.error("Vnic binding not found for router: %s", router_id)
else:
self.nsxv_manager.delete_vdr_internal_interface(
tlr_edge_id, tlr_vnic_binding.vnic_index)
@@ -1775,7 +1775,7 @@ class EdgeManager(object):
# Then delete the internal lswitch
self.nsxv_manager.delete_virtual_wire(lswitch_id)
except Exception:
LOG.warning(_LW("Failed to delete virtual wire: %s"), lswitch_id)
LOG.warning("Failed to delete virtual wire: %s", lswitch_id)
def get_routers_on_edge(self, context, edge_id):
router_ids = []
@@ -1793,8 +1793,8 @@ class EdgeManager(object):
valid_router_ids = [ele['id'] for ele in valid_router_ids]
if set(valid_router_ids) != set(router_ids):
LOG.error(_LE("Get invalid router bindings with "
"router ids: %s"),
LOG.error("Get invalid router bindings with "
"router ids: %s",
str(set(router_ids) - set(valid_router_ids)))
return valid_router_ids
@@ -1849,7 +1849,7 @@ class EdgeManager(object):
else:
# TODO(yangyu): Remove conflict_network_ids
LOG.warning(
_LW("Failed to query conflict_router_ids"))
"Failed to query conflict_router_ids")
if available_edge_id:
edge_binding = nsxv_db.get_nsxv_router_bindings_by_edge(
context.session, available_edge_id)[0]
@@ -1923,23 +1923,23 @@ class EdgeManager(object):
self.nsxv_manager.vcns.delete_dhcp_binding(
edge_id, dhcp_binding.binding_id)
else:
LOG.warning(_LW("Failed to find binding on edge "
"%(edge_id)s for port "
"%(port_id)s with %(binding_id)s"),
LOG.warning("Failed to find binding on edge "
"%(edge_id)s for port "
"%(port_id)s with %(binding_id)s",
{'edge_id': edge_id,
'port_id': port_id,
'binding_id': dhcp_binding.binding_id})
nsxv_db.delete_edge_dhcp_static_binding(
context.session, edge_id, mac_address)
else:
LOG.warning(_LW("Failed to find dhcp binding on edge "
"%(edge_id)s to DELETE for port "
"%(port_id)s"),
LOG.warning("Failed to find dhcp binding on edge "
"%(edge_id)s to DELETE for port "
"%(port_id)s",
{'edge_id': edge_id,
'port_id': port_id})
else:
LOG.warning(_LW("Failed to find edge_id to delete dhcp "
"binding for port %(port_id)s"),
LOG.warning("Failed to find edge_id to delete dhcp "
"binding for port %(port_id)s",
{'port_id': port_id})
@vcns.retry_upon_exception(nsxapi_exc.VcnsApiException, max_delay=10)
@@ -1993,8 +1993,8 @@ class EdgeManager(object):
self.plugin.get_port(context, port_id)
except n_exc.PortNotFound:
LOG.warning(
_LW("port %(port_id)s is deleted, so we would pass "
"creating dhcp binding on edge %(edge_id)s"),
"port %(port_id)s is deleted, so we would pass "
"creating dhcp binding on edge %(edge_id)s",
{'port_id': port_id,
'edge_id': edge_id})
return
@@ -2016,8 +2016,8 @@ class EdgeManager(object):
nsxv_db.delete_edge_dhcp_static_binding(
context.session, edge_id, mac_address)
else:
LOG.warning(_LW("Failed to create dhcp bindings since dhcp edge "
"for net %s not found at the backend"),
LOG.warning("Failed to create dhcp bindings since dhcp edge "
"for net %s not found at the backend",
network_id)
def _get_syslog_config_from_flavor(self, context, router_id, flavor_id):
@@ -2036,7 +2036,7 @@ class EdgeManager(object):
# If no binding was found, no interface to update - exit
if not binding:
LOG.error(_LE('Edge binding not found for router %s'), router_id)
LOG.error('Edge binding not found for router %s', router_id)
return
net_bindings = nsxv_db.get_network_bindings(
@@ -2077,13 +2077,13 @@ class EdgeManager(object):
if address_group['primaryAddress']:
address_groups.append(address_group)
if ipaddr not in addr_list:
LOG.error(_LE("primary address %s of ext vnic is not "
"configured"), ipaddr)
LOG.error("primary address %s of ext vnic is not "
"configured", ipaddr)
if secondary:
missed_ip_sec = set(secondary) - set(addr_list)
if missed_ip_sec:
LOG.error(_LE("secondary address %s of ext vnic are not "
"configured"), str(missed_ip_sec))
LOG.error("secondary address %s of ext vnic are not "
"configured", str(missed_ip_sec))
nsxv_manager.update_interface(router_id, binding['edge_id'],
vcns_const.EXTERNAL_VNIC_INDEX,
vcns_network_id,
@@ -2127,7 +2127,7 @@ def delete_lrouter(nsxv_manager, context, router_id, dist=False):
# delete edge
nsxv_manager.delete_edge(context, router_id, edge_id, dist=dist)
else:
LOG.warning(_LW("router binding for router: %s not found"), router_id)
LOG.warning("router binding for router: %s not found", router_id)
def remove_irrelevant_keys_from_edge_request(edge_request):
@@ -2237,7 +2237,7 @@ def get_routes(edge_manager, context, router_id):
binding = nsxv_db.get_nsxv_router_binding(context.session, router_id)
if not binding:
LOG.error(_LE('Router binding not found for router %s'), router_id)
LOG.error('Router binding not found for router %s', router_id)
return []
edge_id = binding['edge_id']
@@ -2245,7 +2245,7 @@ def get_routes(edge_manager, context, router_id):
vnic_bindings = nsxv_db.get_edge_vnic_bindings_by_edge(context.session,
edge_id)
if not vnic_bindings:
LOG.error(_LE('vNic binding not found for edge %s'), edge_id)
LOG.error('vNic binding not found for edge %s', edge_id)
return []
h, routes = edge_manager.vcns.get_routes(edge_id)
@@ -2265,15 +2265,15 @@ def get_routes(edge_manager, context, router_id):
def update_routes(edge_manager, context, router_id, routes, nexthop=None):
binding = nsxv_db.get_nsxv_router_binding(context.session, router_id)
if not binding:
LOG.error(_LE('Router binding not found for router %s'), router_id)
LOG.error('Router binding not found for router %s', router_id)
return
edge_id = binding['edge_id']
edge_routes = []
for route in routes:
if not route.get('network_id'):
LOG.warning(_LW("There is no network info for the route %s, so "
"the route entry would not be executed!"), route)
LOG.warning("There is no network info for the route %s, so "
"the route entry would not be executed!", route)
continue
if route.get('external'):
edge_routes.append({
@@ -2289,10 +2289,10 @@ def update_routes(edge_manager, context, router_id, routes, nexthop=None):
'cidr': route['destination'],
'nexthop': route['nexthop']})
else:
LOG.error(_LE("vnic binding on edge %(edge_id)s for network "
"%(net_id)s not found, so route: destination: "
"%(dest)s, nexthop: %(nexthop)s can't be "
"applied!"),
LOG.error("vnic binding on edge %(edge_id)s for network "
"%(net_id)s not found, so route: destination: "
"%(dest)s, nexthop: %(nexthop)s can't be "
"applied!",
{'edge_id': edge_id,
'net_id': route['network_id'],
'dest': route['destination'],
@@ -2408,7 +2408,7 @@ def delete_interface(nsxv_manager, context, router_id, network_id, dist=False):
# Get edge id
binding = nsxv_db.get_nsxv_router_binding(context.session, router_id)
if not binding:
LOG.warning(_LW("Failed to find the router binding for router %s"),
LOG.warning("Failed to find the router binding for router %s",
router_id)
return
@@ -2424,8 +2424,8 @@ def delete_interface(nsxv_manager, context, router_id, network_id, dist=False):
edge_vnic_binding = nsxv_db.get_edge_vnic_binding(
context.session, edge_id, network_id)
if not edge_vnic_binding:
LOG.warning(_LW("Failed to find the network %(net_id)s "
"corresponding vnic index on edge %(edge_id)s"),
LOG.warning("Failed to find the network %(net_id)s "
"corresponding vnic index on edge %(edge_id)s",
{'net_id': network_id,
'edge_id': edge_id})
return
@@ -2468,7 +2468,7 @@ def update_nat_rules(nsxv_manager, context, router_id, snat, dnat):
nsxv_manager.update_nat_rules(binding['edge_id'], snat, dnat, indices)
else:
LOG.warning(_LW("Bindings do not exists for %s"), router_id)
LOG.warning("Bindings do not exists for %s", router_id)
def clear_nat_rules(nsxv_manager, context, router_id):
@@ -2484,7 +2484,7 @@ def update_firewall(nsxv_manager, context, router_id, firewall,
nsxv_manager.update_firewall(edge_id, firewall, context,
allow_external=allow_external)
else:
LOG.warning(_LW("Bindings do not exists for %s"), router_id)
LOG.warning("Bindings do not exists for %s", router_id)
def check_network_in_use_at_backend(context, network_id):
@@ -2498,15 +2498,15 @@ def check_network_in_use_at_backend(context, network_id):
context.session, network_id)
if not edge_vnic_bindings:
return
LOG.warning(_LW('NSXv: network is still in use at the backend'))
LOG.error(_LE('NSXv: network is still in use at the backend'))
LOG.warning('NSXv: network is still in use at the backend')
LOG.error('NSXv: network is still in use at the backend')
def default_loglevel_modifier(config, level):
"""Modify log level settings in edge config bulk (standard syntax)"""
if 'logging' not in config:
LOG.error(_LE("Logging section missing in configuration"))
LOG.error("Logging section missing in configuration")
return False
enable = True
@@ -2523,7 +2523,7 @@ def routing_loglevel_modifier(config, level):
"""Modify log level in routing global settings"""
if 'routingGlobalConfig' not in config:
LOG.error(_LE("routingGlobalConfig section missing in config"))
LOG.error("routingGlobalConfig section missing in config")
return False
return default_loglevel_modifier(config['routingGlobalConfig'],
@@ -2547,11 +2547,11 @@ def get_loglevel_modifier(module, level):
def update_edge_loglevel(vcns, edge_id, module, level):
"""Update loglevel on edge for specified module"""
if module not in SUPPORTED_EDGE_LOG_MODULES:
LOG.error(_LE("Unrecognized logging module %s - ignored"), module)
LOG.error("Unrecognized logging module %s - ignored", module)
return
if level not in SUPPORTED_EDGE_LOG_LEVELS:
LOG.error(_LE("Unrecognized log level %s - ignored"), level)
LOG.error("Unrecognized log level %s - ignored", level)
return
vcns.update_edge_config_with_modifier(edge_id, module,
@@ -2570,22 +2570,22 @@ def update_edge_host_groups(vcns, edge_id, dvs, availability_zone,
availability_zone.resource_pool)
for vm in vms:
if vm in configured_vms:
LOG.info(_LI('Edge %s already configured'), edge_id)
LOG.info('Edge %s already configured', edge_id)
return
# Ensure random distribution of the VMs
if availability_zone.ha_placement_random:
random.shuffle(vms)
try:
LOG.info(_LI('Create DRS groups for '
'%(vms)s on edge %(edge_id)s'),
LOG.info('Create DRS groups for '
'%(vms)s on edge %(edge_id)s',
{'vms': vms,
'edge_id': edge_id})
dvs.update_cluster_edge_failover(
availability_zone.resource_pool,
vms, edge_id, availability_zone.edge_host_groups)
except Exception as e:
LOG.error(_LE('Unable to create DRS groups for '
'%(vms)s on edge %(edge_id)s. Error: %(e)s'),
LOG.error('Unable to create DRS groups for '
'%(vms)s on edge %(edge_id)s. Error: %(e)s',
{'vms': vms,
'edge_id': edge_id,
'e': e})
@@ -2593,12 +2593,12 @@ def update_edge_host_groups(vcns, edge_id, dvs, availability_zone,
def clean_host_groups(dvs, availability_zone):
try:
LOG.info(_LI('Cleaning up host groups for AZ %s'),
LOG.info('Cleaning up host groups for AZ %s',
availability_zone.name)
dvs.cluster_host_group_cleanup(
availability_zone.resource_pool)
except Exception as e:
LOG.error(_LE('Unable to cleanup. Error: %s'), e)
LOG.error('Unable to cleanup. Error: %s', e)
class NsxVCallbacks(object):
@@ -2621,7 +2621,7 @@ class NsxVCallbacks(object):
router_db = self.plugin._get_router(context, router_id)
except l3.RouterNotFound:
# Router might have been deleted before deploy finished
LOG.warning(_LW("Router %s not found"), name)
LOG.warning("Router %s not found", name)
if deploy_successful:
metadata_proxy_handler = self.plugin.get_metadata_proxy_handler(
@@ -2652,7 +2652,7 @@ class NsxVCallbacks(object):
update_edge_host_groups(self.plugin.nsx_v.vcns, edge_id,
self._vcm, availability_zone)
else:
LOG.error(_LE("Failed to deploy Edge for router %s"), name)
LOG.error("Failed to deploy Edge for router %s", name)
if router_db:
router_db['status'] = plugin_const.ERROR
nsxv_db.update_nsxv_router_binding(
@@ -2670,8 +2670,8 @@ class NsxVCallbacks(object):
{'edge_id': edge_id,
'router_id': router_id})
else:
LOG.error(_LE("Failed to update %(edge_id)s for router "
"%(router_id)s"),
LOG.error("Failed to update %(edge_id)s for router "
"%(router_id)s",
{'edge_id': edge_id,
'router_id': router_id})
admin_ctx = q_context.get_admin_context()
@@ -2686,7 +2686,7 @@ class NsxVCallbacks(object):
router_db['status'] = plugin_const.ERROR
except l3.RouterNotFound:
# Router might have been deleted before deploy finished
LOG.warning(_LW("Router %s not found"), router_id)
LOG.warning("Router %s not found", router_id)
def interface_update_result(self, task):
LOG.debug("interface_update_result %d", task.status)

View File

@@ -24,7 +24,7 @@ from oslo_log import log as logging
from oslo_service import loopingcall
import six
from vmware_nsx._i18n import _, _LE, _LI
from vmware_nsx._i18n import _
from vmware_nsx.plugins.nsx_v.vshield.tasks import constants
DEFAULT_INTERVAL = 1000
@@ -96,8 +96,8 @@ class Task(object):
try:
func(self)
except Exception:
LOG.exception(_LE("Task %(task)s encountered exception in "
"%(func)s at state %(state)s"),
LOG.exception("Task %(task)s encountered exception in "
"%(func)s at state %(state)s",
{'task': str(self),
'func': str(func),
'state': state})
@@ -188,8 +188,8 @@ class TaskManager(object):
try:
status = task._execute_callback(task)
except Exception:
LOG.exception(_LE("Task %(task)s encountered exception in "
"%(cb)s"),
LOG.exception("Task %(task)s encountered exception in "
"%(cb)s",
{'task': str(task),
'cb': str(task._execute_callback)})
status = constants.TaskStatus.ERROR
@@ -207,8 +207,8 @@ class TaskManager(object):
try:
task._result_callback(task)
except Exception:
LOG.exception(_LE("Task %(task)s encountered exception in "
"%(cb)s"),
LOG.exception("Task %(task)s encountered exception in "
"%(cb)s",
{'task': str(task),
'cb': str(task._result_callback)})
LOG.debug("Task %(task)s return %(status)s",
@@ -229,8 +229,8 @@ class TaskManager(object):
try:
status = task._status_callback(task)
except Exception:
LOG.exception(_LE("Task %(task)s encountered exception in "
"%(cb)s"),
LOG.exception("Task %(task)s encountered exception in "
"%(cb)s",
{'task': str(task),
'cb': str(task._status_callback)})
status = constants.TaskStatus.ERROR
@@ -295,7 +295,7 @@ class TaskManager(object):
if self._stopped:
# Gracefully terminate this thread if the _stopped
# attribute was set to true
LOG.info(_LI("Stopping TaskManager"))
LOG.info("Stopping TaskManager")
break
# get a task from queue, or timeout for periodic status check
@@ -320,8 +320,8 @@ class TaskManager(object):
else:
self._enqueue(task)
except Exception:
LOG.exception(_LE("TaskManager terminating because "
"of an exception"))
LOG.exception("TaskManager terminating because "
"of an exception")
break
def add(self, task):
@@ -342,7 +342,7 @@ class TaskManager(object):
if self._monitor_busy:
self._monitor.wait()
self._abort()
LOG.info(_LI("TaskManager terminated"))
LOG.info("TaskManager terminated")
def has_pending_task(self):
if self._tasks_queue or self._tasks or self._main_thread_exec_task:
@@ -374,7 +374,7 @@ class TaskManager(object):
try:
self._check_pending_tasks()
except Exception:
LOG.exception(_LE("Exception in _check_pending_tasks"))
LOG.exception("Exception in _check_pending_tasks")
self._monitor_busy = False
if self._thread is not None:

View File

@@ -20,7 +20,6 @@ from oslo_serialization import jsonutils
import six
import xml.etree.ElementTree as et
from vmware_nsx._i18n import _LE
from vmware_nsx.common import nsxv_constants
from vmware_nsx.common import utils
from vmware_nsx.plugins.nsx_v.vshield.common import constants
@@ -911,7 +910,7 @@ class Vcns(object):
self._nsx_version = self._get_version()
except Exception as e:
# Versions prior to 6.2.0 do not support the above API
LOG.error(_LE("Unable to get NSX version. Exception: %s"), e)
LOG.error("Unable to get NSX version. Exception: %s", e)
# Minimum supported version is 6.1
self._nsx_version = '6.1'
return self._nsx_version

View File

@@ -20,7 +20,6 @@ import logging
from oslo_config import cfg
from vmware_nsx._i18n import _LE
from vmware_nsx.db import db as nsx_db
LOG = logging.getLogger(__name__)
@@ -82,9 +81,9 @@ class DbCertificateStorageDriver(object):
except fernet.InvalidToken:
# unable to decrypt - probably due to change of password
# cert and PK are useless, need to delete them
LOG.error(_LE("Unable to decrypt private key, possibly due "
"to change of password. Certificate needs to be "
"regenerated"))
LOG.error("Unable to decrypt private key, possibly due "
"to change of password. Certificate needs to be "
"regenerated")
self.delete_cert(purpose)
return None, None

View File

@@ -76,7 +76,7 @@ from oslo_utils import importutils
from oslo_utils import uuidutils
from sqlalchemy import exc as sql_exc
from vmware_nsx._i18n import _, _LE, _LI, _LW
from vmware_nsx._i18n import _
from vmware_nsx.api_replay import utils as api_replay_utils
from vmware_nsx.common import availability_zones as nsx_com_az
from vmware_nsx.common import config # noqa
@@ -180,7 +180,7 @@ class NsxV3Plugin(agentschedulers_db.AZDhcpAgentSchedulerDbMixin,
super(NsxV3Plugin, self).__init__()
# Bind the dummy L3 notifications
self.l3_rpc_notifier = l3_rpc_agent_api.L3NotifyAPI()
LOG.info(_LI("Starting NsxV3Plugin"))
LOG.info("Starting NsxV3Plugin")
self._extension_manager.initialize()
self.supported_extension_aliases.extend(
self._extension_manager.extension_aliases())
@@ -193,7 +193,7 @@ class NsxV3Plugin(agentschedulers_db.AZDhcpAgentSchedulerDbMixin,
resources.PROCESS, events.AFTER_INIT)
self._nsx_version = self.nsxlib.get_version()
LOG.info(_LI("NSX Version: %s"), self._nsx_version)
LOG.info("NSX Version: %s", self._nsx_version)
self._nsx_client = self.nsxlib.client
self.cfg_group = 'nsx_v3' # group name for nsx_v3 section in nsx.ini
@@ -297,8 +297,8 @@ class NsxV3Plugin(agentschedulers_db.AZDhcpAgentSchedulerDbMixin,
# Only expose the extension if it is supported
self.supported_extension_aliases.append('mac-learning')
except Exception as e:
LOG.warning(_LW("Unable to initialize NSX v3 MAC Learning "
"profile: %(name)s. Reason: %(reason)s"),
LOG.warning("Unable to initialize NSX v3 MAC Learning "
"profile: %(name)s. Reason: %(reason)s",
{'name': NSX_V3_MAC_LEARNING_PROFILE_NAME,
'reason': e})
@@ -474,8 +474,8 @@ class NsxV3Plugin(agentschedulers_db.AZDhcpAgentSchedulerDbMixin,
section_id, logging=log_all_rules)
except nsx_lib_exc.ManagerError:
with excutils.save_and_reraise_exception():
LOG.error(_LE("Failed to update firewall rule logging "
"for rule in section %s"), section_id)
LOG.error("Failed to update firewall rule logging "
"for rule in section %s", section_id)
utils.spawn_n(process_security_group_logging)
@@ -523,8 +523,8 @@ class NsxV3Plugin(agentschedulers_db.AZDhcpAgentSchedulerDbMixin,
self._nsx_client)
except nsx_lib_exc.ManagerError:
with excutils.save_and_reraise_exception():
LOG.error(_LE("Unable to retrieve DHCP Profile %s, "
"native DHCP service is not supported"),
LOG.error("Unable to retrieve DHCP Profile %s, "
"native DHCP service is not supported",
az._native_dhcp_profile_uuid)
def _init_native_metadata(self):
@@ -534,8 +534,8 @@ class NsxV3Plugin(agentschedulers_db.AZDhcpAgentSchedulerDbMixin,
az._native_md_proxy_uuid)
except nsx_lib_exc.ManagerError:
with excutils.save_and_reraise_exception():
LOG.error(_LE("Unable to retrieve Metadata Proxy %s, "
"native metadata service is not supported"),
LOG.error("Unable to retrieve Metadata Proxy %s, "
"native metadata service is not supported",
az._native_md_proxy_uuid)
def _setup_rpc(self):
@@ -843,7 +843,7 @@ class NsxV3Plugin(agentschedulers_db.AZDhcpAgentSchedulerDbMixin,
except Exception:
with excutils.save_and_reraise_exception():
# Undo creation on the backend
LOG.exception(_LE('Failed to create network %s'),
LOG.exception('Failed to create network %s',
created_net['id'])
if net_type != utils.NetworkTypes.L3_EXT:
self.nsxlib.logical_switch.delete(created_net['id'])
@@ -978,8 +978,8 @@ class NsxV3Plugin(agentschedulers_db.AZDhcpAgentSchedulerDbMixin,
# the switch when the switch's admin state changes. Do not
# update the admin state of the ports in neutron either.
except nsx_lib_exc.ManagerError:
LOG.exception(_LE("Unable to update NSX backend, rolling "
"back changes on neutron"))
LOG.exception("Unable to update NSX backend, rolling "
"back changes on neutron")
with excutils.save_and_reraise_exception():
super(NsxV3Plugin, self).update_network(
context, id, {'network': original_net})
@@ -1067,8 +1067,8 @@ class NsxV3Plugin(agentschedulers_db.AZDhcpAgentSchedulerDbMixin,
{'port': nsx_port['id'], 'network': network['id']})
except nsx_lib_exc.ManagerError:
with excutils.save_and_reraise_exception():
LOG.error(_LE("Unable to create logical DHCP server for "
"network %s"), network['id'])
LOG.error("Unable to create logical DHCP server for "
"network %s", network['id'])
if dhcp_server:
self._dhcp_server.delete(dhcp_server['id'])
super(NsxV3Plugin, self).delete_port(
@@ -1085,8 +1085,8 @@ class NsxV3Plugin(agentschedulers_db.AZDhcpAgentSchedulerDbMixin,
nsxlib_consts.SERVICE_DHCP, dhcp_server['id'])
except (db_exc.DBError, sql_exc.TimeoutError):
with excutils.save_and_reraise_exception():
LOG.error(_LE("Failed to create mapping for DHCP port %s,"
"deleting port and logical DHCP server"),
LOG.error("Failed to create mapping for DHCP port %s,"
"deleting port and logical DHCP server",
neutron_port['id'])
self._dhcp_server.delete(dhcp_server['id'])
self._cleanup_port(context, neutron_port['id'], nsx_port['id'])
@@ -1096,8 +1096,8 @@ class NsxV3Plugin(agentschedulers_db.AZDhcpAgentSchedulerDbMixin,
for port_data in existing_ports:
self._add_dhcp_binding(context, port_data)
except Exception:
LOG.error(_LE('Unable to create DHCP bindings for existing ports '
'on subnet %s'), subnet['id'])
LOG.error('Unable to create DHCP bindings for existing ports '
'on subnet %s', subnet['id'])
def _disable_native_dhcp(self, context, network_id):
# Disable native DHCP service on the backend for this network.
@@ -1113,12 +1113,12 @@ class NsxV3Plugin(agentschedulers_db.AZDhcpAgentSchedulerDbMixin,
self.delete_port(context, dhcp_service['port_id'])
except Exception:
# This could happen when the port has been manually deleted.
LOG.error(_LE("Failed to delete DHCP port %(port)s for "
"network %(network)s"),
LOG.error("Failed to delete DHCP port %(port)s for "
"network %(network)s",
{'port': dhcp_service['port_id'],
'network': network_id})
else:
LOG.error(_LE("DHCP port is not configured for network %s"),
LOG.error("DHCP port is not configured for network %s",
network_id)
try:
@@ -1129,8 +1129,8 @@ class NsxV3Plugin(agentschedulers_db.AZDhcpAgentSchedulerDbMixin,
'network': network_id})
except nsx_lib_exc.ManagerError:
with excutils.save_and_reraise_exception():
LOG.error(_LE("Unable to delete logical DHCP server %(server)s"
"for network %(network)s"),
LOG.error("Unable to delete logical DHCP server %(server)s "
"for network %(network)s",
{'server': dhcp_service['nsx_service_id'],
'network': network_id})
try:
@@ -1142,8 +1142,8 @@ class NsxV3Plugin(agentschedulers_db.AZDhcpAgentSchedulerDbMixin,
context.session, dhcp_service['nsx_service_id'])
except db_exc.DBError:
with excutils.save_and_reraise_exception():
LOG.error(_LE("Unable to delete DHCP server mapping for "
"network %s"), network_id)
LOG.error("Unable to delete DHCP server mapping for "
"network %s", network_id)
def _validate_address_space(self, subnet):
cidr = subnet.get('cidr')
@@ -1199,8 +1199,8 @@ class NsxV3Plugin(agentschedulers_db.AZDhcpAgentSchedulerDbMixin,
# is already empty.
context.session.rollback()
with excutils.save_and_reraise_exception():
LOG.error(_LE("An exception occurred while creating "
"the %(resource)s:%(item)s"),
LOG.error("An exception occurred while creating "
"the %(resource)s:%(item)s",
{'resource': resource, 'item': item})
return objects
@@ -1222,14 +1222,14 @@ class NsxV3Plugin(agentschedulers_db.AZDhcpAgentSchedulerDbMixin,
try:
self._port_client.delete(dhcp_info['nsx_port_id'])
except Exception as e:
LOG.error(_LE("Failed to delete logical port %(id)s "
"during rollback. Exception: %(e)s"),
LOG.error("Failed to delete logical port %(id)s "
"during rollback. Exception: %(e)s",
{'id': dhcp_info['nsx_port_id'], 'e': e})
try:
self._dhcp_server.delete(dhcp_info['nsx_service_id'])
except Exception as e:
LOG.error(_LE("Failed to delete logical DHCP server %(id)s "
"during rollback. Exception: %(e)s"),
LOG.error("Failed to delete logical DHCP server %(id)s "
"during rollback. Exception: %(e)s",
{'id': dhcp_info['nsx_service_id'], 'e': e})
def create_subnet_bulk(self, context, subnets):
@@ -1303,8 +1303,8 @@ class NsxV3Plugin(agentschedulers_db.AZDhcpAgentSchedulerDbMixin,
try:
self._disable_native_dhcp(context, network['id'])
except Exception as e:
LOG.error(_LE("Failed to disable native DHCP for"
"network %(id)s. Exception: %(e)s"),
LOG.error("Failed to disable native DHCP for"
"network %(id)s. Exception: %(e)s",
{'id': network['id'], 'e': e})
super(NsxV3Plugin, self).delete_subnet(
context, subnet_id)
@@ -1381,8 +1381,8 @@ class NsxV3Plugin(agentschedulers_db.AZDhcpAgentSchedulerDbMixin,
except nsx_lib_exc.ManagerError:
with excutils.save_and_reraise_exception():
LOG.error(
_LE("Unable to update logical DHCP server "
"%(server)s for network %(network)s"),
"Unable to update logical DHCP server "
"%(server)s for network %(network)s",
{'server': dhcp_service['nsx_service_id'],
'network': orig_subnet['network_id']})
if 'gateway_ip' in kwargs:
@@ -1637,7 +1637,7 @@ class NsxV3Plugin(agentschedulers_db.AZDhcpAgentSchedulerDbMixin,
except nsx_lib_exc.ManagerError as inst:
# we may fail if the QoS is not supported for this port
# (for example - transport zone with KVM)
LOG.exception(_LE("Unable to create port on the backend: %s"),
LOG.exception("Unable to create port on the backend: %s",
inst)
msg = _("Unable to create port on the backend")
raise nsx_exc.NsxPluginException(err_msg=msg)
@@ -1748,9 +1748,9 @@ class NsxV3Plugin(agentschedulers_db.AZDhcpAgentSchedulerDbMixin,
fixed_ip['ip_address'], dhcp_service['nsx_service_id'],
binding['id'])
except (db_exc.DBError, sql_exc.TimeoutError):
LOG.error(_LE("Failed to add mapping of DHCP binding "
"%(binding)s for port %(port)s, deleting"
"DHCP binding on server"),
LOG.error("Failed to add mapping of DHCP binding "
"%(binding)s for port %(port)s, deleting"
"DHCP binding on server",
{'binding': binding['id'], 'port': port['id']})
self._delete_dhcp_binding_on_server(context, binding)
@@ -1825,10 +1825,10 @@ class NsxV3Plugin(agentschedulers_db.AZDhcpAgentSchedulerDbMixin,
return binding
except nsx_lib_exc.ManagerError:
with excutils.save_and_reraise_exception():
LOG.error(_LE("Unable to create static binding (mac: %(mac)s, "
"ip: %(ip)s, gateway: %(gateway)s, options: "
"%(options)s) for port %(port)s on logical DHCP "
"server %(server)s"),
LOG.error("Unable to create static binding (mac: %(mac)s, "
"ip: %(ip)s, gateway: %(gateway)s, options: "
"%(options)s) for port %(port)s on logical DHCP "
"server %(server)s",
{'mac': port['mac_address'], 'ip': ip,
'gateway': gateway_ip, 'options': options,
'port': port['id'],
@@ -1845,8 +1845,8 @@ class NsxV3Plugin(agentschedulers_db.AZDhcpAgentSchedulerDbMixin,
context.session, binding['port_id'],
binding['nsx_binding_id'])
except db_exc.DBError:
LOG.error(_LE("Unable to delete mapping of DHCP binding "
"%(binding)s for port %(port)s"),
LOG.error("Unable to delete mapping of DHCP binding "
"%(binding)s for port %(port)s",
{'binding': binding['nsx_binding_id'],
'port': binding['port_id']})
@@ -1860,8 +1860,8 @@ class NsxV3Plugin(agentschedulers_db.AZDhcpAgentSchedulerDbMixin,
'server': binding['nsx_service_id']})
except nsx_lib_exc.ManagerError:
with excutils.save_and_reraise_exception():
LOG.error(_LE("Unable to delete static binding for port "
"%(port)s) on logical DHCP server %(server)s"),
LOG.error("Unable to delete static binding for port "
"%(port)s) on logical DHCP server %(server)s",
{'port': binding['port_id'],
'server': binding['nsx_service_id']})
@@ -1923,8 +1923,8 @@ class NsxV3Plugin(agentschedulers_db.AZDhcpAgentSchedulerDbMixin,
'server': dhcp_service['nsx_service_id']})
except nsx_lib_exc.ManagerError:
with excutils.save_and_reraise_exception():
LOG.error(_LE("Unable to update IP %(ip)s for logical "
"DHCP server %(server)s"),
LOG.error("Unable to update IP %(ip)s for logical "
"DHCP server %(server)s",
{'ip': new_ip,
'server': dhcp_service['nsx_service_id']})
elif utils.is_port_dhcp_configurable(old_port):
@@ -2001,9 +2001,9 @@ class NsxV3Plugin(agentschedulers_db.AZDhcpAgentSchedulerDbMixin,
'server': binding['nsx_service_id']})
except nsx_lib_exc.ManagerError:
with excutils.save_and_reraise_exception():
LOG.error(_LE("Unable to update static binding (mac: %(mac)s, "
"ip: %(ip)s, gateway: %(gateway)s) for port "
"%(port)s on logical DHCP server %(server)s"),
LOG.error("Unable to update static binding (mac: %(mac)s, "
"ip: %(ip)s, gateway: %(gateway)s) for port "
"%(port)s on logical DHCP server %(server)s",
{'mac': mac, 'ip': ip, 'gateway': gateway_ip,
'port': binding['port_id'],
'server': binding['nsx_service_id']})
@@ -2079,8 +2079,8 @@ class NsxV3Plugin(agentschedulers_db.AZDhcpAgentSchedulerDbMixin,
context, port_data, l2gw_port_check, is_psec_on)
except Exception as e:
with excutils.save_and_reraise_exception():
LOG.error(_LE('Failed to create port %(id)s on NSX '
'backend. Exception: %(e)s'),
LOG.error('Failed to create port %(id)s on NSX '
'backend. Exception: %(e)s',
{'id': neutron_db['id'], 'e': e})
self._cleanup_port(context, neutron_db['id'], None)
@@ -2348,7 +2348,7 @@ class NsxV3Plugin(agentschedulers_db.AZDhcpAgentSchedulerDbMixin,
except nsx_lib_exc.ManagerError as inst:
# we may fail if the QoS is not supported for this port
# (for example - transport zone with KVM)
LOG.exception(_LE("Unable to update port on the backend: %s"),
LOG.exception("Unable to update port on the backend: %s",
inst)
msg = _("Unable to update port on the backend")
raise nsx_exc.NsxPluginException(err_msg=msg)
@@ -2466,8 +2466,8 @@ class NsxV3Plugin(agentschedulers_db.AZDhcpAgentSchedulerDbMixin,
nsx_lib_exc.SecurityGroupMaximumCapacityReached) as e:
# In case if there is a failure on NSX-v3 backend, rollback the
# previous update operation on neutron side.
LOG.exception(_LE("Unable to update NSX backend, rolling back "
"changes on neutron"))
LOG.exception("Unable to update NSX backend, rolling back "
"changes on neutron")
with excutils.save_and_reraise_exception(reraise=False):
with context.session.begin(subtransactions=True):
super(NsxV3Plugin, self).update_port(
@@ -2718,8 +2718,8 @@ class NsxV3Plugin(agentschedulers_db.AZDhcpAgentSchedulerDbMixin,
tags=tags)
except nsx_lib_exc.ManagerError:
with excutils.save_and_reraise_exception():
LOG.error(_LE("Unable to create logical router for "
"neutron router %s"), router['id'])
LOG.error("Unable to create logical router for "
"neutron router %s", router['id'])
self.delete_router(context, router['id'])
try:
@@ -2727,8 +2727,8 @@ class NsxV3Plugin(agentschedulers_db.AZDhcpAgentSchedulerDbMixin,
context.session, router['id'], result['id'])
except db_exc.DBError:
with excutils.save_and_reraise_exception():
LOG.error(_LE("Unable to create router mapping for "
"router %s"), router['id'])
LOG.error("Unable to create router mapping for "
"router %s", router['id'])
self.delete_router(context, router['id'])
if gw_info and gw_info != const.ATTR_NOT_SPECIFIED:
@@ -2736,13 +2736,13 @@ class NsxV3Plugin(agentschedulers_db.AZDhcpAgentSchedulerDbMixin,
self._update_router_gw_info(context, router['id'], gw_info)
except (db_exc.DBError, nsx_lib_exc.ManagerError):
with excutils.save_and_reraise_exception():
LOG.error(_LE("Failed to set gateway info for router "
"being created: %s - removing router"),
LOG.error("Failed to set gateway info for router "
"being created: %s - removing router",
router['id'])
self.delete_router(context, router['id'])
LOG.info(_LI("Create router failed while setting external "
"gateway. Router:%s has been removed from "
"DB and backend"),
LOG.info("Create router failed while setting external "
"gateway. Router:%s has been removed from "
"DB and backend",
router['id'])
return self.get_router(context, router['id'])
@@ -2773,9 +2773,9 @@ class NsxV3Plugin(agentschedulers_db.AZDhcpAgentSchedulerDbMixin,
# removed from the neutron DB. Take corrective steps to ensure the
# resulting zombie object does not forward any traffic and is
# eventually removed.
LOG.warning(_LW("Backend router deletion for neutron router %s "
"failed. The object was however removed from the "
"Neutron database"), router_id)
LOG.warning("Backend router deletion for neutron router %s "
"failed. The object was however removed from the "
"Neutron database", router_id)
return ret_val
@@ -2861,8 +2861,8 @@ class NsxV3Plugin(agentschedulers_db.AZDhcpAgentSchedulerDbMixin,
self._port_client.update(nsx_port_id, None,
name=name)
except Exception as e:
LOG.error(_LE("Unable to update port %(port_id)s. "
"Reason: %(e)s"),
LOG.error("Unable to update port %(port_id)s. "
"Reason: %(e)s",
{'port_id': nsx_port_id,
'e': e})
if 'description' in router_data:
@@ -3019,8 +3019,8 @@ class NsxV3Plugin(agentschedulers_db.AZDhcpAgentSchedulerDbMixin,
interface=info)
except Exception:
with excutils.save_and_reraise_exception():
LOG.error(_LE("Neutron failed to add_router_interface on "
"router %s, and would try to rollback."),
LOG.error("Neutron failed to add_router_interface on "
"router %s, and would try to rollback.",
router_id)
self.remove_router_interface(
context, router_id, interface_info)
@@ -3087,8 +3087,8 @@ class NsxV3Plugin(agentschedulers_db.AZDhcpAgentSchedulerDbMixin,
else:
self._router_port_client.delete_by_lswitch_id(nsx_net_id)
except nsx_lib_exc.ResourceNotFound:
LOG.error(_LE("router port on router %(router_id)s for net "
"%(net_id)s not found at the backend"),
LOG.error("router port on router %(router_id)s for net "
"%(net_id)s not found at the backend",
{'router_id': router_id,
'net_id': subnet['network_id']})
info = super(NsxV3Plugin, self).remove_router_interface(
@@ -3146,9 +3146,9 @@ class NsxV3Plugin(agentschedulers_db.AZDhcpAgentSchedulerDbMixin,
nsx_router_id, fip['floating_ip_address'],
fip['fixed_ip_address'])
except nsx_lib_exc.ResourceNotFound:
LOG.warning(_LW("Backend NAT rules for fip: %(fip_id)s "
"(ext_ip: %(ext_ip)s int_ip: %(int_ip)s) "
"not found"),
LOG.warning("Backend NAT rules for fip: %(fip_id)s "
"(ext_ip: %(ext_ip)s int_ip: %(int_ip)s) "
"not found",
{'fip_id': fip_id,
'ext_ip': fip['floating_ip_address'],
'int_ip': fip['fixed_ip_address']})
@@ -3186,9 +3186,9 @@ class NsxV3Plugin(agentschedulers_db.AZDhcpAgentSchedulerDbMixin,
old_nsx_router_id, old_fip['floating_ip_address'],
old_fip['fixed_ip_address'])
except nsx_lib_exc.ResourceNotFound:
LOG.warning(_LW("Backend NAT rules for fip: %(fip_id)s "
"(ext_ip: %(ext_ip)s int_ip: %(int_ip)s) "
"not found"),
LOG.warning("Backend NAT rules for fip: %(fip_id)s "
"(ext_ip: %(ext_ip)s int_ip: %(int_ip)s) "
"not found",
{'fip_id': old_fip['id'],
'ext_ip': old_fip['floating_ip_address'],
'int_ip': old_fip['fixed_ip_address']})
@@ -3229,9 +3229,9 @@ class NsxV3Plugin(agentschedulers_db.AZDhcpAgentSchedulerDbMixin,
nsx_router_id, fip_db.floating_ip_address,
fip_db.fixed_ip_address)
except nsx_lib_exc.ResourceNotFound:
LOG.warning(_LW("Backend NAT rules for fip: %(fip_id)s "
"(ext_ip: %(ext_ip)s int_ip: %(int_ip)s) "
"not found"),
LOG.warning("Backend NAT rules for fip: %(fip_id)s "
"(ext_ip: %(ext_ip)s int_ip: %(int_ip)s) "
"not found",
{'fip_id': fip_db.id,
'ext_ip': fip_db.floating_ip_address,
'int_ip': fip_db.fixed_ip_address})
@@ -3353,8 +3353,8 @@ class NsxV3Plugin(agentschedulers_db.AZDhcpAgentSchedulerDbMixin,
default_sg)
except nsx_lib_exc.ManagerError:
with excutils.save_and_reraise_exception():
LOG.exception(_LE("Unable to create security-group on the "
"backend."))
LOG.exception("Unable to create security-group on the "
"backend.")
if ns_group:
self.nsxlib.ns_group.delete(ns_group['id'])
except Exception:
@@ -3385,9 +3385,9 @@ class NsxV3Plugin(agentschedulers_db.AZDhcpAgentSchedulerDbMixin,
self.save_security_group_rule_mappings(context, rules['rules'])
except nsx_lib_exc.ManagerError:
with excutils.save_and_reraise_exception():
LOG.exception(_LE("Failed to create backend firewall rules "
"for security-group %(name)s (%(id)s), "
"rolling back changes."), secgroup_db)
LOG.exception("Failed to create backend firewall rules "
"for security-group %(name)s (%(id)s), "
"rolling back changes.", secgroup_db)
# default security group deletion requires admin context
if default_sg:
context = context.elevated()
@@ -3415,9 +3415,9 @@ class NsxV3Plugin(agentschedulers_db.AZDhcpAgentSchedulerDbMixin,
cfg.CONF.nsx_v3.log_security_groups_allowed_traffic)
except nsx_lib_exc.ManagerError:
with excutils.save_and_reraise_exception():
LOG.exception(_LE("Failed to update security-group %(name)s "
"(%(id)s), rolling back changes in "
"Neutron."), orig_secgroup)
LOG.exception("Failed to update security-group %(name)s "
"(%(id)s), rolling back changes in "
"Neutron.", orig_secgroup)
super(NsxV3Plugin, self).update_security_group(
context, id, {'security_group': orig_secgroup})

View File

@@ -20,7 +20,6 @@ from oslo_log import log as logging
from neutron import version as n_version
from neutron_lib import context as q_context
from vmware_nsx._i18n import _LE, _LW
from vmware_nsx.common import exceptions as nsx_exc
from vmware_nsx.plugins.nsx_v3 import cert_utils
from vmware_nsxlib import v3
@@ -50,11 +49,11 @@ class DbCertProvider(client_cert.ClientCertProvider):
return
if expires_in_days < 0:
LOG.error(_LE("Client certificate has expired %d days ago."),
LOG.error("Client certificate has expired %d days ago.",
expires_in_days * -1)
else:
LOG.warning(_LW("Client certificate expires in %d days. "
"Once expired, service will become unavailable."),
LOG.warning("Client certificate expires in %d days. "
"Once expired, service will become unavailable.",
expires_in_days)
def __enter__(self):

View File

@@ -28,7 +28,7 @@ from oslo_config import cfg
from oslo_log import helpers as log_helpers
from oslo_log import log as logging
from vmware_nsx._i18n import _, _LE
from vmware_nsx._i18n import _
from vmware_nsx.common import config # noqa
from vmware_nsx.common import exceptions as nsx_exc
from vmware_nsx.common import locking
@@ -332,8 +332,8 @@ class NsxvFlowClassifierDriver(fc_driver.FlowClassifierDriverBase):
break
if redirect_rule is None:
LOG.error(_LE("Failed to delete redirect rule %s: "
"Could not find rule on backed"),
LOG.error("Failed to delete redirect rule %s: "
"Could not find rule on backed",
flow_classifier_id)
# should not fail the deletion
else:

View File

@@ -26,7 +26,7 @@ from neutron.ipam import requests as ipam_req
from neutron_lib.api.definitions import provider_net as pnet
from neutron_lib.api import validators
from vmware_nsx._i18n import _, _LE
from vmware_nsx._i18n import _
from vmware_nsx.plugins.nsx_v.vshield.common import constants
from vmware_nsx.plugins.nsx_v.vshield.common import exceptions as vc_exc
from vmware_nsx.services.ipam.common import driver as common
@@ -113,7 +113,7 @@ class NsxvIpamDriver(common.NsxAbstractIpamDriver, NsxVIpamBase):
try:
self._vcns.delete_ipam_ip_pool(nsx_pool_id)
except vc_exc.VcnsApiException as e:
LOG.error(_LE("Failed to delete IPAM from backend: %s"), e)
LOG.error("Failed to delete IPAM from backend: %s", e)
# Continue anyway, since this subnet was already removed
def update_backend_pool(self, subnet_request):
@@ -132,7 +132,7 @@ class NsxvIpamSubnet(common.NsxAbstractIpamSubnet, NsxVIpamBase):
desc = et.fromstring(e.response)
return int(desc.find('errorCode').text)
except Exception:
LOG.error(_LE('IPAM pool: Error code not present. %s'),
LOG.error('IPAM pool: Error code not present. %s',
e.response)
def backend_allocate(self, address_request):
@@ -169,8 +169,8 @@ class NsxvIpamSubnet(common.NsxAbstractIpamSubnet, NsxVIpamBase):
try:
self._vcns.release_ipam_ip_to_pool(self._nsx_pool_id, address)
except vc_exc.VcnsApiException as e:
LOG.error(_LE("NSX IPAM failed to free ip %(ip)s of subnet %(id)s:"
" %(e)s"),
LOG.error("NSX IPAM failed to free ip %(ip)s of subnet %(id)s:"
" %(e)s",
{'e': e.response,
'ip': address,
'id': self._subnet_id})

View File

@@ -21,7 +21,7 @@ from oslo_log import log as logging
from neutron.ipam import exceptions as ipam_exc
from neutron.ipam import requests as ipam_req
from vmware_nsx._i18n import _, _LE, _LI, _LW
from vmware_nsx._i18n import _
from vmware_nsx.services.ipam.common import driver as common
from vmware_nsxlib.v3 import exceptions as nsx_lib_exc
from vmware_nsxlib.v3 import nsx_constants as error
@@ -92,13 +92,13 @@ class Nsxv3IpamDriver(common.NsxAbstractIpamDriver):
try:
self.nsxlib_ipam.release(nsx_pool_id, ip_addr)
except Exception as e:
LOG.warning(_LW("Failed to release ip %(ip)s from pool "
"%(pool)s: %(e)s"),
LOG.warning("Failed to release ip %(ip)s from pool "
"%(pool)s: %(e)s",
{'ip': ip_addr, 'pool': nsx_pool_id, 'e': e})
try:
self.nsxlib_ipam.delete(nsx_pool_id)
except Exception as e:
LOG.error(_LE("Failed to delete IPAM from backend: %s"), e)
LOG.error("Failed to delete IPAM from backend: %s", e)
# Continue anyway, since this subnet was already removed
def update_backend_pool(self, nsx_pool_id, subnet_request):
@@ -110,8 +110,8 @@ class Nsxv3IpamDriver(common.NsxAbstractIpamDriver):
self.nsxlib_ipam.update(
nsx_pool_id, **update_args)
except nsx_lib_exc.ManagerError as e:
LOG.error(_LE("NSX IPAM failed to update pool %(id)s: "
" %(e)s; code %(code)s"),
LOG.error("NSX IPAM failed to update pool %(id)s: "
" %(e)s; code %(code)s",
{'e': e,
'id': nsx_pool_id,
'code': e.error_code})
@@ -147,7 +147,7 @@ class Nsxv3IpamSubnet(common.NsxAbstractIpamSubnet):
# If this is the subnet gateway IP - no need to allocate it
subnet = self.get_details()
if str(subnet.gateway_ip) == ip_address:
LOG.info(_LI("Skip allocation of gateway-ip for pool %s"),
LOG.info("Skip allocation of gateway-ip for pool %s",
self._nsx_pool_id)
return ip_address
else:
@@ -157,9 +157,8 @@ class Nsxv3IpamSubnet(common.NsxAbstractIpamSubnet):
ip_addr=ip_address)
ip_address = response['allocation_id']
except nsx_lib_exc.ManagerError as e:
LOG.error(_LE("NSX IPAM failed to allocate ip %(ip)s of subnet "
"%(id)s:"
" %(e)s; code %(code)s"),
LOG.error("NSX IPAM failed to allocate ip %(ip)s of subnet "
"%(id)s: %(e)s; code %(code)s",
{'e': e,
'ip': ip_address,
'id': self._subnet_id,
@@ -182,9 +181,8 @@ class Nsxv3IpamSubnet(common.NsxAbstractIpamSubnet):
# another backend error
raise ipam_exc.IPAllocationFailed()
except Exception as e:
LOG.error(_LE("NSX IPAM failed to allocate ip %(ip)s of subnet "
"%(id)s:"
" %(e)s"),
LOG.error("NSX IPAM failed to allocate ip %(ip)s of subnet "
"%(id)s: %(e)s",
{'e': e,
'ip': ip_address,
'id': self._subnet_id})
@@ -197,9 +195,8 @@ class Nsxv3IpamSubnet(common.NsxAbstractIpamSubnet):
self.nsxlib_ipam.release(self._nsx_pool_id, ip_addr=address)
except nsx_lib_exc.ManagerError as e:
# fail silently
LOG.error(_LE("NSX IPAM failed to free ip %(ip)s of subnet "
"%(id)s:"
" %(e)s; code %(code)s"),
LOG.error("NSX IPAM failed to free ip %(ip)s of subnet "
"%(id)s: %(e)s; code %(code)s",
{'e': e,
'ip': address,
'id': self._subnet_id,

View File

@@ -22,7 +22,7 @@ from neutron_lib.plugins import directory
from oslo_log import log as logging
from oslo_utils import uuidutils
from vmware_nsx._i18n import _, _LE
from vmware_nsx._i18n import _
from vmware_nsx.common import exceptions as nsx_exc
from vmware_nsx.common import nsxv_constants
from vmware_nsx.db import db as nsx_db
@@ -89,8 +89,8 @@ class NsxvL2GatewayDriver(l2gateway_db.L2GatewayMixin):
try:
edge_id = self._create_l2_gateway_edge(context)
except nsx_exc.NsxL2GWDeviceNotFound:
LOG.exception(_LE("Failed to create backend device "
"for L2 gateway"))
LOG.exception("Failed to create backend device "
"for L2 gateway")
raise
devices[0]['device_name'] = edge_id
@@ -151,8 +151,8 @@ class NsxvL2GatewayDriver(l2gateway_db.L2GatewayMixin):
try:
self._nsxv.create_bridge(device_name, bridge_dict)
except exceptions.VcnsApiException:
LOG.exception(_LE("Failed to update NSX, "
"rolling back changes on neutron."))
LOG.exception("Failed to update NSX, "
"rolling back changes on neutron.")
raise l2gw_exc.L2GatewayServiceDriverError(
method='create_l2_gateway_connection_postcommit')
return

View File

@@ -33,7 +33,7 @@ from neutron_lib import context
from neutron_lib import exceptions as n_exc
from neutron_lib.plugins import directory
from vmware_nsx._i18n import _, _LE, _LI
from vmware_nsx._i18n import _
from vmware_nsx.common import utils as nsx_utils
from vmware_nsx.db import db as nsx_db
from vmware_nsxlib.v3 import exceptions as nsxlib_exc
@@ -78,8 +78,8 @@ class NsxV3Driver(l2gateway_db.L2GatewayMixin):
def_l2gw_name = cfg.CONF.nsx_v3.default_bridge_cluster
# Return if no default_bridge_cluster set in config
if not def_l2gw_name:
LOG.info(_LI("NSX: Default bridge cluster not configured "
"in nsx.ini. No default L2 gateway created."))
LOG.info("NSX: Default bridge cluster not configured "
"in nsx.ini. No default L2 gateway created.")
return
admin_ctx = context.get_admin_context()
@@ -104,7 +104,7 @@ class NsxV3Driver(l2gateway_db.L2GatewayMixin):
# the first device in the list.
if l2gateway['devices'][0]['device_name'] == def_l2gw_uuid:
if def_l2gw_exists:
LOG.info(_LI("Default L2 gateway is already created."))
LOG.info("Default L2 gateway is already created.")
try:
# Try deleting this duplicate default L2 gateway
self.validate_l2_gateway_for_delete(
@@ -227,8 +227,8 @@ class NsxV3Driver(l2gateway_db.L2GatewayMixin):
seg_id=seg_id,
tags=tags)
except nsxlib_exc.ManagerError as e:
LOG.exception(_LE("Unable to create bridge endpoint, rolling back "
"changes on neutron. Exception is %s"), e)
LOG.exception("Unable to create bridge endpoint, rolling back "
"changes on neutron. Exception is %s", e)
raise l2gw_exc.L2GatewayServiceDriverError(
method='create_l2_gateway_connection_postcommit')
#TODO(abhiraut): Consider specifying the name of the port
@@ -255,8 +255,8 @@ class NsxV3Driver(l2gateway_db.L2GatewayMixin):
LOG.debug("IP addresses deallocated on port %s", port['id'])
except (nsxlib_exc.ManagerError,
n_exc.NeutronException):
LOG.exception(_LE("Unable to create L2 gateway port, "
"rolling back changes on neutron"))
LOG.exception("Unable to create L2 gateway port, "
"rolling back changes on neutron")
self._core_plugin.nsxlib.bridge_endpoint.delete(
bridge_endpoint['id'])
raise l2gw_exc.L2GatewayServiceDriverError(
@@ -270,8 +270,8 @@ class NsxV3Driver(l2gateway_db.L2GatewayMixin):
port_id=port['id'])
except db_exc.DBError:
with excutils.save_and_reraise_exception():
LOG.exception(_LE("Unable to add L2 gateway connection "
"mappings, rolling back changes on neutron"))
LOG.exception("Unable to add L2 gateway connection "
"mappings, rolling back changes on neutron")
self._core_plugin.nsxlib.bridge_endpoint.delete(
bridge_endpoint['id'])
super(NsxV3Driver,
@@ -299,8 +299,8 @@ class NsxV3Driver(l2gateway_db.L2GatewayMixin):
try:
self._core_plugin.nsxlib.bridge_endpoint.delete(bridge_endpoint_id)
except nsxlib_exc.ManagerError as e:
LOG.exception(_LE("Unable to delete bridge endpoint %(id)s on the "
"backend due to exc: %(exc)s"),
LOG.exception("Unable to delete bridge endpoint %(id)s on the "
"backend due to exc: %(exc)s",
{'id': bridge_endpoint_id, 'exc': e})
raise l2gw_exc.L2GatewayServiceDriverError(
method='delete_l2_gateway_connection_postcommit')

View File

@@ -17,7 +17,6 @@ from oslo_log import helpers as log_helpers
from oslo_log import log as logging
from oslo_utils import excutils
from vmware_nsx._i18n import _LE
from vmware_nsx.common import locking
from vmware_nsx.db import nsxv_db
from vmware_nsx.plugins.nsx_v.vshield.common import exceptions as nsxv_exc
@@ -86,8 +85,8 @@ class EdgeHealthMonitorManager(base_mgr.EdgeLoadbalancerBaseManager):
with excutils.save_and_reraise_exception():
self.lbv2_driver.health_monitor.failed_completion(
context, hm)
LOG.error(_LE('Failed to create health monitor on edge: %s'
), edge_id)
LOG.error('Failed to create health monitor on edge: %s',
edge_id)
try:
# Associate monitor with Edge pool
@@ -104,7 +103,7 @@ class EdgeHealthMonitorManager(base_mgr.EdgeLoadbalancerBaseManager):
with excutils.save_and_reraise_exception():
self.lbv2_driver.health_monitor.failed_completion(context, hm)
LOG.error(
_LE('Failed to create health monitor on edge: %s'),
'Failed to create health monitor on edge: %s',
edge_id)
self.lbv2_driver.health_monitor.successful_completion(context, hm)
@@ -132,8 +131,7 @@ class EdgeHealthMonitorManager(base_mgr.EdgeLoadbalancerBaseManager):
with excutils.save_and_reraise_exception():
self.lbv2_driver.health_monitor.failed_completion(context,
new_hm)
LOG.error(
_LE('Failed to update monitor on edge: %s'), edge_id)
LOG.error('Failed to update monitor on edge: %s', edge_id)
self.lbv2_driver.health_monitor.successful_completion(context, new_hm)
@@ -160,9 +158,8 @@ class EdgeHealthMonitorManager(base_mgr.EdgeLoadbalancerBaseManager):
except nsxv_exc.VcnsApiException:
with excutils.save_and_reraise_exception():
self.lbv2_driver.health_monitor.failed_completion(context, hm)
LOG.error(
_LE('Failed to delete monitor mapping on edge: %s'),
edge_id)
LOG.error('Failed to delete monitor mapping on edge: %s',
edge_id)
# If this monitor is not used on this edge anymore, delete it
if not edge_pool['monitorId']:
@@ -174,8 +171,7 @@ class EdgeHealthMonitorManager(base_mgr.EdgeLoadbalancerBaseManager):
with excutils.save_and_reraise_exception():
self.lbv2_driver.health_monitor.failed_completion(context,
hm)
LOG.error(
_LE('Failed to delete monitor on edge: %s'), edge_id)
LOG.error('Failed to delete monitor on edge: %s', edge_id)
nsxv_db.del_nsxv_lbaas_monitor_binding(
context.session, lb_id, hm.pool.id, hm.id, edge_id)

View File

@@ -20,7 +20,7 @@ from oslo_utils import excutils
from neutron_lib import constants
from neutron_lib import exceptions as n_exc
from vmware_nsx._i18n import _, _LE, _LW
from vmware_nsx._i18n import _
from vmware_nsx.common import locking
from vmware_nsx.db import nsxv_db
from vmware_nsx.services.lbaas.nsx_v import lbaas_common as lb_common
@@ -49,9 +49,9 @@ def policy_to_application_rule(policy):
type_by_comp = type_by_compare_type.get(rule.compare_type)
if type_by_comp is None:
type_by_comp = ''
LOG.warnning(_LW('Unsupported compare type %(type)s is used in '
'policy %(id)s'), {'type': rule.compare_type,
'id': policy.id})
LOG.warnning('Unsupported compare type %(type)s is used in '
'policy %(id)s', {'type': rule.compare_type,
'id': policy.id})
if rule.type == lb_const.L7_RULE_TYPE_COOKIE:
# Example: acl <id> hdr_sub(cookie) SEEN=1
@@ -235,8 +235,8 @@ class EdgeL7PolicyManager(base_mgr.EdgeLoadbalancerBaseManager):
except Exception as e:
with excutils.save_and_reraise_exception():
self.lbv2_driver.l7policy.failed_completion(context, pol)
LOG.error(_LE('Failed to create L7policy on edge %(edge)s: '
'%(err)s'),
LOG.error('Failed to create L7policy on edge %(edge)s: '
'%(err)s',
{'edge': edge_id, 'err': e})
if app_rule_id:
# Failed to add the rule to the vip: delete the rule
@@ -273,8 +273,8 @@ class EdgeL7PolicyManager(base_mgr.EdgeLoadbalancerBaseManager):
except Exception as e:
with excutils.save_and_reraise_exception():
self.lbv2_driver.l7policy.failed_completion(context, new_pol)
LOG.error(_LE('Failed to update L7policy on edge %(edge)s: '
'%(err)s'),
LOG.error('Failed to update L7policy on edge %(edge)s: '
'%(err)s',
{'edge': edge_id, 'err': e})
# complete the transaction
@@ -305,8 +305,8 @@ class EdgeL7PolicyManager(base_mgr.EdgeLoadbalancerBaseManager):
except Exception as e:
with excutils.save_and_reraise_exception():
self.lbv2_driver.l7policy.failed_completion(context, pol)
LOG.error(_LE('Failed to delete L7policy on edge '
'%(edge)s: %(err)s'),
LOG.error('Failed to delete L7policy on edge '
'%(edge)s: %(err)s',
{'edge': edge_id, 'err': e})
# delete the nsxv db entry

View File

@@ -17,7 +17,6 @@ from oslo_log import helpers as log_helpers
from oslo_log import log as logging
from oslo_utils import excutils
from vmware_nsx._i18n import _LE
from vmware_nsx.common import locking
from vmware_nsx.services.lbaas.nsx_v.v2 import base_mgr
from vmware_nsx.services.lbaas.nsx_v.v2 import l7policy_mgr
@@ -46,8 +45,8 @@ class EdgeL7RuleManager(base_mgr.EdgeLoadbalancerBaseManager):
except Exception as e:
with excutils.save_and_reraise_exception():
self.lbv2_driver.l7rule.failed_completion(context, rule)
LOG.error(_LE('Failed to update L7rules on edge %(edge)s: '
'%(err)s'),
LOG.error('Failed to update L7rules on edge %(edge)s: '
'%(err)s',
{'edge': edge_id, 'err': e})
# complete the transaction

View File

@@ -17,7 +17,7 @@ from oslo_log import helpers as log_helpers
from oslo_log import log as logging
from oslo_utils import excutils
from vmware_nsx._i18n import _, _LE
from vmware_nsx._i18n import _
from vmware_nsx.common import exceptions as nsxv_exc
from vmware_nsx.common import locking
from vmware_nsx.db import nsxv_db
@@ -167,7 +167,7 @@ class EdgeListenerManager(base_mgr.EdgeLoadbalancerBaseManager):
except vcns_exc.VcnsApiException:
with excutils.save_and_reraise_exception():
self.lbv2_driver.listener.failed_completion(context, listener)
LOG.error(_LE('Failed to create app profile on edge: %s'),
LOG.error('Failed to create app profile on edge: %s',
lb_binding['edge_id'])
vse = listener_to_edge_vse(context, listener,
@@ -190,7 +190,7 @@ class EdgeListenerManager(base_mgr.EdgeLoadbalancerBaseManager):
except vcns_exc.VcnsApiException:
with excutils.save_and_reraise_exception():
self.lbv2_driver.listener.failed_completion(context, listener)
LOG.error(_LE('Failed to create vip on Edge: %s'), edge_id)
LOG.error('Failed to create vip on Edge: %s', edge_id)
self.vcns.delete_app_profile(edge_id, app_profile_id)
@log_helpers.log_method_call
@@ -204,7 +204,7 @@ class EdgeListenerManager(base_mgr.EdgeLoadbalancerBaseManager):
if pool_binding:
default_pool = pool_binding['edge_pool_id']
else:
LOG.error(_LE("Couldn't find pool binding for pool %s"),
LOG.error("Couldn't find pool binding for pool %s",
new_listener.default_pool.id)
lb_id = new_listener.loadbalancer_id
@@ -255,7 +255,7 @@ class EdgeListenerManager(base_mgr.EdgeLoadbalancerBaseManager):
with excutils.save_and_reraise_exception():
self.lbv2_driver.listener.failed_completion(context,
new_listener)
LOG.error(_LE('Failed to update app profile on edge: %s'),
LOG.error('Failed to update app profile on edge: %s',
edge_id)
@log_helpers.log_method_call
@@ -276,25 +276,24 @@ class EdgeListenerManager(base_mgr.EdgeLoadbalancerBaseManager):
self.vcns.delete_vip(edge_id, edge_vse_id)
except vcns_exc.ResourceNotFound:
LOG.error(_LE('vip not found on edge: %s'), edge_id)
LOG.error('vip not found on edge: %s', edge_id)
except vcns_exc.VcnsApiException:
with excutils.save_and_reraise_exception():
self.lbv2_driver.listener.failed_completion(context,
listener)
LOG.error(
_LE('Failed to delete vip on edge: %s'), edge_id)
LOG.error('Failed to delete vip on edge: %s', edge_id)
try:
with locking.LockManager.get_lock(edge_id):
self.vcns.delete_app_profile(edge_id, app_profile_id)
except vcns_exc.ResourceNotFound:
LOG.error(_LE('app profile not found on edge: %s'), edge_id)
LOG.error('app profile not found on edge: %s', edge_id)
except vcns_exc.VcnsApiException:
with excutils.save_and_reraise_exception():
self.lbv2_driver.listener.failed_completion(context,
listener)
LOG.error(
_LE('Failed to delete app profile on Edge: %s'),
'Failed to delete app profile on Edge: %s',
edge_id)
nsxv_db.del_nsxv_lbaas_listener_binding(context.session, lb_id,

View File

@@ -22,7 +22,7 @@ from oslo_log import helpers as log_helpers
from oslo_log import log as logging
from oslo_utils import excutils
from vmware_nsx._i18n import _, _LE
from vmware_nsx._i18n import _
from vmware_nsx.db import nsxv_db
from vmware_nsx.plugins.nsx_v.vshield.common import exceptions as nsxv_exc
from vmware_nsx.services.lbaas.nsx_v import lbaas_common as lb_common
@@ -69,7 +69,7 @@ class EdgeLoadBalancerManager(base_mgr.EdgeLoadbalancerBaseManager):
except nsxv_exc.VcnsApiException:
with excutils.save_and_reraise_exception():
self.lbv2_driver.load_balancer.failed_completion(context, lb)
LOG.error(_LE('Failed to create pool %s'), lb.id)
LOG.error('Failed to create pool %s', lb.id)
@log_helpers.log_method_call
def update(self, context, old_lb, new_lb):
@@ -107,16 +107,16 @@ class EdgeLoadBalancerManager(base_mgr.EdgeLoadbalancerBaseManager):
self.vcns, binding['edge_id'],
binding['edge_fw_rule_id'])
except nsxv_exc.VcnsApiException as e:
LOG.error(_LE('Failed to delete loadbalancer %(lb)s '
'FW rule. exception is %(exc)s'),
LOG.error('Failed to delete loadbalancer %(lb)s '
'FW rule. exception is %(exc)s',
{'lb': lb.id, 'exc': e})
try:
lb_common.del_vip_as_secondary_ip(self.vcns,
binding['edge_id'],
lb.vip_address)
except Exception as e:
LOG.error(_LE('Failed to delete loadbalancer %(lb)s '
'interface IP. exception is %(exc)s'),
LOG.error('Failed to delete loadbalancer %(lb)s '
'interface IP. exception is %(exc)s',
{'lb': lb.id, 'exc': e})
nsxv_db.del_nsxv_lbaas_loadbalancer_binding(context.session, lb.id)

View File

@@ -17,7 +17,6 @@ from oslo_log import helpers as log_helpers
from oslo_log import log as logging
from oslo_utils import excutils
from vmware_nsx._i18n import _LE
from vmware_nsx.common import locking
from vmware_nsx.db import nsxv_db
from vmware_nsx.plugins.nsx_v.vshield.common import exceptions as nsxv_exc
@@ -81,7 +80,7 @@ class EdgeMemberManager(base_mgr.EdgeLoadbalancerBaseManager):
except nsxv_exc.VcnsApiException:
with excutils.save_and_reraise_exception():
self.lbv2_driver.member.failed_completion(context, member)
LOG.error(_LE('Failed to create member on edge: %s'),
LOG.error('Failed to create member on edge: %s',
edge_id)
@log_helpers.log_method_call
@@ -124,13 +123,13 @@ class EdgeMemberManager(base_mgr.EdgeLoadbalancerBaseManager):
with excutils.save_and_reraise_exception():
self.lbv2_driver.member.failed_completion(
context, new_member)
LOG.error(_LE('Failed to update member on edge: %s'),
LOG.error('Failed to update member on edge: %s',
edge_id)
else:
LOG.error(_LE('Pool %(pool_id)s on Edge %(edge_id)s has no '
'members to update')
% {'pool_id': new_member.pool.id,
'edge_id': edge_id})
LOG.error('Pool %(pool_id)s on Edge %(edge_id)s has no '
'members to update',
{'pool_id': new_member.pool.id,
'edge_id': edge_id})
@log_helpers.log_method_call
def delete(self, context, member):
@@ -173,5 +172,5 @@ class EdgeMemberManager(base_mgr.EdgeLoadbalancerBaseManager):
except nsxv_exc.VcnsApiException:
with excutils.save_and_reraise_exception():
self.lbv2_driver.member.failed_completion(context, member)
LOG.error(_LE('Failed to delete member on edge: %s'),
LOG.error('Failed to delete member on edge: %s',
edge_id)

View File

@@ -19,7 +19,6 @@ from oslo_utils import excutils
from neutron_lib import exceptions as n_exc
from vmware_nsx._i18n import _LE
from vmware_nsx.common import locking
from vmware_nsx.db import nsxv_db
from vmware_nsx.plugins.nsx_v.vshield.common import exceptions as nsxv_exc
@@ -83,7 +82,7 @@ class EdgePoolManager(base_mgr.EdgeLoadbalancerBaseManager):
except nsxv_exc.VcnsApiException:
with excutils.save_and_reraise_exception():
self.lbv2_driver.pool.failed_completion(context, pool)
LOG.error(_LE('Failed to create pool %s'), pool.id)
LOG.error('Failed to create pool %s', pool.id)
@log_helpers.log_method_call
def update(self, context, old_pool, new_pool):
@@ -119,7 +118,7 @@ class EdgePoolManager(base_mgr.EdgeLoadbalancerBaseManager):
except nsxv_exc.VcnsApiException:
with excutils.save_and_reraise_exception():
self.lbv2_driver.pool.failed_completion(context, new_pool)
LOG.error(_LE('Failed to update pool %s'), new_pool.id)
LOG.error('Failed to update pool %s', new_pool.id)
@log_helpers.log_method_call
def delete(self, context, pool):
@@ -154,4 +153,4 @@ class EdgePoolManager(base_mgr.EdgeLoadbalancerBaseManager):
context.session, lb_id, pool.id)
except nsxv_exc.VcnsApiException:
self.lbv2_driver.pool.failed_completion(context, pool)
LOG.error(_LE('Failed to delete pool %s'), pool.id)
LOG.error('Failed to delete pool %s', pool.id)

View File

@@ -19,7 +19,7 @@ from neutron.services.qos import qos_plugin
from oslo_config import cfg
from oslo_log import log as logging
from vmware_nsx._i18n import _, _LI
from vmware_nsx._i18n import _
from vmware_nsx.common import exceptions as nsx_exc
LOG = logging.getLogger(__name__)
@@ -32,7 +32,7 @@ class NsxVQosPlugin(qos_plugin.QoSPlugin):
supported_extension_aliases = ["qos"]
def __init__(self):
LOG.info(_LI("Loading VMware NSX-V Qos Service Plugin"))
LOG.info("Loading VMware NSX-V Qos Service Plugin")
super(NsxVQosPlugin, self).__init__()
if not cfg.CONF.nsxv.use_dvs_features:

View File

@@ -22,7 +22,7 @@ from neutron_lib.plugins import directory
from oslo_config import cfg
from oslo_log import log as logging
from vmware_nsx._i18n import _, _LW
from vmware_nsx._i18n import _
from vmware_nsx.common import exceptions as nsx_exc
from vmware_nsx.db import db as nsx_db
@@ -143,16 +143,16 @@ class QosNotificationsHandler(object):
# Validate the max bandwidth value minimum value
# (max value is above what neutron allows so no need to check it)
if (bw_rule.max_kbps < MAX_KBPS_MIN_VALUE):
LOG.warning(_LW("Invalid input for max_kbps. "
"The minimal legal value is %s"),
LOG.warning("Invalid input for max_kbps. "
"The minimal legal value is %s",
MAX_KBPS_MIN_VALUE)
bw_rule.max_kbps = MAX_KBPS_MIN_VALUE
# validate the burst size value max value
# (max value is 0, and neutron already validates this)
if (bw_rule.max_burst_kbps > MAX_BURST_MAX_VALUE):
LOG.warning(_LW("Invalid input for burst_size. "
"The maximal legal value is %s"),
LOG.warning("Invalid input for burst_size. "
"The maximal legal value is %s",
MAX_BURST_MAX_VALUE)
bw_rule.max_burst_kbps = MAX_BURST_MAX_VALUE

View File

@@ -24,7 +24,6 @@ from neutron.services.trunk import constants as trunk_consts
from neutron.services.trunk.drivers import base
from neutron_lib.api.definitions import portbindings
from vmware_nsx._i18n import _LE
from vmware_nsx.common import nsx_constants as nsx_consts
from vmware_nsx.common import utils as nsx_utils
from vmware_nsx.db import db as nsx_db
@@ -69,8 +68,8 @@ class NsxV3TrunkHandler(object):
nsx_child_port_id)
except nsxlib_exc.ResourceNotFound:
with excutils.save_and_reraise_exception():
LOG.error(_LE("Child port %s not found on the backend. "
"Setting trunk status to ERROR."),
LOG.error("Child port %s not found on the backend. "
"Setting trunk status to ERROR.",
nsx_child_port_id)
# Build address bindings and switch profiles otherwise backend will
# clear that information during port update
@@ -103,9 +102,9 @@ class NsxV3TrunkHandler(object):
traffic_tag=seg_id)
except nsxlib_exc.ManagerError as e:
with excutils.save_and_reraise_exception():
LOG.error(_LE("Unable to update subport for attachment "
"type. Setting trunk status to ERROR. "
"Exception is %s"), e)
LOG.error("Unable to update subport for attachment "
"type. Setting trunk status to ERROR. "
"Exception is %s", e)
def _set_subports(self, context, parent_port_id, subports):
for subport in subports:

View File

@@ -18,8 +18,6 @@ from oslo_serialization import jsonutils
import prettytable
from vmware_nsx._i18n import _LI
LOG = logging.getLogger(__name__)
@@ -29,9 +27,9 @@ def output_formatter(resource_name, resources_list, attrs):
Depending on the --fmt cli option we format the output as
JSON or as a table.
"""
LOG.info(_LI('%(resource_name)s'), {'resource_name': resource_name})
LOG.info('%(resource_name)s', {'resource_name': resource_name})
if not resources_list:
LOG.info(_LI('No resources found'))
LOG.info('No resources found')
return ''
fmt = cfg.CONF.fmt

View File

@@ -15,11 +15,12 @@
import six
import sys
from vmware_nsx._i18n import _LI, _
from vmware_nsx._i18n import _
from vmware_nsx.shell import resources as nsxadmin
from neutron.callbacks import registry
from neutron.common import profiler # noqa
from oslo_log import log as logging
from vmware_nsx.shell import resources as nsxadmin
LOG = logging.getLogger(__name__)
@@ -34,7 +35,7 @@ def output_header(func):
def func_desc(*args, **kwargs):
component = '[%s]' % func.__name__.split('_')[0].upper()
op_desc = [n.capitalize() for n in func.__name__.split('_')[1:]]
LOG.info(_LI('==== %(component)s %(operation)s ===='),
LOG.info('==== %(component)s %(operation)s ====',
{'component': component, 'operation': ' '.join(op_desc)})
return func(*args, **kwargs)
func_desc.__name__ = func.__name__

View File

@@ -19,7 +19,6 @@ from neutron_lib import exceptions
from oslo_log import log as logging
from oslo_utils import uuidutils
from vmware_nsx._i18n import _LE, _LI
from vmware_nsx.common import locking
from vmware_nsx.common import nsxv_constants
from vmware_nsx.db import nsxv_db
@@ -90,7 +89,7 @@ def _delete_edge_from_nsx_and_neutron(edge_id, router_id):
_delete_backup_from_neutron_db(edge_id, router_id)
return True
except Exception as expt:
LOG.error(_LE("%s"), str(expt))
LOG.error("%s", str(expt))
return False
@@ -99,7 +98,7 @@ def _nsx_delete_backup_edge(edge_id, all_backup_edges):
try:
edge_result = nsxv.get_edge(edge_id)
except exceptions.NeutronException as x:
LOG.error(_LE("%s"), str(x))
LOG.error("%s", str(x))
else:
# edge_result[0] is response status code
# edge_result[1] is response body
@@ -108,7 +107,7 @@ def _nsx_delete_backup_edge(edge_id, all_backup_edges):
if (not edge['name'].startswith('backup-')
or edge['id'] not in backup_edges):
LOG.error(
_LE('Edge: %s is not a backup edge; aborting delete'),
'Edge: %s is not a backup edge; aborting delete',
edge_id)
else:
return _delete_edge_from_nsx_and_neutron(edge_id, edge['name'])
@@ -119,18 +118,18 @@ def nsx_clean_backup_edge(resource, event, trigger, **kwargs):
errmsg = ("Need to specify edge-id property. Add --property "
"edge-id=<edge-id>")
if not kwargs.get('property'):
LOG.error(_LE("%s"), errmsg)
LOG.error("%s", errmsg)
return
properties = admin_utils.parse_multi_keyval_opt(kwargs['property'])
edge_id = properties.get('edge-id')
if not edge_id:
LOG.error(_LE("%s"), errmsg)
LOG.error("%s", errmsg)
return
#ask for the user confirmation
confirm = admin_utils.query_yes_no(
"Do you want to delete edge: %s" % edge_id, default="no")
if not confirm:
LOG.info(_LI("Backup edge deletion aborted by user"))
LOG.info("Backup edge deletion aborted by user")
return
# delete the backup edge
_nsx_delete_backup_edge(edge_id, get_nsxv_backup_edges())
@@ -145,7 +144,7 @@ def nsx_clean_all_backup_edges(resource, event, trigger, **kwargs):
"Do you want to delete %s backup edges?" % len(backup_edges),
default="no")
if not confirm:
LOG.info(_LI("Backup edges deletion aborted by user"))
LOG.info("Backup edges deletion aborted by user")
return
deleted_cnt = 0
@@ -154,7 +153,7 @@ def nsx_clean_all_backup_edges(resource, event, trigger, **kwargs):
if _nsx_delete_backup_edge(edge['id'], backup_edges):
deleted_cnt = deleted_cnt + 1
LOG.info(_LI('Done Deleting %s backup edges'), deleted_cnt)
LOG.info('Done Deleting %s backup edges', deleted_cnt)
@admin_utils.output_header
@@ -167,12 +166,12 @@ def neutron_clean_backup_edge(resource, event, trigger, **kwargs):
errmsg = ("Need to specify router-id property. Add --property "
"router-id=<router-id>")
if not kwargs.get('property'):
LOG.error(_LE("%s"), errmsg)
LOG.error("%s", errmsg)
return
properties = admin_utils.parse_multi_keyval_opt(kwargs['property'])
router_id = properties.get('router-id')
if not router_id:
LOG.error(_LE("%s"), errmsg)
LOG.error("%s", errmsg)
return
# look for the router-binding entry
@@ -180,7 +179,7 @@ def neutron_clean_backup_edge(resource, event, trigger, **kwargs):
rtr_binding = nsxv_db.get_nsxv_router_binding(
edgeapi.context.session, router_id)
if not rtr_binding:
LOG.error(_LE('Backup %s was not found in DB'), router_id)
LOG.error('Backup %s was not found in DB', router_id)
return
edge_id = rtr_binding['edge_id']
@@ -240,20 +239,20 @@ def nsx_fix_name_mismatch(resource, event, trigger, **kwargs):
errmsg = ("Need to specify edge-id property. Add --property "
"edge-id=<edge-id>")
if not kwargs.get('property'):
LOG.error(_LE("%s"), errmsg)
LOG.error("%s", errmsg)
return
properties = admin_utils.parse_multi_keyval_opt(kwargs['property'])
edgeapi = utils.NeutronDbClient()
edge_id = properties.get('edge-id')
if not edge_id:
LOG.error(_LE("%s"), errmsg)
LOG.error("%s", errmsg)
return
try:
# edge[0] is response status code
# edge[1] is response body
edge = nsxv.get_edge(edge_id)[1]
except exceptions.NeutronException as e:
LOG.error(_LE("%s"), str(e))
LOG.error("%s", str(e))
else:
if edge['name'].startswith('backup-'):
@@ -261,8 +260,7 @@ def nsx_fix_name_mismatch(resource, event, trigger, **kwargs):
edgeapi.context.session, edge['id'])
if rtr_binding['router_id'] == edge['name']:
LOG.error(
_LE('Edge %s no mismatch with NSX'), edge_id)
LOG.error('Edge %s no mismatch with NSX', edge_id)
return
try:
@@ -292,13 +290,13 @@ def nsx_fix_name_mismatch(resource, event, trigger, **kwargs):
'-' + rtr_db['id'])
else:
LOG.error(
_LE('No database entry for router id %s'),
'No database entry for router id %s',
rtr_binding['router_id'])
else:
LOG.error(
_LE('Could not determine the name for '
'Edge %s'), edge_id)
'Could not determine the name for '
'Edge %s', edge_id)
return
confirm = admin_utils.query_yes_no(
@@ -307,21 +305,21 @@ def nsx_fix_name_mismatch(resource, event, trigger, **kwargs):
default="no")
if not confirm:
LOG.info(_LI("Edge rename aborted by user"))
LOG.info("Edge rename aborted by user")
return
LOG.info(_LI("Edge rename started"))
LOG.info("Edge rename started")
# remove some keys that will fail the NSX transaction
edge_utils.remove_irrelevant_keys_from_edge_request(edge)
try:
LOG.error(_LE("Update edge..."))
LOG.error("Update edge...")
nsxv.update_edge(edge_id, edge)
except Exception as e:
LOG.error(_LE("Update failed - %s"), (e))
LOG.error("Update failed - %s", (e))
except Exception as e:
LOG.error(_LE("%s"), str(e))
LOG.error("%s", str(e))
else:
LOG.error(
_LE('Edge %s has no backup prefix on NSX'), edge_id)
'Edge %s has no backup prefix on NSX', edge_id)
return
registry.subscribe(nsx_list_backup_edges,

View File

@@ -16,7 +16,6 @@ from neutron.callbacks import registry
from oslo_config import cfg
from oslo_log import log as logging
from vmware_nsx._i18n import _LE, _LI
from vmware_nsx.plugins.nsx_v.vshield.common import exceptions
from vmware_nsx.shell.admin.plugins.common import constants
from vmware_nsx.shell.admin.plugins.common import utils as admin_utils
@@ -32,12 +31,12 @@ def validate_configuration(resource, event, trigger, **kwargs):
try:
utils.NsxVPluginWrapper()
except exceptions.Forbidden:
LOG.error(_LE("Configuration validation failed: wrong VSM credentials "
"for %s"), cfg.CONF.nsxv.manager_uri)
LOG.error("Configuration validation failed: wrong VSM credentials "
"for %s", cfg.CONF.nsxv.manager_uri)
except Exception as e:
LOG.error(_LE("Configuration validation failed: %s"), e)
LOG.error("Configuration validation failed: %s", e)
else:
LOG.info(_LI("Configuration validation succeeded"))
LOG.info("Configuration validation succeeded")
registry.subscribe(validate_configuration,

View File

@@ -27,7 +27,6 @@ import vmware_nsx.shell.resources as shell
from neutron.callbacks import registry
from neutron.db import l3_db
from vmware_nsx._i18n import _LE, _LI, _LW
from vmware_nsx.common import locking
from vmware_nsx.db import nsxv_db
from vmware_nsx.plugins.nsx_v.vshield.common import (
@@ -48,7 +47,7 @@ def nsx_get_static_bindings_by_edge(edge_id):
try:
nsx_dhcp_bindings = nsxv.query_dhcp_configuration(edge_id)
except exceptions.ResourceNotFound:
LOG.error(_LE("Edge %s was not found"), edge_id)
LOG.error("Edge %s was not found", edge_id)
return
# nsx_dhcp_bindings[0] contains response headers;
@@ -83,39 +82,39 @@ def list_missing_dhcp_bindings(resource, event, trigger, **kwargs):
"""
for (edge_id, count) in nsxv_db.get_nsxv_dhcp_bindings_count_per_edge(
neutron_db.context.session):
LOG.info(_LI("%s"), "=" * 60)
LOG.info(_LI("For edge: %s"), edge_id)
LOG.info("%s", "=" * 60)
LOG.info("For edge: %s", edge_id)
nsx_dhcp_static_bindings = nsx_get_static_bindings_by_edge(edge_id)
if nsx_dhcp_static_bindings is None:
continue
neutron_dhcp_static_bindings = \
neutron_get_static_bindings_by_edge(edge_id)
LOG.info(_LI("# of DHCP bindings in Neutron DB: %s"),
LOG.info("# of DHCP bindings in Neutron DB: %s",
len(neutron_dhcp_static_bindings))
LOG.info(_LI("# of DHCP bindings on NSXv backend: %s"),
LOG.info("# of DHCP bindings on NSXv backend: %s",
len(nsx_dhcp_static_bindings))
missing = neutron_dhcp_static_bindings - nsx_dhcp_static_bindings
if not missing:
LOG.info(_LI("No missing DHCP bindings found."))
LOG.info(_LI("Neutron DB and NSXv backend are in sync"))
LOG.info("No missing DHCP bindings found.")
LOG.info("Neutron DB and NSXv backend are in sync")
else:
LOG.info(_LI("Missing DHCP bindings:"))
LOG.info(_LI("%s"), pprint.pformat(missing))
LOG.info("Missing DHCP bindings:")
LOG.info("%s", pprint.pformat(missing))
@admin_utils.output_header
def nsx_update_dhcp_edge_binding(resource, event, trigger, **kwargs):
"""Resync DHCP bindings on NSXv Edge"""
if not kwargs.get('property'):
LOG.error(_LE("Need to specify edge-id parameter"))
LOG.error("Need to specify edge-id parameter")
return
else:
properties = admin_utils.parse_multi_keyval_opt(kwargs['property'])
edge_id = properties.get('edge-id')
if not edge_id:
LOG.error(_LE("Need to specify edge-id parameter"))
LOG.error("Need to specify edge-id parameter")
return
LOG.info(_LI("Updating NSXv Edge: %s"), edge_id)
LOG.info("Updating NSXv Edge: %s", edge_id)
# Need to create a plugin object; so that we are able to
# do neutron list-ports.
with utils.NsxVPluginWrapper() as plugin:
@@ -126,11 +125,11 @@ def nsx_update_dhcp_edge_binding(resource, event, trigger, **kwargs):
edge_manager.update_dhcp_service_config(
neutron_db.context, edge_id)
except exceptions.ResourceNotFound:
LOG.error(_LE("Edge %s not found"), edge_id)
LOG.error("Edge %s not found", edge_id)
def delete_old_dhcp_edge(context, old_edge_id, bindings):
LOG.info(_LI("Deleting the old DHCP edge: %s"), old_edge_id)
LOG.info("Deleting the old DHCP edge: %s", old_edge_id)
# using one of the router-ids in the bindings for the deleting
dhcp_names = [binding['router_id'] for binding in bindings]
dhcp_name = dhcp_names[0]
@@ -142,7 +141,7 @@ def delete_old_dhcp_edge(context, old_edge_id, bindings):
try:
nsxv.delete_edge(old_edge_id)
except Exception as e:
LOG.warning(_LW("Failed to delete the old edge %(id)s: %(e)s"),
LOG.warning("Failed to delete the old edge %(id)s: %(e)s",
{'id': old_edge_id, 'e': e})
# Continue the process anyway
# The edge may have been already deleted at the backend
@@ -152,8 +151,8 @@ def delete_old_dhcp_edge(context, old_edge_id, bindings):
nsxv_db.delete_nsxv_router_binding(context.session, dhcp_name)
nsxv_db.clean_edge_vnic_binding(context.session, old_edge_id)
except Exception as e:
LOG.warning(_LW("Failed to delete the old edge %(id)s from the "
"DB : %(e)s"), {'id': old_edge_id, 'e': e})
LOG.warning("Failed to delete the old edge %(id)s from the "
"DB : %(e)s", {'id': old_edge_id, 'e': e})
def recreate_vdr_dhcp_edge(context, plugin, edge_manager,
@@ -184,18 +183,18 @@ def recreate_vdr_dhcp_edge(context, plugin, edge_manager,
new_binding = nsxv_db.get_vdr_dhcp_binding_by_vdr(
context.session, vdr_router_id)
if new_binding:
LOG.info(_LI("VDR router %(vdr_id)s was moved to edge %(edge_id)s"),
LOG.info("VDR router %(vdr_id)s was moved to edge %(edge_id)s",
{'vdr_id': vdr_router_id,
'edge_id': new_binding['dhcp_edge_id']})
else:
LOG.error(_LE("VDR router %(vdr_id)s was not moved to a new edge"),
LOG.error("VDR router %(vdr_id)s was not moved to a new edge",
{'vdr_id': vdr_router_id})
def recreate_network_dhcp(context, plugin, edge_manager, old_edge_id, net_id):
"""Handle the DHCP edge recreation of a network
"""
LOG.info(_LI("Moving network %s to a new edge"), net_id)
LOG.info("Moving network %s to a new edge", net_id)
# delete the old binding
resource_id = (nsxv_constants.DHCP_EDGE_PREFIX + net_id)[:36]
nsxv_db.delete_nsxv_router_binding(context.session, resource_id)
@@ -214,7 +213,7 @@ def recreate_network_dhcp(context, plugin, edge_manager, old_edge_id, net_id):
net_filters = {'network_id': [net_id], 'enable_dhcp': [True]}
subnets = plugin.get_subnets(context, filters=net_filters)
for subnet in subnets:
LOG.info(_LI("Moving subnet %s to a new edge"), subnet['id'])
LOG.info("Moving subnet %s to a new edge", subnet['id'])
# allocate / reuse the new dhcp edge
new_resource_id = edge_manager.create_dhcp_edge_service(
context, net_id, subnet)
@@ -223,7 +222,7 @@ def recreate_network_dhcp(context, plugin, edge_manager, old_edge_id, net_id):
plugin._update_dhcp_service_new_edge(context, resource_id)
# Update the ip of the dhcp port
LOG.info(_LI("Creating network %s DHCP address group"), net_id)
LOG.info("Creating network %s DHCP address group", net_id)
address_groups = plugin._create_network_dhcp_address_group(
context, net_id)
plugin._update_dhcp_edge_service(context, net_id, address_groups)
@@ -232,17 +231,17 @@ def recreate_network_dhcp(context, plugin, edge_manager, old_edge_id, net_id):
new_binding = nsxv_db.get_nsxv_router_binding(
context.session, resource_id)
if new_binding:
LOG.info(_LI("Network %(net_id)s was moved to edge %(edge_id)s"),
LOG.info("Network %(net_id)s was moved to edge %(edge_id)s",
{'net_id': net_id, 'edge_id': new_binding['edge_id']})
else:
LOG.error(_LE("Network %(net_id)s was not moved to a new edge"),
LOG.error("Network %(net_id)s was not moved to a new edge",
{'net_id': net_id})
@admin_utils.output_header
def nsx_recreate_dhcp_edge(resource, event, trigger, **kwargs):
"""Recreate a dhcp edge with all the networks n a new NSXv edge"""
usage_msg = _LE("Need to specify edge-id or net-id parameter")
usage_msg = ("Need to specify edge-id or net-id parameter")
if not kwargs.get('property'):
LOG.error(usage_msg)
return
@@ -258,7 +257,7 @@ def nsx_recreate_dhcp_edge(resource, event, trigger, **kwargs):
return
LOG.error(usage_msg)
return
LOG.info(_LI("ReCreating NSXv Edge: %s"), old_edge_id)
LOG.info("ReCreating NSXv Edge: %s", old_edge_id)
context = n_context.get_admin_context()
@@ -268,7 +267,7 @@ def nsx_recreate_dhcp_edge(resource, event, trigger, **kwargs):
if (not bindings or
not bindings[0]['router_id'].startswith(
nsxv_constants.DHCP_EDGE_PREFIX)):
LOG.error(_LE("Edge %(edge_id)s is not a DHCP edge"),
LOG.error("Edge %(edge_id)s is not a DHCP edge",
{'edge_id': old_edge_id})
return
@@ -322,7 +321,7 @@ def _get_net_vdr_router_id(plugin, context, net_id):
def nsx_recreate_dhcp_edge_by_net_id(net_id):
"""Recreate a dhcp edge for a specific network without an edge"""
LOG.info(_LI("ReCreating NSXv Edge for network: %s"), net_id)
LOG.info("ReCreating NSXv Edge for network: %s", net_id)
context = n_context.get_admin_context()
@@ -333,8 +332,8 @@ def nsx_recreate_dhcp_edge_by_net_id(net_id):
if router_binding:
# make sure there is no edge
if router_binding['edge_id']:
LOG.warning(_LW("Network %(net_id)s already has a dhcp edge: "
"%(egde_id)s"),
LOG.warning("Network %(net_id)s already has a dhcp edge: "
"%(egde_id)s",
{'edge_id': router_binding['edge_id'],
'net_id': net_id})
return

View File

@@ -29,7 +29,6 @@ from neutron.callbacks import registry
from neutron_lib import exceptions
from oslo_log import log as logging
from vmware_nsx._i18n import _LE, _LI
from vmware_nsx.common import nsxv_constants
from vmware_nsx.db import nsxv_db
from vmware_nsx.plugins.nsx_v import availability_zones as nsx_az
@@ -98,12 +97,12 @@ def nsx_list_orphaned_edges(resource, event, trigger, **kwargs):
Orphaned edges are NSXv edges that exist on NSXv backend but
don't have a corresponding binding in Neutron DB
"""
LOG.info(_LI("NSXv edges present on NSXv backend but not present "
"in Neutron DB\n"))
LOG.info("NSXv edges present on NSXv backend but not present "
"in Neutron DB\n")
orphaned_edges = get_orphaned_edges()
if not orphaned_edges:
LOG.info(_LI("\nNo orphaned edges found."
"\nNeutron DB and NSXv backend are in sync\n"))
LOG.info("\nNo orphaned edges found."
"\nNeutron DB and NSXv backend are in sync\n")
else:
LOG.info(constants.ORPHANED_EDGES)
data = [('edge_id',)]
@@ -116,7 +115,7 @@ def nsx_list_orphaned_edges(resource, event, trigger, **kwargs):
def nsx_delete_orphaned_edges(resource, event, trigger, **kwargs):
"""Delete orphaned edges from NSXv backend"""
orphaned_edges = get_orphaned_edges()
LOG.info(_LI("Before delete; Orphaned Edges: %s"), orphaned_edges)
LOG.info("Before delete; Orphaned Edges: %s", orphaned_edges)
if not kwargs.get('force'):
if len(orphaned_edges):
@@ -124,15 +123,15 @@ def nsx_delete_orphaned_edges(resource, event, trigger, **kwargs):
"orphaned edges",
default="no")
if not user_confirm:
LOG.info(_LI("NSXv Edge deletion aborted by user"))
LOG.info("NSXv Edge deletion aborted by user")
return
nsxv = utils.get_nsxv_client()
for edge in orphaned_edges:
LOG.info(_LI("Deleting edge: %s"), edge)
LOG.info("Deleting edge: %s", edge)
nsxv.delete_edge(edge)
LOG.info(_LI("After delete; Orphaned Edges: \n%s"),
LOG.info("After delete; Orphaned Edges: \n%s",
pprint.pformat(get_orphaned_edges()))
@@ -161,12 +160,12 @@ def nsx_list_missing_edges(resource, event, trigger, **kwargs):
Missing edges are NSXv edges that have a binding in Neutron DB
but are currently missing from the NSXv backend.
"""
LOG.info(_LI("NSXv edges present in Neutron DB but not present "
"on the NSXv backend\n"))
LOG.info("NSXv edges present in Neutron DB but not present "
"on the NSXv backend\n")
missing_edges = get_missing_edges()
if not missing_edges:
LOG.info(_LI("\nNo edges are missing."
"\nNeutron DB and NSXv backend are in sync\n"))
LOG.info("\nNo edges are missing."
"\nNeutron DB and NSXv backend are in sync\n")
else:
data = [('edge_id', 'network_id')]
for edge in missing_edges:
@@ -188,9 +187,9 @@ def change_edge_ha(ha, edge_id):
try:
nsxv.enable_ha(edge_id, request)
except nsxv_exceptions.ResourceNotFound as e:
LOG.error(_LE("Edge %s not found"), edge_id)
LOG.error("Edge %s not found", edge_id)
except exceptions.NeutronException as e:
LOG.error(_LE("%s"), str(e))
LOG.error("%s", str(e))
def change_edge_syslog(properties):
@@ -200,7 +199,7 @@ def change_edge_syslog(properties):
request['protocol'] = properties.get('syslog-proto', 'tcp')
if request['protocol'] not in ['tcp', 'udp']:
LOG.error(_LE("Property value error: syslog-proto must be tcp/udp"))
LOG.error("Property value error: syslog-proto must be tcp/udp")
return
if properties.get('syslog-server'):
@@ -214,18 +213,18 @@ def change_edge_syslog(properties):
try:
nsxv.update_edge_syslog(edge_id, request)
except nsxv_exceptions.ResourceNotFound as e:
LOG.error(_LE("Edge %s not found"), edge_id)
LOG.error("Edge %s not found", edge_id)
except exceptions.NeutronException as e:
LOG.error(_LE("%s"), str(e))
LOG.error("%s", str(e))
def delete_edge_syslog(edge_id):
try:
nsxv.delete_edge_syslog(edge_id)
except nsxv_exceptions.ResourceNotFound as e:
LOG.error(_LE("Edge %s not found"), edge_id)
LOG.error("Edge %s not found", edge_id)
except exceptions.NeutronException as e:
LOG.error(_LE("%s"), str(e))
LOG.error("%s", str(e))
def change_edge_loglevel(properties):
@@ -257,17 +256,17 @@ def change_edge_loglevel(properties):
for module, level in modules.items():
if level == 'none':
LOG.info(_LI("Disabling logging for %s"), module)
LOG.info("Disabling logging for %s", module)
else:
LOG.info(_LI("Enabling logging for %(m)s with level %(l)s"),
LOG.info("Enabling logging for %(m)s with level %(l)s",
{'m': module, 'l': level})
try:
edge_utils.update_edge_loglevel(nsxv, edge_id, module, level)
except nsxv_exceptions.ResourceNotFound as e:
LOG.error(_LE("Edge %s not found"), edge_id)
LOG.error("Edge %s not found", edge_id)
except exceptions.NeutronException as e:
LOG.error(_LE("%s"), str(e))
LOG.error("%s", str(e))
# take ownership for properties
return True
@@ -276,16 +275,16 @@ def change_edge_loglevel(properties):
def change_edge_appliance_size(properties):
size = properties.get('size')
if size not in vcns_const.ALLOWED_EDGE_SIZES:
LOG.error(_LE("Edge appliance size not in %(size)s"),
LOG.error("Edge appliance size not in %(size)s",
{'size': vcns_const.ALLOWED_EDGE_SIZES})
return
try:
nsxv.change_edge_appliance_size(
properties.get('edge-id'), size)
except nsxv_exceptions.ResourceNotFound as e:
LOG.error(_LE("Edge %s not found"), properties.get('edge-id'))
LOG.error("Edge %s not found", properties.get('edge-id'))
except exceptions.NeutronException as e:
LOG.error(_LE("%s"), str(e))
LOG.error("%s", str(e))
def _get_edge_az_and_size(edge_id):
@@ -322,9 +321,9 @@ def change_edge_appliance(edge_id):
try:
nsxv.change_edge_appliance(edge_id, request)
except nsxv_exceptions.ResourceNotFound as e:
LOG.error(_LE("Edge %s not found"), edge_id)
LOG.error("Edge %s not found", edge_id)
except exceptions.NeutronException as e:
LOG.error(_LE("%s"), str(e))
LOG.error("%s", str(e))
else:
# also update the edge_ha of the edge
change_edge_ha(az.edge_ha, edge_id)
@@ -341,20 +340,20 @@ def change_edge_appliance_reservations(properties):
res['shares'] = properties.get('shares')
resource = properties.get('resource')