scaling_policy.go 2.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081
  1. // Copyright 2019 Yunion
  2. //
  3. // Licensed under the Apache License, Version 2.0 (the "License");
  4. // you may not use this file except in compliance with the License.
  5. // You may obtain a copy of the License at
  6. //
  7. // http://www.apache.org/licenses/LICENSE-2.0
  8. //
  9. // Unless required by applicable law or agreed to in writing, software
  10. // distributed under the License is distributed on an "AS IS" BASIS,
  11. // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
  12. // See the License for the specific language governing permissions and
  13. // limitations under the License.
  14. package compute
  15. import "yunion.io/x/onecloud/pkg/apis"
  16. type ScalingPolicyDetails struct {
  17. apis.VirtualResourceDetails
  18. ScalingGroupResourceInfo
  19. SScalingPolicy
  20. // 定时方式触发
  21. Timer TimerDetails `json:"timer"`
  22. // 周期方式触发
  23. CycleTimer CycleTimerDetails `json:"cycle_timer"`
  24. // 告警方式触发
  25. Alarm ScalingAlarmDetails `json:"alarm"`
  26. }
  27. type ScalingPolicyCreateInput struct {
  28. apis.VirtualResourceCreateInput
  29. apis.EnabledBaseResourceCreateInput
  30. // description: scaling_group ID or Name
  31. // example: sg-test-one
  32. ScalingGroup string `json:"scaling_group"`
  33. // swagger:ignore
  34. ScalingGroupId string `json:"scaling_group_id"`
  35. // description: trigger type
  36. // enum: ["timing","cycle","alarm"]
  37. TriggerType string `json:"trigger_type"`
  38. Timer TimerCreateInput `json:"timer"`
  39. CycleTimer CycleTimerCreateInput `json:"cycle_timer"`
  40. Alarm ScalingAlarmCreateInput `json:"alarm"`
  41. // desciption: 伸缩策略的行为(增加还是删除或者调整为)
  42. // enum: ["add","remove","set"]
  43. // example: add
  44. Action string `json:"action"`
  45. // desciption: 实例的数量
  46. // example: 2
  47. Number int `json:"number"`
  48. // desciption: 实例数量的单位
  49. // enum: ["s","%"]
  50. // example: s
  51. Unit string `json:"unit"`
  52. // desciption: Scaling activity triggered by alarms will be rejected during this period about CoolingTime
  53. // example: 300
  54. CoolingTime int `json:"cooling_time"`
  55. }
  56. type ScalingPolicyListInput struct {
  57. apis.VirtualResourceListInput
  58. apis.EnabledResourceBaseListInput
  59. // description: scaling group
  60. // example: sg-test
  61. ScalingGroupFilterListInput
  62. // description: trigger type
  63. // enum: ["timing","cycel","alarm"]
  64. // example: alarm
  65. TriggerType string `json:"trigger_type"`
  66. }