Implement goal_id, strategy_id and host_aggregate into Audit api

Modifying the api controller for audit objects to allow
creation of audit objects by specifying either an
audit_template uuid/id and/or a goal_id.

strategy_id is optional.

Partially Implements: blueprint persistent-audit-parameters
Change-Id: I7b3eae4d0752a11208f5f92ee13ab1018d8521ad
This commit is contained in:
Michael Gugino
2016-06-15 15:13:15 -04:00
parent 0769e53f93
commit 52ffc2c8e2
15 changed files with 296 additions and 379 deletions

View File

@@ -330,10 +330,13 @@ class Connection(api.BaseConnection):
if filters is None:
filters = {}
plain_fields = ['uuid', 'audit_type', 'state', 'audit_template_id']
plain_fields = ['uuid', 'audit_type', 'state', 'goal_id',
'strategy_id']
join_fieldmap = {
'audit_template_uuid': ("uuid", models.AuditTemplate),
'audit_template_name': ("name", models.AuditTemplate),
'goal_uuid': ("uuid", models.Goal),
'goal_name': ("name", models.Goal),
'strategy_uuid': ("uuid", models.Strategy),
'strategy_name': ("name", models.Strategy),
}
return self._add_filters(

View File

@@ -173,10 +173,11 @@ class Audit(Base):
audit_type = Column(String(20))
state = Column(String(20), nullable=True)
deadline = Column(DateTime, nullable=True)
audit_template_id = Column(Integer, ForeignKey('audit_templates.id'),
nullable=False)
parameters = Column(JSONEncodedDict, nullable=True)
interval = Column(Integer, nullable=True)
host_aggregate = Column(Integer, nullable=True)
goal_id = Column(Integer, ForeignKey('goals.id'), nullable=False)
strategy_id = Column(Integer, ForeignKey('strategies.id'), nullable=True)
class Action(Base):