+# PDUs
+pdu_interface = {
+ "type": "object",
+ "properties": {
+ "name": shortname_schema,
+ "mgmt": bool_schema,
+ "type": {"enum": ["overlay", 'underlay']},
+ "ip-address": ip_schema,
+ # TODO, add user, password, ssh-key
+ "mac-address": mac_schema,
+ "vim-network-name": shortname_schema, # interface is connected to one vim network, or switch port
+ "vim-network-id": shortname_schema,
+ # # provide this in case SDN assist must deal with this interface
+ # "switch-dpid": dpid_Schema,
+ # "switch-port": shortname_schema,
+ # "switch-mac": shortname_schema,
+ # "switch-vlan": vlan_schema,
+ },
+ "required": ["name", "mgmt", "ip-address"],
+ "additionalProperties": False
+}
+pdu_new_schema = {
+ "title": "pdu creation input schema",
+ "$schema": "http://json-schema.org/draft-04/schema#",
+ "type": "object",
+ "properties": {
+ "name": shortname_schema,
+ "type": shortname_schema,
+ "description": description_schema,
+ "shared": bool_schema,
+ "vims": nameshort_list_schema,
+ "vim_accounts": nameshort_list_schema,
+ "interfaces": {
+ "type": "array",
+ "items": pdu_interface,
+ "minItems": 1
+ }
+ },
+ "required": ["name", "type", "interfaces"],
+ "additionalProperties": False
+}
+
+pdu_edit_schema = {
+ "title": "pdu edit input schema",
+ "$schema": "http://json-schema.org/draft-04/schema#",
+ "type": "object",
+ "properties": {
+ "name": shortname_schema,
+ "type": shortname_schema,
+ "description": description_schema,
+ "shared": bool_schema,
+ "vims": {"oneOf": [array_edition_schema, nameshort_list_schema]},
+ "vim_accounts": {"oneOf": [array_edition_schema, nameshort_list_schema]},
+ "interfaces": {"oneOf": [
+ array_edition_schema,
+ {
+ "type": "array",
+ "items": pdu_interface,
+ "minItems": 1
+ }
+ ]}
+ },
+ "additionalProperties": False,
+ "minProperties": 1
+}
+
+# USERS
+project_role_mapping = {
+ "title": "",
+ "$schema": "http://json-schema.org/draft-04/schema#",
+ "type": "object",
+ "properties": {
+ "project": shortname_schema,
+ "role": shortname_schema
+ },
+ "required": ["project", "role"],
+ "additionalProperties": False
+}
+user_new_schema = {
+ "$schema": "http://json-schema.org/draft-04/schema#",
+ "title": "New user schema",
+ "type": "object",
+ "properties": {
+ "username": shortname_schema,
+ "password": passwd_schema,
+ "projects": nameshort_list_schema,
+ "project_role_mappings": {
+ "type": "array",
+ "items": project_role_mapping,
+ "minItems": 1
+ },
+ },
+ "required": ["username", "password"],
+ "additionalProperties": False
+}
+user_edit_schema = {
+ "$schema": "http://json-schema.org/draft-04/schema#",
+ "title": "User edit schema for administrators",
+ "type": "object",
+ "properties": {
+ "password": passwd_schema,
+ "username": shortname_schema, # To allow User Name modification
+ "projects": {
+ "oneOf": [
+ nameshort_list_schema,
+ array_edition_schema
+ ]
+ },
+ "project_role_mappings": {
+ "type": "array",
+ "items": project_role_mapping,
+ "minItems": 1
+ },
+ },
+ "minProperties": 1,
+ "additionalProperties": False
+}
+
+# PROJECTS
+project_new_schema = {
+ "$schema": "http://json-schema.org/draft-04/schema#",
+ "title": "New project schema for administrators",
+ "type": "object",
+ "properties": {
+ "name": shortname_schema,
+ "admin": bool_schema,
+ },
+ "required": ["name"],
+ "additionalProperties": False
+}
+project_edit_schema = {
+ "$schema": "http://json-schema.org/draft-04/schema#",
+ "title": "Project edit schema for administrators",
+ "type": "object",
+ "properties": {
+ "admin": bool_schema,
+ "name": shortname_schema, # To allow Project Name modification
+ },
+ "additionalProperties": False,
+ "minProperties": 1
+}
+
+# ROLES
+roles_new_schema = {
+ "$schema": "http://json-schema.org/draft-04/schema#",
+ "title": "New role schema for administrators",
+ "type": "object",
+ "properties": {
+ "name": shortname_schema,
+ },
+ "required": ["name"],
+ "additionalProperties": True
+}
+roles_edit_schema = {
+ "$schema": "http://json-schema.org/draft-04/schema#",
+ "title": "Roles edit schema for administrators",
+ "type": "object",
+ "properties": {
+ "_id": id_schema,
+ "name": shortname_schema,
+ },
+ "required": ["_id", "name"],
+ "additionalProperties": True,
+ "minProperties": 1
+}
+
+# GLOBAL SCHEMAS