diff --git a/savanna/api/v10.py b/savanna/api/v10.py index ba6abf07..f91f578c 100644 --- a/savanna/api/v10.py +++ b/savanna/api/v10.py @@ -17,6 +17,7 @@ from savanna.openstack.common import log as logging from savanna.service import api from savanna.service import validation as v from savanna.service.validations import images as v_images +from savanna.service.validations import node_group_templates as v_ngt import savanna.utils.api as u LOG = logging.getLogger(__name__) @@ -97,6 +98,7 @@ def node_group_templates_list(): @rest.post('/node-group-templates') +@v.validate(v_ngt.node_group_template_schema) def node_group_templates_create(data): return u.render(api.create_node_group_template(data).wrapped_dict) diff --git a/savanna/service/validations/node_group_templates.py b/savanna/service/validations/node_group_templates.py index e3f3e8d4..228aded9 100644 --- a/savanna/service/validations/node_group_templates.py +++ b/savanna/service/validations/node_group_templates.py @@ -12,3 +12,65 @@ # implied. # See the License for the specific language governing permissions and # limitations under the License. + +node_group_template_schema = { + "type": "object", + "properties": { + "name": { + "type": "string", + }, + "tenant_id": { + "type": "string", + "format": "uuid", + }, + "flavor_id": { + "type": "string", + "format": "uuid", + }, + "plugin_name": { + "type": "string", + }, + "hadoop_version": { + "type": "string", + }, + "node_processes": { + "type": "array", + "items": { + "type": "string", + } + }, + "image_id": { + "type": "string", + "format": "uuid", + }, + "node_configs": { + "type": "configs", + }, + "anti-affinity-group": { + "type": "string", + }, + "volumes_per_node": { + "type": "integer", + "minimum": 0, + }, + "volumes_size": { + "type": "integer", + "minimum": 0, + }, + "volumes_mount_prefix": { + "type": "string", + }, + "description": { + "type": "string", + }, + }, + "additionalProperties": False, + "required": [ + "name", + "tenant_id", + "flavor_id", + "plugin_name", + "hadoop_version", + "node_processes", + ] +}