ca_model.py 3.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129
  1. """
  2. This module provides a model class for CA.
  3. """
  4. class Instance(dict):
  5. """
  6. This class defines the Tag object.
  7. """
  8. def __init__(self, instance_id):
  9. """
  10. :param instance_id: Instance Id
  11. :type instance_id: str
  12. """
  13. super(Instance, self).__init__()
  14. self["instanceId"] = instance_id
  15. class Command(dict):
  16. """
  17. This class defines the Command object.
  18. """
  19. def __init__(self, type, content, scope, enable_parameter, parameters, user, work_dir):
  20. """
  21. :param type: Command type
  22. :type type: str
  23. :param content: Command content
  24. :type content: str
  25. :param scope: Command scope
  26. :type scope: str
  27. :param enable_parameter: Enable parameter flag
  28. :type enable_parameter: bool
  29. :param user: User
  30. :type user: str
  31. :param work_dir: Working directory
  32. :type work_dir: str
  33. """
  34. super(Command, self).__init__()
  35. self["type"] = type
  36. self["content"] = content
  37. self["scope"] = scope
  38. self["enableParameter"] = enable_parameter
  39. self["parameters"] = parameters
  40. self["user"] = user
  41. self["workDir"] = work_dir
  42. class Action(dict):
  43. """
  44. This class defines the Action object.
  45. """
  46. def __init__(self, ref=None, id=None, type=None, name=None, timeout_second=None, command=None):
  47. """
  48. :param ref: Action ref
  49. :ref type: str
  50. :param ref: Action id
  51. :id type: str
  52. :param type: Action type
  53. :type type: str
  54. :param name: Action name
  55. :type name: str
  56. :param timeout_second: Timeout in seconds
  57. :type timeout_second: int
  58. :param command: Command object
  59. :type command: Command
  60. """
  61. super(Action, self).__init__()
  62. self["ref"] = ref
  63. self["id"] = id
  64. self["type"] = type
  65. self["name"] = name
  66. self["timeoutSecond"] = timeout_second
  67. self["command"] = command
  68. class Target(dict):
  69. """
  70. This class defines the Target object.
  71. """
  72. def __init__(self, instance_type, instance_id):
  73. """
  74. :param instance_type: Instance type
  75. :type instance_type: str
  76. :param instance_id: Instance Id
  77. :type instance_id: str
  78. """
  79. super(Target, self).__init__()
  80. self["instanceType"] = instance_type
  81. self["instanceId"] = instance_id
  82. class TargetSelector(dict):
  83. """
  84. This class defines the Target object.
  85. """
  86. def __init__(self, instance_type, tags):
  87. """
  88. :param instance_type: Instance type
  89. :type instance_type: str
  90. :param tags: tags
  91. :type tags: list
  92. """
  93. super(TargetSelector, self).__init__()
  94. self["instanceType"] = instance_type
  95. self["tags"] = tags
  96. class Execution(dict):
  97. """
  98. This class defines the Execution object.
  99. """
  100. def __init__(self, execution, action, targets):
  101. """
  102. :param execution: Execution type
  103. :type execution: str
  104. :param action: Action object
  105. :type action: Action
  106. :param targets: List of Target objects
  107. :type targets: list
  108. """
  109. super(Execution, self).__init__()
  110. self["execution"] = execution
  111. self["action"] = action
  112. self["targets"] = targets