yunion.io/x/cloudmux@v0.3.10-0-alpha.1/pkg/apis/compute/guest_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  const (
    18  	VM_INIT            = "init"
    19  	VM_UNKNOWN         = "unknown"
    20  	VM_SCHEDULE        = "schedule"
    21  	VM_SCHEDULE_FAILED = "sched_fail"
    22  	VM_CREATE_NETWORK  = "network"
    23  	VM_NETWORK_FAILED  = "net_fail"
    24  	VM_DEVICE_FAILED   = "dev_fail"
    25  	VM_CREATE_FAILED   = "create_fail"
    26  	VM_CREATE_DISK     = "disk"
    27  	VM_DISK_FAILED     = "disk_fail"
    28  	VM_IMAGE_CACHING   = "image_caching" // 缓存镜像中
    29  	VM_START_DEPLOY    = "start_deploy"
    30  	VM_DEPLOYING       = "deploying"
    31  	VM_DEPLOY_FAILED   = "deploy_fail"
    32  	VM_READY           = "ready"
    33  	VM_START_START     = "start_start"
    34  	VM_STARTING        = "starting"
    35  	VM_START_FAILED    = "start_fail" // # = ready
    36  	VM_RUNNING         = "running"
    37  	VM_START_STOP      = "start_stop"
    38  	VM_STOPPING        = "stopping"
    39  	VM_STOP_FAILED     = "stop_fail" // # = running
    40  	VM_RENEWING        = "renewing"
    41  	VM_RENEW_FAILED    = "renew_failed"
    42  	VM_ATTACH_DISK     = "attach_disk"
    43  	VM_DETACH_DISK     = "detach_disk"
    44  
    45  	VM_BACKUP_STARTING         = "backup_starting"
    46  	VM_BACKUP_CREATING         = "backup_creating"
    47  	VM_BACKUP_CREATE_FAILED    = "backup_create_fail"
    48  	VM_DEPLOYING_BACKUP        = "deploying_backup"
    49  	VM_DEPLOYING_BACKUP_FAILED = "deploging_backup_fail"
    50  	VM_DELETING_BACKUP         = "deleting_backup"
    51  	VM_BACKUP_DELETE_FAILED    = "backup_delete_fail"
    52  	VM_SWITCH_TO_BACKUP        = "switch_to_backup"
    53  	VM_SWITCH_TO_BACKUP_FAILED = "switch_to_backup_fail"
    54  
    55  	VM_ATTACH_DISK_FAILED = "attach_disk_fail"
    56  	VM_DETACH_DISK_FAILED = "detach_disk_fail"
    57  
    58  	VM_START_SUSPEND  = "start_suspend"
    59  	VM_SUSPENDING     = "suspending"
    60  	VM_SUSPEND        = "suspend"
    61  	VM_SUSPEND_FAILED = "suspend_failed"
    62  
    63  	VM_RESUMING      = "resuming"
    64  	VM_RESUME_FAILED = "resume_failed"
    65  
    66  	VM_START_DELETE = "start_delete"
    67  	VM_DELETE_FAIL  = "delete_fail"
    68  	VM_DELETING     = "deleting"
    69  
    70  	VM_DEALLOCATED = "deallocated"
    71  
    72  	VM_START_MIGRATE  = "start_migrate"
    73  	VM_MIGRATING      = "migrating"
    74  	VM_LIVE_MIGRATING = "live_migrating"
    75  	VM_MIGRATE_FAILED = "migrate_failed"
    76  
    77  	VM_CHANGE_FLAVOR      = "change_flavor"
    78  	VM_CHANGE_FLAVOR_FAIL = "change_flavor_fail"
    79  	VM_REBUILD_ROOT       = "rebuild_root"
    80  	VM_REBUILD_ROOT_FAIL  = "rebuild_root_fail"
    81  
    82  	VM_START_SNAPSHOT           = "snapshot_start"
    83  	VM_SNAPSHOT                 = "snapshot"
    84  	VM_SNAPSHOT_DELETE          = "snapshot_delete"
    85  	VM_BLOCK_STREAM             = "block_stream"
    86  	VM_BLOCK_STREAM_FAIL        = "block_stream_fail"
    87  	VM_SNAPSHOT_SUCC            = "snapshot_succ"
    88  	VM_SNAPSHOT_FAILED          = "snapshot_failed"
    89  	VM_DISK_RESET               = "disk_reset"
    90  	VM_DISK_RESET_FAIL          = "disk_reset_failed"
    91  	VM_DISK_CHANGE_STORAGE      = "disk_change_storage"
    92  	VM_DISK_CHANGE_STORAGE_FAIL = "disk_change_storage_fail"
    93  
    94  	VM_START_INSTANCE_SNAPSHOT   = "start_instance_snapshot"
    95  	VM_INSTANCE_SNAPSHOT_FAILED  = "instance_snapshot_failed"
    96  	VM_START_SNAPSHOT_RESET      = "start_snapshot_reset"
    97  	VM_SNAPSHOT_RESET_FAILED     = "snapshot_reset_failed"
    98  	VM_SNAPSHOT_AND_CLONE_FAILED = "clone_from_snapshot_failed"
    99  
   100  	VM_START_INSTANCE_BACKUP  = "start_instance_backup"
   101  	VM_INSTANCE_BACKUP_FAILED = "instance_backup_failed"
   102  
   103  	VM_SYNC_CONFIG = "sync_config"
   104  	VM_SYNC_FAIL   = "sync_fail"
   105  
   106  	VM_START_RESIZE_DISK  = "start_resize_disk"
   107  	VM_RESIZE_DISK        = "resize_disk"
   108  	VM_RESIZE_DISK_FAILED = "resize_disk_fail"
   109  
   110  	VM_START_SAVE_DISK  = "start_save_disk"
   111  	VM_SAVE_DISK        = "save_disk"
   112  	VM_SAVE_DISK_FAILED = "save_disk_failed"
   113  
   114  	VM_RESTORING_SNAPSHOT = "restoring_snapshot"
   115  	VM_RESTORE_DISK       = "restore_disk"
   116  	VM_RESTORE_STATE      = "restore_state"
   117  	VM_RESTORE_FAILED     = "restore_failed"
   118  
   119  	VM_ASSOCIATE_EIP         = INSTANCE_ASSOCIATE_EIP
   120  	VM_ASSOCIATE_EIP_FAILED  = INSTANCE_ASSOCIATE_EIP_FAILED
   121  	VM_DISSOCIATE_EIP        = INSTANCE_DISSOCIATE_EIP
   122  	VM_DISSOCIATE_EIP_FAILED = INSTANCE_DISSOCIATE_EIP_FAILED
   123  
   124  	// 公网IP转换Eip中(EIP转换中)
   125  	VM_START_EIP_CONVERT  = "start_eip_convert"
   126  	VM_EIP_CONVERT_FAILED = "eip_convert_failed"
   127  
   128  	// 设置自动续费
   129  	VM_SET_AUTO_RENEW        = "set_auto_renew"
   130  	VM_SET_AUTO_RENEW_FAILED = "set_auto_renew_failed"
   131  
   132  	VM_REMOVE_STATEFILE = "remove_state"
   133  
   134  	VM_IO_THROTTLE      = "io_throttle"
   135  	VM_IO_THROTTLE_FAIL = "io_throttle_fail"
   136  
   137  	VM_ADMIN = "admin"
   138  
   139  	VM_IMPORT        = "import"
   140  	VM_IMPORT_FAILED = "import_fail"
   141  
   142  	VM_CONVERT        = "convert"
   143  	VM_CONVERTING     = "converting"
   144  	VM_CONVERT_FAILED = "convert_failed"
   145  	VM_CONVERTED      = "converted"
   146  
   147  	VM_TEMPLATE_SAVING      = "tempalte_saving"
   148  	VM_TEMPLATE_SAVE_FAILED = "template_save_failed"
   149  
   150  	VM_UPDATE_TAGS        = "update_tags"
   151  	VM_UPDATE_TAGS_FAILED = "update_tags_fail"
   152  
   153  	VM_RESTART_NETWORK        = "restart_network"
   154  	VM_RESTART_NETWORK_FAILED = "restart_network_failed"
   155  
   156  	VM_SYNC_ISOLATED_DEVICE_FAILED = "sync_isolated_device_failed"
   157  
   158  	VM_QGA_SET_PASSWORD      = "qga_set_password"
   159  	VM_QGA_COMMAND_EXECUTING = "qga_command_executing"
   160  
   161  	SHUTDOWN_STOP      = "stop"
   162  	SHUTDOWN_TERMINATE = "terminate"
   163  
   164  	HYPERVISOR_KVM       = "kvm"
   165  	HYPERVISOR_CONTAINER = "container"
   166  	HYPERVISOR_BAREMETAL = "baremetal"
   167  	HYPERVISOR_ESXI      = "esxi"
   168  	HYPERVISOR_HYPERV    = "hyperv"
   169  	HYPERVISOR_XEN       = "xen"
   170  
   171  	HYPERVISOR_ALIYUN         = "aliyun"
   172  	HYPERVISOR_APSARA         = "apsara"
   173  	HYPERVISOR_QCLOUD         = "qcloud"
   174  	HYPERVISOR_AZURE          = "azure"
   175  	HYPERVISOR_AWS            = "aws"
   176  	HYPERVISOR_HUAWEI         = "huawei"
   177  	HYPERVISOR_HCS            = "hcs"
   178  	HYPERVISOR_HCSO           = "hcso"
   179  	HYPERVISOR_OPENSTACK      = "openstack"
   180  	HYPERVISOR_UCLOUD         = "ucloud"
   181  	HYPERVISOR_ZSTACK         = "zstack"
   182  	HYPERVISOR_GOOGLE         = "google"
   183  	HYPERVISOR_CTYUN          = "ctyun"
   184  	HYPERVISOR_ECLOUD         = "ecloud"
   185  	HYPERVISOR_JDCLOUD        = "jdcloud"
   186  	HYPERVISOR_CLOUDPODS      = "cloudpods"
   187  	HYPERVISOR_NUTANIX        = "nutanix"
   188  	HYPERVISOR_BINGO_CLOUD    = "bingocloud"
   189  	HYPERVISOR_INCLOUD_SPHERE = "incloudsphere"
   190  	HYPERVISOR_PROXMOX        = "proxmox"
   191  	HYPERVISOR_REMOTEFILE     = "remotefile"
   192  
   193  	//	HYPERVISOR_DEFAULT = HYPERVISOR_KVM
   194  	HYPERVISOR_DEFAULT = HYPERVISOR_KVM
   195  )
   196  
   197  const (
   198  	VM_POWER_STATES_ON      = "on"
   199  	VM_POWER_STATES_OFF     = "off"
   200  	VM_POWER_STATES_UNKNOWN = "unknown"
   201  )
   202  
   203  const (
   204  	QGA_STATUS_UNKNOWN        = "unknown"
   205  	QGA_STATUS_EXCUTING       = "executing"
   206  	QGA_STATUS_EXECUTE_FAILED = "execute_failed"
   207  	QGA_STATUS_AVAILABLE      = "available"
   208  )
   209  
   210  const (
   211  	CPU_MODE_QEMU = "qemu"
   212  	CPU_MODE_HOST = "host"
   213  )
   214  
   215  const (
   216  	VM_MACHINE_TYPE_PC  = "pc"
   217  	VM_MACHINE_TYPE_Q35 = "q35"
   218  
   219  	VM_MACHINE_TYPE_ARM_VIRT = "virt"
   220  
   221  	VM_VDI_PROTOCOL_VNC   = "vnc"
   222  	VM_VDI_PROTOCOL_SPICE = "spice"
   223  
   224  	VM_VIDEO_STANDARD = "std"
   225  	VM_VIDEO_QXL      = "qxl"
   226  	VM_VIDEO_VIRTIO   = "virtio"
   227  )
   228  
   229  var VM_RUNNING_STATUS = []string{VM_START_START, VM_STARTING, VM_RUNNING, VM_BLOCK_STREAM, VM_BLOCK_STREAM_FAIL}
   230  var VM_CREATING_STATUS = []string{VM_CREATE_NETWORK, VM_CREATE_DISK, VM_START_DEPLOY, VM_DEPLOYING}
   231  
   232  var HYPERVISORS = []string{
   233  	HYPERVISOR_KVM,
   234  	HYPERVISOR_BAREMETAL,
   235  	HYPERVISOR_ESXI,
   236  	HYPERVISOR_CONTAINER,
   237  	HYPERVISOR_ALIYUN,
   238  	HYPERVISOR_APSARA,
   239  	HYPERVISOR_AZURE,
   240  	HYPERVISOR_AWS,
   241  	HYPERVISOR_QCLOUD,
   242  	HYPERVISOR_HUAWEI,
   243  	HYPERVISOR_HCSO,
   244  	HYPERVISOR_HCS,
   245  	HYPERVISOR_OPENSTACK,
   246  	HYPERVISOR_UCLOUD,
   247  	HYPERVISOR_ZSTACK,
   248  	HYPERVISOR_GOOGLE,
   249  	HYPERVISOR_CTYUN,
   250  	HYPERVISOR_ECLOUD,
   251  	HYPERVISOR_JDCLOUD,
   252  	HYPERVISOR_CLOUDPODS,
   253  	HYPERVISOR_NUTANIX,
   254  	HYPERVISOR_BINGO_CLOUD,
   255  	HYPERVISOR_INCLOUD_SPHERE,
   256  	HYPERVISOR_PROXMOX,
   257  	HYPERVISOR_REMOTEFILE,
   258  }
   259  
   260  var ONECLOUD_HYPERVISORS = []string{
   261  	HYPERVISOR_BAREMETAL,
   262  	HYPERVISOR_KVM,
   263  	HYPERVISOR_CONTAINER,
   264  }
   265  
   266  var PUBLIC_CLOUD_HYPERVISORS = []string{
   267  	HYPERVISOR_ALIYUN,
   268  	HYPERVISOR_AWS,
   269  	HYPERVISOR_AZURE,
   270  	HYPERVISOR_QCLOUD,
   271  	HYPERVISOR_HUAWEI,
   272  	HYPERVISOR_UCLOUD,
   273  	HYPERVISOR_GOOGLE,
   274  	HYPERVISOR_CTYUN,
   275  	HYPERVISOR_ECLOUD,
   276  	HYPERVISOR_JDCLOUD,
   277  }
   278  
   279  var PRIVATE_CLOUD_HYPERVISORS = []string{
   280  	HYPERVISOR_ZSTACK,
   281  	HYPERVISOR_OPENSTACK,
   282  	HYPERVISOR_APSARA,
   283  	HYPERVISOR_CLOUDPODS,
   284  	HYPERVISOR_HCSO,
   285  	HYPERVISOR_HCS,
   286  	HYPERVISOR_NUTANIX,
   287  	HYPERVISOR_BINGO_CLOUD,
   288  	HYPERVISOR_INCLOUD_SPHERE,
   289  	HYPERVISOR_PROXMOX,
   290  	HYPERVISOR_REMOTEFILE,
   291  }
   292  
   293  // var HYPERVISORS = []string{HYPERVISOR_ALIYUN}
   294  
   295  var HYPERVISOR_HOSTTYPE = map[string]string{
   296  	HYPERVISOR_KVM:            HOST_TYPE_HYPERVISOR,
   297  	HYPERVISOR_BAREMETAL:      HOST_TYPE_BAREMETAL,
   298  	HYPERVISOR_ESXI:           HOST_TYPE_ESXI,
   299  	HYPERVISOR_CONTAINER:      HOST_TYPE_KUBELET,
   300  	HYPERVISOR_ALIYUN:         HOST_TYPE_ALIYUN,
   301  	HYPERVISOR_APSARA:         HOST_TYPE_APSARA,
   302  	HYPERVISOR_AZURE:          HOST_TYPE_AZURE,
   303  	HYPERVISOR_AWS:            HOST_TYPE_AWS,
   304  	HYPERVISOR_QCLOUD:         HOST_TYPE_QCLOUD,
   305  	HYPERVISOR_HUAWEI:         HOST_TYPE_HUAWEI,
   306  	HYPERVISOR_HCSO:           HOST_TYPE_HCSO,
   307  	HYPERVISOR_HCS:            HOST_TYPE_HCS,
   308  	HYPERVISOR_OPENSTACK:      HOST_TYPE_OPENSTACK,
   309  	HYPERVISOR_UCLOUD:         HOST_TYPE_UCLOUD,
   310  	HYPERVISOR_ZSTACK:         HOST_TYPE_ZSTACK,
   311  	HYPERVISOR_GOOGLE:         HOST_TYPE_GOOGLE,
   312  	HYPERVISOR_CTYUN:          HOST_TYPE_CTYUN,
   313  	HYPERVISOR_ECLOUD:         HOST_TYPE_ECLOUD,
   314  	HYPERVISOR_JDCLOUD:        HOST_TYPE_JDCLOUD,
   315  	HYPERVISOR_CLOUDPODS:      HOST_TYPE_CLOUDPODS,
   316  	HYPERVISOR_NUTANIX:        HOST_TYPE_NUTANIX,
   317  	HYPERVISOR_BINGO_CLOUD:    HOST_TYPE_BINGO_CLOUD,
   318  	HYPERVISOR_INCLOUD_SPHERE: HOST_TYPE_INCLOUD_SPHERE,
   319  	HYPERVISOR_PROXMOX:        HOST_TYPE_PROXMOX,
   320  	HYPERVISOR_REMOTEFILE:     HOST_TYPE_REMOTEFILE,
   321  }
   322  
   323  var HOSTTYPE_HYPERVISOR = map[string]string{
   324  	HOST_TYPE_HYPERVISOR:     HYPERVISOR_KVM,
   325  	HOST_TYPE_BAREMETAL:      HYPERVISOR_BAREMETAL,
   326  	HOST_TYPE_ESXI:           HYPERVISOR_ESXI,
   327  	HOST_TYPE_KUBELET:        HYPERVISOR_CONTAINER,
   328  	HOST_TYPE_ALIYUN:         HYPERVISOR_ALIYUN,
   329  	HOST_TYPE_APSARA:         HYPERVISOR_APSARA,
   330  	HOST_TYPE_AZURE:          HYPERVISOR_AZURE,
   331  	HOST_TYPE_AWS:            HYPERVISOR_AWS,
   332  	HOST_TYPE_QCLOUD:         HYPERVISOR_QCLOUD,
   333  	HOST_TYPE_HUAWEI:         HYPERVISOR_HUAWEI,
   334  	HOST_TYPE_HCSO:           HYPERVISOR_HCSO,
   335  	HOST_TYPE_HCS:            HYPERVISOR_HCS,
   336  	HOST_TYPE_OPENSTACK:      HYPERVISOR_OPENSTACK,
   337  	HOST_TYPE_UCLOUD:         HYPERVISOR_UCLOUD,
   338  	HOST_TYPE_ZSTACK:         HYPERVISOR_ZSTACK,
   339  	HOST_TYPE_GOOGLE:         HYPERVISOR_GOOGLE,
   340  	HOST_TYPE_CTYUN:          HYPERVISOR_CTYUN,
   341  	HOST_TYPE_ECLOUD:         HYPERVISOR_ECLOUD,
   342  	HOST_TYPE_JDCLOUD:        HYPERVISOR_JDCLOUD,
   343  	HOST_TYPE_CLOUDPODS:      HYPERVISOR_CLOUDPODS,
   344  	HOST_TYPE_NUTANIX:        HYPERVISOR_NUTANIX,
   345  	HOST_TYPE_BINGO_CLOUD:    HYPERVISOR_BINGO_CLOUD,
   346  	HOST_TYPE_INCLOUD_SPHERE: HYPERVISOR_INCLOUD_SPHERE,
   347  	HOST_TYPE_PROXMOX:        HYPERVISOR_PROXMOX,
   348  	HOST_TYPE_REMOTEFILE:     HYPERVISOR_REMOTEFILE,
   349  }
   350  
   351  const (
   352  	VM_DEFAULT_WINDOWS_LOGIN_USER         = "Administrator"
   353  	VM_DEFAULT_LINUX_LOGIN_USER           = "root"
   354  	VM_AWS_DEFAULT_LOGIN_USER             = "ec2user"
   355  	VM_AWS_DEFAULT_WINDOWS_LOGIN_USER     = "Administrator"
   356  	VM_JDCLOUD_DEFAULT_WINDOWS_LOGIN_USER = "administrator"
   357  	VM_AZURE_DEFAULT_LOGIN_USER           = "azureuser"
   358  	VM_ZSTACK_DEFAULT_LOGIN_USER          = "root"
   359  
   360  	VM_METADATA_APP_TAGS            = "app_tags"
   361  	VM_METADATA_CREATE_PARAMS       = "create_params"
   362  	VM_METADATA_LOGIN_ACCOUNT       = "login_account"
   363  	VM_METADATA_LOGIN_KEY           = "login_key"
   364  	VM_METADATA_LAST_LOGIN_KEY      = "last_login_key"
   365  	VM_METADATA_LOGIN_KEY_TIMESTAMP = "login_key_timestamp"
   366  	VM_METADATA_OS_ARCH             = "os_arch"
   367  	VM_METADATA_OS_DISTRO           = "os_distribution"
   368  	VM_METADATA_OS_NAME             = "os_name"
   369  	VM_METADATA_OS_VERSION          = "os_version"
   370  	VM_METADATA_CGROUP_CPUSET       = "cgroup_cpuset"
   371  	VM_METADATA_ENABLE_MEMCLEAN     = "enable_memclean"
   372  )
   373  
   374  func Hypervisors2HostTypes(hypervisors []string) []string {
   375  	hostTypes := make([]string, len(hypervisors))
   376  	for i := range hypervisors {
   377  		hostTypes[i] = HYPERVISOR_HOSTTYPE[hypervisors[i]]
   378  	}
   379  	return hostTypes
   380  }
   381  
   382  // windows allow a maximal length of 15
   383  // http://support.microsoft.com/kb/909264
   384  const MAX_WINDOWS_COMPUTER_NAME_LENGTH = 15