[core] Refactor validation

* do not save validation errors from CLI layer to database. It includes
  such redundant data as IOError (when task file doesn't exist)
* include validation at task start by default. It is bad sign to allow
  starting tasks without validation.

Change-Id: I0d30ff31fb6fbc467ef3cda01e7de1f46c5f79fe
This commit is contained in:
Andrey Kurilin
2017-04-05 23:08:05 +03:00
parent 2b36cc1e8b
commit 6fb4655ca0

View File

@@ -13,6 +13,7 @@
# License for the specific language governing permissions and limitations # License for the specific language governing permissions and limitations
# under the License. # under the License.
import itertools
import multiprocessing import multiprocessing
import random import random
import re import re
@@ -1840,7 +1841,6 @@ class FakeUserContext(FakeContext):
class FakeDeployment(dict): class FakeDeployment(dict):
update_status = mock.Mock()
def __init__(self, **kwargs): def __init__(self, **kwargs):
namespace = kwargs.pop("namespace", "openstack") namespace = kwargs.pop("namespace", "openstack")
@@ -1849,6 +1849,7 @@ class FakeDeployment(dict):
"users": kwargs.pop("users", [])}], "users": kwargs.pop("users", [])}],
"default": [{"admin": None, "users": []}]} "default": [{"admin": None, "users": []}]}
dict.__init__(self, **kwargs) dict.__init__(self, **kwargs)
self.update_status = mock.Mock()
def get_platforms(self): def get_platforms(self):
return [platform for platform in self["credentials"]] return [platform for platform in self["credentials"]]
@@ -1857,18 +1858,16 @@ class FakeDeployment(dict):
return self["credentials"][namespace][0] return self["credentials"][namespace][0]
class FakeTask(dict): class FakeTask(dict, object):
def __init__(self, task=None, temporary=False, **kwargs): def __init__(self, task=None, temporary=False, **kwargs):
self.is_temporary = temporary self.is_temporary = temporary
self.task = task or kwargs
self.set_failed = mock.Mock() self.set_failed = mock.Mock()
self.set_validation_failed = mock.Mock() self.set_validation_failed = mock.Mock()
task = task or {}
def __getitem__(self, key): for k, v in itertools.chain(task.items(), kwargs.items()):
if key in self: self[k] = v
return self[key] self.task = self
return self.task[key]
def to_dict(self): def to_dict(self):
return self return self