Fuel UI
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

cluster.py 2.5KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677
  1. # -*- coding: utf-8 -*-
  2. # Copyright 2014 Mirantis, Inc.
  3. #
  4. # Licensed under the Apache License, Version 2.0 (the "License"); you may
  5. # not use this file except in compliance with the License. You may obtain
  6. # a copy of the License at
  7. #
  8. # http://www.apache.org/licenses/LICENSE-2.0
  9. #
  10. # Unless required by applicable law or agreed to in writing, software
  11. # distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
  12. # WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
  13. # License for the specific language governing permissions and limitations
  14. # under the License.
  15. from nailgun import consts
  16. from nailgun.api.v1.validators.json_schema import base_types
  17. COMPONENTS_TYPES_STR = '|'.join(
  18. ['hypervisor', 'network', 'storage', 'additional_service'])
  19. COMPONENT_NAME_PATTERN = \
  20. '^({0}):([0-9a-z_-]+:)*[0-9a-z_-]+$'.format(COMPONENTS_TYPES_STR)
  21. # TODO(@ikalnitsky): add `required` properties to all needed objects
  22. single_schema = {
  23. "$schema": "http://json-schema.org/draft-04/schema#",
  24. "title": "Cluster",
  25. "description": "Serialized Cluster object",
  26. "type": "object",
  27. "properties": {
  28. "id": {"type": "number"},
  29. "name": {"type": "string"},
  30. "mode": {
  31. "type": "string",
  32. "enum": list(consts.CLUSTER_MODES)
  33. },
  34. "status": {
  35. "type": "string",
  36. "enum": list(consts.CLUSTER_STATUSES)
  37. },
  38. "ui_settings": base_types.UI_SETTINGS,
  39. "release": {"type": "integer"},
  40. "release_id": {"type": "integer"},
  41. "replaced_deployment_info": {"type": "object"},
  42. "replaced_provisioning_info": {"type": "object"},
  43. "is_customized": {"type": "boolean"},
  44. "fuel_version": {"type": "string"},
  45. "components": {
  46. 'type': 'array',
  47. 'items': [{
  48. 'type': 'string',
  49. 'pattern': COMPONENT_NAME_PATTERN}]
  50. }
  51. }
  52. }
  53. collection_schema = {
  54. "$schema": "http://json-schema.org/draft-04/schema#",
  55. "title": "Cluster collection",
  56. "description": "Serialized Cluster collection",
  57. "type": "object",
  58. "items": single_schema["properties"]
  59. }
  60. vmware_attributes_schema = {
  61. "$schema": "http://json-schema.org/draft-04/schema#",
  62. "title": "Vmware attributes",
  63. "description": "Serialized VmwareAttributes object",
  64. "type": "object",
  65. "required": ["editable"],
  66. "properties": {
  67. "editable": {"type": "object"}
  68. }
  69. }