github.com/chnsz/golangsdk@v0.0.0-20240506093406-85a3fbfa605b/openstack/sms/v3/sources/results.go (about) 1 package sources 2 3 import "github.com/chnsz/golangsdk/pagination" 4 5 // SourceServerPage is a single page result representing a query by offset page. 6 type SourceServerPage struct { 7 pagination.OffsetPageBase 8 } 9 10 // IsEmpty checks whether a SourceServerPage struct is empty. 11 func (r SourceServerPage) IsEmpty() (bool, error) { 12 servers, err := ExtractSourceServers(r) 13 return len(servers) == 0, err 14 } 15 16 // ExtractSourceServers is a method to extract the list of source servers details. 17 func ExtractSourceServers(r pagination.Page) ([]SourceServer, error) { 18 var s struct { 19 Servers []SourceServer `json:"source_servers"` 20 } 21 22 rst := r.(SourceServerPage).Result 23 err := rst.ExtractInto(&s) 24 if err != nil { 25 return nil, err 26 } 27 28 return s.Servers, nil 29 } 30 31 // SourceServer 源端服务器列表信息 32 type SourceServer struct { 33 // 源端服务器id 34 Id string `json:"id"` 35 // 源端服务器的ip地址 36 Ip string `json:"ip"` 37 // 源端服务器名称 38 Name string `json:"name"` 39 // 源端服务器状态 40 State string `json:"state"` 41 // 源端服务器与主机迁移服务端是否连接 42 Connected bool `json:"connected"` 43 // 源端服务器的注册时间 44 AddDate int64 `json:"add_date"` 45 // Agent 版本 46 AgentVersion string `json:"agent_version"` 47 // 操作系统类型: WINDOWS/LINUX 48 OsType string `json:"os_type"` 49 // 系统详细版本号,如CENTOS7.6等 50 OsVersion string `json:"os_version"` 51 // 是否是OEM操作系统(Windows) 52 OemSystem bool `json:"oem_system"` 53 // 企业项目id 54 EnterpriseProjectId string `json:"enterprise_project_id"` 55 // 源端CPU核心数 56 CPU int `json:"cpu_quantity"` 57 // 源端物理内存大小(单位:字节) 58 Memory int64 `json:"memory"` 59 // 源端列表中关联的任务 60 CurrentTask Task `json:"current_task"` 61 // 源端校验检查项列表 62 Checks []Check `json:"checks"` 63 // 推荐的目的端服务器配置 64 InitTargetServer InitTargetServer `json:"init_target_server"` 65 // 迁移周期 66 MigrationCycle string `json:"migration_cycle"` 67 // 已复制的大小(单位:字节) 68 Replicatesize int64 `json:"replicatesize"` 69 // 需要迁移的数据量总大小(单位:字节) 70 Totalsize int64 `json:"totalsize"` 71 // 迁移周期(migration_cycle)上一次变化的时间 72 StageActionTime int64 `json:"stage_action_time"` 73 // Agent上一次连接状态发生变化的时间 74 LastVisitTime int64 `json:"last_visit_time"` 75 // 源端状态(state)上次发生变化的时间 76 StateActionTime int64 `json:"state_action_time"` 77 } 78 79 // Task 源端列表中关联的任务 80 type Task struct { 81 // 任务id 82 Id string `json:"id"` 83 // 任务名称 84 Name string `json:"name"` 85 // 任务类型 86 Type string `json:"type"` 87 // 任务状态 88 State string `json:"state"` 89 // 预估结束时间 90 EstimateCompleteTime int64 `json:"estimate_complete_time"` 91 // 开始时间 92 StartDate int64 `json:"start_date"` 93 // 限速 94 SpeedLimit float32 `json:"speed_limit"` 95 // 迁移速率 96 MigrateSpeed float32 `json:"migrate_speed"` 97 // 压缩率 98 CompressRate float32 `json:"compress_rate"` 99 // 是否启动虚拟机 100 StartTargetServer bool `json:"start_target_server"` 101 // 虚拟机模板id 102 VmTemplateId string `json:"vm_template_id"` 103 // region_id 104 RegionId string `json:"region_id"` 105 // 项目名称 106 ProjectName string `json:"project_name"` 107 // 项目id 108 ProjectId string `json:"project_id"` 109 // 目的端 110 TargetServer TargetServer `json:"target_server"` 111 // 克隆服务器端 112 CloneServer CloneServer `json:"clone_server"` 113 // 日志收集状态 114 LogCollectStatus string `json:"log_collect_status"` 115 // 是否使用已有虚拟机 116 ExistServer bool `json:"exist_server"` 117 // 是否使用公网ip 118 UsePublicIp bool `json:"use_public_ip"` 119 // 已迁移时长 120 RemainSeconds int64 `json:"remain_seconds"` 121 } 122 123 // TargetServer 目的端 124 type TargetServer struct { 125 // 目的端服务器ID 126 VmId string `json:"vm_id"` 127 // 目的端服务器名称 128 Name string `json:"name"` 129 } 130 131 // CloneServer 克隆服务器类 132 type CloneServer struct { 133 // 克隆服务器ID 134 VmId string `json:"vm_id"` 135 // 克隆虚拟机的名称 136 Name string `json:"name"` 137 // 克隆错误信息 138 CloneError string `json:"clone_error"` 139 // 克隆状态 140 CloneState string `json:"clone_state"` 141 // 克隆错误信息描述 142 ErrorMsg string `json:"error_msg"` 143 } 144 145 // Check 源端校验项 146 type Check struct { 147 // 该检查项的ID 148 Id int `json:"id"` 149 // 参数 150 Params []string `json:"params"` 151 // 检查项名称 152 Name string `json:"name"` 153 // 检查结果 154 Result string `json:"result"` 155 // 检查不通过的错误码 156 ErrorCode string `json:"error_code"` 157 // 检查不通过的错误参数 158 ErrorParams string `json:"error_params"` 159 } 160 161 // InitTargetServer 推荐的目的端服务器配置 162 type InitTargetServer struct { 163 // 推荐的目的端服务器的磁盘信息 164 Disks []ServerDisk `json:"disks"` 165 } 166 167 // ServerDisk 目的端服务器关联磁盘 168 type ServerDisk struct { 169 // 磁盘名称 170 Name string `json:"name"` 171 // 磁盘大小,单位:字节 172 Size int64 `json:"size"` 173 // 磁盘的作用 174 DeviceUse string `json:"device_use"` 175 // 逻辑卷信息 176 PhysicalVolumes []PhysicalVolumes `json:"physical_volumes"` 177 } 178 179 // PhysicalVolumes 物理分区 180 type PhysicalVolumes struct { 181 // 分区类型 182 DeviceType string `json:"device_use"` 183 // 文件系统 184 FileSystem string `json:"file_system"` 185 // 编号 186 Index int `json:"index"` 187 // 挂载点 188 MountPoint string `json:"mount_point"` 189 // 名称 190 Name string `json:"name"` 191 // 大小 192 Size int64 `json:"size"` 193 // 使用大小 194 UsedSize int64 `json:"used_size"` 195 // uuid 196 UUID string `json:"uuid"` 197 }