Logging audit for trove/configuration module
Adjust log messages to conform to logging standards. Change-Id: I16e48928d7a710e2ba31524be02d358b4e1dd713 Partial-Bug: #1324206
This commit is contained in:
parent
46a2f7d377
commit
6763a032a1
|
@ -42,13 +42,13 @@ class Configurations(object):
|
|||
|
||||
if context.is_admin:
|
||||
db_info = DBConfiguration.find_all(deleted=False)
|
||||
if db_info is None:
|
||||
LOG.debug("No configurations found")
|
||||
if db_info.count() == 0:
|
||||
LOG.debug("No configurations found for admin user")
|
||||
else:
|
||||
db_info = DBConfiguration.find_all(tenant_id=context.tenant,
|
||||
deleted=False)
|
||||
if db_info is None:
|
||||
LOG.debug("No configurations found for tenant % s"
|
||||
if db_info.count() == 0:
|
||||
LOG.debug("No configurations found for tenant %s"
|
||||
% context.tenant)
|
||||
|
||||
limit = int(context.limit or Configurations.DEFAULT_LIMIT)
|
||||
|
@ -85,9 +85,8 @@ class Configuration(object):
|
|||
|
||||
@staticmethod
|
||||
def create_items(cfg_id, values):
|
||||
LOG.debug("saving the values to the database")
|
||||
LOG.debug("cfg_id: %s" % cfg_id)
|
||||
LOG.debug("values: %s" % values)
|
||||
LOG.debug("Saving configuration values for %s - "
|
||||
"values: %s" % (cfg_id, values))
|
||||
config_items = []
|
||||
for key, val in values.iteritems():
|
||||
config_item = ConfigurationParameter.create(
|
||||
|
@ -107,11 +106,9 @@ class Configuration(object):
|
|||
|
||||
@staticmethod
|
||||
def remove_all_items(context, id, deleted_at):
|
||||
LOG.debug("removing the values from the database with configuration"
|
||||
" %s" % id)
|
||||
items = ConfigurationParameter.find_all(configuration_id=id,
|
||||
deleted=False).all()
|
||||
LOG.debug("removing items: %s" % items)
|
||||
LOG.debug("Removing all configuration values for %s" % id)
|
||||
for item in items:
|
||||
item.deleted = True
|
||||
item.deleted_at = deleted_at
|
||||
|
@ -149,7 +146,6 @@ class Configuration(object):
|
|||
datastore_manager=datastore.manager)
|
||||
|
||||
def _get_rule(key):
|
||||
LOG.debug("finding rule with key : %s" % key)
|
||||
for rule in rules['configuration-parameters']:
|
||||
if str(rule.get('name')) == key:
|
||||
return rule
|
||||
|
@ -186,7 +182,8 @@ class Configuration(object):
|
|||
items = Configuration.load_items(context, configuration.id)
|
||||
|
||||
for instance in instances:
|
||||
LOG.debug("applying to instance: %s" % instance.id)
|
||||
LOG.debug("Configuration %s being applied to "
|
||||
"instance: %s" % (configuration.id, instance.id))
|
||||
overrides = {}
|
||||
for i in items:
|
||||
overrides[i.configuration_key] = i.configuration_value
|
||||
|
|
|
@ -46,6 +46,8 @@ class ConfigurationsController(wsgi.Controller):
|
|||
return wsgi.Result(paged.data(), 200)
|
||||
|
||||
def show(self, req, tenant_id, id):
|
||||
LOG.debug("Showing configuration group %(id)s on tenant %(tenant)s"
|
||||
% {"tenant": tenant_id, "id": id})
|
||||
context = req.environ[wsgi.CONTEXT_KEY]
|
||||
configuration = models.Configuration.load(context, id)
|
||||
configuration_items = models.Configuration.load_items(context, id)
|
||||
|
@ -81,6 +83,10 @@ class ConfigurationsController(wsgi.Controller):
|
|||
description = body['configuration'].get('description')
|
||||
values = body['configuration']['values']
|
||||
|
||||
msg = _("Creating configuration group on tenant "
|
||||
"%(tenant_id)s with name: %(cfg_name)s")
|
||||
LOG.info(msg % {"tenant_id": tenant_id, "cfg_name": name})
|
||||
|
||||
datastore_args = body['configuration'].get('datastore', {})
|
||||
datastore, datastore_version = (
|
||||
ds_models.get_datastore_version(**datastore_args))
|
||||
|
@ -107,6 +113,10 @@ class ConfigurationsController(wsgi.Controller):
|
|||
return wsgi.Result(view_data.data(), 200)
|
||||
|
||||
def delete(self, req, tenant_id, id):
|
||||
msg = _("Deleting configuration group %(cfg_id)s on tenant: "
|
||||
"%(tenant_id)s")
|
||||
LOG.info(msg % {"tenant_id": tenant_id, "cfg_id": id})
|
||||
|
||||
context = req.environ[wsgi.CONTEXT_KEY]
|
||||
group = models.Configuration.load(context, id)
|
||||
instances = instances_models.DBInstance.find_all(
|
||||
|
@ -119,13 +129,18 @@ class ConfigurationsController(wsgi.Controller):
|
|||
return wsgi.Result(None, 202)
|
||||
|
||||
def update(self, req, body, tenant_id, id):
|
||||
LOG.info(_("Updating configuration for tenant id %s") % tenant_id)
|
||||
msg = _("Updating configuration group %(cfg_id)s for tenant "
|
||||
"id %(tenant_id)s")
|
||||
LOG.info(msg % {"tenant_id": tenant_id, "cfg_id": id})
|
||||
|
||||
context = req.environ[wsgi.CONTEXT_KEY]
|
||||
group = models.Configuration.load(context, id)
|
||||
instances = instances_models.DBInstance.find_all(
|
||||
tenant_id=context.tenant,
|
||||
configuration_id=id,
|
||||
deleted=False).all()
|
||||
LOG.debug("Loaded instances for configuration group %s on "
|
||||
"tenant %s: %s" % (id, tenant_id, instances))
|
||||
|
||||
# if name/description are provided in the request body, update the
|
||||
# model with these values as well.
|
||||
|
@ -138,7 +153,6 @@ class ConfigurationsController(wsgi.Controller):
|
|||
items = self._configuration_items_list(group, body['configuration'])
|
||||
deleted_at = datetime.utcnow()
|
||||
models.Configuration.remove_all_items(context, group.id, deleted_at)
|
||||
LOG.info(_("loaded configuration instances: %s") % instances)
|
||||
models.Configuration.save(context, group, items, instances)
|
||||
return wsgi.Result(None, 202)
|
||||
|
||||
|
@ -149,7 +163,8 @@ class ConfigurationsController(wsgi.Controller):
|
|||
tenant_id=context.tenant,
|
||||
configuration_id=id,
|
||||
deleted=False).all()
|
||||
LOG.info(_("loaded configuration instances: %s") % instances)
|
||||
LOG.debug("Loaded instances for configuration group %s on "
|
||||
"tenant %s: %s" % (id, tenant_id, instances))
|
||||
items = self._configuration_items_list(group, body['configuration'])
|
||||
models.Configuration.save(context, group, items, instances)
|
||||
|
||||
|
@ -157,7 +172,6 @@ class ConfigurationsController(wsgi.Controller):
|
|||
ds_version_id = group.datastore_version_id
|
||||
ds_version = ds_models.DatastoreVersion.load_by_uuid(ds_version_id)
|
||||
items = []
|
||||
LOG.info(_("loaded configuration group: %s") % group)
|
||||
if 'values' in configuration:
|
||||
# validate that the values passed in are permitted by the operator.
|
||||
ConfigurationsController._validate_configuration(
|
||||
|
@ -174,7 +188,8 @@ class ConfigurationsController(wsgi.Controller):
|
|||
rules = configurations.get_validation_rules(
|
||||
datastore_manager=datastore_manager)
|
||||
|
||||
LOG.info(_("Validating configuration values"))
|
||||
LOG.debug("Validating configuration values for group "
|
||||
"with manager %s" % datastore_manager)
|
||||
for k, v in values.iteritems():
|
||||
# get the validation rule dictionary, which will ensure there is a
|
||||
# rule for the given key name. An exception will be thrown if no
|
||||
|
|
Loading…
Reference in New Issue