sku.go 1.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354
  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 ctyun
  15. type ServerSku struct {
  16. GpuVendor string `json:"gpuVendor"`
  17. CPUInfo string `json:"cpuInfo"`
  18. BaseBandwidth float64 `json:"baseBandwidth"`
  19. FlavorName string `json:"flavorName"`
  20. VideoMemSize int `json:"videoMemSize"`
  21. FlavorType string `json:"flavorType"`
  22. FlavorSeries string `json:"flavorSeries"`
  23. FlavorRAM int `json:"flavorRAM"`
  24. NicMultiQueue int `json:"nicMultiQueue"`
  25. Pps string `json:"pps"`
  26. FlavorCPU int `json:"flavorCPU"`
  27. Bandwidth int `json:"bandwidth"`
  28. GpuType string `json:"gpuType"`
  29. FlavorId string `json:"flavorID"`
  30. GpuCount int `json:"gpuCount"`
  31. }
  32. func (self *SRegion) GetServerSkus(zoneId string) ([]ServerSku, error) {
  33. params := map[string]interface{}{}
  34. if zoneId != "default" {
  35. params["azName"] = zoneId
  36. }
  37. resp, err := self.post(SERVICE_ECS, "/v4/ecs/flavor/list", params)
  38. if err != nil {
  39. return nil, err
  40. }
  41. ret := struct {
  42. ReturnObj struct {
  43. FlavorList []ServerSku
  44. }
  45. }{}
  46. err = resp.Unmarshal(&ret)
  47. if err != nil {
  48. return nil, err
  49. }
  50. return ret.ReturnObj.FlavorList, nil
  51. }