serverskus.go 4.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129
  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 (
  16. "yunion.io/x/jsonutils"
  17. baseoptions "yunion.io/x/onecloud/pkg/mcclient/options"
  18. )
  19. type ServerSkusListOptions struct {
  20. baseoptions.BaseListOptions
  21. Cloudregion string `help:"region Id or name"`
  22. Usable bool `help:"Filter usable sku"`
  23. Zone string `help:"zone Id or name"`
  24. City *string `help:"city name,eg. BeiJing"`
  25. Cpu *int `help:"Cpu core count" json:"cpu_core_count"`
  26. Mem *int `help:"Memory size in MB" json:"memory_size_mb"`
  27. Name string `help:"Name of Sku"`
  28. PostpaidStatus string `help:"Postpaid status" choices:"soldout|available"`
  29. PrepaidStatus string `help:"Prepaid status" choices:"soldout|available"`
  30. CpuArch string `help:"Cpu Arch" choices:"x86|arm"`
  31. Enabled *bool `help:"Filter enabled skus"`
  32. Distinct bool `help:"distinct sku by name"`
  33. OrderByTotalGuestCount string
  34. }
  35. func (opts *ServerSkusListOptions) GetId() string {
  36. return "instance-specs"
  37. }
  38. func (opts *ServerSkusListOptions) Params() (jsonutils.JSONObject, error) {
  39. return baseoptions.ListStructToParams(opts)
  40. }
  41. type ServerSkusIdOptions struct {
  42. ID string `help:"ID or Name of SKU to show"`
  43. }
  44. func (opts *ServerSkusIdOptions) GetId() string {
  45. return opts.ID
  46. }
  47. func (opts *ServerSkusIdOptions) Params() (jsonutils.JSONObject, error) {
  48. return nil, nil
  49. }
  50. type ServerSkusCreateOptions struct {
  51. Name string `help:"ServerSku name"`
  52. CpuCoreCount int `help:"Cpu Count" required:"true" positional:"true"`
  53. MemorySizeMB int `help:"Memory MB" required:"true" positional:"true"`
  54. CpuArch string `help:"CPU architecture" choices:"x86|aarch64"`
  55. OsName *string `help:"OS name/type" choices:"Linux|Windows|Any" default:"Any"`
  56. InstanceTypeCategory *string `help:"instance type category" choices:"general_purpose|compute_optimized|memory_optimized|storage_optimized|hardware_accelerated|high_memory|high_storage"`
  57. SysDiskResizable *bool `help:"system disk is resizable"`
  58. SysDiskType *string `help:"system disk type"`
  59. SysDiskMaxSizeGB *int `help:"system disk maximal size in gb"`
  60. AttachedDiskType *string `help:"attached data disk type"`
  61. AttachedDiskSizeGB *int `help:"attached data disk size in GB"`
  62. AttachedDiskCount *int `help:"attached data disk count"`
  63. DataDiskTypes string `help:"data disk type"`
  64. MaxDataDiskCount *int `help:"maximal allowed data disk count"`
  65. NicType *string `help:"nic type"`
  66. MaxNicCount *int `help:"maximal nic count"`
  67. GPUSpec *string `help:"GPU spec"`
  68. GPUCount *int `help:"GPU count"`
  69. GPUAttachable *bool `help:"Allow attach GPU"`
  70. ZoneId string `help:"Zone ID or name"`
  71. CloudregionId string `help:"Cloudregion ID or name"`
  72. Provider string `help:"provider"`
  73. Brand string `help:"brand"`
  74. }
  75. func (opts *ServerSkusCreateOptions) Params() (jsonutils.JSONObject, error) {
  76. return baseoptions.StructToParams(opts)
  77. }
  78. type ServerSkusUpdateOptions struct {
  79. ServerSkusIdOptions
  80. PostpaidStatus *string `help:"skus available status for postpaid instance" choices:"available|soldout"`
  81. PrepaidStatus *string `help:"skus available status for prepaid instance" choices:"available|soldout"`
  82. CpuCoreCount *int `help:"Cpu Count"`
  83. MemorySizeMB *int `help:"Memory MB"`
  84. InstanceTypeCategory *string `help:"instance type category" choices:"general_purpose|compute_optimized|memory_optimized|storage_optimized|hardware_accelerated|high_memory|high_storage"`
  85. SysDiskResizable *bool `help:"system disk is resizable"`
  86. SysDiskMaxSizeGB *int `help:"system disk maximal size in gb"`
  87. AttachedDiskType *string `help:"attached data disk type"`
  88. AttachedDiskSizeGB *int `help:"attached data disk size in GB"`
  89. AttachedDiskCount *int `help:"attached data disk count"`
  90. MaxDataDiskCount *int `help:"maximal allowed data disk count"`
  91. NicType *string `help:"nic type"`
  92. MaxNicCount *int `help:"maximal nic count"`
  93. GPUSpec *string `help:"GPU spec"`
  94. GPUCount *int `help:"GPU count"`
  95. GPUAttachable *bool `help:"Allow attach GPU"`
  96. Zone *string `help:"Zone ID or name"`
  97. Region *string `help:"Region ID or name"`
  98. }
  99. func (opts *ServerSkusUpdateOptions) Params() (jsonutils.JSONObject, error) {
  100. return baseoptions.StructToParams(opts)
  101. }