// 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" cloudmux "yunion.io/x/cloudmux/pkg/apis/compute" "yunion.io/x/jsonutils" "yunion.io/x/onecloud/pkg/apis" billing_api "yunion.io/x/onecloud/pkg/apis/billing" "yunion.io/x/onecloud/pkg/cloudcommon/types" ) type HostSpec struct { apis.Meta Cpu int `json:"cpu"` Mem int `json:"mem"` NicCount int `json:"nic_count"` Manufacture string `json:"manufacture"` Model string `json:"model"` Disk DiskDriverSpec `json:"disk"` Driver string `json:"driver"` IsolatedDevices []IsolatedDeviceSpec `json:"isolated_devices"` } type IsolatedDeviceSpec struct { apis.Meta DevType string `json:"dev_type"` Model string `json:"model"` PciId string `json:"pci_id"` Vendor string `json:"vendor"` } type DiskDriverSpec map[string]DiskAdapterSpec type DiskAdapterSpec map[string][]*DiskSpec type DiskSpec struct { apis.Meta Type string `json:"type"` Size int64 `json:"size"` StartIndex int `json:"start_index"` EndIndex int `json:"end_index"` Count int `json:"count"` } type HostListInput struct { apis.EnabledStatusInfrasResourceBaseListInput apis.ExternalizedResourceBaseListInput ManagedResourceListInput ZonalFilterListInput WireFilterListInput SchedtagFilterListInput StorageFilterListInput UsableResourceListInput BackupstorageFilterListInput // filter by ResourceType ResourceType string `json:"resource_type"` // filter by mac of any network interface AnyMac string `json:"any_mac"` // filter by ip of any network interface AnyIp []string `json:"any_ip"` // filter storages not attached to this host StorageNotAttached *bool `json:"storage_not_attached"` // filter by Hypervisor Hypervisor string `json:"hypervisor"` // filter host that is empty IsEmpty *bool `json:"is_empty"` // filter host that is baremetal Baremetal *bool `json:"baremetal"` // 机架 Rack []string `json:"rack"` // 机位 Slots []string `json:"slots"` // 管理口MAC AccessMac []string `json:"access_mac"` // 管理口Ip地址 AccessIp []string `json:"access_ip"` // 公网IP地址 PublicIp []string `json:"public_ip"` // 物理机序列号信息 SN []string `json:"sn"` // CPU大小 CpuCount []int `json:"cpu_count"` // 内存大小,单位Mb MemSize []int `json:"mem_size"` // 存储类型(磁盘类型,sdd, rotate, hybrid) StorageType []string `json:"storage_type"` // 宿主机绑定存储类型 HostStorageType []string `json:"host_storage_type"` // IPMI地址 IpmiIp []string `json:"ipmi_ip"` // 宿主机状态 // example: online HostStatus []string `json:"host_status"` // 宿主机类型 HostType []string `json:"host_type"` // host服务软件版本 Version []string `json:"version"` // OVN软件版本 OvnVersion []string `json:"ovn_version"` // 是否处于维护状态 IsMaintenance *bool `json:"is_maintenance"` // 是否为导入的宿主机 IsImport *bool `json:"is_import"` // 是否允许PXE启动 EnablePxeBoot *bool `json:"enable_pxe_boot"` // 主机UUID Uuid []string `json:"uuid"` // 主机启动模式, 可能值位PXE和ISO BootMode []string `json:"boot_mode"` // 虚拟机所在的二层网络 ServerIdForNetwork string `json:"server_id_for_network"` // 宿主机 cpu 架构 CpuArchitecture []string `json:"cpu_architecture"` OsArch []string `json:"os_arch"` // 按虚拟机数量排序 // enum: ["asc","desc"] OrderByServerCount string `json:"order_by_server_count"` // 按存储大小排序 // enmu: asc,desc OrderByStorage string `json:"order_by_storage"` // 按存储超分率排序 // enmu: asc,desc OrderByStorageCommitRate string `json:"order_by_storage_commit_rate"` // 按cpu超分率排序 // enmu: asc,desc OrderByCpuCommitRate string `json:"order_by_cpu_commit_rate"` // 按内存超分率排序 // enmu: asc,desc OrderByMemCommitRate string `json:"order_by_mem_commit_rate"` // 按本地存储分配大小排序 // enmu: asc,desc OrderByStorageUsed string `json:"order_by_storage_used"` // 按cpu分配大小排序 // enmu: asc,desc OrderByCpuCommit string `json:"order_by_cpu_commit"` // 按内存分配大小排序 // enmu: asc,desc OrderByMemCommit string `json:"order_by_mem_commit"` // 按物理cpu使用率排序 // enmu: asc,desc OrderByCpuUsage string `json:"order_by_cpu_usage"` // 按物理内存使用率排序 // enmu: asc,desc OrderByMemUsage string `json:"order_by_mem_usage"` // 按物理存储使用率排序 // enmu: asc,desc OrderByStorageUsage string `json:"order_by_storage_usage"` // 按虚拟内存使用率排序 // enmu: asc,desc OrderByVirtualMemUsage string `json:"order_by_virtual_mem_usage"` // 按虚拟cpu使用率排序 // enmu: asc,desc OrderByVirtualCpuUsage string `json:"order_by_virtual_cpu_usage"` // 按虚拟存储使用率排序 // enmu: asc,desc OrderByVirtualStorageUsage string `json:"order_by_virtual_storage_usage"` } type HostDetails struct { apis.EnabledStatusInfrasResourceBaseDetails ManagedResourceInfo ZoneResourceInfo SHost Schedtags []SchedtagShortDescDetails `json:"schedtags"` ServerId string `json:"server_id"` Server string `json:"server"` ServerIps string `json:"server_ips"` ServerPendingDeleted bool `json:"server_pending_deleted"` // 网卡数量 NicCount int `json:"nic_count"` // 网卡详情 NicInfo []*types.SNic `json:"nic_info"` // CPU超分比 CpuCommit int `json:"cpu_commit"` // 内存超分比 MemCommit int `json:"mem_commit"` // 云主机数量 // example: 10 Guests int `json:"guests,allowempty"` // 主备云主机数量 // example: 10 BackupGuests int `json:"backup_guests,allowempty"` // 非系统云主机数量 // example: 0 NonsystemGuests int `json:"nonsystem_guests,allowempty"` // 运行状态云主机数量 // example: 2 RunningGuests int `json:"running_guests,allowempty"` // 关机状态云主机数量 // example: 2 ReadyGuests int `json:"ready_guests,allowempty"` // 其他状态云主机数量 // example: 2 OtherGuests int `json:"other_guests,allowempty"` // 回收站中云主机数量 // example: 2 PendingDeletedGuests int `json:"pending_deleted_guests,allowempty"` // CPU超分率 CpuCommitRate float64 `json:"cpu_commit_rate"` // 内存超分率 MemCommitRate float64 `json:"mem_commit_rate"` // CPU超售比 CpuCommitBound float32 `json:"cpu_commit_bound"` // 内存超售比 MemCommitBound float32 `json:"mem_commit_bound"` // 存储大小 Storage int64 `json:"storage"` // 已使用存储大小 StorageUsed int64 `json:"storage_used"` // 实际已使用存储大小 ActualStorageUsed int64 `json:"actual_storage_used"` // 浪费存储大小(异常磁盘存储大小) StorageWaste int64 `json:"storage_waste"` // 虚拟存储大小 StorageVirtual int64 `json:"storage_virtual"` // 可用存储大小 StorageFree int64 `json:"storage_free"` // 存储超分率 StorageCommitRate float64 `json:"storage_commit_rate"` Spec *jsonutils.JSONDict `json:"spec"` IsPrepaidRecycle bool `json:"is_prepaid_recycle"` CanPrepare bool `json:"can_prepare"` PrepareFailReason string `json:"prepare_fail_reason"` // 允许开启宿主机健康检查 AllowHealthCheck bool `json:"allow_health_check"` AutoMigrateOnHostDown bool `json:"auto_migrate_on_host_down"` AutoMigrateOnHostShutdown bool `json:"auto_migrate_on_host_shutdown"` // reserved resource for isolated device ReservedResourceForGpu *IsolatedDeviceReservedResourceInput `json:"reserved_resource_for_gpu"` // isolated device count IsolatedDeviceCount int `json:"isolated_device_count"` IsolatedDeviceTypeCount map[string]int `json:"isolated_device_type_count"` GuestPinnedCpus []int `json:"guest_pinned_cpus"` // host init warnning SysWarn string `json:"sys_warn"` // host init error info SysError string `json:"sys_error"` HostFiles []string `json:"host_files"` } func (self HostDetails) GetMetricTags() map[string]string { ret := map[string]string{ "id": self.Id, "host_id": self.Id, "host_ip": self.AccessIp, "host": self.Name, "zone": self.Zone, "zone_id": self.ZoneId, "zone_ext_id": self.ZoneExtId, "status": self.Status, "cloudregion": self.Cloudregion, "cloudregion_id": self.CloudregionId, "region_ext_id": self.RegionExtId, "brand": self.Brand, "domain_id": self.DomainId, "project_domain": self.ProjectDomain, "account": self.Account, "res_type": "host", "account_id": self.AccountId, "external_id": self.ExternalId, } return AppendMetricTags(ret, self.MetadataResourceInfo) } func (self HostDetails) GetMetricPairs() map[string]string { ret := map[string]string{} return ret } type HostInfo struct { // 宿主机ID Id string `json:"id"` // 宿主机名称 Name string `json:"name"` ResourceType string `json:"resource_type"` // 宿主机序列号 SN string `json:"sn"` // 宿主是否启用 Enabled bool `json:"enabled"` // 宿主机状态 Status string `json:"status"` // 宿主机计费类型 BillingType string `json:"billing_type"` // 宿主机服务状态` HostStatus string `json:"host_status"` // 宿主机类型 HostType string `json:"host_type"` // 宿主机管理IP AccessIp string `json:"access_ip"` // 宿主机公网IP(如果有) PublicIp string `json:"public_ip"` // 宿主机MAC AccessMac string `json:"access_mac"` } type HostResourceInfo struct { // 归属云订阅ID ManagerId string `json:"manager_id"` ManagedResourceInfo // 归属可用区ID ZoneId string `json:"zone_id"` ZoneResourceInfo // 宿主机名称 Host string `json:"host"` // 宿主机序列号 HostSN string `json:"host_sn"` // 宿主是否启用 HostEnabled bool `json:"host_enabled"` // 宿主机状态 HostStatus string `json:"host_status"` HostResourceType string `json:"host_resource_type"` // 宿主机计费类型 HostBillingType billing_api.TBillingType `json:"host_billing_type"` // 宿主机服务状态` HostServiceStatus string `json:"host_service_status"` // 宿主机类型 HostType string `json:"host_type"` // 宿主机管理IP HostAccessIp string `json:"host_access_ip"` // 宿主机公网IP(如果有) HostEIP string `json:"host_eip"` // 宿主机MAC HostAccessMac string `json:"host_access_mac"` } type HostFilterListInput struct { ZonalFilterListInput ManagedResourceListInput HostFilterListInputBase } type HostFilterListInputBase struct { HostResourceInput // 以宿主机序列号过滤 HostSN []string `json:"host_sn"` // 以宿主机对接二层网络过滤 HostWireId string `json:"host_wire_id"` // 以宿主机名称排序 OrderByHost string `json:"order_by_host"` // 以宿主机序列号名称排序 OrderByHostSN string `json:"order_by_host_sn"` } type HostResourceInput struct { // 宿主机或物理机(ID或Name) HostId string `json:"host_id"` // swagger:ignore // Deprecated // filter by host_id Host string `json:"host" yunion-deprecated-by:"host_id"` } type HostRegisterMetadata struct { apis.Meta OnKubernetes bool `json:"on_kubernetes"` Hostname string `json:"hostname"` SysError string `json:"sys_error,allowempty"` SysWarn string `json:"sys_warn,allowempty"` RootPartitionTotalCapacityMB int64 `json:"root_partition_total_capacity_mb"` RootPartitionUsedCapacityMB int64 `json:"root_partition_used_capacity_mb"` } type HostAccessAttributes struct { // 物理机管理URI ManagerUri string `json:"manager_uri"` // 物理机管理口IP AccessIp string `json:"access_ip"` // 物理机管理口MAC AccessMac string `json:"access_mac"` // 物理机管理口IP子网 AccessNet string `json:"access_net"` // 物理机管理口二次网络 AccessWire string `json:"access_wire"` // 公网IP PublicIp *string `json:"public_ip"` } type HostSizeAttributes struct { // CPU核数 CpuCount *int `json:"cpu_count"` // 物理CPU颗数 NodeCount *int8 `json:"node_count"` // CPU描述信息 CpuDesc string `json:"cpu_desc"` // CPU频率 CpuMhz *int `json:"cpu_mhz"` // CPU缓存大小,单位KB CpuCache string `json:"cpu_cache"` // 预留CPU大小 CpuReserved *int `json:"cpu_reserved"` // CPU超分比 CpuCmtbound *float32 `json:"cpu_cmtbound"` // CPUMicrocode CpuMicrocode string `json:"cpu_microcode"` // CPU架构 CpuArchitecture string `json:"cpu_architecture"` // KVM 允许单台虚机最大 vcpu 个数 KvmCapMaxVcpu *int `json:"kvm_cap_max_vcpu"` // 内存大小(单位MB) MemSize string `json:"mem_size"` // 预留内存大小(单位MB) MemReserved string `json:"mem_reserved"` // 内存超分比 MemCmtbound *float32 `json:"mem_cmtbound"` // 页大小 PageSizeKB *int `json:"page_size_kb"` // 存储大小,单位Mb StorageSize *int `json:"storage_size"` // 存储类型 StorageType string `json:"storage_type"` // 存储驱动类型 StorageDriver string `json:"storage_driver"` // 存储详情 StorageInfo jsonutils.JSONObject `json:"storage_info"` } type HostIpmiAttributes struct { // username IpmiUsername string `json:"ipmi_username"` // password IpmiPassword string `json:"ipmi_password"` // ip address IpmiIpAddr string `json:"ipmi_ip_addr"` // presence IpmiPresent *bool `json:"ipmi_present"` // lan channel IpmiLanChannel *uint8 `json:"ipmi_lan_channel"` // verified IpmiVerified *bool `json:"ipmi_verified"` // Redfish API support IpmiRedfishApi *bool `json:"ipmi_redfish_api"` // Cdrom boot support IpmiCdromBoot *bool `json:"ipmi_cdrom_boot"` // ipmi_pxe_boot IpmiPxeBoot *bool `json:"ipmi_pxe_boot"` } type HostCreateInput struct { apis.EnabledStatusInfrasResourceBaseCreateInput ZoneResourceInput HostnameInput HostAccessAttributes HostSizeAttributes HostIpmiAttributes // 新建带IPMI信息的物理机时不进行IPMI信息探测 NoProbe *bool `json:"no_probe"` // 物理机不带 BMC 控制器 NoBMC bool `json:"no_bmc"` // host uuid Uuid string `json:"uuid"` // Host类型 HostType string `json:"host_type"` // 是否为裸金属 IsBaremetal *bool `json:"is_baremetal"` // 机架 Rack string `json:"rack"` // 机位 Slots string `json:"slots"` // 系统信息 SysInfo jsonutils.JSONObject `json:"sys_info"` // 物理机序列号信息 SN string `json:"sn"` // host服务软件版本 Version string `json:"version"` // OVN软件版本 OvnVersion string `json:"ovn_version"` // 是否为导入的宿主机 IsImport *bool `json:"is_import"` // 是否允许PXE启动 EnablePxeBoot *bool `json:"enable_pxe_boot"` // 主机启动模式, 可能值位PXE和ISO BootMode string `json:"boot_mode"` } type HostUpdateInput struct { apis.EnabledStatusInfrasResourceBaseUpdateInput HostAccessAttributes HostSizeAttributes HostIpmiAttributes HostnameInput // IPMI info IpmiInfo jsonutils.JSONObject `json:"ipmi_info"` // 机架 Rack string `json:"rack"` // 机位 Slots string `json:"slots"` // 系统信息 SysInfo jsonutils.JSONObject `json:"sys_info"` // 物理机序列号信息 SN string `json:"sn"` // 宿主机类型 HostType string `json:"host_type"` // host服务软件版本 Version string `json:"version"` // OVN软件版本 OvnVersion string `json:"ovn_version"` // 是否为裸金属 IsBaremetal *bool `json:"is_baremetal"` // 是否允许PXE启动 EnablePxeBoot *bool `json:"enable_pxe_boot"` // 主机UUID Uuid string `json:"uuid"` // 主机启动模式, 可能值位PXE和ISO BootMode string `json:"boot_mode"` EnableNumaAllocate *bool `json:"enable_numa_allocate"` } type HostOfflineInput struct { UpdateHealthStatus *bool `json:"update_health_status"` Reason string `json:"reason"` } type SHostStorageStat struct { StorageId string `json:"storage_id"` CapacityMb int64 `json:"capacity_mb"` ActualCapacityUsedMb int64 `json:"actual_capacity_used_mb"` } type SHostPingInput struct { WithData bool `json:"with_data"` MemoryUsedMb int `json:"memory_used_mb"` CpuUsagePercent float64 `json:"cpu_usage_percent"` RootPartitionUsedCapacityMb int `json:"root_partition_used_capacity_mb"` StorageStats []SHostStorageStat `json:"storage_stats"` QgaRunningGuestIds []string `json:"qga_running_guests"` } type SKmsgEntry struct { Level int `json:"level"` Seq int `json:"sql"` Message string `json:"message"` Time time.Time `json:"time"` } type SHostReportDmesgInput struct { Entries []SKmsgEntry `json:"entries"` } type HostReserveCpusInput struct { Cpus string `json:"cpus"` Mems string `json:"mems"` DisableSchedLoadBalance *bool `json:"disable_sched_load_balance"` ProcessesPrefix []string `json:"processes_prefix"` } type HostAutoMigrateInput struct { AutoMigrateOnHostDown string `json:"auto_migrate_on_host_down"` AutoMigrateOnHostShutdown string `json:"auto_migrate_on_host_shutdown"` } type HostNetifInput struct { Mac string `json:"mac"` VlanId int `json:"vlan_id"` } type HostAddNetifInput struct { HostNetifInput // Deprecated Wire string `json:"wire" yunion-deprecated-by:"wire_id"` WireId string `json:"wire_id"` IpAddr string `json:"ip_addr"` Rate int `json:"rate"` NicType cloudmux.TNicType `json:"nic_type"` Index int `json:"index"` LinkUp string `json:"link_up"` Mtu int16 `json:"mtu"` Reset *bool `json:"reset"` Interface *string `json:"interface"` Bridge *string `json:"bridge"` Reserve *bool `json:"reserve"` RequireDesignatedIp *bool `json:"require_designated_ip"` Ip6Addr string `json:"ip6_addr"` RequireIpv6 *bool `json:"require_ipv6"` StrictIpv6 *bool `json:"strict_ipv6"` } type HostEnableNetifInput struct { HostNetifInput // Deprecated // swagger:ignore Network string `json:"network" yunion-deprecated-by:"network_id"` NetworkId string `json:"network_id"` IpAddr string `json:"ip_addr"` AllocDir string `json:"alloc_dir"` NetType TNetworkType `json:"net_type"` Reserve *bool `json:"reserve"` RequireDesignatedIp *bool `json:"require_designated_ip"` Ip6Addr string `json:"ip6_addr"` RequireIpv6 *bool `json:"require_ipv6"` StrictIpv6 *bool `json:"strict_ipv6"` } type HostDisableNetifInput struct { HostNetifInput Reserve *bool `json:"reserve"` } type HostRemoveNetifInput struct { HostNetifInput Reserve *bool `json:"reserve"` } type HostError struct { Type string `json:"type"` Id string `json:"id"` Name string `json:"name"` Content string `json:"content"` Time time.Time `json:"time"` } type HostSyncErrorsInput struct { HostErrors []HostError `json:"host_errors"` } type HostLoginInfoInput struct { } type HostLoginInfoOutput struct { Ip string `json:"ip"` Username string `json:"username"` Password string `json:"password"` } type HostPerformStartInput struct { } type HostSetCommitBoundInput struct { CpuCmtbound *float32 MemCmtbound *float32 } type HostUploadGuestsStatusRequest struct { GuestIds []string `json:"guest_ids"` } type HostUploadGuestStatusInput struct { apis.PerformStatusInput Containers map[string]*ContainerPerformStatusInput `json:"containers"` } type HostUploadGuestsStatusInput struct { Guests map[string]*HostUploadGuestStatusInput `json:"guests"` } type HostIsolatedDeviceNumaStatsInput struct { DevType string `json:"dev_type"` } type GuestUploadContainerStatusResponse struct { Error string `json:"error"` OK bool `json:"ok"` } type GuestUploadStatusResponse struct { Error string `json:"error"` OK bool `json:"ok"` Containers map[string]*GuestUploadContainerStatusResponse `json:"containers"` } type GuestUploadStatusesResponse struct { Guests map[string]*GuestUploadStatusResponse `json:"guests"` }