Replace voluptuous with JSONSchema in BaseAction
Now that we replaced voluptuous with JSONSchema in all actions, this patch replaces voluptuous with JSONSchema in BaseAction and removes validate_parameters method in each action. Partially Implements: blueprint jsonschema-validation Change-Id: I07c907ddfa4a568d7fff42776df02218330d56a0
This commit is contained in:
@@ -18,6 +18,7 @@
|
|||||||
|
|
||||||
import abc
|
import abc
|
||||||
|
|
||||||
|
import jsonschema
|
||||||
import six
|
import six
|
||||||
|
|
||||||
from watcher.common import clients
|
from watcher.common import clients
|
||||||
@@ -130,8 +131,11 @@ class BaseAction(loadable.Loadable):
|
|||||||
raise NotImplementedError()
|
raise NotImplementedError()
|
||||||
|
|
||||||
def validate_parameters(self):
|
def validate_parameters(self):
|
||||||
self.schema(self.input_parameters)
|
try:
|
||||||
|
jsonschema.validate(self.input_parameters, self.schema)
|
||||||
return True
|
return True
|
||||||
|
except jsonschema.ValidationError as e:
|
||||||
|
raise e
|
||||||
|
|
||||||
@abc.abstractmethod
|
@abc.abstractmethod
|
||||||
def get_description(self):
|
def get_description(self):
|
||||||
|
|||||||
@@ -18,7 +18,6 @@
|
|||||||
#
|
#
|
||||||
|
|
||||||
import enum
|
import enum
|
||||||
import jsonschema
|
|
||||||
|
|
||||||
from watcher._i18n import _
|
from watcher._i18n import _
|
||||||
from watcher.applier.actions import base
|
from watcher.applier.actions import base
|
||||||
@@ -69,13 +68,6 @@ class ChangeNodePowerState(base.BaseAction):
|
|||||||
'additionalProperties': False,
|
'additionalProperties': False,
|
||||||
}
|
}
|
||||||
|
|
||||||
def validate_parameters(self):
|
|
||||||
try:
|
|
||||||
jsonschema.validate(self.input_parameters, self.schema)
|
|
||||||
return True
|
|
||||||
except jsonschema.ValidationError as e:
|
|
||||||
raise e
|
|
||||||
|
|
||||||
@property
|
@property
|
||||||
def node_uuid(self):
|
def node_uuid(self):
|
||||||
return self.resource_id
|
return self.resource_id
|
||||||
|
|||||||
@@ -17,8 +17,6 @@
|
|||||||
# limitations under the License.
|
# limitations under the License.
|
||||||
#
|
#
|
||||||
|
|
||||||
import jsonschema
|
|
||||||
|
|
||||||
from watcher._i18n import _
|
from watcher._i18n import _
|
||||||
from watcher.applier.actions import base
|
from watcher.applier.actions import base
|
||||||
from watcher.common import exception
|
from watcher.common import exception
|
||||||
@@ -69,13 +67,6 @@ class ChangeNovaServiceState(base.BaseAction):
|
|||||||
'additionalProperties': False,
|
'additionalProperties': False,
|
||||||
}
|
}
|
||||||
|
|
||||||
def validate_parameters(self):
|
|
||||||
try:
|
|
||||||
jsonschema.validate(self.input_parameters, self.schema)
|
|
||||||
return True
|
|
||||||
except jsonschema.ValidationError as e:
|
|
||||||
raise e
|
|
||||||
|
|
||||||
@property
|
@property
|
||||||
def host(self):
|
def host(self):
|
||||||
return self.resource_id
|
return self.resource_id
|
||||||
|
|||||||
@@ -18,7 +18,6 @@
|
|||||||
#
|
#
|
||||||
|
|
||||||
|
|
||||||
import jsonschema
|
|
||||||
from oslo_log import log
|
from oslo_log import log
|
||||||
from watcher._i18n import _
|
from watcher._i18n import _
|
||||||
from watcher.applier.actions import base
|
from watcher.applier.actions import base
|
||||||
@@ -91,13 +90,6 @@ class Migrate(base.BaseAction):
|
|||||||
'additionalProperties': False,
|
'additionalProperties': False,
|
||||||
}
|
}
|
||||||
|
|
||||||
def validate_parameters(self):
|
|
||||||
try:
|
|
||||||
jsonschema.validate(self.input_parameters, self.schema)
|
|
||||||
return True
|
|
||||||
except jsonschema.ValidationError as e:
|
|
||||||
raise e
|
|
||||||
|
|
||||||
@property
|
@property
|
||||||
def instance_uuid(self):
|
def instance_uuid(self):
|
||||||
return self.resource_id
|
return self.resource_id
|
||||||
|
|||||||
@@ -17,7 +17,6 @@
|
|||||||
# limitations under the License.
|
# limitations under the License.
|
||||||
#
|
#
|
||||||
|
|
||||||
import jsonschema
|
|
||||||
from oslo_log import log
|
from oslo_log import log
|
||||||
|
|
||||||
from watcher.applier.actions import base
|
from watcher.applier.actions import base
|
||||||
@@ -52,13 +51,6 @@ class Nop(base.BaseAction):
|
|||||||
'additionalProperties': False,
|
'additionalProperties': False,
|
||||||
}
|
}
|
||||||
|
|
||||||
def validate_parameters(self):
|
|
||||||
try:
|
|
||||||
jsonschema.validate(self.input_parameters, self.schema)
|
|
||||||
return True
|
|
||||||
except jsonschema.ValidationError as e:
|
|
||||||
raise e
|
|
||||||
|
|
||||||
@property
|
@property
|
||||||
def message(self):
|
def message(self):
|
||||||
return self.input_parameters.get(self.MESSAGE)
|
return self.input_parameters.get(self.MESSAGE)
|
||||||
|
|||||||
@@ -17,7 +17,6 @@
|
|||||||
# limitations under the License.
|
# limitations under the License.
|
||||||
#
|
#
|
||||||
|
|
||||||
import jsonschema
|
|
||||||
from oslo_log import log
|
from oslo_log import log
|
||||||
|
|
||||||
from watcher.applier.actions import base
|
from watcher.applier.actions import base
|
||||||
@@ -67,13 +66,6 @@ class Resize(base.BaseAction):
|
|||||||
'additionalProperties': False,
|
'additionalProperties': False,
|
||||||
}
|
}
|
||||||
|
|
||||||
def validate_parameters(self):
|
|
||||||
try:
|
|
||||||
jsonschema.validate(self.input_parameters, self.schema)
|
|
||||||
return True
|
|
||||||
except jsonschema.ValidationError as e:
|
|
||||||
raise e
|
|
||||||
|
|
||||||
@property
|
@property
|
||||||
def instance_uuid(self):
|
def instance_uuid(self):
|
||||||
return self.resource_id
|
return self.resource_id
|
||||||
|
|||||||
@@ -17,7 +17,6 @@
|
|||||||
# limitations under the License.
|
# limitations under the License.
|
||||||
#
|
#
|
||||||
|
|
||||||
import jsonschema
|
|
||||||
import time
|
import time
|
||||||
|
|
||||||
from oslo_log import log
|
from oslo_log import log
|
||||||
@@ -54,13 +53,6 @@ class Sleep(base.BaseAction):
|
|||||||
'additionalProperties': False,
|
'additionalProperties': False,
|
||||||
}
|
}
|
||||||
|
|
||||||
def validate_parameters(self):
|
|
||||||
try:
|
|
||||||
jsonschema.validate(self.input_parameters, self.schema)
|
|
||||||
return True
|
|
||||||
except jsonschema.ValidationError as e:
|
|
||||||
raise e
|
|
||||||
|
|
||||||
@property
|
@property
|
||||||
def duration(self):
|
def duration(self):
|
||||||
return int(self.input_parameters.get(self.DURATION))
|
return int(self.input_parameters.get(self.DURATION))
|
||||||
|
|||||||
Reference in New Issue
Block a user