Files
cloudpods/pkg/apis/compute/api.go

845 lines
30 KiB
Go
Raw Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

// Copyright 2019 Yunion
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
// http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.
package compute
import (
"time"
"yunion.io/x/jsonutils"
"yunion.io/x/onecloud/pkg/apis"
billing_api "yunion.io/x/onecloud/pkg/apis/billing"
)
type SchedtagConfig struct {
apis.Meta
// swagger:ignore
Id string `json:"id"`
// 调度策略
// required: 必须使用
// prefer: 尽量使用
// avoid: 避免使用
// exclude: 禁止使用
// enmu: required, prefer, avoid, exclude
Strategy string `json:"strategy"`
// swagger:ignore
Weight int `json:"weight"`
// 资源类型
// hosts: 宿主机
// networks: 网络
// storages: 存储
// enmu: hosts, storages, networks
ResourceType string `json:"resource_type"`
}
type NetworkConfig struct {
apis.Meta
// 网卡序号, 从0开始
// required: true
Index int `json:"index"`
// 子网名称或ID
// required: true
Network string `json:"network"`
// swagger:ignore
Wire string `json:"wire"`
// 内网地址
Exit bool `json:"exit"`
Private bool `json:"private"`
// 网卡MAC地址
// requried: false
Mac string `json:"mac"`
// 如果是批量创建指定每个网卡MAC地址
// requried: false
Macs []string `json:"macs"`
// 子网内的IPv4地址, 若不指定会按照子网的地址分配策略分配一个IP地址
// required: false
Address string `json:"address"`
// 如果是批量创建指定每台主机子网内的IPv4地址
// required: false
Addresses []string `json:"addresses"`
// 子网内的IPv6地址
// required: false
Address6 string `json:"address6"`
// 如果是批量创建指定每台主机子网内的IPv4地址
// required: false
Addresses6 []string `json:"addresses6"`
// 是否要求分配IPv6地址
// required: false
RequireIPv6 bool `json:"require_ipv6"`
// 只分配IPv6地址禁用IPv4
// required: false
StrictIPv6 bool `json:"strict_ipv6"`
// 驱动方式
// 若指定镜像的网络驱动方式,此参数会被覆盖
Driver string `json:"driver"`
BwLimit int `json:"bw_limit"`
TxBwLimit int `json:"tx_bw_limit"`
RxBwLimit int `json:"rx_bw_limit"`
Vip bool `json:"vip"`
Reserved bool `json:"reserved"`
NumQueues int `json:"num_queues"`
RxTrafficLimit int64 `json:"rx_traffic_limit"`
TxTrafficLimit int64 `json:"tx_traffic_limit"`
NetType TNetworkType `json:"net_type"`
IsDefault bool `json:"is_default"`
// sriov nic
SriovDevice *IsolatedDeviceConfig `json:"sriov_device"`
RequireDesignatedIP bool `json:"require_designated_ip"`
RequireTeaming bool `json:"require_teaming"`
TryTeaming bool `json:"try_teaming"`
StandbyPortCount int `json:"standby_port_count"`
StandbyAddrCount int `json:"standby_addr_count"`
PortMappings GuestPortMappings `json:"port_mappings"`
// 计费模式
BillingType billing_api.TBillingType `json:"billing_type"`
// 计量模式
ChargeType billing_api.TNetChargeType `json:"charge_type"`
// swagger:ignore
Project string `json:"project_id"`
// swagger:ignore
Domain string `json:"domain_id"`
Ifname string `json:"ifname"`
Schedtags []*SchedtagConfig `json:"schedtags"`
// network secgroups
Secgroups []string `json:"secgroups"`
}
type AttachNetworkInput struct {
// 添加的网卡的配置
// required: false
Nets []*NetworkConfig `json:"nets"`
// 添加的网卡的配置
// required: false
NetDesc []string `json:"net_desc"`
// 添加后不立即同步配置
DisableSyncConfig *bool `json:"disable_sync_config"`
}
type DiskConfig struct {
apis.Meta
// 挂载到虚拟机的磁盘顺序, -1代表不挂载任何虚拟机
// default: -1
Index int `json:"index"`
BootIndex *int8 `json:"boot_index"`
// 镜像ID,通过镜像创建磁盘,创建虚拟机时第一块磁盘需要指定此参数
// required: false
ImageId string `json:"image_id"`
// 镜像加密key ID
ImageEncryptKeyId string `json:"image_encrypt_key_id"`
// 快照ID,通过快照创建磁盘,此参数必须加上 'snapshot-' 前缀
// example: snapshot-3140cecb-ccc4-4865-abae-3a5ba8c69d9b
// requried: false
SnapshotId string `json:"snapshot_id"`
BackupId string `json:"backup_id"`
// 磁盘类型
// enum: ["sys", "data", "swap"]
DiskType string `json:"disk_type"`
Schedtags []*SchedtagConfig `json:"schedtags"`
// 磁盘大小,单位Mb
// 若创建裸金属服务器是, -1代表自动向后扩展存储
// requried:true
SizeMb int `json:"size"`
// 文件系统,仅kvm支持自动格式化磁盘,私有云和公有云此参数不会生效
// enum: ["swap", "ext2", "ext3", "ext4", "xfs", "ntfs", "fat", "hfsplus"]
// requried: false
Fs string `json:"fs"`
// 文件系统特性
FsFeatures *DiskFsFeatures `json:"fs_features"`
// 关机后自动重置磁盘
// required: false
AutoReset bool `json:"auto_reset"`
// 是否跟随主机删除而自动删除
// 默认跟随主机创建的磁盘为 true
// required: false
AutoDelete *bool `json:"auto_delete,omitempty"`
// 磁盘存储格式
// enum: ["qcow2", "raw", "docker", "iso", "vmdk", "vmdkflatver1", "vmdkflatver2", "vmdkflat", "vmdksparse", "vmdksparsever1", "vmdksparsever2", "vmdksepsparse", "vhd"]
// requried: false
Format string `json:"format"`
// 磁盘驱动方式
// enum: ["virtio", "ide", "scsi", "sata", "pvscsi"]
// requried: false
Driver string `json:"driver"`
// 磁盘缓存模式
// enum: ["writeback", "none", "writethrough"]
// requried: false
Cache string `json:"cache"`
// 挂载点,必须以 '/' 开头,例如 /opt 仅KVM此参数有效
// requried: false
Mountpoint string `json:"mountpoint"`
// 操作系统CPU架构
// required: false
OsArch string `json:"os_arch"`
//后端存储类型,若指定了存储ID,此参数会根据存储设置,若不指定,则作为调度的一个参考
//
//
//
// | 平台 | 存储类型 | 中文 | 数据盘 | 系统盘 | 可否扩容 | 可否单独创建 | 扩容步长 | 说明 |
// |---- | ---- | ---- | ----- | ----- | ------- | ----------- | ------- | ----- |
// |Esxi |local |本地盘 |1-500GB |30~500GB | 是 | 否 | 1G | |
// |Esxi |nas |NAS盘 |30-3072GB |30~500GB | 是 | 否 | 1G | |
// |Esxi |vsan |VSAN盘 |30-3072GB |30~500GB | 是 | 否 | 1G | |
// |KVM |local |本地盘盘 |1-500GB |30~500GB | 是 | 否 | 1G | |
// |KVM |rbd |云硬盘 |1-3072GB |30~500GB | 是 | 是 | 1G | |
// |Azure |standard_lrs |标准 HDD |1-4095GB |30~4095GB | 是 | 是 | 1G | |
// |Azure |standardssd_lrs |标准 SSD |1-4095GB |30~4095GB | 是 | 是 | 1G | |
// |Azure |premium_lrs |高级SSD |1-4095GB |30~4095GB | 是 | 是 | 1G | |
// |AWS |gp2 |通用型SSD |1-16384GB |20~16384GB | 是 | 是 | 1G | |
// |AWS |io1 |预配置 IOPS SSD |4-16384GB |20-16384GB | 是 | 是 | 1G | |
// |AWS |st1 |吞吐优化HDD |500-16384GB |不支持 | 是 | 是 | 1G | |
// |AWS |sc1 |Cold HDD |500-16384GB |不支持 | 是 | 是 | 1G | |
// |AWS |standard |磁介质 |1-1024GB |20-1024GB | 是 | 是 | 1G | |
// |腾讯云 |cloud_ssd |SSD云硬盘 |10-16000GB |50~500GB | 是 | 是 | 10G | |
// |腾讯云 |cloud_basic |普通云硬盘 |10-16000GB |50~500GB | 是 | 是 | 10G | |
// |腾讯云 |cloud_preium |高性能云硬盘 |10-16000GB |50~1024GB | 是 | 是 | 10G | |
// |腾讯云 |local_basic |普通本地盘 |10-1600GB |不支持 | 否 | 否 | | |
// |腾讯云 |local_ssd |SSD本地盘 |10-7000GB |部分区域套餐支持 | 否 | 否 | | |
// |腾讯云 |local_pro |HDD本地盘 |跟随套餐 |部分区域套餐支持 | 否 | 否 | | |
// |华为云或天翼云 |SSD |超高IO云硬盘 |10-32768GB |40~1024GB | 是 | 是 | 1G | |
// |华为云或天翼云 |SAS |高IO云硬盘 |10-32768GB |40~1024GB | 是 | 是 | 1G | |
// |华为云或天翼云 |SATA |普通IO云硬盘 |10-32768GB |40~1024GB | 是 | 是 | 1G | |
// |OpenStack |nova |nova |不支持 |30-500GB | 否 | 否 | | |
// |OpenStack |自定义 |... |无限制 |无限制 | 是 | 是 | 1G | |
// |Ucloud |CLOUD_NORMAL |普通云盘 |20-8000GB |不支持 | 是 | 是 | 1G | |
// |Ucloud |CLOUD_SSD |SSD云盘 |20-4000GB |20-500GB | 是 | 是 | 1G | |
// |Ucloud |LOCAL_NORMAL |普通本地盘 | | | 是 | 是 | 1G | |
// |Ucloud |LOCAL_SSD |SSD本地盘 | | | 是 | 是 | 1G | |
// |Ucloud |EXCLUSIVE_LOCAL_DISK |独享本地盘 | | | 是 | 是 | 1G | |
// |ZStack |localstorage |本地盘 | | | 是 | 是 | 1G | |
// |ZStack |ceph |云硬盘 | | | 是 | 是 | 1G | |
// |Google |local-ssd |本地SSD暂存盘 |375GB |不支持 | 否 | 否 | | 跟随实例创建一次最多添加8个 |
// |Google |pd-standard |标准永久性磁盘 |10-65536GB |10-65536GB | 是 | 是 | 1G | |
// |Google |pd-ssd |SSD永久性磁盘 |10-65536GB |10-65536GB | 是 | 是 | 1G | |
Backend string `json:"backend"`
//介质类型
//rotate: 机械盘
//ssd: 固态硬盘
//hybird: 混合盘
//emum: [rotate, ssd, hybrid]
//default: hybird
Medium string `json:"medium"`
//swagger:ignore
ImageProperties map[string]string `json:"image_properties"`
//存储ID, 指定存储后,磁盘会在此存储上创建
//存储列表可以参数 storage 列表API
//required: false
Storage string `json:"storage_id"`
//swagger:ignore
DiskId string `json:"disk_id"`
//swagger:ignore
ExistingPath string `json:"existing_path"`
// requried:false
Iops int `json:"iops"`
// 磁盘吞吐量, 仅对aws gp3生效
// 范围: 125-1000
Throughput int `json:"throughput"`
// NVNe device
NVMEDevice *IsolatedDeviceConfig `json:"nvme_device"`
// 预分配策略:
// off: 关闭预分配,默认关闭
// metadata: 精简置备
// falloc: 厚置备延迟置零
// full: 厚置备快速置零
// default: off
Preallocation string `json:"preallocation"`
}
type IsolatedDeviceConfig struct {
Index int `json:"index"`
Id string `json:"id"`
DevType string `json:"dev_type"`
Model string `json:"model"`
SharingMode string `json:"sharing_mode"`
Vendor string `json:"vendor"`
NetworkIndex *int `json:"network_index"`
WireId string `json:"wire_id"`
DiskIndex *int8 `json:"disk_index"`
DevicePath string `json:"device_path"`
GpuType string `json:"gpu_type"`
// MemoryMb is the minimum on-device memory in MiB required from the
// candidate isolated_device (e.g. NVIDIA GPU VRAM). 0 means no constraint.
// The scheduler excludes devices whose memory_size > 0 and is below this
// threshold; devices with memory_size == 0 are treated as unknown and
// allowed through to avoid penalising hosts that haven't reported yet.
MemoryMb int `json:"memory_mb,omitempty"`
// Memory request for Devices allocate by Memory size
MemoryRequest int `json:"memory_request,omitempty"`
SmUtilLimit int `json:"sm_util_limit,omitempty"`
}
type BaremetalDiskConfig struct {
//Index int `json:"index"`
// disk type
Type string `json:"type"` // ssd / rotate
// raid config
Conf string `json:"conf"` // raid配置
Count int64 `json:"count"` // 连续几块
Range []int64 `json:"range"` // 指定几块
Splits string `json:"splits"`
Size []int64 `json:"size"` //
Adapter *int `json:"adapter,omitempty"`
Driver string `json:"driver"`
Cachedbadbbu *bool `json:"cachedbadbbu,omitempty"`
Strip *int64 `json:"strip,omitempty"`
RA *bool `json:"ra,omitempty"`
WT *bool `json:"wt,omitempty"`
Direct *bool `json:"direct,omitempty"`
SoftRaidIdx *int `json:"soft_raid_idx"`
}
type RootDiskMatcherSizeMBRange struct {
Start int64 `json:"start"`
End int64 `json:"end"`
}
const (
BAREMETAL_SERVER_METATA_ROOT_DISK_MATCHER = "baremetal_root_disk_matcher"
)
type BaremetalRootDiskMatcher struct {
Device string `json:"device"`
SizeMB int64 `json:"size_mb"`
SizeMBRange *RootDiskMatcherSizeMBRange `json:"size_mb_range"`
PCIPath string `json:"pci_path"`
}
type ServerConfigs struct {
// 调度使用指定的云账号
PreferManager string `json:"prefer_manager_id"`
// 调度到指定区域,优先级低于prefer_zone_id
PreferRegion string `json:"prefer_region_id"`
// 调度到指定可用区,优先级低于prefer_host_id
PreferZone string `json:"prefer_zone_id" yunion-deprecated-by:"prefer_zones"`
// 调度到指定可用区列表,优先级低于prefer_host_id
PreferZones []string `json:"prefer_zones"`
// 调度使用指定二层网络, 优先级低于prefer_host_id
PreferWire string `json:"prefer_wire_id"`
// 调度使用指定宿主机
PreferHost string `json:"prefer_host_id"`
// 主机高可用时,将备机调度到指定宿主机, 此参数仅对KVM生效
PreferBackupHost string `json:"prefer_backup_host"`
// 虚拟化技术或平台
//
//
//
// |hypervisor | 技术或平台 |
// |------- | ---------- |
// |kvm | 本地私有云 |
// |esxi | VMWare |
// |baremetal | 裸金属 |
// |aliyun | 阿里云 |
// |aws | 亚马逊 |
// |qcloud | 腾讯云 |
// |azure | 微软云 |
// |huawei | 华为云 |
// |openstack | OpenStack |
// |ucloud | Ucloud |
// |zstack | ZStack |
// |google | 谷歌云 |
// |ctyun | 天翼云 |
// default: kvm
Hypervisor string `json:"hypervisor"`
// swagger:ignore
Provider string `json:"provider"`
// 包年包月资源池
// swagger:ignore
// emum: shared, prepaid, dedicated
ResourceType string `json:"resource_type"`
// 套餐名称, 此参数优先级高于vcpu_count和vmem_size
// 套餐可以通过 serverskus 列表获取
// esxi, openstack, zstack等私有云都统一使用provider为OneCloud的套餐
// 公有云使用各自的套餐
InstanceType string `json:"instance_type"`
// swagger:ignore
// Deprecated
// alias for InstanceType
Sku string `json:"sku" yunion-deprecated-by:"instance_type"`
// 虚拟机高可用(创建备机)
// default: false
// required: false
Backup bool `json:"backup"`
// 设置为 daemon 虚机
// default: false
// required: false
IsDaemon *bool `json:"is_daemon"`
// swagger:ignore
// 创建虚拟机数量
// default: 1
Count int `json:"count"`
// 磁盘列表,第一块磁盘为系统盘,需要指定image_id
// 若指定主机快照,此参数可以为空
// required: true
Disks []*DiskConfig `json:"disks"`
// 指定主机网络
// required: false
Networks []*NetworkConfig `json:"nets"`
// 调度标签
// required: false
Schedtags []*SchedtagConfig `json:"schedtags"`
// 宿主机路径调度约束,仅检查 auto_create=false 的 host_path
HostPathRequirements []apis.HostPathRequirement `json:"host_path_requirements,omitempty"`
// 透传设备列表
// required: false
IsolatedDevices []*IsolatedDeviceConfig `json:"isolated_devices"`
// 裸金属磁盘配置列表
BaremetalDiskConfigs []*BaremetalDiskConfig `json:"baremetal_disk_configs"`
// 裸金属系统盘匹配器
BaremetalRootDiskMatcher *BaremetalRootDiskMatcher `json:"baremetal_root_disk_matcher"`
// 主机组列表, 参数可以是主机组名称或ID,建议使用ID
InstanceGroupIds []string `json:"groups"`
// DEPRECATE
Suggestion bool `json:"suggestion"`
}
func NewServerConfigs() *ServerConfigs {
return &ServerConfigs{
Disks: make([]*DiskConfig, 0),
Networks: make([]*NetworkConfig, 0),
Schedtags: make([]*SchedtagConfig, 0),
IsolatedDevices: make([]*IsolatedDeviceConfig, 0),
BaremetalDiskConfigs: make([]*BaremetalDiskConfig, 0),
InstanceGroupIds: make([]string, 0),
}
}
func (c *ServerConfigs) GetPreferZones() []string {
if len(c.PreferZones) > 0 {
return c.PreferZones
}
if c.PreferZone != "" {
return []string{c.PreferZone}
}
return nil
}
func (c *ServerConfigs) HasPreferZone() bool {
return len(c.GetPreferZones()) > 0
}
type DeployConfig struct {
Action string `json:"action"`
Path string `json:"path"`
Content string `json:"content"`
}
// KickstartConfig Kickstart/Autoinstall自动化安装配置
type KickstartConfig struct {
// 配置文件内容 (当用户直接提供配置时使用)
// required: false
Config string `json:"config,omitempty"`
// 配置文件 URL (当配置文件位于外部服务器时使用)
// required: false
ConfigURL string `json:"config_url,omitempty"`
// 操作系统类型 (用于确定内核参数和文件路径)
// enum: ["centos", "rhel", "fedora", "openeuler", "ubuntu"]
// required: true
OSType string `json:"os_type" validate:"required,oneof=centos rhel fedora openeuler ubuntu"`
// 是否启用 (用于临时禁用而不删除配置)
// default: true
// required: false
Enabled *bool `json:"enabled,omitempty"`
// 最大重试次数
// default: 3
// required: false
MaxRetries int `json:"max_retries,omitempty"`
// 安装超时时间 (分钟)
// default: 60
// required: false
TimeoutMinutes int `json:"timeout_minutes,omitempty"`
}
type ServerCreateInput struct {
apis.VirtualResourceCreateInput
DeletePreventableCreateInput
HostnameInput
*ServerConfigs
apis.EncryptedResourceCreateInput
// 虚拟机内存大小,单位Mb,若未指定instance_type,此参数为必传项
VmemSize int `json:"vmem_size"`
EnableMemclean bool `json:"enable_memclean"`
// 虚拟机Cpu大小,若未指定instance_type,此参数为必传项
// default: 1
VcpuCount int `json:"vcpu_count"`
// cpu卡槽数
// 目前仅vmware支持此参数
// default: 1
CpuSockets int `json:"cpu_sockets"`
// 额外分配 cpu 数量
// required: false
ExtraCpuCount int `json:"extra_cpu_count"`
// 用户自定义启动脚本
// 支持 #cloud-config yaml 格式及shell脚本
// 支持特殊user data平台: Aliyun, Qcloud, Azure, Apsara, Ucloud
// required: false
UserData string `json:"user_data"`
// swagger:ignore
// 创建测试数据,不实际创建资源
FakeCreate bool `json:"fake_create"`
// swagger:ignore
// Deprecated
Keypair string `json:"keypair" yunion-deprecated-by:"keypair_id"`
// 秘钥对Id
// required: false
KeypairId string `json:"keypair_id"`
// 密码
// 要求: 密码长度 >= 20, 至少包含一个数字一个小写字母一个大小字母及特殊字符~`!@#$%^&*()-_=+[]{}|:';\",./<>?中的一个
// requried: false
Password string `json:"password"`
// 登录账户
// required: false
LoginAccount string `json:"login_account"`
// 使用ISO光盘启动, 仅KVM平台支持
// required: false
Cdrom string `json:"cdrom"`
CdromBootIndex *int8 `json:"cdrom_boot_index"`
// enum: ["cirros", "vmware", "qxl", "std"]
// default: std
Vga string `json:"vga"`
// 远程连接协议
// enum: ["vnc", "spice"]
// default: vnc
Vdi string `json:"vdi"`
// BIOS类型, 若镜像是Windows并且支持UEFI,则自动会设置为UEFI
// emulate: BIOS, UEFI
Bios string `json:"bios"`
EnableTpm bool `json:"enable_tpm"`
// Machine类型
// emulate: pc, q35
Machine string `json:"machine"`
// 启动顺序
// c: cdrome
// d: disk
// n: network
// example: cnd
// default: cdn
BootOrder string `json:"boot_order"`
// 启用cloud-init,需要镜像装有cloud-init服务
// default: false
EnableCloudInit bool `json:"enable_cloud_init"`
// 随机密码, 若指定password参数,此参数不生效
// 若值为false并且password为空,则表示保留镜像密码
ResetPassword *bool `json:"reset_password"`
// 关机后执行的操作
// terminate: 关机后自动删除
// enum: ["stop", "terminate", "stop_release_gpu"]
// default: stop
ShutdownBehavior string `json:"shutdown_behavior"`
// 创建后自动启动
// 部分云创建后会自动启动例如: 腾讯云, AWS, OpenStack, ZStack, Ucloud, Huawei, Azure, 天翼云
// default: false
AutoStart bool `json:"auto_start"`
DeployConfigs []*DeployConfig `json:"deploy_configs"`
DeployTelegraf bool `json:"deploy_telegraf"`
// 包年包月时长
//
//
// |平台 |是否支持 |
// |---- |------- |
// |KVM |否 |
// |ESxi |否 |
// |OpenStack |否 |
// |ZStack |否 |
// |Google |否 |
// |Azure |否 |
// |AWS |否 |
// |腾讯云 |是 |
// |Aliyun |是 |
// |Ucloud |是 |
// |Huawei |是 |
// |天翼云 |是 |
Duration string `json:"duration"`
// 是否自动续费
// default: false
AutoRenew bool `json:"auto_renew"`
// swagger:ignore
AutoPrepaidRecycle bool `json:"auto_prepaid_recycle,omitfalse"`
// 弹性公网IP带宽
// 指定此参数后会创建新的弹性公网IP并绑定到新建的虚拟机
// 此参数优先级低于public_ip
EipBw int `json:"eip_bw,omitzero"`
// 弹性公网IP上行带宽
EipTxBw int `json:"eip_tx_bw,omitzero"`
// 弹性公网IP下行带宽
EipRxBw int `json:"eip_rx_bw,omitzero"`
// 弹性公网IP线路类型
EipBgpType string `json:"eip_bgp_type,omitzero"`
// 弹性公网IP计费类型
EipChargeType billing_api.TNetChargeType `json:"eip_charge_type,omitempty"`
// 是否跟随主机删除而自动释放
EipAutoDellocate bool `json:"eip_auto_dellocate,omitempty"`
// 弹性公网IP名称或ID
// 绑定已有弹性公网IP, 此参数会限制虚拟机再谈下公网IP所在的区域创建
// required: false
Eip string `json:"eip,omitempty"`
// 公网IP带宽(单位MB)
// 若指定此参数则忽略eip相关参数
// 私有云不支持此参数
//
//
// |平台 |支持范围 |
// |---- |------- |
// |腾讯云 |按量计费1-100, 包年包月1-200 |
PublicIpBw int `json:"public_ip_bw,omitzero"`
// 公网IP计费类型
// 默认按流量计费
//
//
// |类别 |说明 |
// |---- |------- |
// |traffic |按流量计费|
// |bandwidth |按带宽计费|
PublicIpChargeType billing_api.TNetChargeType `json:"public_ip_charge_type,omitempty"`
// 使用主机快照创建虚拟机, 主机快照不会重置密码及秘钥信息
// 使用主机快照创建的虚拟机将沿用之前的密码秘钥及安全组信息
// required: false
InstanceSnapshotId string `json:"instance_snapshot_id,omitempty"`
// 使用主机备份创建虚拟机, 主机快照不会重置密码及秘钥信息
// 使用主机备份创建的虚拟机将沿用之前的密码秘钥及安全组信息
// required: false
InstanceBackupId string `json:"instance_backup_id,omitempty"`
// 安全组Id, 此参数会和secgroups参数合并
SecgroupId string `json:"secgrp_id"`
// 安全组Id列表
Secgroups []string `json:"secgroups"`
// GCP 网络标记(network tags),仅对 Google 云有效
// 传入后可不指定安全组,创建时直接作为实例 tags 下发
// required: false
NetworkTags []string `json:"network_tags"`
// swagger:ignore
OsType string `json:"os_type"`
// swagger:ignore
OsArch string `json:"os_arch"`
// swagger:ignore
DisableUsbKbd bool `json:"disable_usb_kbd"`
// swagger:ignore
OsProfile jsonutils.JSONObject `json:"__os_profile__"`
// swagger:ignore
BillingType billing_api.TBillingType `json:"billing_type"`
// swagger:ignore
BillingCycle string `json:"billing_cycle"`
// 到期释放时间
ReleaseAt time.Time `json:"release_at"`
// swagger:ignore
// Deprecated
// 此参数等同于 hypervisor=baremetal
Baremetal bool `json:"baremetal"`
// Used to store BaremetalConvertHypervisorTaskId
ParentTaskId string `json:"__parent_task_id,omitempty"`
// 指定系统盘默认存储类型, 如果指定宿主机
// swagger:ignore
DefaultStorageType string `json:"default_storage_type,omitempty"`
// 指定用于新建主机的主机镜像ID
GuestImageID string `json:"guest_image_id"`
// Kickstart/Autoinstall自动化安装配置
// required: false
KickstartConfig *KickstartConfig `json:"kickstart_config,omitempty"`
Pod *PodCreateInput `json:"pod"`
}
func (c *KickstartConfig) IsEnabled() bool {
if c.Enabled != nil && !*c.Enabled {
return false
}
return true
}
// ServerUpdateKickstartStatusInput 更新虚拟机 kickstart 状态的输入
type ServerUpdateKickstartStatusInput struct {
// kickstart 状态
// enum: ["kickstart_pending", "kickstart_installing", "kickstart_completed", "kickstart_failed"]
// required: true
Status string `json:"status" validate:"required,oneof=kickstart_pending kickstart_installing kickstart_completed kickstart_failed"`
// 错误信息(可选)
// required: false
ErrorMessage string `json:"error_message,omitempty"`
}
func (input *ServerCreateInput) AfterUnmarshal() {
if input.Baremetal {
input.Hypervisor = HYPERVISOR_BAREMETAL
}
}
type ServerCloneInput struct {
apis.Meta
Name string `json:"name"`
AutoStart bool `json:"auto_start"`
EipBw int `json:"eip_bw,omitzero"`
EipChargeType string `json:"eip_charge_type,omitempty"`
Eip string `json:"eip,omitempty"`
PreferHostId string `json:"prefer_host_id"`
}
type GuestBatchMigrateRequest struct {
apis.Meta
GuestIds []string `json:"guest_ids"`
PreferHostId string `json:"prefer_host_id"`
// Deprecated
// swagger:ignore
PreferHost string `json:"prefer_host" yunion-deprecated-by:"prefer_host_id"`
SkipCpuCheck bool `json:"skip_cpu_check"`
SkipKernelCheck bool `json:"skip_kernel_check"`
EnableTLS *bool `json:"enable_tls"`
MaxBandwidthMb *int64 `json:"max_bandwidth_mb"`
QuciklyFinish *bool `json:"quickly_finish"`
}
type GuestBatchMigrateParams struct {
Id string `json:"id"`
LiveMigrate bool `json:"live_migrate"`
SkipCpuCheck bool `json:"skip_cpu_check"`
SkipKernelCheck bool `json:"skip_kernel_check"`
EnableTLS *bool `json:"enable_tls"`
RescueMode bool `json:"rescue_mode"`
OldStatus string `json:"old_status"`
MaxBandwidthMb *int64 `json:"max_bandwidth_mb"`
QuciklyFinish *bool `json:"quickly_finish"`
}
type HostLoginInfo struct {
apis.Meta
Username string `json:"username"`
Password string `json:"password"`
Ip string `json:"ip"`
}