avoid repeated actions in the solution
Change-Id: If163aee969b51764d69d42655c05e0651e4f150c
This commit is contained in:
@@ -16,10 +16,14 @@
|
|||||||
# See the License for the specific language governing permissions and
|
# See the License for the specific language governing permissions and
|
||||||
# limitations under the License.
|
# limitations under the License.
|
||||||
#
|
#
|
||||||
|
from oslo_log import log
|
||||||
|
|
||||||
from watcher.applier.actions import base as baction
|
from watcher.applier.actions import base as baction
|
||||||
from watcher.common import exception
|
from watcher.common import exception
|
||||||
from watcher.decision_engine.solution import base
|
from watcher.decision_engine.solution import base
|
||||||
|
|
||||||
|
LOG = log.getLogger(__name__)
|
||||||
|
|
||||||
|
|
||||||
class DefaultSolution(base.BaseSolution):
|
class DefaultSolution(base.BaseSolution):
|
||||||
def __init__(self, goal, strategy):
|
def __init__(self, goal, strategy):
|
||||||
@@ -50,7 +54,11 @@ class DefaultSolution(base.BaseSolution):
|
|||||||
'action_type': action_type,
|
'action_type': action_type,
|
||||||
'input_parameters': input_parameters
|
'input_parameters': input_parameters
|
||||||
}
|
}
|
||||||
self._actions.append(action)
|
if action not in self._actions:
|
||||||
|
self._actions.append(action)
|
||||||
|
else:
|
||||||
|
LOG.warning('Action %s has been added into the solution, '
|
||||||
|
'duplicate action will be dropped.', str(action))
|
||||||
|
|
||||||
def __str__(self):
|
def __str__(self):
|
||||||
return "\n".join(self._actions)
|
return "\n".join(self._actions)
|
||||||
|
|||||||
@@ -339,8 +339,8 @@ class TestActionScheduling(base.DbTestCase):
|
|||||||
goal=mock.Mock(), strategy=self.strategy)
|
goal=mock.Mock(), strategy=self.strategy)
|
||||||
|
|
||||||
parameters = {
|
parameters = {
|
||||||
"source_node": "server1",
|
"source_node": "server0",
|
||||||
"destination_node": "server2",
|
"destination_node": "server1",
|
||||||
}
|
}
|
||||||
solution.add_action(action_type="migrate",
|
solution.add_action(action_type="migrate",
|
||||||
resource_id="DOESNOTMATTER",
|
resource_id="DOESNOTMATTER",
|
||||||
@@ -435,8 +435,8 @@ class TestActionScheduling(base.DbTestCase):
|
|||||||
goal=mock.Mock(), strategy=self.strategy)
|
goal=mock.Mock(), strategy=self.strategy)
|
||||||
|
|
||||||
parameters = {
|
parameters = {
|
||||||
"source_node": "server1",
|
"source_node": "server0",
|
||||||
"destination_node": "server2",
|
"destination_node": "server1",
|
||||||
}
|
}
|
||||||
solution.add_action(action_type="migrate",
|
solution.add_action(action_type="migrate",
|
||||||
resource_id="DOESNOTMATTER",
|
resource_id="DOESNOTMATTER",
|
||||||
@@ -534,8 +534,8 @@ class TestActionScheduling(base.DbTestCase):
|
|||||||
goal=mock.Mock(), strategy=self.strategy)
|
goal=mock.Mock(), strategy=self.strategy)
|
||||||
|
|
||||||
parameters = {
|
parameters = {
|
||||||
"source_node": "server1",
|
"source_node": "server0",
|
||||||
"destination_node": "server2",
|
"destination_node": "server1",
|
||||||
}
|
}
|
||||||
solution.add_action(action_type="migrate",
|
solution.add_action(action_type="migrate",
|
||||||
resource_id="DOESNOTMATTER",
|
resource_id="DOESNOTMATTER",
|
||||||
@@ -639,8 +639,8 @@ class TestActionScheduling(base.DbTestCase):
|
|||||||
goal=mock.Mock(), strategy=self.strategy)
|
goal=mock.Mock(), strategy=self.strategy)
|
||||||
|
|
||||||
parameters = {
|
parameters = {
|
||||||
"source_node": "server1",
|
"source_node": "server0",
|
||||||
"destination_node": "server2",
|
"destination_node": "server1",
|
||||||
}
|
}
|
||||||
solution.add_action(action_type="migrate",
|
solution.add_action(action_type="migrate",
|
||||||
resource_id="DOESNOTMATTER",
|
resource_id="DOESNOTMATTER",
|
||||||
|
|||||||
Reference in New Issue
Block a user