yunion.io/x/cloudmux@v0.3.10-0-alpha.1/pkg/multicloud/hcs/nat_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 hcs
    16  
    17  import (
    18  	api "yunion.io/x/cloudmux/pkg/apis/compute"
    19  	"yunion.io/x/cloudmux/pkg/cloudprovider"
    20  )
    21  
    22  const (
    23  	HUAWEI_NAT_SKU_SMALL  = "Small"
    24  	HUAWEI_NAT_SKU_MIDDLE = "Middle"
    25  	HUAWEI_NAT_SKU_LARGE  = "Large"
    26  	HUAWEI_NAT_SKU_XLARGE = "XLarge"
    27  )
    28  
    29  type SNatSku struct {
    30  	spec string
    31  }
    32  
    33  func (self *SNatSku) GetName() string {
    34  	return self.spec
    35  }
    36  
    37  func (self *SNatSku) GetPps() int {
    38  	return 1000000
    39  }
    40  
    41  func (self *SNatSku) GetConns() int {
    42  	switch self.spec {
    43  	case HUAWEI_NAT_SKU_SMALL:
    44  		return 10000
    45  	case HUAWEI_NAT_SKU_MIDDLE:
    46  		return 50000
    47  	case HUAWEI_NAT_SKU_LARGE:
    48  		return 200000
    49  	case HUAWEI_NAT_SKU_XLARGE:
    50  		return 1000000
    51  	}
    52  	return 0
    53  }
    54  
    55  func (self *SNatSku) GetThroughput() int {
    56  	return 10
    57  }
    58  
    59  func (self *SNatSku) GetDesc() string {
    60  	switch self.spec {
    61  	case HUAWEI_NAT_SKU_SMALL:
    62  		return "小型"
    63  	case HUAWEI_NAT_SKU_MIDDLE:
    64  		return "中型"
    65  	case HUAWEI_NAT_SKU_LARGE:
    66  		return "大型"
    67  	case HUAWEI_NAT_SKU_XLARGE:
    68  		return "超大型"
    69  	}
    70  	return ""
    71  }
    72  
    73  func (self *SNatSku) GetPostpaidStatus() string {
    74  	return api.NAT_SKU_AVAILABLE
    75  }
    76  
    77  func (self *SNatSku) GetPrepaidStatus() string {
    78  	return api.NAT_SKU_SOLDOUT
    79  }
    80  
    81  func (self *SNatSku) GetGlobalId() string {
    82  	return self.spec
    83  }
    84  
    85  func (self *SRegion) GetICloudNatSkus() ([]cloudprovider.ICloudNatSku, error) {
    86  	ret := []cloudprovider.ICloudNatSku{}
    87  	for _, spec := range []string{
    88  		HUAWEI_NAT_SKU_SMALL,
    89  		HUAWEI_NAT_SKU_MIDDLE,
    90  		HUAWEI_NAT_SKU_LARGE,
    91  		HUAWEI_NAT_SKU_XLARGE,
    92  	} {
    93  		sku := &SNatSku{spec: spec}
    94  		ret = append(ret, sku)
    95  	}
    96  	return ret, nil
    97  }