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')
if not res:
LOG.error(_LE("Please configure reservations"))
LOG.error("Please configure reservations")
return
if resource == 'cpu':
reservations['cpuReservation'] = res
elif resource == 'memory':
reservations['memoryReservation'] = res
else:
LOG.error(_LE("Please configure resource"))
LOG.error("Please configure resource")
return
edge_id = properties.get('edge-id')
try:
h, edge = nsxv.get_edge(edge_id)
except exceptions.NeutronException as e:
LOG.error(_LE("%s"), str(e))
LOG.error("%s", str(e))
return
appliances = edge['appliances']['appliances']
for appliance in appliances:
@ -363,9 +362,9 @@ def change_edge_appliance_reservations(properties):
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))
def _update_host_group_for_edge(nsxv, dvs_mng, edge_id, edge):
@ -378,11 +377,11 @@ def _update_host_group_for_edge(nsxv, dvs_mng, edge_id, edge):
dvs_mng, az,
validate=True)
except Exception as e:
LOG.error(_LE("Failed to update edge %(id)s - %(e)s"),
LOG.error("Failed to update edge %(id)s - %(e)s",
{'id': edge['id'],
'e': e})
else:
LOG.error(_LE("%s is not a gateway services"), edge_id)
LOG.error("%s is not a gateway services", edge_id)
def change_edge_hostgroup(properties):
@ -392,7 +391,7 @@ def change_edge_hostgroup(properties):
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
@ -411,32 +410,32 @@ def change_edge_hostgroup(properties):
try:
edge_utils.clean_host_groups(dvs_mng, az)
except Exception:
LOG.error(_LE("Failed to clean AZ %s"), az.name)
LOG.error("Failed to clean AZ %s", az.name)
else:
LOG.error(_LE('Currently not supported'))
LOG.error('Currently not supported')
@admin_utils.output_header
def nsx_update_edge(resource, event, trigger, **kwargs):
"""Update edge properties"""
usage_msg = _LE("Need to specify edge-id parameter and "
"attribute to update. Add --property edge-id=<edge-id> "
"and --property highavailability=<True/False> or "
"--property size=<size> or --property appliances=True. "
"\nFor syslog, add --property syslog-server=<ip>|none and "
"(optional) --property syslog-server2=<ip> and/or "
"(optional) --property syslog-proto=[tcp/udp] "
"\nFor log levels, add --property [routing|dhcp|dns|"
"highavailability|loadbalancer]-log-level="
"[debug|info|warning|error]. To set log level for all "
"modules, add --property log-level=<level> "
"\nFor edge reservations, add "
"--property resource=cpu|memory and "
"(optional) --property limit=<limit> and/or "
"(optional) --property shares=<shares> and/or "
"(optional) --property reservation=<reservation> "
"\nFor hostgroup updates, add "
"--property hostgroup=update/all/clean")
usage_msg = ("Need to specify edge-id parameter and "
"attribute to update. Add --property edge-id=<edge-id> "
"and --property highavailability=<True/False> or "
"--property size=<size> or --property appliances=True. "
"\nFor syslog, add --property syslog-server=<ip>|none and "
"(optional) --property syslog-server2=<ip> and/or "
"(optional) --property syslog-proto=[tcp/udp] "
"\nFor log levels, add --property [routing|dhcp|dns|"
"highavailability|loadbalancer]-log-level="
"[debug|info|warning|error]. To set log level for all "
"modules, add --property log-level=<level> "
"\nFor edge reservations, add "
"--property resource=cpu|memory and "
"(optional) --property limit=<limit> and/or "
"(optional) --property shares=<shares> and/or "
"(optional) --property reservation=<reservation> "
"\nFor hostgroup updates, add "
"--property hostgroup=update/all/clean")
if not kwargs.get('property'):
LOG.error(usage_msg)
return
@ -444,10 +443,10 @@ def nsx_update_edge(resource, event, trigger, **kwargs):
if (not properties.get('edge-id') and
not properties.get('hostgroup', '').lower() == "all" and
not properties.get('hostgroup', '').lower() == "clean"):
LOG.error(_LE("Need to specify edge-id. "
"Add --property edge-id=<edge-id>"))
LOG.error("Need to specify edge-id. "
"Add --property edge-id=<edge-id>")
return
LOG.info(_LI("Updating NSXv edge: %(edge)s with properties\n%(prop)s"),
LOG.info("Updating NSXv edge: %(edge)s with properties\n%(prop)s",
{'edge': properties.get('edge-id'), 'prop': properties})
if properties.get('highavailability'):
change_edge_ha(properties['highavailability'].lower() == "true",
@ -477,8 +476,8 @@ def nsx_update_edge(resource, event, trigger, **kwargs):
def nsx_update_edges(resource, event, trigger, **kwargs):
"""Update all edges with the given property"""
if not kwargs.get('property'):
usage_msg = _LE("Need to specify a property to update all edges. "
"Add --property appliances=<True/False>")
usage_msg = ("Need to specify a property to update all edges. "
"Add --property appliances=<True/False>")
LOG.error(usage_msg)
return
@ -491,14 +490,13 @@ def nsx_update_edges(resource, event, trigger, **kwargs):
change_edge_appliance(edge.get('edge-id'))
except Exception as e:
result += 1
LOG.error(_LE("Failed to update edge %(edge)s. Exception: "
"%(e)s"), {'edge': edge.get('edge-id'),
'e': str(e)})
LOG.error("Failed to update edge %(edge)s. Exception: "
"%(e)s", {'edge': edge.get('edge-id'),
'e': str(e)})
if result > 0:
total = len(edges)
msg = (_LE("%(result)s of %(total)s edges failed "
"to update.") % {'result': result, 'total': total})
LOG.error(msg)
LOG.error("%(result)s of %(total)s edges failed "
"to update.", {'result': result, 'total': total})
registry.subscribe(nsx_list_edges,

View File

@ -21,7 +21,6 @@ from neutron.db import models_v2
from oslo_config import cfg
from oslo_log import log as logging
from vmware_nsx._i18n import _LE, _LI
from vmware_nsx.common import config
from vmware_nsx.common import locking
from vmware_nsx.common import nsxv_constants
@ -52,12 +51,12 @@ def nsx_redo_metadata_cfg(resource, event, trigger, **kwargs):
if az.supports_metadata():
nsx_redo_metadata_cfg_for_az(az, edgeapi)
else:
LOG.info(_LI("Skipping availability zone: %s - no metadata "
"configuration"), az.name)
LOG.info("Skipping availability zone: %s - no metadata "
"configuration", az.name)
def nsx_redo_metadata_cfg_for_az(az, edgeapi):
LOG.info(_LI("Updating MetaData for availability zone: %s"), az.name)
LOG.info("Updating MetaData for availability zone: %s", az.name)
# Get the list of internal networks for this AZ
db_net = nsxv_db.get_nsxv_internal_network(
@ -95,9 +94,9 @@ def nsx_redo_metadata_cfg_for_az(az, edgeapi):
edge_internal_ips.append(edge_internal_ip['ip_address'])
if not internal_net or not internal_subnet or not edge_internal_ips:
LOG.error(_LE("Metadata infrastructure is missing or broken. "
"It is recommended to restart neutron service before "
"proceeding with configuration restoration"))
LOG.error("Metadata infrastructure is missing or broken. "
"It is recommended to restart neutron service before "
"proceeding with configuration restoration")
return
router_bindings = nsxv_db.get_nsxv_router_bindings(
@ -210,10 +209,10 @@ def get_metadata_status(resource, event, trigger, **kwargs):
edgeapi.context.session, net_id)
providers = [asp['edge_id'] for asp in as_provider_data]
if providers:
LOG.info(_LI('Metadata providers for network %s'), net_id)
LOG.info('Metadata providers for network %s', net_id)
_md_member_status('Edge %s', providers)
else:
LOG.info(_LI('No providers found for network %s'), net_id)
LOG.info('No providers found for network %s', net_id)
registry.subscribe(nsx_redo_metadata_cfg,

View File

@ -18,7 +18,6 @@ from oslo_serialization import jsonutils
import re
import xml.etree.ElementTree as et
from vmware_nsx._i18n import _LE, _LI
from vmware_nsx.db import db as nsx_db
from vmware_nsx.plugins.nsx_v.vshield.common import exceptions
from vmware_nsx.shell.admin.plugins.common import constants
@ -76,20 +75,20 @@ def neutron_list_networks(resource, event, trigger,
def nsx_update_switch(resource, event, trigger, **kwargs):
nsxv = utils.get_nsxv_client()
if not kwargs.get('property'):
LOG.error(_LE("Need to specify dvs-id parameter and "
"attribute to update. Add --property dvs-id=<dvs-id> "
"--property teamingpolicy=<policy>"))
LOG.error("Need to specify dvs-id parameter and "
"attribute to update. Add --property dvs-id=<dvs-id> "
"--property teamingpolicy=<policy>")
return
properties = admin_utils.parse_multi_keyval_opt(kwargs['property'])
dvs_id = properties.get('dvs-id')
if not dvs_id:
LOG.error(_LE("Need to specify dvs-id. "
"Add --property dvs-id=<dvs-id>"))
LOG.error("Need to specify dvs-id. "
"Add --property dvs-id=<dvs-id>")
return
try:
h, switch = nsxv.get_vdn_switch(dvs_id)
except exceptions.ResourceNotFound:
LOG.error(_LE("DVS %s not found"), dvs_id)
LOG.error("DVS %s not found", dvs_id)
return
supported_policies = ['ETHER_CHANNEL', 'LOADBALANCE_LOADBASED',
'LOADBALANCE_SRCID', 'LOADBALANCE_SRCMAC',
@ -98,10 +97,10 @@ def nsx_update_switch(resource, event, trigger, **kwargs):
policy = properties.get('teamingpolicy')
if policy in supported_policies:
if switch['teamingPolicy'] == policy:
LOG.info(_LI("Policy already set!"))
LOG.info("Policy already set!")
return
LOG.info(_LI("Updating NSXv switch %(dvs)s teaming policy to "
"%(policy)s"), {'dvs': dvs_id, 'policy': policy})
LOG.info("Updating NSXv switch %(dvs)s teaming policy to "
"%(policy)s", {'dvs': dvs_id, 'policy': policy})
switch['teamingPolicy'] = policy
try:
switch = nsxv.update_vdn_switch(switch)
@ -109,17 +108,17 @@ def nsx_update_switch(resource, event, trigger, **kwargs):
desc = jsonutils.loads(e.response)
details = desc.get('details')
if details.startswith("No enum constant"):
LOG.error(_LE("Unknown teaming policy %s"), policy)
LOG.error("Unknown teaming policy %s", policy)
else:
LOG.error(_LE("Unexpected error occurred: %s"), details)
LOG.error("Unexpected error occurred: %s", details)
return
LOG.info(_LI("Switch value after update: %s"), switch)
LOG.info("Switch value after update: %s", switch)
else:
LOG.info(_LI("Current switch value is: %s"), switch)
LOG.error(_LE("Invalid teaming policy. "
"Add --property teamingpolicy=<policy>"))
LOG.error(_LE("Possible values: %s"), ', '.join(supported_policies))
LOG.info("Current switch value is: %s", switch)
LOG.error("Invalid teaming policy. "
"Add --property teamingpolicy=<policy>")
LOG.error("Possible values: %s", ', '.join(supported_policies))
@admin_utils.output_header
@ -202,17 +201,17 @@ def delete_backend_network(resource, event, trigger, **kwargs):
"""
errmsg = ("Need to specify moref property. Add --property moref=<moref>")
if not kwargs.get('property'):
LOG.error(_LE("%s"), errmsg)
LOG.error("%s", errmsg)
return
properties = admin_utils.parse_multi_keyval_opt(kwargs['property'])
moref = properties.get('moref')
if not moref:
LOG.error(_LE("%s"), errmsg)
LOG.error("%s", errmsg)
return
backend_name = get_networks_name_map().get(moref)
if not backend_name:
LOG.error(_LE("Failed to find the backend network %(moref)s"),
LOG.error("Failed to find the backend network %(moref)s",
{'moref': moref})
return
@ -224,26 +223,26 @@ def delete_backend_network(resource, event, trigger, **kwargs):
# get the dvs id from the backend name:
dvs_id = get_dvs_id_from_backend_name(backend_name)
if not dvs_id:
LOG.error(_LE("Failed to find the DVS id of backend network "
"%(moref)s"), {'moref': moref})
LOG.error("Failed to find the DVS id of backend network "
"%(moref)s", {'moref': moref})
else:
try:
nsxv.delete_port_group(dvs_id, moref)
except Exception as e:
LOG.error(_LE("Failed to delete backend network %(moref)s : "
"%(e)s"), {'moref': moref, 'e': e})
LOG.error("Failed to delete backend network %(moref)s : "
"%(e)s", {'moref': moref, 'e': e})
else:
LOG.info(_LI("Backend network %(moref)s was deleted"),
LOG.info("Backend network %(moref)s was deleted",
{'moref': moref})
else:
# Virtual wire
try:
nsxv.delete_virtual_wire(moref)
except Exception as e:
LOG.error(_LE("Failed to delete backend network %(moref)s : "
"%(e)s"), {'moref': moref, 'e': e})
LOG.error("Failed to delete backend network %(moref)s : "
"%(e)s", {'moref': moref, 'e': e})
else:
LOG.info(_LI("Backend network %(moref)s was deleted"),
LOG.info("Backend network %(moref)s was deleted",
{'moref': moref})

View File

@ -23,7 +23,6 @@ from neutron_lib import context as n_context
from oslo_config import cfg
from oslo_log import log as logging
from vmware_nsx._i18n import _LE, _LI, _LW
from vmware_nsx.common import locking
from vmware_nsx.db import nsxv_db
from vmware_nsx.extensions import routersize
@ -35,7 +34,7 @@ LOG = logging.getLogger(__name__)
def delete_old_edge(context, old_edge_id):
LOG.info(_LI("Deleting the old edge: %s"), old_edge_id)
LOG.info("Deleting the old edge: %s", old_edge_id)
# clean it up from the DB
nsxv_db.clean_edge_router_binding(context.session, old_edge_id)
@ -51,7 +50,7 @@ def delete_old_edge(context, old_edge_id):
nsxv = utils.get_nsxv_client()
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
@ -74,16 +73,16 @@ def _get_router_az_from_plugin_router(router):
def nsx_recreate_router_edge(resource, event, trigger, **kwargs):
"""Recreate a router edge with all the data on a new 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
# input validation
properties = admin_utils.parse_multi_keyval_opt(kwargs['property'])
old_edge_id = properties.get('edge-id')
if not old_edge_id:
LOG.error(_LE("Need to specify edge-id parameter"))
LOG.error("Need to specify edge-id parameter")
return
LOG.info(_LI("ReCreating NSXv Router Edge: %s"), old_edge_id)
LOG.info("ReCreating NSXv Router Edge: %s", old_edge_id)
# init the plugin and edge manager
cfg.CONF.set_override('core_plugin',
@ -98,7 +97,7 @@ def nsx_recreate_router_edge(resource, event, trigger, **kwargs):
# verify that this is a Router edge
router_ids = edge_manager.get_routers_on_edge(context, old_edge_id)
if not router_ids:
LOG.error(_LE("Edge %(edge_id)s is not a router edge"),
LOG.error("Edge %(edge_id)s is not a router edge",
{'edge_id': old_edge_id})
return
@ -108,8 +107,8 @@ def nsx_recreate_router_edge(resource, event, trigger, **kwargs):
router_driver = plugin._router_managers.get_tenant_router_driver(
context, example_router['router_type'])
if router_driver.get_type() == "distributed":
LOG.error(_LE("Recreating a distributed driver edge is not "
"supported"))
LOG.error("Recreating a distributed driver edge is not "
"supported")
return
# load all the routers before deleting their binding
@ -137,7 +136,7 @@ def nsx_recreate_router_edge(resource, event, trigger, **kwargs):
# find out who is the new edge to print it
new_edge_id = router_driver._get_edge_id_or_raise(
context, router_id)
LOG.info(_LI("Router %(router)s was attached to edge %(edge)s"),
LOG.info("Router %(router)s was attached to edge %(edge)s",
{'router': router_id, 'edge': new_edge_id})

View File

@ -23,7 +23,6 @@ from neutron.extensions import securitygroup as ext_sg
from neutron_lib import context
from oslo_log import log as logging
from vmware_nsx._i18n import _LE, _LI, _LW
from vmware_nsx.db import db as nsx_db
from vmware_nsx.db import nsx_models
from vmware_nsx.db import nsxv_db
@ -137,7 +136,7 @@ class NsxFirewallAPI(object):
# read all the sections
h, firewall_config = self.vcns.get_dfw_config()
if not firewall_config:
LOG.info(_LI("No firewall sections were found."))
LOG.info("No firewall sections were found.")
return
root = et.fromstring(firewall_config)
@ -158,7 +157,7 @@ class NsxFirewallAPI(object):
child.remove(sec)
if not policy_sections:
LOG.info(_LI("No need to reorder the firewall sections."))
LOG.info("No need to reorder the firewall sections.")
return
# reorder the sections to have the policy sections first
@ -167,7 +166,7 @@ class NsxFirewallAPI(object):
# update the new order of sections in the backend
self.vcns.update_dfw_config(et.tostring(root), h)
LOG.info(_LI("L3 Firewall sections were reordered."))
LOG.info("L3 Firewall sections were reordered.")
neutron_sg = NeutronSecurityGroupDB()
@ -304,19 +303,19 @@ def fix_security_groups(resource, event, trigger, **kwargs):
def migrate_sg_to_policy(resource, event, trigger, **kwargs):
"""Change the mode of a security group from rules to NSX policy"""
if not kwargs.get('property'):
LOG.error(_LE("Need to specify security-group-id and policy-id "
"parameters"))
LOG.error("Need to specify security-group-id and policy-id "
"parameters")
return
# input validation
properties = admin_utils.parse_multi_keyval_opt(kwargs['property'])
sg_id = properties.get('security-group-id')
if not sg_id:
LOG.error(_LE("Need to specify security-group-id parameter"))
LOG.error("Need to specify security-group-id parameter")
return
policy_id = properties.get('policy-id')
if not policy_id:
LOG.error(_LE("Need to specify policy-id parameter"))
LOG.error("Need to specify policy-id parameter")
return
# validate that the security group exist and contains rules and no policy
@ -325,45 +324,45 @@ def migrate_sg_to_policy(resource, event, trigger, **kwargs):
try:
secgroup = plugin.get_security_group(context_, sg_id)
except ext_sg.SecurityGroupNotFound:
LOG.error(_LE("Security group %s was not found"), sg_id)
LOG.error("Security group %s was not found", sg_id)
return
if secgroup.get('policy'):
LOG.error(_LE("Security group %s already uses a policy"), sg_id)
LOG.error("Security group %s already uses a policy", sg_id)
return
# validate that the policy exists
if not plugin.nsx_v.vcns.validate_inventory(policy_id):
LOG.error(_LE("NSX policy %s was not found"), policy_id)
LOG.error("NSX policy %s was not found", policy_id)
return
# Delete the rules from the security group
LOG.info(_LI("Deleting the rules of security group: %s"), sg_id)
LOG.info("Deleting the rules of security group: %s", sg_id)
for rule in secgroup.get('security_group_rules', []):
try:
plugin.delete_security_group_rule(context_, rule['id'])
except Exception as e:
LOG.warning(_LW("Failed to delete rule %(r)s from security "
"group %(sg)s: %(e)s"),
LOG.warning("Failed to delete rule %(r)s from security "
"group %(sg)s: %(e)s",
{'r': rule['id'], 'sg': sg_id, 'e': e})
# continue anyway
# Delete the security group FW section
LOG.info(_LI("Deleting the section of security group: %s"), sg_id)
LOG.info("Deleting the section of security group: %s", sg_id)
try:
section_uri = plugin._get_section_uri(context_.session, sg_id)
plugin._delete_section(section_uri)
nsxv_db.delete_neutron_nsx_section_mapping(
context_.session, sg_id)
except Exception as e:
LOG.warning(_LW("Failed to delete firewall section of security "
"group %(sg)s: %(e)s"),
LOG.warning("Failed to delete firewall section of security "
"group %(sg)s: %(e)s",
{'sg': sg_id, 'e': e})
# continue anyway
# bind this security group to the policy in the backend and DB
nsx_sg_id = nsx_db.get_nsx_security_group_id(context_.session, sg_id)
LOG.info(_LI("Binding the NSX security group %(nsx)s to policy "
"%(pol)s"),
LOG.info("Binding the NSX security group %(nsx)s to policy "
"%(pol)s",
{'nsx': nsx_sg_id, 'pol': policy_id})
plugin._update_nsx_security_group_policies(
policy_id, None, nsx_sg_id)
@ -371,7 +370,7 @@ def migrate_sg_to_policy(resource, event, trigger, **kwargs):
with context_.session.begin(subtransactions=True):
prop.update({sg_policy.POLICY: policy_id})
LOG.info(_LI("Done."))
LOG.info("Done.")
registry.subscribe(migrate_sg_to_policy,

View File

@ -23,7 +23,6 @@ import vmware_nsx.shell.resources as shell
from neutron.callbacks import registry
from neutron_lib import exceptions
from vmware_nsx._i18n import _LE, _LI
from vmware_nsx.db import nsxv_db
from oslo_log import log as logging
@ -85,15 +84,15 @@ def nsx_list_missing_spoofguard_policies(resource, event, trigger,
props = kwargs.get('property')
reverse = True if props and props[0] == 'reverse' else False
if reverse:
LOG.info(_LI("Spoofguard policies on NSXv but not present in "
"Neutron Db"))
LOG.info("Spoofguard policies on NSXv but not present in "
"Neutron Db")
else:
LOG.info(_LI("Spoofguard policies in Neutron Db but not present "
"on NSXv"))
LOG.info("Spoofguard policies in Neutron Db but not present "
"on NSXv")
missing_policies = get_missing_spoofguard_policy_mappings(reverse)
if not missing_policies:
LOG.info(_LI("\nNo missing spoofguard policies found."
"\nNeutron DB and NSXv backend are in sync\n"))
LOG.info("\nNo missing spoofguard policies found."
"\nNeutron DB and NSXv backend are in sync\n")
else:
LOG.info(missing_policies)
missing_policies = [{'policy_id': pid} for pid in missing_policies]
@ -106,33 +105,33 @@ def nsx_clean_spoofguard_policy(resource, event, trigger, **kwargs):
errmsg = ("Need to specify policy-id. Add --property "
"policy-id=<policy-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'])
policy_id = properties.get('policy-id')
if not policy_id:
LOG.error(_LE("%s"), errmsg)
LOG.error("%s", errmsg)
return
try:
h, c = nsxv.get_spoofguard_policy(policy_id)
except exceptions.NeutronException as e:
LOG.error(_LE("Unable to retrieve policy %(p)s: %(e)s"),
LOG.error("Unable to retrieve policy %(p)s: %(e)s",
{'p': policy_id, 'e': str(e)})
else:
if not c['spoofguardList']:
LOG.error(_LE("Policy %s does not exist"), policy_id)
LOG.error("Policy %s does not exist", policy_id)
return
confirm = admin_utils.query_yes_no(
"Do you want to delete spoofguard-policy: %s" % policy_id,
default="no")
if not confirm:
LOG.info(_LI("spoofguard-policy deletion aborted by user"))
LOG.info("spoofguard-policy deletion aborted by user")
return
try:
nsxv.delete_spoofguard_policy(policy_id)
except Exception as e:
LOG.error(_LE("%s"), str(e))
LOG.info(_LI('spoofguard-policy successfully deleted.'))
LOG.error("%s", str(e))
LOG.info('spoofguard-policy successfully deleted.')
registry.subscribe(neutron_list_spoofguard_policy_mappings,

View File

@ -21,7 +21,6 @@ from neutron.db import common_db_mixin as common_db
from neutron_lib import context as neutron_context
from neutron_lib.plugins import directory
from vmware_nsx._i18n import _LW
from vmware_nsx.common import config
from vmware_nsx import plugin
from vmware_nsx.plugins.nsx_v.vshield import vcns
@ -77,7 +76,7 @@ class NsxVPluginWrapper(plugin.NsxVPlugin):
if not self.count_spawn_jobs():
return
LOG.warning(_LW("Waiting for plugin jobs to finish properly..."))
LOG.warning("Waiting for plugin jobs to finish properly...")
sleep_time = 1
print_time = 20
max_loop = 600
@ -85,17 +84,17 @@ class NsxVPluginWrapper(plugin.NsxVPlugin):
n_jobs = self.count_spawn_jobs()
if n_jobs > 0:
if (print_index % print_time) == 0:
LOG.warning(_LW("Still Waiting on %(jobs)s "
"job%(plural)s"),
LOG.warning("Still Waiting on %(jobs)s "
"job%(plural)s",
{'jobs': n_jobs,
'plural': 's' if n_jobs > 1 else ''})
time.sleep(sleep_time)
else:
LOG.warning(_LW("Done."))
LOG.warning("Done.")
return
LOG.warning(_LW("Sorry. Waited for too long. Some jobs are still "
"running."))
LOG.warning("Sorry. Waited for too long. Some jobs are still "
"running.")
def get_nsxv_backend_edges():

View File

@ -15,7 +15,6 @@
import logging
from vmware_nsx._i18n import _LI
from vmware_nsx.plugins.nsx_v3 import cert_utils
from vmware_nsx.shell.admin.plugins.common import constants
from vmware_nsx.shell.admin.plugins.common import utils as admin_utils
@ -55,7 +54,7 @@ def get_nsx_trust_management(**kwargs):
def get_certificate_manager(**kwargs):
storage_driver_type = cfg.CONF.nsx_v3.nsx_client_cert_storage.lower()
LOG.info(_LI("Certificate storage is %s"), storage_driver_type)
LOG.info("Certificate storage is %s", storage_driver_type)
if storage_driver_type == 'nsx-db':
storage_driver = cert_utils.DbCertificateStorageDriver(
context.get_admin_context())
@ -75,8 +74,8 @@ def generate_cert(resource, event, trigger, **kwargs):
"""
if cfg.CONF.nsx_v3.nsx_client_cert_storage.lower() == "none":
LOG.info(_LI("Generate operation is not supported "
"with storage type 'none'"))
LOG.info("Generate operation is not supported "
"with storage type 'none'")
return
# update cert defaults based on user input
@ -91,7 +90,7 @@ def generate_cert(resource, event, trigger, **kwargs):
prop = 'valid-days'
valid_for_days = int(properties.get(prop))
except ValueError:
LOG.info(_LI("%s property must be a number"), prop)
LOG.info("%s property must be a number", prop)
return
signature_alg = properties.get('sig-alg')
@ -105,7 +104,7 @@ def generate_cert(resource, event, trigger, **kwargs):
with get_certificate_manager(**kwargs) as cert:
if cert.exists():
LOG.info(_LI("Deleting existing certificate"))
LOG.info("Deleting existing certificate")
# Need to delete cert first
cert.delete()
@ -115,7 +114,7 @@ def generate_cert(resource, event, trigger, **kwargs):
LOG.info(e)
return
LOG.info(_LI("Client certificate generated succesfully"))
LOG.info("Client certificate generated succesfully")
@admin_utils.output_header
@ -126,17 +125,17 @@ def delete_cert(resource, event, trigger, **kwargs):
if cfg.CONF.nsx_v3.nsx_client_cert_storage.lower() == "none":
filename = get_cert_filename(**kwargs)
if not filename:
LOG.info(_LI("Please specify file containing the certificate "
"using filename property"))
LOG.info("Please specify file containing the certificate "
"using filename property")
return
cert.delete_pem(filename)
else:
if not cert.exists():
LOG.info(_LI("Nothing to clean"))
LOG.info("Nothing to clean")
return
cert.delete()
LOG.info(_LI("Client certificate deleted succesfully"))
LOG.info("Client certificate deleted succesfully")
@admin_utils.output_header
@ -152,24 +151,24 @@ def show_cert(resource, event, trigger, **kwargs):
cert_data['alg'] = cert.get_signature_alg()
cert_data['key_size'] = cert.get_key_size()
if expires_in_days >= 0:
LOG.info(_LI("Client certificate is valid. "
"Expires on %(date)s UTC (in %(days)d days)."),
LOG.info("Client certificate is valid. "
"Expires on %(date)s UTC (in %(days)d days).",
{'date': expires_on,
'days': expires_in_days})
else:
LOG.info(_LI("Client certificate expired on %s."), expires_on)
LOG.info("Client certificate expired on %s.", expires_on)
LOG.info(_LI("Key Size %(key_size)s, "
"Signature Algorithm %(alg)s\n"
"Subject: Country %(country)s, State %(state)s, "
"Organization %(organization)s, Unit %(unit)s, "
"Common Name %(hostname)s"), cert_data)
LOG.info("Key Size %(key_size)s, "
"Signature Algorithm %(alg)s\n"
"Subject: Country %(country)s, State %(state)s, "
"Organization %(organization)s, Unit %(unit)s, "
"Common Name %(hostname)s", cert_data)
LOG.info(cert_pem)
else:
LOG.info(_LI("Client certificate is not registered "
"in storage"))
LOG.info("Client certificate is not registered "
"in storage")
def get_cert_filename(**kwargs):
@ -179,8 +178,8 @@ def get_cert_filename(**kwargs):
filename = properties.get('filename', filename)
if not filename:
LOG.info(_LI("Please specify file containing the certificate "
"using filename property"))
LOG.info("Please specify file containing the certificate "
"using filename property")
return filename
@ -189,13 +188,13 @@ def import_cert(resource, event, trigger, **kwargs):
"""Import client certificate that was generated externally"""
if cfg.CONF.nsx_v3.nsx_client_cert_storage.lower() != "none":
LOG.info(_LI("Import operation is supported "
"with storage type 'none' only"))
LOG.info("Import operation is supported "
"with storage type 'none' only")
return
with get_certificate_manager(**kwargs) as cert:
if cert.exists():
LOG.info(_LI("Deleting existing certificate"))
LOG.info("Deleting existing certificate")
cert.delete()
filename = get_cert_filename(**kwargs)
@ -203,7 +202,7 @@ def import_cert(resource, event, trigger, **kwargs):
return
cert.import_pem(filename)
LOG.info(_LI("Client certificate imported succesfully"))
LOG.info("Client certificate imported succesfully")
@admin_utils.output_header
@ -213,11 +212,11 @@ def show_nsx_certs(resource, event, trigger, **kwargs):
ids = nsx_trust.get_identities(cert_utils.NSX_OPENSTACK_IDENTITY)
if not ids:
LOG.info(_LI("Principal identity %s not found"),
LOG.info("Principal identity %s not found",
cert_utils.NSX_OPENSTACK_IDENTITY)
return
LOG.info(_LI("Certificate(s) associated with principal identity %s\n"),
LOG.info("Certificate(s) associated with principal identity %s\n",
cert_utils.NSX_OPENSTACK_IDENTITY)
cert = None
@ -228,7 +227,7 @@ def show_nsx_certs(resource, event, trigger, **kwargs):
LOG.info(cert['pem_encoded'])
if not cert:
LOG.info(_LI("No certificates found"))
LOG.info("No certificates found")
registry.subscribe(generate_cert,

View File

@ -15,7 +15,6 @@
from neutron.callbacks import registry
from oslo_log import log as logging
from vmware_nsx._i18n import _LE, _LI
from vmware_nsx.shell.admin.plugins.common import constants
from vmware_nsx.shell.admin.plugins.common import utils as admin_utils
from vmware_nsx.shell.admin.plugins.nsxv3.resources import utils
@ -30,9 +29,9 @@ def validate_configuration(resource, event, trigger, **kwargs):
try:
utils.NsxV3PluginWrapper()
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

@ -19,7 +19,6 @@ from neutron_lib import constants as const
from oslo_config import cfg
from oslo_log import log as logging
from vmware_nsx._i18n import _LE, _LI
from vmware_nsx.common import utils as nsx_utils
from vmware_nsx.shell.admin.plugins.common import constants
from vmware_nsx.shell.admin.plugins.common import formatters
@ -50,7 +49,7 @@ def nsx_update_dhcp_bindings(resource, event, trigger, **kwargs):
nsx_version = nsxlib.get_version()
if not nsx_utils.is_nsx_version_1_1_0(nsx_version):
LOG.error(_LE("This utility is not available for NSX version %s"),
LOG.error("This utility is not available for NSX version %s",
nsx_version)
return
@ -60,7 +59,7 @@ def nsx_update_dhcp_bindings(resource, event, trigger, **kwargs):
properties = admin_utils.parse_multi_keyval_opt(kwargs['property'])
dhcp_profile_uuid = properties.get('dhcp_profile_uuid')
if not dhcp_profile_uuid:
LOG.error(_LE("dhcp_profile_uuid is not defined"))
LOG.error("dhcp_profile_uuid is not defined")
return
cfg.CONF.set_override('dhcp_agent_notification', False)
@ -98,8 +97,8 @@ def nsx_update_dhcp_bindings(resource, event, trigger, **kwargs):
network, subnet, port, net_tags)
server_data['dhcp_profile_id'] = dhcp_profile_uuid
dhcp_server = dhcp_server_resource.create(**server_data)
LOG.info(_LI("Created logical DHCP server %(server)s for "
"network %(network)s"),
LOG.info("Created logical DHCP server %(server)s for "
"network %(network)s",
{'server': dhcp_server['id'],
'network': port['network_id']})
# Add DHCP service binding in neutron DB.
@ -112,8 +111,8 @@ def nsx_update_dhcp_bindings(resource, event, trigger, **kwargs):
lport_id, dhcp_server['id'],
attachment_type=nsx_constants.ATTACHMENT_DHCP)
server_bindings[lswitch_id] = dhcp_server['id']
LOG.info(_LI("Updated DHCP logical port %(port)s for "
"network %(network)s"),
LOG.info("Updated DHCP logical port %(port)s for "
"network %(network)s",
{'port': lport_id, 'network': port['network_id']})
elif subnet['enable_dhcp']:
# Store (mac, ip) binding of each compute port in a
@ -144,8 +143,8 @@ def nsx_update_dhcp_bindings(resource, event, trigger, **kwargs):
# Add DHCP static binding in neutron DB.
neutron_client.add_dhcp_static_binding(
port_id, subnet_id, ip, dhcp_server_id, binding['id'])
LOG.info(_LI("Added DHCP binding (mac: %(mac)s, ip: %(ip)s) "
"for neutron port %(port)s"),
LOG.info("Added DHCP binding (mac: %(mac)s, ip: %(ip)s) "
"for neutron port %(port)s",
{'mac': mac, 'ip': ip, 'port': port_id})

View File

@ -17,7 +17,6 @@ from neutron_lib import context
from oslo_config import cfg
from oslo_log import log as logging
from vmware_nsx._i18n import _LE, _LI
from vmware_nsx.common import utils as nsx_utils
from vmware_nsx.db import db as nsx_db
from vmware_nsx.shell.admin.plugins.common import constants
@ -98,13 +97,13 @@ def nsx_list_orphaned_dhcp_servers(resource, event, trigger, **kwargs):
nsx_version = nsxlib.get_version()
if not nsx_utils.is_nsx_version_1_1_0(nsx_version):
LOG.error(_LE("This utility is not available for NSX version %s"),
LOG.error("This utility is not available for NSX version %s",
nsx_version)
return
dhcp_profile_uuid = _get_dhcp_profile_uuid(**kwargs)
if not dhcp_profile_uuid:
LOG.error(_LE("dhcp_profile_uuid is not defined"))
LOG.error("dhcp_profile_uuid is not defined")
return
orphaned_servers = _get_orphaned_dhcp_servers(dhcp_profile_uuid)
@ -124,13 +123,13 @@ def nsx_clean_orphaned_dhcp_servers(resource, event, trigger, **kwargs):
nsx_version = nsxlib.get_version()
if not nsx_utils.is_nsx_version_1_1_0(nsx_version):
LOG.error(_LE("This utility is not available for NSX version %s"),
LOG.error("This utility is not available for NSX version %s",
nsx_version)
return
dhcp_profile_uuid = _get_dhcp_profile_uuid(**kwargs)
if not dhcp_profile_uuid:
LOG.error(_LE("dhcp_profile_uuid is not defined"))
LOG.error("dhcp_profile_uuid is not defined")
return
cfg.CONF.set_override('dhcp_agent_notification', False)
@ -153,10 +152,10 @@ def nsx_clean_orphaned_dhcp_servers(resource, event, trigger, **kwargs):
nsx_db.delete_neutron_nsx_service_binding(
context.get_admin_context().session, net_id,
nsx_constants.SERVICE_DHCP)
LOG.info(_LI("Removed orphaned DHCP server %s"), server['id'])
LOG.info("Removed orphaned DHCP server %s", server['id'])
except Exception as e:
LOG.error(_LE("Failed to clean orphaned DHCP server %(id)s. "
"Exception: %(e)s"), {'id': server['id'], 'e': e})
LOG.error("Failed to clean orphaned DHCP server %(id)s. "
"Exception: %(e)s", {'id': server['id'], 'e': e})
registry.subscribe(nsx_list_orphaned_dhcp_servers,

View File

@ -17,7 +17,6 @@ from neutron_lib import constants as const
from oslo_config import cfg
from oslo_log import log as logging
from vmware_nsx._i18n import _LE, _LI
from vmware_nsx.common import utils as nsx_utils
from vmware_nsx.dhcp_meta import rpc as nsx_rpc
from vmware_nsx.shell.admin.plugins.common import constants
@ -60,7 +59,7 @@ def nsx_update_metadata_proxy(resource, event, trigger, **kwargs):
nsx_version = nsxlib.get_version()
if not nsx_utils.is_nsx_version_1_1_0(nsx_version):
LOG.error(_LE("This utility is not available for NSX version %s"),
LOG.error("This utility is not available for NSX version %s",
nsx_version)
return
@ -69,7 +68,7 @@ def nsx_update_metadata_proxy(resource, event, trigger, **kwargs):
properties = admin_utils.parse_multi_keyval_opt(kwargs['property'])
metadata_proxy_uuid = properties.get('metadata_proxy_uuid')
if not metadata_proxy_uuid:
LOG.error(_LE("metadata_proxy_uuid is not defined"))
LOG.error("metadata_proxy_uuid is not defined")
return
cfg.CONF.set_override('dhcp_agent_notification', False)
@ -97,9 +96,9 @@ def nsx_update_metadata_proxy(resource, event, trigger, **kwargs):
router_id = ports[0]['device_id']
interface = {'subnet_id': network['subnets'][0]}
plugin.remove_router_interface(router_id, interface)
LOG.info(_LI("Removed metadata interface on router %s"), router_id)
LOG.info("Removed metadata interface on router %s", router_id)
plugin.delete_network(network['id'])
LOG.info(_LI("Removed metadata network %s"), network['id'])
LOG.info("Removed metadata network %s", network['id'])
else:
lswitch_id = neutron_client.net_id_to_lswitch_id(network['id'])
if not lswitch_id:
@ -112,7 +111,7 @@ def nsx_update_metadata_proxy(resource, event, trigger, **kwargs):
port_resource.create(
lswitch_id, metadata_proxy_uuid, tags=tags, name=name,
attachment_type=nsx_constants.ATTACHMENT_MDPROXY)
LOG.info(_LI("Enabled native metadata proxy for network %s"),
LOG.info("Enabled native metadata proxy for network %s",
network['id'])

View File

@ -13,7 +13,6 @@
# under the License.
from vmware_nsx._i18n import _LI
from vmware_nsx.db import db as nsx_db
from vmware_nsx.shell.admin.plugins.common import constants
from vmware_nsx.shell.admin.plugins.common import formatters
@ -60,13 +59,13 @@ def list_missing_networks(resource, event, trigger, **kwargs):
'neutron_id': neutron_id,
'nsx_id': nsx_id})
if len(networks) > 0:
title = _LI("Found %d internal networks missing from the NSX "
"manager:") % len(networks)
title = ("Found %d internal networks missing from the NSX "
"manager:") % len(networks)
LOG.info(formatters.output_formatter(
title, networks,
['name', 'neutron_id', 'nsx_id']))
else:
LOG.info(_LI("All internal networks exist on the NSX manager"))
LOG.info("All internal networks exist on the NSX manager")
registry.subscribe(list_missing_networks,

View File

@ -17,7 +17,6 @@ from oslo_config import cfg
from oslo_log import log as logging
from sqlalchemy.orm import exc
from vmware_nsx._i18n import _LE, _LI, _LW
from vmware_nsx.db import db as nsx_db
from vmware_nsx.db import nsx_models
from vmware_nsx.dvs import dvs
@ -90,7 +89,7 @@ def get_dhcp_profile_id(profile_client):
plugin.NSX_V3_DHCP_PROFILE_NAME)
if profiles and len(profiles) == 1:
return profiles[0]['id']
LOG.warning(_LW("Could not find DHCP profile on backend"))
LOG.warning("Could not find DHCP profile on backend")
def get_spoofguard_profile_id(profile_client):
@ -98,12 +97,12 @@ def get_spoofguard_profile_id(profile_client):
plugin.NSX_V3_PSEC_PROFILE_NAME)
if profiles and len(profiles) == 1:
return profiles[0]['id']
LOG.warning(_LW("Could not find Spoof Guard profile on backend"))
LOG.warning("Could not find Spoof Guard profile on backend")
def add_profile_mismatch(problems, neutron_id, nsx_id, prf_id, title):
msg = (_LI('Wrong %(title)s profile %(prf_id)s') % {'title': title,
'prf_id': prf_id})
msg = ('Wrong %(title)s profile %(prf_id)s') % {'title': title,
'prf_id': prf_id}
problems.append({'neutron_id': neutron_id,
'nsx_id': nsx_id,
'error': msg})
@ -141,7 +140,7 @@ def list_missing_ports(resource, event, trigger, **kwargs):
except nsx_exc.ResourceNotFound:
problems.append({'neutron_id': neutron_id,
'nsx_id': nsx_id,
'error': _LI('Missing from backend')})
'error': 'Missing from backend'})
continue
# Port found on backend!
@ -184,13 +183,13 @@ def list_missing_ports(resource, event, trigger, **kwargs):
prf_id, "Spoof Guard")
if len(problems) > 0:
title = _LI("Found internal ports misconfiguration on the "
"NSX manager:")
title = ("Found internal ports misconfiguration on the "
"NSX manager:")
LOG.info(formatters.output_formatter(
title, problems,
['neutron_id', 'nsx_id', 'error']))
else:
LOG.info(_LI("All internal ports verified on the NSX manager"))
LOG.info("All internal ports verified on the NSX manager")
def get_vm_network_device(vm_mng, vm_moref, mac_address):
@ -218,8 +217,8 @@ def migrate_compute_ports_vms(resource, event, trigger, **kwargs):
try:
vm_mng = dvs.VMManager()
except Exception as e:
LOG.error(_LE("Cannot connect to the DVS: Please update the [dvs] "
"section in the nsx.ini file: %s"), e)
LOG.error("Cannot connect to the DVS: Please update the [dvs] "
"section in the nsx.ini file: %s", e)
return
# Go over all the compute ports from the plugin
@ -235,7 +234,7 @@ def migrate_compute_ports_vms(resource, event, trigger, **kwargs):
vm_moref = vm_mng.get_vm_moref_obj(device_id)
vm_spec = vm_mng.get_vm_spec(vm_moref)
if not vm_spec:
LOG.error(_LE("Failed to get the spec of vm %s"), device_id)
LOG.error("Failed to get the spec of vm %s", device_id)
continue
# Go over the VM interfaces and check if it should be updated
@ -248,22 +247,22 @@ def migrate_compute_ports_vms(resource, event, trigger, **kwargs):
update_spec = True
if not update_spec:
LOG.info(_LI("No need to update the spec of vm %s"), device_id)
LOG.info("No need to update the spec of vm %s", device_id)
continue
# find the old interface by it's mac and delete it
device = get_vm_network_device(vm_mng, vm_moref, port['mac_address'])
if device is None:
LOG.warning(_LW("No device with MAC address %s exists on the VM"),
LOG.warning("No device with MAC address %s exists on the VM",
port['mac_address'])
continue
device_type = device.__class__.__name__
LOG.info(_LI("Detaching old interface from VM %s"), device_id)
LOG.info("Detaching old interface from VM %s", device_id)
vm_mng.detach_vm_interface(vm_moref, device)
# add the new interface as OpaqueNetwork
LOG.info(_LI("Attaching new interface to VM %s"), device_id)
LOG.info("Attaching new interface to VM %s", device_id)
nsx_net_id = get_network_nsx_id(admin_cxt.session, port['network_id'])
vm_mng.attach_vm_interface(vm_moref, port['id'], port['mac_address'],
nsx_net_id, device_type)

View File

@ -13,7 +13,6 @@
# under the License.
from vmware_nsx._i18n import _LI
from vmware_nsx.db import db as nsx_db
from vmware_nsx.shell.admin.plugins.common import constants
from vmware_nsx.shell.admin.plugins.common import formatters
@ -68,13 +67,13 @@ def list_missing_routers(resource, event, trigger, **kwargs):
'neutron_id': neutron_id,
'nsx_id': nsx_id})
if len(routers) > 0:
title = _LI("Found %d routers missing from the NSX "
"manager:") % len(routers)
title = ("Found %d routers missing from the NSX "
"manager:") % len(routers)
LOG.info(formatters.output_formatter(
title, routers,
['name', 'neutron_id', 'nsx_id']))
else:
LOG.info(_LI("All routers exist on the NSX manager"))
LOG.info("All routers exist on the NSX manager")
registry.subscribe(list_missing_routers,

View File

@ -30,7 +30,6 @@ from vmware_nsx.shell.admin.plugins.common import utils as admin_utils
from vmware_nsx.shell.admin.plugins.nsxv3.resources import ports
from vmware_nsx.shell.admin.plugins.nsxv3.resources import utils as v3_utils
from vmware_nsx.shell import resources as shell
from vmware_nsx._i18n import _LE, _LW
from vmware_nsxlib.v3 import nsx_constants as consts
from vmware_nsxlib.v3 import security
@ -271,17 +270,17 @@ def _update_security_group_dynamic_criteria():
membership_criteria=membership_criteria,
members=[])
except Exception as e:
LOG.warning(_LW("Failed to update membership criteria for nsgroup "
"%(nsgroup_id)s, request to backend returned "
"with error: %(error)s"),
LOG.warning("Failed to update membership criteria for nsgroup "
"%(nsgroup_id)s, request to backend returned "
"with error: %(error)s",
{'nsgroup_id': nsgroup_id, 'error': str(e)})
@admin_utils.output_header
def migrate_nsgroups_to_dynamic_criteria(resource, event, trigger, **kwargs):
if not utils.is_nsx_version_1_1_0(nsxlib.get_version()):
LOG.error(_LE("Dynamic criteria grouping feature isn't supported by "
"this NSX version."))
LOG.error("Dynamic criteria grouping feature isn't supported by "
"this NSX version.")
return
# First, we add the criteria tags for all ports.
_update_ports_dynamic_criteria_tags()

View File

@ -31,7 +31,6 @@ from neutron.callbacks import registry
from neutron.common import config as neutron_config
from neutron.conf import common as neutron_common_config
from vmware_nsx._i18n import _LE, _LI
from vmware_nsx.common import config # noqa
from oslo_config import cfg
@ -74,11 +73,11 @@ def _init_cfg():
def _validate_resource_choice(resource, nsx_plugin):
if nsx_plugin == 'nsxv' and resource not in resources.nsxv_resources:
LOG.error(_LE('Supported list of NSX-V resources: %s'),
LOG.error('Supported list of NSX-V resources: %s',
resources.nsxv_resources_names)
sys.exit(1)
elif nsx_plugin == 'nsxv3'and resource not in resources.nsxv3_resources:
LOG.error(_LE('Supported list of NSX-V3 resources: %s'),
LOG.error('Supported list of NSX-V3 resources: %s',
resources.nsxv3_resources_names)
sys.exit(1)
@ -88,16 +87,16 @@ def _validate_op_choice(choice, nsx_plugin):
supported_resource_ops = \
resources.nsxv_resources[cfg.CONF.resource].supported_ops
if choice not in supported_resource_ops:
LOG.error(_LE('Supported list of operations for the NSX-V '
'resource %s'), supported_resource_ops)
LOG.error('Supported list of operations for the NSX-V '
'resource %s', supported_resource_ops)
sys.exit(1)
elif nsx_plugin == 'nsxv3':
supported_resource_ops = \
resources.nsxv3_resources[cfg.CONF.resource].supported_ops
if choice not in supported_resource_ops:
LOG.error(_LE('Supported list of operations for the NSX-V3 '
'resource %s'), supported_resource_ops)
LOG.error('Supported list of operations for the NSX-V3 '
'resource %s', supported_resource_ops)
sys.exit(1)
@ -107,7 +106,7 @@ def main(argv=sys.argv[1:]):
resources.init_resource_plugin(
nsx_plugin_in_use,
resources.get_plugin_dir(nsx_plugin_in_use))
LOG.info(_LI('NSX Plugin in use: %s'), nsx_plugin_in_use)
LOG.info('NSX Plugin in use: %s', nsx_plugin_in_use)
_validate_resource_choice(cfg.CONF.resource, nsx_plugin_in_use)
_validate_op_choice(cfg.CONF.operation, nsx_plugin_in_use)

View File

@ -21,7 +21,6 @@ from neutron.tests import base
from oslo_log import log as logging
from six.moves import http_client as httplib
from vmware_nsx._i18n import _LI
from vmware_nsx.api_client import (
eventlet_client as client)
from vmware_nsx.api_client import (
@ -60,7 +59,7 @@ class ApiRequestEventletTest(base.BaseTestCase):
def test_apirequest_spawn(self):
def x(id):
eventlet.greenthread.sleep(random.random())
LOG.info(_LI('spawned: %d'), id)
LOG.info('spawned: %d', id)
for i in range(10):
request.EventletApiRequest._spawn(x, i)
@ -72,7 +71,7 @@ class ApiRequestEventletTest(base.BaseTestCase):
a._handle_request = mock.Mock()
a.start()
eventlet.greenthread.sleep(0.1)
LOG.info(_LI('_handle_request called: %s'),
LOG.info('_handle_request called: %s',
a._handle_request.called)
request.EventletApiRequest.joinall()
@ -107,8 +106,8 @@ class ApiRequestEventletTest(base.BaseTestCase):
def test_run_and_timeout(self):
def my_handle_request():
LOG.info(_LI('my_handle_request() self: %s'), self.req)
LOG.info(_LI('my_handle_request() dir(self): %s'), dir(self.req))
LOG.info('my_handle_request() self: %s', self.req)
LOG.info('my_handle_request() dir(self): %s', dir(self.req))
eventlet.greenthread.sleep(REQUEST_TIMEOUT * 2)
with mock.patch.object(
@ -330,5 +329,5 @@ class ApiRequestEventletTest(base.BaseTestCase):
{ "role": "api_provider",
"listen_addr": "pssl:1.1.1.1:1" }]}]}"""
r.successful = mock.Mock(return_value=True)
LOG.info(_LI('%s'), r.api_providers())
LOG.info('%s', r.api_providers())
self.assertIsNotNone(r.api_providers())

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

@ -21,8 +21,6 @@ from tempest import config
from tempest import test
from vmware_nsx_tempest._i18n import _
from vmware_nsx_tempest._i18n import _LI
from vmware_nsx_tempest._i18n import _LW
from vmware_nsx_tempest.common import constants
from vmware_nsx_tempest.services import l2_gateway_client
from vmware_nsx_tempest.services import l2_gateway_connection_client
@ -140,7 +138,7 @@ class BaseL2GatewayTest(base.BaseAdminNetworkTest):
_params = manager.default_params_withy_timeout_values.copy()
except AttributeError as attribute_err:
LOG.warning(
_LW("Failed to locate the attribute, Error: %(err_msg)s") %
"Failed to locate the attribute, Error: %(err_msg)s",
{"err_msg": attribute_err.__str__()})
_params = {}
cls.l2gw_client = l2_gateway_client.L2GatewayClient(
@ -191,7 +189,7 @@ class BaseL2GatewayTest(base.BaseAdminNetworkTest):
:return: response of L2GW create API
"""
LOG.info(_LI("l2gw name: %(name)s, l2gw_param: %(devices)s ") %
LOG.info("l2gw name: %(name)s, l2gw_param: %(devices)s ",
{"name": l2gw_name, "devices": l2gw_param})
devices = []
for device_dict in l2gw_param:
@ -203,10 +201,10 @@ class BaseL2GatewayTest(base.BaseAdminNetworkTest):
"interfaces": interface}
devices.append(device)
l2gw_request_body = {"devices": devices}
LOG.info(_LI(" l2gw_request_body: %s") % l2gw_request_body)
LOG.info(" l2gw_request_body: %s", l2gw_request_body)
rsp = self.l2gw_client.create_l2_gateway(
name=l2gw_name, **l2gw_request_body)
LOG.info(_LI(" l2gw response: %s") % rsp)
LOG.info(" l2gw response: %s", rsp)
self.l2gw_created[rsp[constants.L2GW]["id"]] = rsp[constants.L2GW]
return rsp, devices
@ -218,9 +216,9 @@ class BaseL2GatewayTest(base.BaseAdminNetworkTest):
:return: response of the l2gw delete API.
"""
LOG.info(_LI("L2GW id: %(id)s to be deleted.") % {"id": l2gw_id})
LOG.info("L2GW id: %(id)s to be deleted.", {"id": l2gw_id})
rsp = self.l2gw_client.delete_l2_gateway(l2gw_id)
LOG.info(_LI("response : %(rsp)s") % {"rsp": rsp})
LOG.info("response : %(rsp)s", {"rsp": rsp})
return rsp
def update_l2gw(self, l2gw_id, l2gw_new_name, devices):
@ -256,16 +254,16 @@ class BaseL2GatewayTest(base.BaseAdminNetworkTest):
:return: response of L2GWC create API.
"""
LOG.info(_LI("l2gwc param: %(param)s ") % {"param": l2gwc_param})
LOG.info("l2gwc param: %(param)s ", {"param": l2gwc_param})
l2gwc_request_body = {"l2_gateway_id": l2gwc_param["l2_gateway_id"],
"network_id": l2gwc_param["network_id"]}
if "segmentation_id" in l2gwc_param:
l2gwc_request_body["segmentation_id"] = l2gwc_param[
"segmentation_id"]
LOG.info(_LI("l2gwc_request_body: %s") % l2gwc_request_body)
LOG.info("l2gwc_request_body: %s", l2gwc_request_body)
rsp = self.l2gwc_client.create_l2_gateway_connection(
**l2gwc_request_body)
LOG.info(_LI("l2gwc response: %s") % rsp)
LOG.info("l2gwc response: %s", rsp)
self.l2gwc_created[rsp[constants.L2GWC]["id"]] = rsp[constants.L2GWC]
return rsp
@ -277,8 +275,8 @@ class BaseL2GatewayTest(base.BaseAdminNetworkTest):
:return: response of the l2gwc delete API.
"""
LOG.info(_LI("L2GW connection id: %(id)s to be deleted")
% {"id": l2gwc_id})
LOG.info("L2GW connection id: %(id)s to be deleted",
{"id": l2gwc_id})
rsp = self.l2gwc_client.delete_l2_gateway_connection(l2gwc_id)
LOG.info(_LI("response : %(rsp)s") % {"rsp": rsp})
LOG.info("response : %(rsp)s", {"rsp": rsp})
return rsp

View File

@ -16,8 +16,6 @@ from oslo_log import log
from tempest.lib.services.network import base
from vmware_nsx_tempest._i18n import _LI
from vmware_nsx_tempest._i18n import _LW
from vmware_nsx_tempest.common import constants
LOG = log.getLogger(__name__)
@ -36,31 +34,31 @@ class L2GatewayClient(base.BaseNetworkClient):
def create_l2_gateway(self, **kwargs):
uri = constants.L2_GWS_BASE_URI
post_data = {constants.L2GW: kwargs}
LOG.info(_LI("URI : %(uri)s, posting data : %(post_data)s") % {
"uri": uri, "post_data": post_data})
LOG.info("URI : %(uri)s, posting data : %(post_data)s",
{"uri": uri, "post_data": post_data})
return self.create_resource(uri, post_data)
def update_l2_gateway(self, l2_gateway_id, **kwargs):
uri = constants.L2_GWS_BASE_URI + "/" + l2_gateway_id
post_data = {constants.L2GW: kwargs}
constants.LOG.info(
_LI("URI : %(uri)s, posting data : %(post_data)s") % {
"uri": uri, "post_data": post_data})
"URI : %(uri)s, posting data : %(post_data)s",
{"uri": uri, "post_data": post_data})
return self.update_resource(uri, post_data)
def show_l2_gateway(self, l2_gateway_id, **fields):
uri = constants.L2_GWS_BASE_URI + "/" + l2_gateway_id
LOG.info(_LI("URI : %(uri)s") % {"uri": uri})
LOG.info("URI : %(uri)s", {"uri": uri})
return self.show_resource(uri, **fields)
def delete_l2_gateway(self, l2_gateway_id):
uri = constants.L2_GWS_BASE_URI + "/" + l2_gateway_id
LOG.info(_LI("URI : %(uri)s") % {"uri": uri})
LOG.info("URI : %(uri)s", {"uri": uri})
return self.delete_resource(uri)
def list_l2_gateways(self, **filters):
uri = constants.L2_GWS_BASE_URI
LOG.info(_LI("URI : %(uri)s") % {"uri": uri})
LOG.info("URI : %(uri)s", {"uri": uri})
return self.list_resources(uri, **filters)
@ -73,7 +71,7 @@ def get_client(client_mgr):
net_client = getattr(manager, "networks_client")
_params = manager.default_params_withy_timeout_values.copy()
except AttributeError as attribute_err:
LOG.warning(_LW("Failed to locate the attribute, Error: %(err_msg)s") %
LOG.warning("Failed to locate the attribute, Error: %(err_msg)s",
{"err_msg": attribute_err.__str__()})
_params = {}
client = L2GatewayClient(net_client.auth_provider,

View File

@ -21,10 +21,6 @@ import six.moves.urllib.parse as urlparse
from oslo_log import log as logging
from oslo_serialization import jsonutils
from vmware_nsx_tempest._i18n import _LE
from vmware_nsx_tempest._i18n import _LI
from vmware_nsx_tempest._i18n import _LW
requests.packages.urllib3.disable_warnings()
LOG = logging.getLogger(__name__)
@ -173,8 +169,8 @@ class NSXV3Client(object):
Return the logical port if found, otherwise return None.
"""
if not os_name:
LOG.error(_LE("Name of OS port should be present "
"in order to query backend logical port created"))
LOG.error("Name of OS port should be present "
"in order to query backend logical port created")
return None
lports = self.get_logical_ports()
return self.get_nsx_resource_by_name(lports, os_name)
@ -217,7 +213,7 @@ class NSXV3Client(object):
endpoint = "/logical-ports/%s" % p['id']
response = self.put(endpoint=endpoint, body=p)
if response.status_code != requests.codes.ok:
LOG.error(_LE("Failed to update lport %s"), p['id'])
LOG.error("Failed to update lport %s", p['id'])
def cleanup_os_logical_ports(self):
"""
@ -225,7 +221,7 @@ class NSXV3Client(object):
"""
lports = self.get_logical_ports()
os_lports = self.get_os_resources(lports)
LOG.info(_LI("Number of OS Logical Ports to be deleted: %s"),
LOG.info("Number of OS Logical Ports to be deleted: %s",
len(os_lports))
# logical port vif detachment
self.update_logical_port_attachment(os_lports)
@ -233,10 +229,10 @@ class NSXV3Client(object):
endpoint = '/logical-ports/%s' % p['id']
response = self.delete(endpoint=endpoint)
if response.status_code == requests.codes.ok:
LOG.info(_LI("Successfully deleted logical port %s"), p['id'])
LOG.info("Successfully deleted logical port %s", p['id'])
else:
LOG.error(_LE("Failed to delete lport %(port_id)s, response "
"code %(code)s"),
LOG.error("Failed to delete lport %(port_id)s, response "
"code %(code)s",
{'port_id': p['id'], 'code': response.status_code})
def get_os_resources(self, resources):
@ -258,14 +254,14 @@ class NSXV3Client(object):
nsx_resource = [n for n in nsx_resources if
n['display_name'] == nsx_name]
if len(nsx_resource) == 0:
LOG.warning(_LW("Backend nsx resource %s NOT found!"), nsx_name)
LOG.warning("Backend nsx resource %s NOT found!", nsx_name)
return None
if len(nsx_resource) > 1:
LOG.error(_LE("More than 1 nsx resources found: %s!"),
LOG.error("More than 1 nsx resources found: %s!",
nsx_resource)
return None
else:
LOG.info(_LI("Found nsgroup: %s"), nsx_resource[0])
LOG.info("Found nsgroup: %s", nsx_resource[0])
return nsx_resource[0]
def get_logical_switches(self):
@ -297,8 +293,8 @@ class NSXV3Client(object):
Return logical switch if found, otherwise return None
"""
if not os_name or not os_uuid:
LOG.error(_LE("Name and uuid of OpenStack L2 network need to be "
"present in order to query backend logical switch!"))
LOG.error("Name and uuid of OpenStack L2 network need to be "
"present in order to query backend logical switch!")
return None
nsx_name = os_name + "_" + os_uuid[:5] + "..." + os_uuid[-5:]
lswitches = self.get_logical_switches()
@ -322,9 +318,9 @@ class NSXV3Client(object):
Get the firewall section by os_name and os_uuid
"""
if not os_name or not os_uuid:
LOG.error(_LE("Name and uuid of OS security group should be "
"present in order to query backend FW section "
"created"))
LOG.error("Name and uuid of OS security group should be "
"present in order to query backend FW section "
"created")
return None
nsx_name = os_name + " - " + os_uuid
fw_sections = self.get_firewall_sections()
@ -378,8 +374,8 @@ class NSXV3Client(object):
Return nsgroup if found, otherwise return None
"""
if not os_name or not os_uuid:
LOG.error(_LE("Name and uuid of OS security group should be "
"present in order to query backend nsgroup created"))
LOG.error("Name and uuid of OS security group should be "
"present in order to query backend nsgroup created")
return None
nsx_name = os_name + " - " + os_uuid
nsgroups = self.get_ns_groups()
@ -404,8 +400,8 @@ class NSXV3Client(object):
Return the logical router if found, otherwise return None.
"""
if not os_name or not os_uuid:
LOG.error(_LE("Name and uuid of OS router should be present "
"in order to query backend logical router created"))
LOG.error("Name and uuid of OS router should be present "
"in order to query backend logical router created")
return None
nsx_name = os_name + "_" + os_uuid[:5] + "..." + os_uuid[-5:]
lrouters = self.get_logical_routers()
@ -423,8 +419,8 @@ class NSXV3Client(object):
Get all user defined NAT rules of the specific logical router
"""
if not lrouter:
LOG.error(_LE("Logical router needs to be present in order "
"to get the NAT rules"))
LOG.error("Logical router needs to be present in order "
"to get the NAT rules")
return None
endpoint = "/logical-routers/%s/nat/rules" % lrouter['id']
return self.get_logical_resources(endpoint)
@ -432,8 +428,8 @@ class NSXV3Client(object):
def get_logical_router_advertisement(self, lrouter):
"""Get logical router advertisement"""
if not lrouter:
LOG.error(_LE("Logical router needs to be present in order "
"to get router advertisement!"))
LOG.error("Logical router needs to be present in order "
"to get router advertisement!")
return None
endpoint = "/logical-routers/%s/routing/advertisement" % lrouter['id']
response = self.get(endpoint)
@ -454,9 +450,9 @@ class NSXV3Client(object):
Return logical dhcp server if found, otherwise return None
"""
if not os_name or not os_uuid:
LOG.error(_LE("Name and uuid of OpenStack L2 network need to be "
"present in order to query backend logical dhcp "
"server!"))
LOG.error("Name and uuid of OpenStack L2 network need to be "
"present in order to query backend logical dhcp "
"server!")
return None
nsx_name = os_name + "_" + os_uuid[:5] + "..." + os_uuid[-5:]
dhcp_servers = self.get_logical_dhcp_servers()

View File

@ -26,7 +26,6 @@ from tempest.lib.common.utils import data_utils
from tempest.lib.common.utils import test_utils
from tempest.lib import exceptions
from vmware_nsx_tempest._i18n import _LI
from vmware_nsx_tempest.services.lbaas import health_monitors_client
from vmware_nsx_tempest.services.lbaas import l7policies_client
from vmware_nsx_tempest.services.lbaas import l7rules_client
@ -153,12 +152,12 @@ class BaseTestCase(base.BaseNetworkTest):
super(BaseTestCase, cls).setUpClass()
def setUp(cls):
cls.LOG.info(_LI('Starting: {0}').format(cls._testMethodName))
cls.LOG.info(('Starting: {0}').format(cls._testMethodName))
super(BaseTestCase, cls).setUp()
def tearDown(cls):
super(BaseTestCase, cls).tearDown()
cls.LOG.info(_LI('Finished: {0}').format(cls._testMethodName))
cls.LOG.info(('Finished: {0}').format(cls._testMethodName))
@classmethod
def _create_load_balancer(cls, wait=True, **lb_kwargs):

View File

@ -21,8 +21,6 @@ from tempest.lib import decorators
from tempest.lib import exceptions as lib_exc
from tempest import test
from vmware_nsx_tempest._i18n import _LI
LOG = logging.getLogger(__name__)
CONF = config.CONF
@ -261,5 +259,5 @@ class SubnetPoolsTestJSON(base.BaseNetworkTest):
self.clean_subnet(subnet_client, subnet['subnet']['id'])
except lib_exc.ServerFault:
pass
LOG.info(_LI("Failed to allocate subnet: Insufficient "
"prefix space to allocate subnet size"))
LOG.info("Failed to allocate subnet: Insufficient "
"prefix space to allocate subnet size")

View File

@ -28,7 +28,6 @@ from tempest.lib import decorators
from tempest.lib import exceptions
from tempest import test
from vmware_nsx_tempest._i18n import _LI
from vmware_nsx_tempest.services import nsxv_client
from vmware_nsx_tempest.tests.nsxv.scenario import (
manager_topo_deployment as dmgr)
@ -125,14 +124,14 @@ class TestDHCP121BasicOps(dmgr.TopoDeployScenarioManager):
cmd = ('/sbin/route -n')
out_data = client.exec_command(cmd)
self.assertIn(Metadataserver_ip, out_data)
LOG.info(_LI("Metadata routes available on vm"))
LOG.info("Metadata routes available on vm")
cmd = ('wget http://169.254.169.254 -O sample.txt')
client.exec_command(cmd)
cmd = ('cat sample.txt')
out_data = client.exec_command(cmd)
# Check metadata server inforamtion available or not
self.assertIn('latest', out_data)
LOG.info(_LI("metadata server is acessible"))
LOG.info("metadata server is acessible")
# Fetch dhcp edge infor from nsx-v
exc_edge = self.vsm.get_dhcp_edge_info()
self.assertIsNotNone(exc_edge)
@ -186,7 +185,7 @@ class TestDHCP121BasicOps(dmgr.TopoDeployScenarioManager):
self.assertIn(
_subnet_data['new_host_routes'][0]['nexthop'], out_data)
self.assertIn(self.nexthop_host_route, out_data)
LOG.info(_LI("Host routes available on vm"))
LOG.info("Host routes available on vm")
# Check Host route info at beckend
exc_edge = self.vsm.get_dhcp_edge_info()
self.assertIsNotNone(exc_edge)
@ -200,7 +199,7 @@ class TestDHCP121BasicOps(dmgr.TopoDeployScenarioManager):
dest_subnet = destination_net['destinationSubnet']
dest_router = destination_net['router']
if (dest in dest_subnet and self.nexthop1 in dest_router):
LOG.info(_LI("Host routes available on nsxv"))
LOG.info("Host routes available on nsxv")
# Update subnet with no host-routes
_subnet_data1 = {'new_host_routes': []}
new_host_routes = _subnet_data1['new_host_routes']
@ -227,7 +226,7 @@ class TestDHCP121BasicOps(dmgr.TopoDeployScenarioManager):
for destination_net in dhcp_options_info:
if (_subnet_data['new_host_routes'][0]['destination']
not in destination_net['destinationSubnet']):
LOG.info(_LI("Host routes not available on nsxv"))
LOG.info("Host routes not available on nsxv")
project_dict = dict(security_group=vm_env['security_group'],
network=vm_env['network'], subnet=vm_env['subnet'],
router=vm_env['router'],
@ -297,30 +296,30 @@ class TestDhcpMetadata(TestDHCP121BasicOps):
@test.attr(type='nsxv')
@decorators.idempotent_id('95d06aba-895f-47f8-b47d-ae48c6853a85')
def test_dhcp_121_metadata_check_on_vm_nsxv(self):
LOG.info(_LI("Testcase DHCP-121 option metadata check on vm and \
on nsx deploying"))
LOG.info("Testcase DHCP-121 option metadata check on vm and "
"on nsx deploying")
self.vm_env = self.setup_vm_enviornment(self.manager, 'green', True)
self.green = self.dhcp_121_metadata_hostroutes_check_on_vm_nsxv(
self.vm_env)
LOG.info(_LI("Testcase DHCP-121 option metadata check on vm and on \
nsx completed"))
LOG.info("Testcase DHCP-121 option metadata check on vm and on "
"nsx completed")
class TestDhcpHostroutesClear(TestDHCP121BasicOps):
@test.attr(type='nsxv')
@decorators.idempotent_id('6bec6eb4-8632-493d-a895-a3ee87cb3002')
def test_dhcp_121_hostroutes_clear(self):
LOG.info(_LI("Testcase DHCP-121 option host routes clear deploying"))
LOG.info("Testcase DHCP-121 option host routes clear deploying")
self.vm_env = self.setup_vm_enviornment(self.manager, 'green', True)
self.green = self.dhcp_121_hostroutes_clear(self.vm_env)
LOG.info(_LI("Testcase DHCP-121 option host routes clear completed"))
LOG.info("Testcase DHCP-121 option host routes clear completed")
class TestDhcpNegative(TestDHCP121BasicOps):
@test.attr(type='nsxv')
@decorators.idempotent_id('a58dc6c5-9f28-4184-baf7-37ded52593c4')
def test_dhcp121_negative_test(self):
LOG.info(_LI("Testcase DHCP-121 option negative test deploying"))
LOG.info("Testcase DHCP-121 option negative test deploying")
t_net_id, t_network, t_subnet =\
self.create_project_network_subnet('admin')
subnet_id = t_subnet['id']
@ -349,9 +348,9 @@ class TestDhcpNegative(TestDHCP121BasicOps):
except exceptions.BadRequest:
e = sys.exc_info()[0].__dict__['message']
if (e == "Bad request"):
LOG.info(_LI("Invalid input for operation:\
Host routes can only be supported when\
DHCP is enabled"))
LOG.info("Invalid input for operation: "
"Host routes can only be supported when "
"DHCP is enabled")
pass
subnet_id = t_subnet['id']
kwargs = {'enable_dhcp': 'true'}
@ -379,16 +378,16 @@ class TestDhcpNegative(TestDHCP121BasicOps):
except exceptions.BadRequest:
e = sys.exc_info()[0].__dict__['message']
if (e == "Bad request"):
LOG.info(_LI("Can't disable DHCP while using host routes"))
LOG.info("Can't disable DHCP while using host routes")
pass
LOG.info(_LI("Testcase DHCP-121 option negative test completed"))
LOG.info("Testcase DHCP-121 option negative test completed")
class TestDhcpMultiHostRoute(TestDHCP121BasicOps):
@test.attr(type='nsxv')
@decorators.idempotent_id('c3ca96d7-b704-4d94-b42d-e7bae94b82cd')
def test_dhcp121_multi_host_route(self):
LOG.info(_LI("Testcase DHCP-121 option multi host routes deploying"))
LOG.info("Testcase DHCP-121 option multi host routes deploying")
t_net_id, t_network, t_subnet =\
self.create_project_network_subnet('admin')
# Fetch next hop information from tempest.conf
@ -448,8 +447,8 @@ class TestDhcpMultiHostRoute(TestDHCP121BasicOps):
subnet host_routes equal to 19 or not
'''
if (len(subnet['subnet']['host_routes']) == 19):
LOG.info(_LI("Multiple entries for host routes available"))
LOG.info(_LI("Testcase DHCP-121 option multi host routes completed"))
LOG.info("Multiple entries for host routes available")
LOG.info("Testcase DHCP-121 option multi host routes completed")
class TestDhcpHostRoutesBetweenVms(TestDHCP121BasicOps):

View File

@ -23,7 +23,6 @@ from tempest.lib.common.utils import test_utils
from tempest.lib import decorators
from tempest import test
from vmware_nsx_tempest._i18n import _LI
from vmware_nsx_tempest.services import nsxv_client
from vmware_nsx_tempest.tests.nsxv.scenario import (
manager_topo_deployment as dmgr)
@ -195,7 +194,7 @@ class TestSpoofGuardFeature(TestSpoofGuardBasicOps):
exclude_list = [item.encode('utf-8') for item in items]
for exclude_vm in exclude_list:
if vm_id in exclude_vm:
LOG.info(_LI("Vm in exclude list"))
LOG.info("Vm in exclude list")
# Update Port security to disabled
port_client.update_port(
port_id=port_id,
@ -204,7 +203,7 @@ class TestSpoofGuardFeature(TestSpoofGuardBasicOps):
exclude_list = [item.encode('utf-8') for item in items]
if exclude_vm in exclude_list:
if vm_id not in exclude_vm:
LOG.info(_LI("Vm not in exclude list"))
LOG.info("Vm not in exclude list")
# Detach interface from vm
self.interface_client.delete_interface(vm_id, port_id)
@ -315,7 +314,7 @@ class TestSpoofGuardFeature(TestSpoofGuardBasicOps):
exclude_list = [item.encode('utf-8') for item in items]
for exclude_vm in exclude_list:
if vm_id in exclude_vm:
LOG.info(_LI("Vm1 in exclude list"))
LOG.info("Vm1 in exclude list")
vm2_id = t_serv2['id']
# Update vm2 port to disable port security
port_client.update_port(
@ -326,7 +325,7 @@ class TestSpoofGuardFeature(TestSpoofGuardBasicOps):
# Check vm2 in exclude list or not
for exclude_vm in exclude_list:
if vm2_id in exclude_vm:
LOG.info(_LI("Vm2 in exclude list"))
LOG.info("Vm2 in exclude list")
vm3_id = t_serv3['id']
# Update vm3 port to enable port security
port_client.update_port(
@ -337,7 +336,7 @@ class TestSpoofGuardFeature(TestSpoofGuardBasicOps):
# Check vm3 in exclude list or not
for exclude_vm in exclude_list:
if vm3_id in exclude_vm:
LOG.info(_LI("Vm3 in exclude list"))
LOG.info("Vm3 in exclude list")
# Update vm1 port to enable port security
port_client.update_port(
port_id=port1_id,
@ -347,7 +346,7 @@ class TestSpoofGuardFeature(TestSpoofGuardBasicOps):
# Check vm should not be in exclude list
for exclude_vm in exclude_list:
if vm_id not in exclude_vm:
LOG.info(_LI("Vm1 not in exclude list"))
LOG.info("Vm1 not in exclude list")
@test.attr(type='nsxv')
@decorators.idempotent_id('f034d3e9-d717-4bcd-8e6e-18e9ada7b81a')
@ -365,7 +364,7 @@ class TestSpoofGuardFeature(TestSpoofGuardBasicOps):
exclude_list = [item.encode('utf-8') for item in items]
for exclude_vm in exclude_list:
if vm_id in exclude_vm:
LOG.info(_LI("Vm in exclude list"))
LOG.info("Vm in exclude list")
port_client.update_port(
port_id=port_id,
port_security_enabled='true')
@ -373,7 +372,7 @@ class TestSpoofGuardFeature(TestSpoofGuardBasicOps):
exclude_list = [item.encode('utf-8') for item in items]
if exclude_vm in exclude_list:
if vm_id not in exclude_vm:
LOG.info(_LI("Vm not in exclude list"))
LOG.info("Vm not in exclude list")
self.interface_client.delete_interface(vm_id, port_id)
@test.attr(type='nsxv')
@ -394,7 +393,7 @@ class TestSpoofGuardFeature(TestSpoofGuardBasicOps):
# Check port security of created port
port_details = port_client.show_port(port_id=port_id)
if (port_details['port']['port_security_enabled'] == 'false'):
LOG.info(_LI("Port security of port is disabled"))
LOG.info("Port security of port is disabled")
kwargs = {'port_security_enabled': 'true'}
# Update port security of network to enabled
network_client.update_network(network_id=net_id, **kwargs)
@ -404,7 +403,7 @@ class TestSpoofGuardFeature(TestSpoofGuardBasicOps):
port_id = port['id']
port_details = port_client.show_port(port_id=port_id)
if (port_details['port']['port_security_enabled'] == 'true'):
LOG.info(_LI("Port security of port is enabled"))
LOG.info("Port security of port is enabled")
@test.attr(type='nsxv')
@decorators.idempotent_id('c8683cb7-4be5-4670-95c6-344a0aea3667')
@ -425,7 +424,7 @@ class TestSpoofGuardFeature(TestSpoofGuardBasicOps):
exclude_list = [item.encode('utf-8') for item in items]
for exclude_vm in exclude_list:
if vm_id in exclude_vm:
LOG.info(_LI("Vm in exclude list"))
LOG.info("Vm in exclude list")
name = 'disabled-port-security-port2'
kwargs = {'name': name, 'network_id': net_id,
'port_security_enabled': 'false'}
@ -436,7 +435,7 @@ class TestSpoofGuardFeature(TestSpoofGuardBasicOps):
exclude_list = [item.encode('utf-8') for item in items]
for exclude_vm in exclude_list:
if vm_id in exclude_vm:
LOG.info(_LI("Vm in exclude list"))
LOG.info("Vm in exclude list")
port_client.update_port(
port_id=port2_id,
port_security_enabled='true')
@ -444,7 +443,7 @@ class TestSpoofGuardFeature(TestSpoofGuardBasicOps):
exclude_list = [item.encode('utf-8') for item in items]
for exclude_vm in exclude_list:
if vm_id in exclude_vm:
LOG.info(_LI("Vm in exclude list"))
LOG.info("Vm in exclude list")
port_client.update_port(
port_id=port1_id,
port_security_enabled='true')
@ -452,6 +451,6 @@ class TestSpoofGuardFeature(TestSpoofGuardBasicOps):
exclude_list = [item.encode('utf-8') for item in items]
if exclude_vm in exclude_list:
if vm_id not in exclude_vm:
LOG.info(_LI("Vm not in exclude list"))
LOG.info("Vm not in exclude list")
self.interface_client.delete_interface(vm_id, port1_id)
self.interface_client.delete_interface(vm_id, port2_id)

View File

@ -20,7 +20,6 @@ from tempest.lib.common.utils import data_utils
from tempest.lib import decorators
from tempest import test
from vmware_nsx_tempest._i18n import _LI
from vmware_nsx_tempest.common import constants
from vmware_nsx_tempest.services import base_l2gw
@ -42,7 +41,7 @@ class L2GatewayTest(base_l2gw.BaseL2GatewayTest):
To create l2gw we need bridge cluster name (interface name) and
bridge cluster UUID (device name) from NSX manager.
"""
LOG.info(_LI("Testing l2_gateway_create api"))
LOG.info("Testing l2_gateway_create api")
cluster_info = self.nsx_bridge_cluster_info()
device_name, interface_name = cluster_info[0][0], cluster_info[0][1]
l2gw_name = data_utils.rand_name(constants.L2GW)
@ -67,7 +66,7 @@ class L2GatewayTest(base_l2gw.BaseL2GatewayTest):
To create l2gw we need bridge cluster name (interface name) and
bridge cluster UUID (device name) from NSX manager and vlan id.
"""
LOG.info(_LI("Testing l2_gateway_create api with segmentation ID"))
LOG.info("Testing l2_gateway_create api with segmentation ID")
cluster_info = self.nsx_bridge_cluster_info()
device_name, interface_name = cluster_info[0][0], cluster_info[0][1]
l2gw_name = data_utils.rand_name(constants.L2GW)
@ -104,7 +103,7 @@ class L2GatewayTest(base_l2gw.BaseL2GatewayTest):
To create l2gw we need bridge cluster name (interface name) and
bridge cluster UUID (device name) from NSX manager and vlan id.
"""
LOG.info(_LI("Testing l2_gateway_create api with segmentation ID"))
LOG.info("Testing l2_gateway_create api with segmentation ID")
cluster_info = self.nsx_bridge_cluster_info()
device_name, interface_name = cluster_info[0][0], cluster_info[0][1]
l2gw_name = data_utils.rand_name(constants.L2GW)
@ -140,7 +139,7 @@ class L2GatewayTest(base_l2gw.BaseL2GatewayTest):
Delete l2gw will create l2gw and delete recently created l2gw. To
delete l2gw we need l2gw id.
"""
LOG.info(_LI("Testing l2_gateway_delete api"))
LOG.info("Testing l2_gateway_delete api")
cluster_info = self.nsx_bridge_cluster_info()
device_name, interface_name = cluster_info[0][0], cluster_info[0][1]
l2gw_name = data_utils.rand_name(constants.L2GW)
@ -171,7 +170,7 @@ class L2GatewayTest(base_l2gw.BaseL2GatewayTest):
Update l2gw will update info in already created l2gw. To
update l2gw we need l2gw id and payload to update.
"""
LOG.info(_LI("Testing l2_gateway_update api"))
LOG.info("Testing l2_gateway_update api")
cluster_info = self.nsx_bridge_cluster_info()
device_name, interface_name = cluster_info[0][0], cluster_info[0][1]
l2gw_name = data_utils.rand_name(constants.L2GW)
@ -198,7 +197,7 @@ class L2GatewayTest(base_l2gw.BaseL2GatewayTest):
"code":
constants.EXPECTED_HTTP_RESPONSE_200})
rsp_l2gw = update_rsp[constants.L2GW]
LOG.info(_LI("response : %(rsp_l2gw)s") % {"rsp_l2gw": rsp_l2gw})
LOG.info("response : %(rsp_l2gw)s", {"rsp_l2gw": rsp_l2gw})
# Assert if name is not updated.
self.assertEqual(l2gw_new_name, rsp_l2gw["name"],
"l2gw name=%(rsp_name)s is not the same as "
@ -213,7 +212,7 @@ class L2GatewayTest(base_l2gw.BaseL2GatewayTest):
Update l2gw will update info in already created l2gw. To
update l2gw we need l2gw id and payload to update.
"""
LOG.info(_LI("Testing l2_gateway_update api"))
LOG.info("Testing l2_gateway_update api")
cluster_info = self.nsx_bridge_cluster_info()
device_name, interface_name = cluster_info[0][0], cluster_info[0][1]
l2gw_name = data_utils.rand_name(constants.L2GW)
@ -243,7 +242,7 @@ class L2GatewayTest(base_l2gw.BaseL2GatewayTest):
constants.EXPECTED_HTTP_RESPONSE_200})
rsp_l2gw = update_rsp[constants.L2GW]
self.l2gw_created[rsp_l2gw["id"]] = rsp_l2gw
LOG.info(_LI("response : %(rsp_l2gw)s") % {"rsp_l2gw": rsp_l2gw})
LOG.info("response : %(rsp_l2gw)s", {"rsp_l2gw": rsp_l2gw})
if "segmentation_id" in devices["devices"][0]["interfaces"][0]:
self.assertEqual(devices["devices"][0]["interfaces"][0][
"segmentation_id"][0],
@ -258,7 +257,7 @@ class L2GatewayTest(base_l2gw.BaseL2GatewayTest):
"""
show l2gw based on UUID. To see l2gw info we need l2gw id.
"""
LOG.info(_LI("Testing l2_gateway_show api"))
LOG.info("Testing l2_gateway_show api")
cluster_info = self.nsx_bridge_cluster_info()
device_name, interface_name = cluster_info[0][0], cluster_info[0][1]
l2gw_name = data_utils.rand_name(constants.L2GW)
@ -301,7 +300,7 @@ class L2GatewayTest(base_l2gw.BaseL2GatewayTest):
"""
list created l2gw.
"""
LOG.info(_LI("Testing l2_gateway_list api"))
LOG.info("Testing l2_gateway_list api")
cluster_info = self.nsx_bridge_cluster_info()
device_name, interface_name = cluster_info[0][0], cluster_info[0][1]
l2gw_name = data_utils.rand_name(constants.L2GW)

View File

@ -22,7 +22,6 @@ from tempest.lib.common.utils import test_utils
from tempest.lib import decorators
from tempest import test
from vmware_nsx_tempest._i18n import _LI
from vmware_nsx_tempest.common import constants
from vmware_nsx_tempest.services import base_l2gw
@ -83,7 +82,7 @@ class L2GatewayConnectionTest(base_l2gw.BaseL2GatewayTest):
Create l2 gateway connection using one vlan. Vlan parameter is
passed into L2GW create.
"""
LOG.info(_LI("Testing test_l2_gateway_connection_create api"))
LOG.info("Testing test_l2_gateway_connection_create api")
cluster_info = self.nsx_bridge_cluster_info()
device_name, interface_name = cluster_info[0][0], cluster_info[0][1]
l2gw_name = data_utils.rand_name(constants.L2GW)
@ -116,7 +115,7 @@ class L2GatewayConnectionTest(base_l2gw.BaseL2GatewayTest):
Create l2 gateway connection using multiple vlans. Vlan parameter is
passed into L2GW create.
"""
LOG.info(_LI("Testing test_l2_gateway_connection_create api"))
LOG.info("Testing test_l2_gateway_connection_create api")
cluster_info = self.nsx_bridge_cluster_info()
device_name, interface_name = cluster_info[0][0], cluster_info[0][1]
l2gw_name = data_utils.rand_name(constants.L2GW)
@ -149,7 +148,7 @@ class L2GatewayConnectionTest(base_l2gw.BaseL2GatewayTest):
Create l2 gateway connection using one vlan. Vlan parameter is
passed into L2GW connection create.
"""
LOG.info(_LI("Testing test_l2_gateway_connection_create api"))
LOG.info("Testing test_l2_gateway_connection_create api")
cluster_info = self.nsx_bridge_cluster_info()
device_name, interface_name = cluster_info[0][0], cluster_info[0][1]
l2gw_name = data_utils.rand_name(constants.L2GW)
@ -186,7 +185,7 @@ class L2GatewayConnectionTest(base_l2gw.BaseL2GatewayTest):
Create l2 gateway connection using one vlan and tes l2 gateway
connection show api
"""
LOG.info(_LI("Testing test_l2_gateway_connection_create api"))
LOG.info("Testing test_l2_gateway_connection_create api")
cluster_info = self.nsx_bridge_cluster_info()
device_name, interface_name = cluster_info[0][0], cluster_info[0][1]
l2gw_name = data_utils.rand_name(constants.L2GW)
@ -231,7 +230,7 @@ class L2GatewayConnectionTest(base_l2gw.BaseL2GatewayTest):
Create l2 gateway connection using one vlan and test l2 gateway
connection list api.
"""
LOG.info(_LI("Testing test_l2_gateway_connection_create api"))
LOG.info("Testing test_l2_gateway_connection_create api")
cluster_info = self.nsx_bridge_cluster_info()
device_name, interface_name = cluster_info[0][0], cluster_info[0][1]
l2gw_name = data_utils.rand_name(constants.L2GW)
@ -250,7 +249,7 @@ class L2GatewayConnectionTest(base_l2gw.BaseL2GatewayTest):
"Response code is not %(code)s" % {
"code": constants.EXPECTED_HTTP_RESPONSE_201})
list_rsp = self.l2gwc_client.list_l2_gateway_connections()
LOG.info(_LI("l2gw connection list response: %s") % list_rsp)
LOG.info("l2gw connection list response: %s", list_rsp)
# Assert in case of failure.
self.assertEqual(constants.EXPECTED_HTTP_RESPONSE_200,
list_rsp.response["status"],
@ -289,10 +288,10 @@ class L2GatewayConnectionTest(base_l2gw.BaseL2GatewayTest):
- Recreate l2gw connection
- verify with l2gw connection list API.
"""
LOG.info(_LI("Testing test_l2_gateway_connection_create api"))
LOG.info("Testing test_l2_gateway_connection_create api")
# List all the L2GW connection.
list_rsp = self.l2gwc_client.list_l2_gateway_connections()
LOG.info(_LI("l2gw connection list response: %s") % list_rsp)
LOG.info("l2gw connection list response: %s", list_rsp)
# Assert in case of failure.
self.assertEqual(constants.EXPECTED_HTTP_RESPONSE_200,
list_rsp.response["status"],
@ -333,7 +332,7 @@ class L2GatewayConnectionTest(base_l2gw.BaseL2GatewayTest):
"code": constants.EXPECTED_HTTP_RESPONSE_201})
# List all the L2GW connection.
list_rsp = self.l2gwc_client.list_l2_gateway_connections()
LOG.info(_LI("l2gw connection list response: %s") % list_rsp)
LOG.info("l2gw connection list response: %s", list_rsp)
# Assert in case of failure.
self.assertEqual(constants.EXPECTED_HTTP_RESPONSE_200,
list_rsp.response["status"],
@ -353,7 +352,7 @@ class L2GatewayConnectionTest(base_l2gw.BaseL2GatewayTest):
Delete l2gw will create l2gw and delete recently created l2gw. To
delete l2gw we need l2gw id.
"""
LOG.info(_LI("Testing l2_gateway_connection_delete api"))
LOG.info("Testing l2_gateway_connection_delete api")
cluster_info = self.nsx_bridge_cluster_info()
device_name, interface_name = cluster_info[0][0], cluster_info[0][1]
l2gw_name = data_utils.rand_name(constants.L2GW)

View File

@ -24,7 +24,6 @@ from tempest.lib.common.utils import test_utils
from tempest.lib import decorators
from tempest.lib import exceptions as lib_exc
from vmware_nsx_tempest._i18n import _LI
from vmware_nsx_tempest.common import constants
from vmware_nsx_tempest.services import base_l2gw
@ -85,7 +84,7 @@ class L2GatewayConnectionNegative(base_l2gw.BaseL2GatewayTest):
"""
Delete l2 gateway with active mapping.
"""
LOG.info(_LI("Testing test_l2_gateway_create api"))
LOG.info("Testing test_l2_gateway_create api")
cluster_info = self.nsx_bridge_cluster_info()
device_name, interface_name = cluster_info[0][0], cluster_info[0][1]
l2gw_name = data_utils.rand_name(constants.L2GW)
@ -112,7 +111,7 @@ class L2GatewayConnectionNegative(base_l2gw.BaseL2GatewayTest):
"""
Recreate l2 gateway connection using same parameters.
"""
LOG.info(_LI("Testing test_l2_gateway_connection_create api"))
LOG.info("Testing test_l2_gateway_connection_create api")
cluster_info = self.nsx_bridge_cluster_info()
device_name, interface_name = cluster_info[0][0], cluster_info[0][1]
l2gw_name = data_utils.rand_name(constants.L2GW)
@ -138,7 +137,7 @@ class L2GatewayConnectionNegative(base_l2gw.BaseL2GatewayTest):
"""
Create l2 gateway connection using non exist l2gw uuid.
"""
LOG.info(_LI("Testing test_l2_gateway_connection_create api"))
LOG.info("Testing test_l2_gateway_connection_create api")
non_exist_l2gw_uuid = NON_EXIST_UUID
cluster_info = self.nsx_bridge_cluster_info()
device_name, interface_name = cluster_info[0][0], cluster_info[0][1]
@ -160,7 +159,7 @@ class L2GatewayConnectionNegative(base_l2gw.BaseL2GatewayTest):
"""
Create l2 gateway connection using non exist l2gw uuid.
"""
LOG.info(_LI("Testing test_l2_gateway_connection_create api"))
LOG.info("Testing test_l2_gateway_connection_create api")
non_exist_network_uuid = NON_EXIST_UUID
cluster_info = self.nsx_bridge_cluster_info()
device_name, interface_name = cluster_info[0][0], cluster_info[0][1]
@ -182,7 +181,7 @@ class L2GatewayConnectionNegative(base_l2gw.BaseL2GatewayTest):
"""
Create l2 gateway connection using invalid seg id.
"""
LOG.info(_LI("Testing l2_gateway_create api with segmentation ID"))
LOG.info("Testing l2_gateway_create api with segmentation ID")
invalid_seg_id = 20000
cluster_info = self.nsx_bridge_cluster_info()
device_name, interface_name = cluster_info[0][0], cluster_info[0][1]
@ -201,7 +200,7 @@ class L2GatewayConnectionNegative(base_l2gw.BaseL2GatewayTest):
"""
Create l2 gateway connection using invalid seg id.
"""
LOG.info(_LI("Testing l2_gateway_create api with segmentation ID"))
LOG.info("Testing l2_gateway_create api with segmentation ID")
invalid_seg_id = 2.45
cluster_info = self.nsx_bridge_cluster_info()
device_name, interface_name = cluster_info[0][0], cluster_info[0][1]

View File

@ -24,7 +24,6 @@ from tempest.lib.common.utils import data_utils
from tempest.lib import decorators
from tempest import test
from vmware_nsx_tempest._i18n import _LI
from vmware_nsx_tempest.services import nsxv3_client
LOG = logging.getLogger(__name__)
@ -93,7 +92,7 @@ class NSXv3SecGroupTest(base.BaseSecGroupTest):
group_create_body, name = self._create_security_group()
secgroup = group_create_body['security_group']
time.sleep(NSX_FIREWALL_REALIZED_DELAY)
LOG.info(_LI("Create security group with name %(name)s and id %(id)s"),
LOG.info("Create security group with name %(name)s and id %(id)s",
{'name': secgroup['name'], 'id': secgroup['id']})
# List security groups and verify if created group is there in response
list_body = self.security_groups_client.list_security_groups()

View File

@ -22,7 +22,6 @@ from tempest.lib import decorators
from tempest.lib import exceptions
from tempest import test
from vmware_nsx_tempest._i18n import _LI
from vmware_nsx_tempest.common import constants
from vmware_nsx_tempest.services import nsxv3_client
@ -298,8 +297,8 @@ class ProviderSecurityGroupTest(base.BaseAdminNetworkTest):
if (provider_sg_name in sec_name['display_name'] and
sg_name not in sec_name['display_name']):
if count == 0:
LOG.info(_LI("Provider group has high priority over"
"default sec group"))
LOG.info("Provider group has high priority over "
"default sec group")
break
count += count
self.assertIn(provider_sg_name, sec_name['display_name'])
@ -316,8 +315,8 @@ class ProviderSecurityGroupTest(base.BaseAdminNetworkTest):
try:
self.delete_security_group(sg_client, sg_id)
except Exception:
LOG.info(_LI("Non Admin tenant can't see admin"
"provider security group"))
LOG.info("Non Admin tenant can't see admin "
"provider security group")
pass
@test.attr(type='nsxv3')
@ -328,7 +327,7 @@ class ProviderSecurityGroupTest(base.BaseAdminNetworkTest):
self.create_security_provider_group,
self.cmgr_alt, project_id=project_id,
provider=True)
LOG.info(_LI("Non-Admin Tenant cannot create provider sec group"))
LOG.info("Non-Admin Tenant cannot create provider sec group")
@test.attr(type='nsxv3')
@decorators.idempotent_id('0d021bb2-9e21-422c-a509-6ac27803b2a2')

View File

@ -22,7 +22,6 @@ from tempest.lib import decorators
from tempest.scenario import manager
from tempest import test
from vmware_nsx_tempest._i18n import _LI
from vmware_nsx_tempest.common import constants
from vmware_nsx_tempest.services import nsxv3_client
@ -150,7 +149,7 @@ class TestMDProxy(manager.NetworkScenarioTest):
break
exec_cmd_retried += 1
time.sleep(constants.INTERVAL_BETWEEN_EXEC_RETRY_ON_SSH)
LOG.info(_LI("Tried %s times!!!") % exec_cmd_retried)
LOG.info("Tried %s times!!!", exec_cmd_retried)
if check_exist_only:
return "Verification is successful!"
msg = ("Failed while verifying metadata on server. Result "

View File

@ -22,8 +22,6 @@ from tempest.lib import decorators
from tempest.scenario import manager
from tempest import test
from vmware_nsx_tempest._i18n import _LE
CONF = config.CONF
LOG = logging.getLogger(__name__)
@ -153,8 +151,8 @@ class TestMultiHVNetworkOps(manager.NetworkScenarioTest):
(ssh_source, remote_ip, should_connect),
msg)
except Exception:
LOG.exception(_LE("Unable to access %{dest}s via ssh to "
"floating-ip %{src}s"),
LOG.exception("Unable to access %{dest}s via ssh to "
"floating-ip %{src}s",
{'dest': remote_ip, 'src': floating_ip})
raise

View File

@ -24,8 +24,6 @@ from tempest.lib import decorators
from tempest.scenario import manager
from tempest import test
from vmware_nsx_tempest._i18n import _LE
CONF = config.CONF
LOG = logging.getLogger(__name__)
@ -194,8 +192,8 @@ class TestMultiNetworksOps(manager.NetworkScenarioTest):
(ssh_source, remote_ip, should_connect),
msg)
except Exception:
LOG.exception(_LE("Unable to access %{dest}s via ssh to "
"floating-ip %{src}s"),
LOG.exception("Unable to access %{dest}s via ssh to "
"floating-ip %{src}s",
{'dest': remote_ip, 'src': floating_ip})
raise

View File

@ -24,7 +24,6 @@ from tempest.lib import decorators
from tempest.scenario import manager
from tempest import test
from vmware_nsx_tempest._i18n import _LE
from vmware_nsx_tempest.services import nsxv3_client
CONF = config.CONF
@ -213,8 +212,8 @@ class TestRouterNoNATOps(manager.NetworkScenarioTest):
(ssh_source, remote_ip, should_connect),
msg)
except Exception:
LOG.exception(_LE("Unable to access %{dest}s via ssh to "
"floating-ip %{src}s"),
LOG.exception("Unable to access %{dest}s via ssh to "
"floating-ip %{src}s",
{'dest': remote_ip, 'src': floating_ip})
raise

View File

@ -23,8 +23,6 @@ from tempest.lib import decorators
from tempest.scenario import manager
from tempest import test
from vmware_nsx_tempest._i18n import _LE
CONF = config.CONF
LOG = logging.getLogger(__name__)
@ -248,8 +246,8 @@ class TestMicroSegmentationOps(manager.NetworkScenarioTest):
(ssh_source, remote_ip, should_connect),
msg)
except Exception:
LOG.exception(_LE("Unable to access %{dest}s via ssh to "
"floating-ip %{src}s"),
LOG.exception("Unable to access %{dest}s via ssh to "
"floating-ip %{src}s",
{'dest': remote_ip, 'src': floating_ip})
raise