Replace assertEqual(None, *) with assertIsNone in tests to have
more clear messages in case of failure.
Change-Id: I98261ef7cca06447ea9d443a2c287c046f380f77
Closes-Bug: #1280522
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
In this changeset, I added the /strategies endpoint to the Watcher
API service.
This also includes the related Tempest tests.
Partially Implements: blueprint get-goal-from-strategy
Change-Id: I1b70836e0df2082ab0016ecc207e89fdcb0fc8b9
In this changeset, I changed the Strategy base class to add new
abstract class methods. I also added an abstract strategy class
per Goal type (dummy, server consolidation, thermal optimization).
This changeset also includes an update of the /goals Watcher API
endpoint to now use the new Goal model (DB entries) instead of
reading from the configuration file.
Partially Implements: blueprint get-goal-from-strategy
Change-Id: Iecfed58c72f3f9df4e9d27e50a3a274a1fc0a75f
This patch set removes the possibility of using UUID field
in POST methods of Watcher API.
Closes-Bug: #1572625
Change-Id: I88a8aa5346e937e3e9409b55da3316cbe1ed832a
We have to check Audit Type and Audit State to make sure
these parameters are in valid status.
Also, we provide default states for the next attributes:
- 'audit_template' is required and should be either UUID or text field
- 'state' is readonly so it raises an error if submitted in POST
and is set by default to PENDING
- 'deadline' is optional and should be a datetime
- 'type' is a required text field
Change-Id: I2a7e0deec0ee2040e86400b500bb0efd8eade564
Closes-Bug: #1532843
Closes-Bug: #1533210
We need to update sqlalchemy/api and sqlalchemy/models (and appropriate tests)
to support deleting audit templates and recreating them with the same names.
Change-Id: Icf54cf1ed989a3f2ad689e25be4474b16a3a3eb2
Related-Bug: #1510179
I removed the POST, PATCH and DELETE verbs from the actions
controller as they should only be modified internally.
Change-Id: Ia72484249240f829423056f66c5c0f9632d02106
Closes-Bug: #1533281
When creating a new audit template, the verification of its goal
existence was previously done in watcher/objects/audit_template.py.
This check was moved to api/controllers/v1/audit_template.py, rather
than in the DAO class.
Change-Id: I6efb0657f64c46a56914a946ec78013b9e47331b
Closes-Bug: #1536191
In several places, assertEqual is used the following way:
assertEqual(observed, expected)
However, the correct way to use assertEqual is:
assertEqual(expected, observed)
Change-Id: I5a7442f4adf98bf7bc73cef1d17d20da39d9a7f8
Closes-Bug: #1551861
"TRIGGERED" is not the correct word to use to describe the action
state, we should use "PENDING" instead.
Change-Id: If24979cdb916523861324f7bcc024e2f1fc28b05
Closes-Bug: #1548377
In watcher/api/controllers/v1/utils.py, in
the validate_sort_dir method has a return statement,
however the return value is exactly the parameter's value.
This is misleading, so I removed it.
Change-Id: I18c5c7853a5afedac88431347712a4348c9fd5dd
Closes-Bug: #1546917
Although it was proposed via python-watcherclient, the feature was
not implemented on the Watcher API.
As the notion of host aggregate is currently unused in Watcher,
decision was made to only implement the filtering of goal within
the Watcher API whilst removing the host_aggregate filter from the
Watcher client.
Thus, this patchset adds this missing functionality by adding the
'goal' parameter to the API.
Change-Id: I54d248f7e470249c6412650ddf50a3e3631d2a09
Related-Bug: #1510189
When a user deletes an action plan, we now delete all related actions.
Partially Implements: blueprint deletion-of-actions-plan
Change-Id: I5d519c38458741be78591cbec04dbd410a6dc14b
Whenever trying to get the first action related to a given action
plan, we were getting back a 'null' value from the API even though
we knew there were actions to be linked to it in the DB.
So I fixed this issue and added a related unit test.
Change-Id: I1fa755f24fbf37ecd6ce2cc2396658fca8743a1c
Closes-Bug: #1538130
This patchset fixes the lack of field validation that are provided
by an API user.
Via a PATCH on /action_plans, the only field that can be modified
is now the 'state'. This field can only perform to the following
state transitions:
- RECOMMENDED --> TRIGGERED
- RECOMMENDED --> CANCELLED
- ONGOING --> CANCELLED
- TRIGGERED --> CANCELLED
The DELETED state can only be set using a DELETE request.
Closes-Bug: #1531106
Change-Id: I6669cbe63407f0bbb792fb2e2ce6b1e8a7365238
As the STARTING state was not clear on its meaning, I renamed it
to TRIGGERED.
Change-Id: I99cceeb57f3d7d42c1543b21fad88a6872bc4e55
Closes-Bug: #1533245
As we can see in the codebase, we have 3 "Status" enums which are
located at:
- watcher/objects/action.py
- watcher/objects/action_plan.py
- watcher/objects/audit.py
So I renamed them from "Status" to "State" to be consistent with
the DB schema.
Change-Id: If3d180c9daba6ae9083775ad6813aa4c21763dbf
Closes-Bug: #1522733
The audit template UUID should be validated during the creation of an
audit. An HTTP 400 error is returned to the client if an invalid audit
template UUID is passed as part of the body when creating an audit.
APIImpact
Closes-Bug: #1510188
Change-Id: I0543d22751b77f6641ddef6a7f0f4acce61180fd
Replacing dict.iteritems()/.itervalues() with
six.iteritems(dict)/six.itervalues(dict) was preferred in the past,
but there was a discussion suggesting to avoid six for this.
ref:
http://lists.openstack.org/pipermail/openstack-dev/2015-June/066391.html
Change-Id: I63b1e51597307862968f37803ffdbba63306d8c6
Each config option has limitation for type and value.
We make enforce_type=True to check whether we pass wrong type.
Also fixes a type error issue in test_db_manager.py.
Change-Id: I6e111e21588525d32b05eeba75b06583d4e605ed
Related-Bug: #1517839
In watcher, an audit generates a set of actions which
aims at achieving a given goal (lower energy consumption, ...).
It is possible to configure different strategies in order to achieve
each goal. Each strategy is written as a Python class which produces
a set of actions. Today, the set of possible actions is fixed for a
given version of Watcher and enables optimization algorithms to
include actions such as instance migration, changing hypervisor state,
changing power state (ACPI level, ...).
This patchset add the possibility to store several parameters
for an Action.
The parameters store info that the custom Action needs.
The parameters provided as tuples with the following fields:
(parameter_name, parameter_type).
It remove also the deprecated attributes
(src,dst,description)
APIImpact
Partially implements: blueprint watcher-add-actions-via-conf
Change-Id: Ic6727341822f8ac62f212d337814b2dca76044e3
The usage of assertEqual(True/False, ***) should be changed
to a meaningful format of assertTrue/False(***).
Change-Id: Id708a94ac461adf021893a05796163bd2ced153c
Closes-Bug:#1512207
Some of the modules still utilized string concatenation
instead of using formatting. In order to align with other
modules in the project, I refactored these modules to use string
formatting instead.
Change-Id: I708392e1d03b6331a134419aa0ae9dc02a05c31b
Closes-Bug: 1522738
Some Python class and packages need to be renamed
for a better compliance with the shared terminology
which provides a better understanding of Watcher
objects and components by every contributor.
This patchset add missing Base in class name
Partially implements: blueprint glossary-related-refactoring
Change-Id: I95a3e41fbd5fcd90a99d81c9cf278940f50c7732
Even though Watcher was mentioning python 3.4 as supported, it
really wasn't the case as all the unit tests were not passing in this
version of Python.
This patchset fixes all the failing tests in Python 3.4 while
keeping Watcher Python 2.7 compatible.
DocImpact
BugImpact
Change-Id: Ie74acc08ef0a2899349a4b419728c89e416a18cb
This patchset is there to change the code structure.
The objective is to flatten the project file tree by merging
'api/' and 'framework/' into a single package. This also contains
some tidy ups in package naming (like using only singular nouns).
This should only affect file/folder names and their subsequent
import paths wherever they were used.
Change-Id: Id7b37667c613086d8ef3cd1f367c4219bf026fc7
This should make our 'dummy' strategy available for use.
I also removed all previously defined default goals, which means
that they will have to define it themselves from now on.
This can also be useful for future integration tests.
Change-Id: I6c43eba941022a88851a199b56a6c20f017b9e71
DocImpact
Closes-Bug: #1520178
In several places in Watcher, there are statuses which corresponds
to a status in the respective life cycle. There were used past tense
everywhere, except "SUCCESS" which was written in present tense.
So I searched for all the occurences of this state, and replaced them
with their past tense form.
Change-Id: Ic41def96d1a608da06a1e394e24704d4f06ab32a
Closes-Bug: #1520276
This patchset is there to change the code structure.
The objective is to flatten the project file tree by merging
'api/' and 'framework/' into a single package. This also contains
some tidy ups in package naming (like using only singular nouns).
This should only affect file/folder names and their subsequent
import paths wherever they were used.
Change-Id: Ie903ba20ca5cf03b0b42efa60131d1b919b0c2c9