yunion.io/x/cloudmux@v0.3.10-0-alpha.1/pkg/apis/compute/cloudaccount_const.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 compute
    16  
    17  import (
    18  	"yunion.io/x/onecloud/pkg/util/choices"
    19  
    20  	"yunion.io/x/cloudmux/pkg/apis"
    21  	"yunion.io/x/cloudmux/pkg/cloudprovider"
    22  )
    23  
    24  const (
    25  	CLOUD_PROVIDER_INIT          = "init"
    26  	CLOUD_PROVIDER_CONNECTED     = "connected"
    27  	CLOUD_PROVIDER_DISCONNECTED  = "disconnected"
    28  	CLOUD_PROVIDER_START_DELETE  = "start_delete"
    29  	CLOUD_PROVIDER_DELETING      = "deleting"
    30  	CLOUD_PROVIDER_DELETED       = "deleted"
    31  	CLOUD_PROVIDER_DELETE_FAILED = "delete_failed"
    32  	CLOUD_PROVIDER_SYNC_NETWORK  = "sync_network"
    33  
    34  	CLOUD_PROVIDER_SYNC_STATUS_QUEUING = "queuing"
    35  	CLOUD_PROVIDER_SYNC_STATUS_QUEUED  = "queued"
    36  	CLOUD_PROVIDER_SYNC_STATUS_SYNCING = "syncing"
    37  	CLOUD_PROVIDER_SYNC_STATUS_IDLE    = "idle"
    38  	CLOUD_PROVIDER_SYNC_STATUS_ERROR   = "error"
    39  
    40  	CLOUD_PROVIDER_ONECLOUD       = "OneCloud"
    41  	CLOUD_PROVIDER_VMWARE         = "VMware"
    42  	CLOUD_PROVIDER_NUTANIX        = "Nutanix"
    43  	CLOUD_PROVIDER_ALIYUN         = "Aliyun"
    44  	CLOUD_PROVIDER_APSARA         = "Apsara"
    45  	CLOUD_PROVIDER_QCLOUD         = "Qcloud"
    46  	CLOUD_PROVIDER_AZURE          = "Azure"
    47  	CLOUD_PROVIDER_AWS            = "Aws"
    48  	CLOUD_PROVIDER_HUAWEI         = "Huawei"
    49  	CLOUD_PROVIDER_HCSO           = "HCSO"
    50  	CLOUD_PROVIDER_HCS            = "HCS"
    51  	CLOUD_PROVIDER_OPENSTACK      = "OpenStack"
    52  	CLOUD_PROVIDER_UCLOUD         = "Ucloud"
    53  	CLOUD_PROVIDER_ZSTACK         = "ZStack"
    54  	CLOUD_PROVIDER_GOOGLE         = "Google"
    55  	CLOUD_PROVIDER_CTYUN          = "Ctyun"
    56  	CLOUD_PROVIDER_ECLOUD         = "Ecloud"
    57  	CLOUD_PROVIDER_JDCLOUD        = "JDcloud"
    58  	CLOUD_PROVIDER_CLOUDPODS      = "Cloudpods"
    59  	CLOUD_PROVIDER_BINGO_CLOUD    = "BingoCloud"
    60  	CLOUD_PROVIDER_INCLOUD_SPHERE = "InCloudSphere"
    61  	CLOUD_PROVIDER_PROXMOX        = "Proxmox"
    62  	CLOUD_PROVIDER_REMOTEFILE     = "RemoteFile"
    63  
    64  	CLOUD_PROVIDER_GENERICS3 = "S3"
    65  	CLOUD_PROVIDER_CEPH      = "Ceph"
    66  	CLOUD_PROVIDER_XSKY      = "Xsky"
    67  
    68  	CLOUD_PROVIDER_HEALTH_NORMAL        = "normal"        // 远端处于健康状态
    69  	CLOUD_PROVIDER_HEALTH_INSUFFICIENT  = "insufficient"  // 不足按需资源余额
    70  	CLOUD_PROVIDER_HEALTH_SUSPENDED     = "suspended"     // 远端处于冻结状态
    71  	CLOUD_PROVIDER_HEALTH_ARREARS       = "arrears"       // 远端处于欠费状态
    72  	CLOUD_PROVIDER_HEALTH_UNKNOWN       = "unknown"       // 未知状态,查询失败
    73  	CLOUD_PROVIDER_HEALTH_NO_PERMISSION = "no permission" // 没有权限获取账单信息
    74  
    75  	ZSTACK_BRAND_DSTACK     = "DStack"
    76  	ONECLOUD_BRAND_ONECLOUD = "OneCloud"
    77  
    78  	CLOUD_ACCOUNT_WIRE_LEVEL_VCENTER    = "vcenter"
    79  	CLOUD_ACCOUNT_WIRE_LEVEL_DATACENTER = "datacenter"
    80  	CLOUD_ACCOUNT_WIRE_LEVEL_CLUSTER    = "cluster"
    81  )
    82  
    83  var CLOUD_ACCOUNT_WIRE_LEVELS = choices.NewChoices(
    84  	CLOUD_ACCOUNT_WIRE_LEVEL_VCENTER,
    85  	CLOUD_ACCOUNT_WIRE_LEVEL_DATACENTER,
    86  	CLOUD_ACCOUNT_WIRE_LEVEL_CLUSTER,
    87  )
    88  
    89  const (
    90  	CLOUD_ACCESS_ENV_AWS_GLOBAL          = CLOUD_PROVIDER_AWS + "-int"
    91  	CLOUD_ACCESS_ENV_AWS_CHINA           = CLOUD_PROVIDER_AWS
    92  	CLOUD_ACCESS_ENV_AZURE_GLOBAL        = CLOUD_PROVIDER_AZURE + "-int"
    93  	CLOUD_ACCESS_ENV_AZURE_GERMAN        = CLOUD_PROVIDER_AZURE + "-de"
    94  	CLOUD_ACCESS_ENV_AZURE_US_GOVERNMENT = CLOUD_PROVIDER_AZURE + "-us-gov"
    95  	CLOUD_ACCESS_ENV_AZURE_CHINA         = CLOUD_PROVIDER_AZURE
    96  	CLOUD_ACCESS_ENV_HUAWEI_GLOBAL       = CLOUD_PROVIDER_HUAWEI + "-int"
    97  	CLOUD_ACCESS_ENV_HUAWEI_CHINA        = CLOUD_PROVIDER_HUAWEI
    98  	CLOUD_ACCESS_ENV_ALIYUN_GLOBAL       = CLOUD_PROVIDER_ALIYUN
    99  	CLOUD_ACCESS_ENV_ALIYUN_FINANCE      = CLOUD_PROVIDER_ALIYUN + "-fin"
   100  	CLOUD_ACCESS_ENV_CTYUN_CHINA         = CLOUD_PROVIDER_CTYUN
   101  	CLOUD_ACCESS_ENV_ECLOUD_CHINA        = CLOUD_PROVIDER_ECLOUD
   102  	CLOUD_ACCESS_ENV_JDCLOUD_CHINA       = CLOUD_PROVIDER_JDCLOUD
   103  )
   104  
   105  var (
   106  	CLOUD_PROVIDER_VALID_STATUS        = []string{CLOUD_PROVIDER_CONNECTED}
   107  	CLOUD_PROVIDER_VALID_HEALTH_STATUS = []string{CLOUD_PROVIDER_HEALTH_NORMAL, CLOUD_PROVIDER_HEALTH_NO_PERMISSION}
   108  	PRIVATE_CLOUD_PROVIDERS            = []string{CLOUD_PROVIDER_ZSTACK, CLOUD_PROVIDER_OPENSTACK, CLOUD_PROVIDER_APSARA,
   109  		CLOUD_PROVIDER_HCSO, CLOUD_PROVIDER_HCS, CLOUD_PROVIDER_INCLOUD_SPHERE, CLOUD_PROVIDER_PROXMOX, CLOUD_PROVIDER_REMOTEFILE}
   110  
   111  	CLOUD_PROVIDERS = []string{
   112  		CLOUD_PROVIDER_ONECLOUD,
   113  		CLOUD_PROVIDER_VMWARE,
   114  		CLOUD_PROVIDER_ALIYUN,
   115  		CLOUD_PROVIDER_APSARA,
   116  		CLOUD_PROVIDER_QCLOUD,
   117  		CLOUD_PROVIDER_AZURE,
   118  		CLOUD_PROVIDER_AWS,
   119  		CLOUD_PROVIDER_HUAWEI,
   120  		CLOUD_PROVIDER_HCSO,
   121  		CLOUD_PROVIDER_HCS,
   122  		CLOUD_PROVIDER_OPENSTACK,
   123  		CLOUD_PROVIDER_UCLOUD,
   124  		CLOUD_PROVIDER_ZSTACK,
   125  		CLOUD_PROVIDER_GOOGLE,
   126  		CLOUD_PROVIDER_CTYUN,
   127  		CLOUD_PROVIDER_ECLOUD,
   128  		CLOUD_PROVIDER_JDCLOUD,
   129  		CLOUD_PROVIDER_CLOUDPODS,
   130  		CLOUD_PROVIDER_NUTANIX,
   131  		CLOUD_PROVIDER_BINGO_CLOUD,
   132  		CLOUD_PROVIDER_INCLOUD_SPHERE,
   133  		CLOUD_PROVIDER_PROXMOX,
   134  		CLOUD_PROVIDER_REMOTEFILE,
   135  	}
   136  
   137  	CLOUD_PROVIDER_HOST_TYPE_MAP = map[string][]string{
   138  		CLOUD_PROVIDER_ONECLOUD: {
   139  			HOST_TYPE_KVM,
   140  			HOST_TYPE_BAREMETAL,
   141  			HOST_TYPE_HYPERVISOR,
   142  		},
   143  		CLOUD_PROVIDER_VMWARE: {
   144  			HOST_TYPE_ESXI,
   145  		},
   146  		CLOUD_PROVIDER_ALIYUN: {
   147  			HOST_TYPE_ALIYUN,
   148  		},
   149  		CLOUD_PROVIDER_APSARA: {
   150  			HOST_TYPE_APSARA,
   151  		},
   152  		CLOUD_PROVIDER_QCLOUD: {
   153  			HOST_TYPE_QCLOUD,
   154  		},
   155  		CLOUD_PROVIDER_AZURE: {
   156  			HOST_TYPE_AZURE,
   157  		},
   158  		CLOUD_PROVIDER_AWS: {
   159  			HOST_TYPE_AWS,
   160  		},
   161  		CLOUD_PROVIDER_HUAWEI: {
   162  			HOST_TYPE_HUAWEI,
   163  		},
   164  		CLOUD_PROVIDER_HCSO: {
   165  			HOST_TYPE_HCSO,
   166  		},
   167  		CLOUD_PROVIDER_HCS: {
   168  			HOST_TYPE_HCS,
   169  		},
   170  		CLOUD_PROVIDER_OPENSTACK: {
   171  			HOST_TYPE_OPENSTACK,
   172  		},
   173  		CLOUD_PROVIDER_UCLOUD: {
   174  			HOST_TYPE_UCLOUD,
   175  		},
   176  		CLOUD_PROVIDER_ZSTACK: {
   177  			HOST_TYPE_ZSTACK,
   178  		},
   179  		CLOUD_PROVIDER_GOOGLE: {
   180  			HOST_TYPE_GOOGLE,
   181  		},
   182  		CLOUD_PROVIDER_CTYUN: {
   183  			HOST_TYPE_CTYUN,
   184  		},
   185  		CLOUD_PROVIDER_ECLOUD: {
   186  			HOST_TYPE_ECLOUD,
   187  		},
   188  		CLOUD_PROVIDER_JDCLOUD: {
   189  			HOST_TYPE_JDCLOUD,
   190  		},
   191  		CLOUD_PROVIDER_CLOUDPODS: {
   192  			HOST_TYPE_CLOUDPODS,
   193  		},
   194  		CLOUD_PROVIDER_NUTANIX: {
   195  			HOST_TYPE_NUTANIX,
   196  		},
   197  		CLOUD_PROVIDER_BINGO_CLOUD: {
   198  			HOST_TYPE_BINGO_CLOUD,
   199  		},
   200  		CLOUD_PROVIDER_INCLOUD_SPHERE: {
   201  			HOST_TYPE_INCLOUD_SPHERE,
   202  		},
   203  		CLOUD_PROVIDER_PROXMOX: {
   204  			HOST_TYPE_PROXMOX,
   205  		},
   206  		CLOUD_PROVIDER_REMOTEFILE: {
   207  			HOST_TYPE_REMOTEFILE,
   208  		},
   209  	}
   210  )
   211  
   212  const (
   213  	CLOUD_ENV_PUBLIC_CLOUD  = cloudprovider.CLOUD_ENV_PUBLIC_CLOUD
   214  	CLOUD_ENV_PRIVATE_CLOUD = cloudprovider.CLOUD_ENV_PRIVATE_CLOUD
   215  	CLOUD_ENV_ON_PREMISE    = cloudprovider.CLOUD_ENV_ON_PREMISE
   216  
   217  	CLOUD_ENV_PRIVATE_ON_PREMISE = cloudprovider.CLOUD_ENV_PRIVATE_ON_PREMISE
   218  )
   219  
   220  const (
   221  	CLOUD_ACCOUNT_SHARE_MODE_ACCOUNT_DOMAIN  = apis.CLOUD_ACCOUNT_SHARE_MODE_ACCOUNT_DOMAIN
   222  	CLOUD_ACCOUNT_SHARE_MODE_SYSTEM          = apis.CLOUD_ACCOUNT_SHARE_MODE_SYSTEM
   223  	CLOUD_ACCOUNT_SHARE_MODE_PROVIDER_DOMAIN = apis.CLOUD_ACCOUNT_SHARE_MODE_PROVIDER_DOMAIN
   224  )
   225  
   226  var (
   227  	CLOUD_ACCOUNT_SHARE_MODES = []string{
   228  		CLOUD_ACCOUNT_SHARE_MODE_ACCOUNT_DOMAIN,
   229  		CLOUD_ACCOUNT_SHARE_MODE_SYSTEM,
   230  		CLOUD_ACCOUNT_SHARE_MODE_PROVIDER_DOMAIN,
   231  	}
   232  
   233  	CLOUD_ENV_MAP = map[string]map[string]string{
   234  		CLOUD_PROVIDER_AZURE: {
   235  			"AzureGermanCloud":       CLOUD_ACCESS_ENV_AZURE_GERMAN,
   236  			"AzureChinaCloud":        CLOUD_ACCESS_ENV_AZURE_CHINA,
   237  			"AzureUSGovernmentCloud": CLOUD_ACCESS_ENV_AZURE_US_GOVERNMENT,
   238  			"AzurePublicCloud":       CLOUD_ACCESS_ENV_AZURE_GLOBAL,
   239  		},
   240  		CLOUD_PROVIDER_AWS: {
   241  			"InternationalCloud": CLOUD_ACCESS_ENV_AWS_GLOBAL,
   242  			"ChinaCloud":         CLOUD_ACCESS_ENV_AWS_CHINA,
   243  		},
   244  		CLOUD_PROVIDER_HUAWEI: {
   245  			"InternationalCloud": CLOUD_ACCESS_ENV_HUAWEI_GLOBAL,
   246  			"ChinaCloud":         CLOUD_ACCESS_ENV_HUAWEI_CHINA,
   247  		},
   248  		CLOUD_PROVIDER_ALIYUN: {
   249  			"InternationalCloud": CLOUD_PROVIDER_ALIYUN,
   250  			"FinanceCloud":       CLOUD_ACCESS_ENV_ALIYUN_FINANCE,
   251  		},
   252  	}
   253  )
   254  
   255  func GetCloudEnv(provider, accessUrl string) string {
   256  	envMap, ok := CLOUD_ENV_MAP[provider]
   257  	if !ok {
   258  		return provider
   259  	}
   260  	env, ok := envMap[accessUrl]
   261  	if !ok {
   262  		return provider
   263  	}
   264  	return env
   265  }