oos_model.py 2.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107
  1. # Copyright (c) 2014 Baidu.com, Inc. All Rights Reserved
  2. #
  3. # Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file
  4. # except in compliance with the License. You may obtain a copy of the License at
  5. #
  6. # http://www.apache.org/licenses/LICENSE-2.0
  7. #
  8. # Unless required by applicable law or agreed to in writing, software distributed under the
  9. # License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND,
  10. # either express or implied. See the License for the specific language governing permissions
  11. # and limitations under the License.
  12. """
  13. This module provides a model class for OOS.
  14. """
  15. class OperatorModel(dict):
  16. """
  17. This class define operator.
  18. """
  19. def __init__(self, name, operator, properties, retries=0, retry_interval=60000, timeout=3600000, description=""):
  20. """
  21. :param name:
  22. Operator name.
  23. :type name: string
  24. :param operator:
  25. Operator type.
  26. :type operator: string
  27. :param properties:
  28. Operator execute parameters.
  29. :type properties: dict
  30. :param retries:
  31. Operator retry count.
  32. :type retries: int
  33. :param retry_interval:
  34. Operator retry interval.
  35. :type retries: int
  36. :param timeout:
  37. Operator execute timeout.
  38. :type timeout: int
  39. :param description:
  40. Operator description.
  41. :type description: string
  42. """
  43. super(OperatorModel, self).__init__()
  44. self["name"] = name
  45. self["operator"] = operator
  46. self["properties"] = properties
  47. self["retries"] = retries
  48. self["retryInterval"] = retry_interval
  49. self["timeout"] = timeout
  50. self["description"] = description
  51. class TemplateModel(dict):
  52. """
  53. This class define template.
  54. """
  55. def __init__(self, name, operators=[], linear=True, ref=""):
  56. """
  57. :param name:
  58. Template name.
  59. :type name: string
  60. :param operators:
  61. Include template operators to execute.
  62. :type operators: OperatorModel array
  63. :param linear:
  64. Operator execute linearly.
  65. :type linear: bool
  66. :param ref:
  67. template id.
  68. :type ref: string
  69. """
  70. super(TemplateModel, self).__init__()
  71. self["name"] = name
  72. self["ref"] = ref
  73. self["operators"] = operators
  74. self["linear"] = linear
  75. class TagModel(dict):
  76. """
  77. This class define tag.
  78. """
  79. def __init__(self, key, value):
  80. """
  81. :param key:
  82. Tag key.
  83. :type key: string
  84. :param value:
  85. Tag value.
  86. :type value: string
  87. """
  88. super(TagModel, self).__init__()
  89. self["tagKey"] = key
  90. self["tagValue"] = value