Add strategy_id & goal_id fields in audit template

In this changeset, I updated the 'goal_id' field into the AuditTemplate
to now become a mandatory foreign key towards the Goal model. I also
added the 'strategy_id' field into the AuditTemplate model to be an
optional foreign key onto the Strategy model.

This changeset also includes an update of the /audit_template
Watcher API endpoint to reflect the previous changes.

As this changeset changes the API, this should be merged alongside the
related changeset from python-watcherclient.

Partially Implements: blueprint get-goal-from-strategy

Change-Id: Ic0573d036d1bbd7820f8eb963e47912d6b3ed1a9
This commit is contained in:
Vincent Françoise
2016-04-13 10:32:47 +02:00
parent e67b532110
commit 2966b93777
20 changed files with 614 additions and 341 deletions

View File

@@ -73,27 +73,30 @@ class BaseInfraOptimScenarioTest(manager.ScenarioTest):
# ### AUDIT TEMPLATES ### #
def create_audit_template(self, name=None, description=None, goal=None,
host_aggregate=None, extra=None):
def create_audit_template(self, goal_uuid, name=None, description=None,
strategy_uuid=None, host_aggregate=None,
extra=None):
"""Wrapper utility for creating a test audit template
:param goal_uuid: The goal UUID related to the audit template.
Default: DUMMY
:param name: The name of the audit template. Default: My Audit Template
:param description: The description of the audit template.
Default: AT Description
:param goal: The goal associated within the audit template.
Default: DUMMY
:param strategy_uuid: The strategy UUID related to the audit template.
Default: dummy
:param host_aggregate: ID of the host aggregate targeted by
this audit template. Default: 1
:param extra: IMetadata associated to this audit template.
Default: {}
:return: A tuple with The HTTP response and its body
"""
description = description or data_utils.rand_name(
'test-audit_template')
resp, body = self.client.create_audit_template(
name=name, description=description, goal=goal,
host_aggregate=host_aggregate, extra=extra)
name=name, description=description, goal_uuid=goal_uuid,
strategy_uuid=strategy_uuid, host_aggregate=host_aggregate,
extra=extra)
self.addCleanup(
self.delete_audit_template,

View File

@@ -108,8 +108,8 @@ class TestExecuteBasicStrategy(base.BaseInfraOptimScenarioTest):
"""
self.addCleanup(self.rollback_compute_nodes_status)
self._create_one_instance_per_host()
_, audit_template = self.create_audit_template(goal=self.BASIC_GOAL)
_, goal = self.client.show_goal(self.BASIC_GOAL)
_, audit_template = self.create_audit_template(goal['uuid'])
_, audit = self.create_audit(audit_template['uuid'])
self.assertTrue(test.call_until_true(

View File

@@ -37,7 +37,8 @@ class TestExecuteDummyStrategy(base.BaseInfraOptimScenarioTest):
- run the action plan
- get results and make sure it succeeded
"""
_, audit_template = self.create_audit_template()
_, goal = self.client.show_goal("DUMMY")
_, audit_template = self.create_audit_template(goal['uuid'])
_, audit = self.create_audit(audit_template['uuid'])
self.assertTrue(test.call_until_true(