Merge "remove log translation from nova.api.metadata"
This commit is contained in:
commit
8e1100f641
|
@ -38,7 +38,6 @@ from nova.cells import rpcapi as cells_rpcapi
|
|||
import nova.conf
|
||||
from nova import context
|
||||
from nova import exception
|
||||
from nova.i18n import _LI, _LW
|
||||
from nova import network
|
||||
from nova.network.security_group import openstack_driver
|
||||
from nova import objects
|
||||
|
@ -520,8 +519,8 @@ class InstanceMetadata(object):
|
|||
values = self.vendordata_providers[provider].get()
|
||||
for key in list(values):
|
||||
if key in j:
|
||||
LOG.warning(_LW('Removing duplicate metadata key: '
|
||||
'%s'), key, instance=self.instance)
|
||||
LOG.warning('Removing duplicate metadata key: %s',
|
||||
key, instance=self.instance)
|
||||
del values[key]
|
||||
j.update(values)
|
||||
|
||||
|
@ -666,7 +665,7 @@ class RouteConfiguration(object):
|
|||
def get_metadata_by_address(address):
|
||||
ctxt = context.get_admin_context()
|
||||
fixed_ip = network.API().get_fixed_ip_by_address(ctxt, address)
|
||||
LOG.info(_LI('Fixed IP %(ip)s translates to instance UUID %(uuid)s'),
|
||||
LOG.info('Fixed IP %(ip)s translates to instance UUID %(uuid)s',
|
||||
{'ip': address, 'uuid': fixed_ip['instance_uuid']})
|
||||
|
||||
return get_metadata_by_instance_id(fixed_ip['instance_uuid'],
|
||||
|
@ -683,8 +682,8 @@ def get_metadata_by_instance_id(instance_id, address, ctxt=None):
|
|||
try:
|
||||
im = objects.InstanceMapping.get_by_instance_uuid(ctxt, instance_id)
|
||||
except exception.InstanceMappingNotFound:
|
||||
LOG.warning(_LW('Instance mapping for %(uuid)s not found; '
|
||||
'cell setup is incomplete'), {'uuid': instance_id})
|
||||
LOG.warning('Instance mapping for %(uuid)s not found; '
|
||||
'cell setup is incomplete', {'uuid': instance_id})
|
||||
instance = objects.Instance.get_by_uuid(ctxt, instance_id,
|
||||
expected_attrs=attrs)
|
||||
return InstanceMetadata(instance, address)
|
||||
|
|
|
@ -32,8 +32,6 @@ import nova.conf
|
|||
from nova import context as nova_context
|
||||
from nova import exception
|
||||
from nova.i18n import _
|
||||
from nova.i18n import _LE
|
||||
from nova.i18n import _LW
|
||||
from nova.network.neutronv2 import api as neutronapi
|
||||
from nova import wsgi
|
||||
|
||||
|
@ -49,9 +47,9 @@ class MetadataRequestHandler(wsgi.Application):
|
|||
expiration_time=CONF.api.metadata_cache_expiration)
|
||||
if (CONF.neutron.service_metadata_proxy and
|
||||
not CONF.neutron.metadata_proxy_shared_secret):
|
||||
LOG.warning(_LW("metadata_proxy_shared_secret is not configured, "
|
||||
"the metadata information returned by the proxy "
|
||||
"cannot be trusted"))
|
||||
LOG.warning("metadata_proxy_shared_secret is not configured, "
|
||||
"the metadata information returned by the proxy "
|
||||
"cannot be trusted")
|
||||
|
||||
def get_metadata_by_remote_address(self, address):
|
||||
if not address:
|
||||
|
@ -106,9 +104,9 @@ class MetadataRequestHandler(wsgi.Application):
|
|||
else:
|
||||
if req.headers.get('X-Instance-ID'):
|
||||
LOG.warning(
|
||||
_LW("X-Instance-ID present in request headers. The "
|
||||
"'service_metadata_proxy' option must be "
|
||||
"enabled to process this header."))
|
||||
"X-Instance-ID present in request headers. The "
|
||||
"'service_metadata_proxy' option must be "
|
||||
"enabled to process this header.")
|
||||
meta_data = self._handle_remote_ip_request(req)
|
||||
|
||||
if meta_data is None:
|
||||
|
@ -136,7 +134,7 @@ class MetadataRequestHandler(wsgi.Application):
|
|||
try:
|
||||
meta_data = self.get_metadata_by_remote_address(remote_address)
|
||||
except Exception:
|
||||
LOG.exception(_LE('Failed to get metadata for IP %s'),
|
||||
LOG.exception('Failed to get metadata for IP %s',
|
||||
remote_address)
|
||||
msg = _('An unknown error has occurred. '
|
||||
'Please try your request again.')
|
||||
|
@ -144,7 +142,7 @@ class MetadataRequestHandler(wsgi.Application):
|
|||
explanation=six.text_type(msg))
|
||||
|
||||
if meta_data is None:
|
||||
LOG.error(_LE('Failed to get metadata for IP %s: no metadata'),
|
||||
LOG.error('Failed to get metadata for IP %s: no metadata',
|
||||
remote_address)
|
||||
|
||||
return meta_data
|
||||
|
@ -215,10 +213,10 @@ class MetadataRequestHandler(wsgi.Application):
|
|||
network_id=md_networks,
|
||||
fields=['device_id', 'tenant_id'])['ports'][0]
|
||||
except Exception as e:
|
||||
LOG.error(_LE('Failed to get instance id for metadata '
|
||||
'request, provider %(provider)s '
|
||||
'networks %(networks)s '
|
||||
'requester %(requester)s. Error: %(error)s'),
|
||||
LOG.error('Failed to get instance id for metadata '
|
||||
'request, provider %(provider)s '
|
||||
'networks %(networks)s '
|
||||
'requester %(requester)s. Error: %(error)s',
|
||||
{'provider': provider_id,
|
||||
'networks': md_networks,
|
||||
'requester': instance_address,
|
||||
|
@ -268,11 +266,11 @@ class MetadataRequestHandler(wsgi.Application):
|
|||
|
||||
if not secutils.constant_time_compare(expected_signature, signature):
|
||||
if requestor_id:
|
||||
LOG.warning(_LW('X-Instance-ID-Signature: %(signature)s does '
|
||||
'not match the expected value: '
|
||||
'%(expected_signature)s for id: '
|
||||
'%(requestor_id)s. Request From: '
|
||||
'%(requestor_address)s'),
|
||||
LOG.warning('X-Instance-ID-Signature: %(signature)s does '
|
||||
'not match the expected value: '
|
||||
'%(expected_signature)s for id: '
|
||||
'%(requestor_id)s. Request From: '
|
||||
'%(requestor_address)s',
|
||||
{'signature': signature,
|
||||
'expected_signature': expected_signature,
|
||||
'requestor_id': requestor_id,
|
||||
|
@ -286,7 +284,7 @@ class MetadataRequestHandler(wsgi.Application):
|
|||
meta_data = self.get_metadata_by_instance_id(instance_id,
|
||||
remote_address)
|
||||
except Exception:
|
||||
LOG.exception(_LE('Failed to get metadata for instance id: %s'),
|
||||
LOG.exception('Failed to get metadata for instance id: %s',
|
||||
instance_id)
|
||||
msg = _('An unknown error has occurred. '
|
||||
'Please try your request again.')
|
||||
|
@ -294,11 +292,11 @@ class MetadataRequestHandler(wsgi.Application):
|
|||
explanation=six.text_type(msg))
|
||||
|
||||
if meta_data is None:
|
||||
LOG.error(_LE('Failed to get metadata for instance id: %s'),
|
||||
LOG.error('Failed to get metadata for instance id: %s',
|
||||
instance_id)
|
||||
elif meta_data.instance.project_id != tenant_id:
|
||||
LOG.warning(_LW("Tenant_id %(tenant_id)s does not match tenant_id "
|
||||
"of instance %(instance_id)s."),
|
||||
LOG.warning("Tenant_id %(tenant_id)s does not match tenant_id "
|
||||
"of instance %(instance_id)s.",
|
||||
{'tenant_id': tenant_id, 'instance_id': instance_id})
|
||||
# causes a 404 to be raised
|
||||
meta_data = None
|
||||
|
|
|
@ -25,7 +25,6 @@ import six
|
|||
|
||||
from nova.api.metadata import vendordata
|
||||
import nova.conf
|
||||
from nova.i18n import _LW
|
||||
|
||||
CONF = nova.conf.CONF
|
||||
LOG = logging.getLogger(__name__)
|
||||
|
@ -48,9 +47,9 @@ def _load_ks_session(conf):
|
|||
conf, nova.conf.vendordata.vendordata_group.name)
|
||||
|
||||
if not _ADMIN_AUTH:
|
||||
LOG.warning(_LW('Passing insecure dynamic vendordata requests '
|
||||
'because of missing or incorrect service account '
|
||||
'configuration.'))
|
||||
LOG.warning('Passing insecure dynamic vendordata requests '
|
||||
'because of missing or incorrect service account '
|
||||
'configuration.')
|
||||
|
||||
if not _SESSION:
|
||||
_SESSION = ks_loading.load_session_from_conf_options(
|
||||
|
@ -109,8 +108,8 @@ class DynamicVendorData(vendordata.VendorDataDriver):
|
|||
except (TypeError, ValueError,
|
||||
ks_exceptions.connection.ConnectionError,
|
||||
ks_exceptions.http.HttpError) as e:
|
||||
LOG.warning(_LW('Error from dynamic vendordata service '
|
||||
'%(service_name)s at %(url)s: %(error)s'),
|
||||
LOG.warning('Error from dynamic vendordata service '
|
||||
'%(service_name)s at %(url)s: %(error)s',
|
||||
{'service_name': service_name,
|
||||
'url': url,
|
||||
'error': e},
|
||||
|
@ -129,8 +128,8 @@ class DynamicVendorData(vendordata.VendorDataDriver):
|
|||
# where name is the name to use in the metadata handed to
|
||||
# instances, and url is the URL to fetch it from
|
||||
if target.find('@') == -1:
|
||||
LOG.warning(_LW('Vendordata target %(target)s lacks a name. '
|
||||
'Skipping'),
|
||||
LOG.warning('Vendordata target %(target)s lacks a name. '
|
||||
'Skipping',
|
||||
{'target': target}, instance=self.instance)
|
||||
continue
|
||||
|
||||
|
@ -139,8 +138,8 @@ class DynamicVendorData(vendordata.VendorDataDriver):
|
|||
url = '@'.join(tokens[1:])
|
||||
|
||||
if name in j:
|
||||
LOG.warning(_LW('Vendordata already contains an entry named '
|
||||
'%(target)s. Skipping'),
|
||||
LOG.warning('Vendordata already contains an entry named '
|
||||
'%(target)s. Skipping',
|
||||
{'target': target}, instance=self.instance)
|
||||
continue
|
||||
|
||||
|
|
|
@ -22,7 +22,6 @@ from oslo_serialization import jsonutils
|
|||
|
||||
from nova.api.metadata import vendordata
|
||||
import nova.conf
|
||||
from nova.i18n import _LW
|
||||
|
||||
CONF = nova.conf.CONF
|
||||
LOG = logging.getLogger(__name__)
|
||||
|
@ -40,14 +39,14 @@ class JsonFileVendorData(vendordata.VendorDataDriver):
|
|||
data = jsonutils.load(fp)
|
||||
except IOError as e:
|
||||
if e.errno == errno.ENOENT:
|
||||
LOG.warning(_LW("%(logprefix)s file does not exist"),
|
||||
LOG.warning("%(logprefix)s file does not exist",
|
||||
{'logprefix': logprefix})
|
||||
else:
|
||||
LOG.warning(_LW("%(logprefix)s unexpected IOError when "
|
||||
"reading"), {'logprefix': logprefix})
|
||||
LOG.warning("%(logprefix)s unexpected IOError when "
|
||||
"reading", {'logprefix': logprefix})
|
||||
raise
|
||||
except ValueError:
|
||||
LOG.warning(_LW("%(logprefix)s failed to load json"),
|
||||
LOG.warning("%(logprefix)s failed to load json",
|
||||
{'logprefix': logprefix})
|
||||
raise
|
||||
|
||||
|
|
Loading…
Reference in New Issue