yunion.io/x/cloudmux@v0.3.10-0-alpha.1/pkg/multicloud/cloudpods/sku.go (about)

     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  
    15  package cloudpods
    16  
    17  import (
    18  	api "yunion.io/x/onecloud/pkg/apis/compute"
    19  	modules "yunion.io/x/onecloud/pkg/mcclient/modules/compute"
    20  
    21  	"yunion.io/x/cloudmux/pkg/cloudprovider"
    22  	"yunion.io/x/cloudmux/pkg/multicloud"
    23  )
    24  
    25  type SServerSku struct {
    26  	multicloud.SResourceBase
    27  	CloudpodsTags
    28  	region *SRegion
    29  
    30  	api.ServerSkuDetails
    31  }
    32  
    33  func (self *SServerSku) GetName() string {
    34  	return self.Name
    35  }
    36  
    37  func (self *SServerSku) GetId() string {
    38  	return self.Id
    39  }
    40  
    41  func (self *SServerSku) GetGlobalId() string {
    42  	return self.Id
    43  }
    44  
    45  func (self *SServerSku) GetStatus() string {
    46  	return self.Status
    47  }
    48  
    49  func (self *SServerSku) GetInstanceTypeFamily() string {
    50  	return self.InstanceTypeFamily
    51  }
    52  
    53  func (self *SServerSku) GetInstanceTypeCategory() string {
    54  	return self.InstanceTypeCategory
    55  }
    56  
    57  func (self *SServerSku) GetPrepaidStatus() string {
    58  	return self.PrepaidStatus
    59  }
    60  
    61  func (self *SServerSku) GetPostpaidStatus() string {
    62  	return self.PostpaidStatus
    63  }
    64  
    65  func (self *SServerSku) GetCpuArch() string {
    66  	return "x86"
    67  }
    68  
    69  func (self *SServerSku) GetCpuCoreCount() int {
    70  	return self.CpuCoreCount
    71  }
    72  
    73  func (self *SServerSku) GetMemorySizeMB() int {
    74  	return self.MemorySizeMB
    75  }
    76  
    77  func (self *SServerSku) GetOsName() string {
    78  	return self.OsName
    79  }
    80  
    81  func (self *SServerSku) GetSysDiskResizable() bool {
    82  	return self.SysDiskResizable != nil && *self.SysDiskResizable
    83  }
    84  
    85  func (self *SServerSku) GetSysDiskType() string {
    86  	return self.SysDiskType
    87  }
    88  
    89  func (self *SServerSku) GetSysDiskMinSizeGB() int {
    90  	return self.SysDiskMinSizeGB
    91  }
    92  
    93  func (self *SServerSku) GetSysDiskMaxSizeGB() int {
    94  	return self.SysDiskMaxSizeGB
    95  }
    96  
    97  func (self *SServerSku) GetAttachedDiskType() string {
    98  	return self.AttachedDiskType
    99  }
   100  
   101  func (self *SServerSku) GetAttachedDiskSizeGB() int {
   102  	return self.AttachedDiskSizeGB
   103  }
   104  
   105  func (self *SServerSku) GetAttachedDiskCount() int {
   106  	return self.AttachedDiskCount
   107  }
   108  
   109  func (self *SServerSku) GetDataDiskTypes() string {
   110  	return self.DataDiskTypes
   111  }
   112  
   113  func (self *SServerSku) GetDataDiskMaxCount() int {
   114  	return self.DataDiskMaxCount
   115  }
   116  
   117  func (self *SServerSku) GetNicType() string {
   118  	return self.NicType
   119  }
   120  
   121  func (self *SServerSku) GetNicMaxCount() int {
   122  	return self.NicMaxCount
   123  }
   124  
   125  func (self *SServerSku) GetGpuAttachable() bool {
   126  	return self.GpuAttachable != nil && *self.GpuAttachable
   127  }
   128  
   129  func (self *SServerSku) GetGpuSpec() string {
   130  	return self.GpuSpec
   131  }
   132  
   133  func (self *SServerSku) GetGpuCount() int {
   134  	return self.GpuCount
   135  }
   136  
   137  func (self *SServerSku) GetGpuMaxCount() int {
   138  	return self.GpuMaxCount
   139  }
   140  
   141  func (self *SServerSku) Delete() error {
   142  	return self.region.cli.delete(&modules.ServerSkus, self.Id)
   143  }
   144  
   145  func (self *SRegion) GetISkus() ([]cloudprovider.ICloudSku, error) {
   146  	skus, err := self.GetServerSkus()
   147  	if err != nil {
   148  		return nil, err
   149  	}
   150  	ret := []cloudprovider.ICloudSku{}
   151  	for i := range skus {
   152  		skus[i].region = self
   153  		ret = append(ret, &skus[i])
   154  	}
   155  	return ret, nil
   156  }
   157  
   158  func (self *SRegion) GetServerSkus() ([]SServerSku, error) {
   159  	skus := []SServerSku{}
   160  	return skus, self.list(&modules.ServerSkus, nil, &skus)
   161  }