更新时间:2024-08-16 GMT+08:00

查询源端服务器列表

功能介绍

用户在源端安装并成功启动Agent后,Agent会将源端服务器信息注册在主机迁移服务中,调用该接口查询已注册的源端服务器列表信息。

调用方法

请参见如何调用API

URI

GET /v3/sources

表1 Query参数

参数

是否必选

参数类型

描述

state

String

源端服务器状态 unavailable:环境校验不通过 waiting:等待 initialize:初始化 replicate:复制 syncing:持续同步 stopping:暂停中 stopped:已暂停 deleting:删除中 error:错误 cloning:等待克隆完成 cutovering:启动目的端中 finished:启动目的端完成

枚举值:

  • unavailable

  • waiting

  • initialize

  • replicate

  • syncing

  • stopping

  • stopped

  • deleting

  • error

  • cloning

  • cutovering

  • finished

name

String

源端服务器名称

最小长度:0

最大长度:255

id

String

源端服务器ID

最小长度:0

最大长度:255

ip

String

源端服务器IP地址

最小长度:0

最大长度:255

migproject

String

迁移项目ID,填写该参数将查询迁移项目下的所有虚拟机

最小长度:0

最大长度:255

limit

Integer

每一页记录的源端服务器数量,0表示用默认值 200

最小值:0

最大值:200

缺省值:200

offset

Integer

偏移量,默认值0

最小值:0

最大值:65535

缺省值:0

migration_cycle

String

checking:检查中 setting:设置中 replicating:复制中 syncing:同步中 cutovering:启动目的端中 cutovered:启动目的端完成

最小长度:0

最大长度:255

枚举值:

  • checking

  • setting

  • replicating

  • syncing

  • cutovering

  • cutovered

connected

Boolean

查询失去连接的源端

enterprise_project_id

String

需要查询的企业项目ID

最小长度:0

最大长度:255

is_consistency_result_exist

Boolean

是否存在一致性校验结果

请求参数

表2 请求Header参数

参数

是否必选

参数类型

描述

X-Auth-Token

String

用户Token。

通过调用IAM服务获取用户Token接口获取(响应消息头中X-Subject-Token的值)。

最小长度:1

最大长度:16384

响应参数

状态码: 200

表3 响应Body参数

参数

参数类型

描述

count

Integer

符合查询条件的源端总数量,不受limit和offset影响

最小值:0

最大值:2147483647

source_servers

Array of SourceServersResponseBody objects

批量查询的源端服务器详列表

数组长度:0 - 65535

表4 SourceServersResponseBody

参数

参数类型

描述

id

String

源端服务器ID

最小长度:0

最大长度:255

ip

String

源端服务器的IP地址

最小长度:0

最大长度:255

name

String

源端服务器名称

最小长度:0

最大长度:255

enterprise_project_id

String

企业项目ID

最小长度:0

最大长度:255

add_date

Long

源端服务器的注册时间

最小值:0

最大值:9223372036854775807

os_type

String

操作系统类型,OS_TYPE (WINDOWS/LINUX)

最小长度:0

最大长度:255

枚举值:

  • WINDOWS

  • LINUX

os_version

String

系统详细版本号,如CENTOS7.6等

最小长度:0

最大长度:255

oem_system

Boolean

是否是OEM操作系统(Windows)

state

String

源端服务器状态 unavailable:环境校验不通过 waiting:等待 initialize:初始化 replicate:复制 syncing:持续同步 stopping:暂停中 stopped:已暂停 deleting:删除中 error:错误 cloning:等待克隆完成 cutovering:启动目的端中 finished:启动目的端完成

最小长度:0

最大长度:255

枚举值:

  • unavailable

  • waiting

  • initialize

  • replicate

  • syncing

  • stopping

  • stopped

  • deleting

  • error

  • cloning

  • cutovering

  • finished

connected

Boolean

源端服务器与主机迁移服务端是否连接

cpu_quantity

Integer

源端CPU核心数

最小值:0

最大值:2147483647

memory

Long

源端物理内存大小(单位:字节)

最小值:0

最大值:9223372036854775807

current_task

TaskByServerSources object

源端列表中关联的任务

checks

Array of EnvironmentCheck objects

源端校验检查项列表

数组长度:0 - 65535

init_target_server

InitTargetServer object

推荐的目的端服务器配置

replicatesize

Long

已复制的大小(单位:字节)

最小值:0

最大值:9223372036854775807

stage_action_time

Long

迁移周期(migration_cycle)上一次变化的时间

最小值:0

最大值:9223372036854775807

totalsize

Long

需要迁移的数据量总大小(单位:字节)

最小值:0

最大值:9223372036854775807

last_visit_time

Long

Agent上一次连接状态发生变化的时间

最小值:0

最大值:9223372036854775807

migration_cycle

String

迁移周期 cutovering:启动目的端中 cutovered:启动目的端完成 checking:检查中 setting:设置中 replicating:复制中 syncing:同步中

最小长度:0

最大长度:255

枚举值:

  • cutovering

  • cutovered

  • checking

  • setting

  • replicating

  • syncing

state_action_time

Long

源端状态(state)上次发生变化的时间

最小值:0

最大值:9223372036854775807

is_consistency_result_exist

Boolean

是否有一致性校验结果

缺省值:false

表5 TaskByServerSources

参数

参数类型

描述

id

String

任务ID

最小长度:1

最大长度:255

name

String

任务名称

最小长度:0

最大长度:255

type

String

任务类型

最小长度:0

最大长度:255

state

String

任务状态

最小长度:0

最大长度:255

estimate_complete_time

Long

预估结束时间

最小值:0

最大值:9223372036854775807

start_date

Long

开始时间

最小值:0

最大值:9223372036854775807

speed_limit

Integer

限速

最小值:0

最大值:10000

migrate_speed

Double

迁移速率

最小值:0

最大值:10000

compress_rate

Double

压缩率

最小值:0

最大值:10000

start_target_server

Boolean

是否启动虚拟机

vm_template_id

String

虚拟机模板ID

最小长度:0

最大长度:255

region_id

String

region_id

最小长度:0

最大长度:255

project_name

String

项目名称

最小长度:0

最大长度:255

project_id

String

项目ID

最小长度:0

最大长度:255

target_server

TargetServerById object

目的端

log_collect_status

String

日志收集状态

最小长度:0

最大长度:255

exist_server

Boolean

是否使用已有虚拟机

use_public_ip

Boolean

是否使用公网IP

clone_server

CloneServer object

克隆服务器类

remain_seconds

Long

已迁移时长

最小值:0

最大值:9223372036854775807

log_bucket

String

上传日志指定桶名称

最小长度:0

最大长度:255

log_expire

Long

分享链接有效期

最小值:300

最大值:64800

log_upload_time

Long

日志上传时间

最小值:0

最大值:9223372036854775807

log_share_url

String

分享链接url

最小长度:0

最大长度:65535

表6 TargetServerById

参数

参数类型

描述

vm_id

String

目的端服务器ID

最小长度:0

最大长度:255

name

String

目的端服务器名称

最小长度:0

最大长度:255

表7 CloneServer

参数

参数类型

描述

vm_id

String

克隆服务器ID

最小长度:0

最大长度:255

name

String

克隆虚拟机的名称

最小长度:0

最大长度:255

clone_error

String

克隆错误信息

最小长度:0

最大长度:255

clone_state

String

克隆状态

最小长度:0

最大长度:255

error_msg

String

克隆错误信息描述

最小长度:0

最大长度:1024

表8 EnvironmentCheck

参数

参数类型

描述

id

Long

该检查项的ID

最小值:0

最大值:9223372036854775807

params

Array of strings

参数

最小长度:0

最大长度:255

数组长度:0 - 65535

name

String

检查项名称

最小长度:0

最大长度:255

result

String

检查结果 OK:检查通过 WARN:警告 ERROR:检查不通过

最小长度:0

最大长度:255

枚举值:

  • OK

  • WARN

  • ERROR

error_code

String

检查不通过的错误码

最小长度:0

最大长度:255

error_or_warn

String

检查的错误或者警告

最小长度:0

最大长度:255

error_params

String

检查不通过的错误参数

最小长度:0

最大长度:255

表9 InitTargetServer

参数

参数类型

描述

disks

Array of DiskIntargetServer objects

推荐的目的端服务器的磁盘信息

数组长度:0 - 65535

volume_groups

Array of VolumeGroups objects

Linux必选,如果没有卷组,输入[]

数组长度:0 - 65535

表10 DiskIntargetServer

参数

参数类型

描述

name

String

磁盘名称

最小长度:0

最大长度:255

size

Long

磁盘大小,单位:字节

最小值:0

最大值:9223372036854775807

device_use

String

磁盘的作用 BOOT:BOOT设备 OS:系统设备 NORMAL:平常

最小长度:0

最大长度:255

枚举值:

  • BOOT

  • OS

  • NORMAL

used_size

Long

磁盘已使用大小,以字节为单位

最小值:0

最大值:9223372036854775807

physical_volumes

Array of PhysicalVolumes objects

物理卷信息

数组长度:0 - 65535

表11 PhysicalVolumes

参数

参数类型

描述

device_use

String

分区类型,普通分区,启动分区,系统分区

最小长度:0

最大长度:255

file_system

String

文件系统类型

最小长度:0

最大长度:255

index

Integer

顺序

最小值:0

最大值:2147483647

mount_point

String

挂载点

最小长度:0

最大长度:255

name

String

名称,windows表示盘符,Linux表示设备号

最小长度:0

最大长度:255

size

Long

大小

最小值:0

最大值:9223372036854775807

inode_size

Long

inode数量

最小值:0

最大值:9223372036854775807

used_size

Long

使用大小

最小值:0

最大值:9223372036854775807

uuid

String

GUID,可从源端查询

最小长度:0

最大长度:255

表12 VolumeGroups

参数

参数类型

描述

components

String

Pv信息

最小长度:0

最大长度:255

free_size

Long

剩余空间

最小值:0

最大值:9223372036854775807

logical_volumes

Array of LogicalVolumes objects

lv信息

数组长度:0 - 255

name

String

名称

最小长度:0

最大长度:255

size

Long

大小

最小值:0

最大值:9223372036854775807

表13 LogicalVolumes

参数

参数类型

描述

block_count

Integer

块数量

最小值:0

最大值:2147483647

缺省值:0

block_size

Long

块大小

最小值:0

最大值:1048576

缺省值:0

file_system

String

文件系统

最小长度:0

最大长度:255

inode_size

Integer

inode数量

最小值:0

最大值:2147483647

inode_nums

Long

inode节点数量

最小值:0

最大值:9223372036854775807

device_use

String

分区类型,普通分区,启动分区,系统分区

最小长度:0

最大长度:255

mount_point

String

挂载点

最小长度:0

最大长度:256

name

String

名称

最小长度:0

最大长度:1024

size

Long

大小

最小值:0

最大值:9223372036854775807

used_size

Long

使用大小

最小值:0

最大值:9223372036854775807

free_size

Long

剩余空间

最小值:0

最大值:9223372036854775807

状态码: 500

表14 响应Body参数

参数

参数类型

描述

error_code

String

错误码

最小长度:0

最大长度:255

error_msg

String

错误信息

最小长度:0

最大长度:1024

请求示例

查询源端列表信息,每页10个源端,查看第0页。

GET https://{endpoint}/v3/sources?limit=10&offset=0

响应示例

状态码: 200

查询源端服务器列表成功。

{
  "count" : 10,
  "source_servers" : [ {
    "id" : "xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxx0001",
    "ip" : "192.168.0.1",
    "name" : "sms-test",
    "enterprise_project_id" : 0,
    "add_date" : 1598417717000,
    "os_type" : "WINDOWS",
    "os_version" : "WINDOWS2008_R2_64BIT",
    "oem_system" : false,
    "state" : "finished",
    "connected" : true,
    "cpu_quantity" : 1,
    "memory" : 2146557952,
    "current_task" : {
      "id" : "xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxx0001",
      "name" : "MigrationTask",
      "type" : "MIGRATE_BLOCK",
      "state" : "MIGRATE_SUCCESS",
      "estimate_complete_time" : null,
      "start_date" : 1598417771000,
      "speed_limit" : 0,
      "migrate_speed" : 0.0,
      "start_target_server" : true,
      "vm_template_id" : "xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxx0001",
      "region_id" : "region_id",
      "project_name" : "project_name",
      "project_id" : "xxxxxxxxxxxxxxxxxxxxxxxx00000001",
      "target_server" : {
        "vm_id" : "xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxx0001",
        "name" : "sms-test"
      },
      "log_collect_status" : "INIT",
      "exist_server" : false,
      "use_public_ip" : true,
      "clone_server" : null,
      "remain_seconds" : null
    },
    "checks" : [ {
      "id" : 524062,
      "params" : [ "" ],
      "name" : "OS_VERSION",
      "result" : "OK",
      "error_code" : null,
      "error_params" : ""
    }, {
      "id" : 524063,
      "params" : [ "" ],
      "name" : "FIRMWARE",
      "result" : "OK",
      "error_code" : null,
      "error_params" : ""
    }, {
      "id" : 524064,
      "params" : [ "" ],
      "name" : "CPU",
      "result" : "OK",
      "error_code" : null,
      "error_params" : ""
    }, {
      "id" : 524065,
      "params" : [ "" ],
      "name" : "MEMORY",
      "result" : "OK",
      "error_code" : null,
      "error_params" : ""
    }, {
      "id" : 524066,
      "params" : [ "" ],
      "name" : "SYSTEM_ROOT",
      "result" : "OK",
      "error_code" : null,
      "error_params" : ""
    }, {
      "id" : 524067,
      "params" : [ "" ],
      "name" : "PARTITION_STYLE",
      "result" : "OK",
      "error_code" : null,
      "error_params" : ""
    }, {
      "id" : 524068,
      "params" : [ "" ],
      "name" : "FILE_SYSTEM",
      "result" : "OK",
      "error_code" : null,
      "error_params" : ""
    }, {
      "id" : 524069,
      "params" : [ "" ],
      "name" : "FREE_SPACE",
      "result" : "OK",
      "error_code" : null,
      "error_params" : ""
    }, {
      "id" : 524070,
      "params" : [ "" ],
      "name" : "OEM_SYSTEM",
      "result" : "OK",
      "error_code" : null,
      "error_params" : ""
    }, {
      "id" : 524071,
      "params" : [ "" ],
      "name" : "DRIVER_FILE",
      "result" : "OK",
      "error_code" : null,
      "error_params" : ""
    }, {
      "id" : 524072,
      "params" : [ "" ],
      "name" : "SERVICE",
      "result" : "OK",
      "error_code" : null,
      "error_params" : ""
    }, {
      "id" : 524073,
      "params" : [ "" ],
      "name" : "ACCOUNT_RIGHTS",
      "result" : "OK",
      "error_code" : null,
      "error_params" : ""
    } ],
    "init_target_server" : {
      "disks" : [ {
        "name" : "Disk 0",
        "size" : 42949672960,
        "device_use" : "OS"
      } ]
    },
    "replicatesize" : 0,
    "stage_action_time" : 1598419352959,
    "totalsize" : 0,
    "last_visit_time" : 1598434312002,
    "migration_cycle" : "cutovered",
    "state_action_time" : 1598419352959
  }, {
    "id" : "xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxx0001",
    "ip" : "192.168.0.154",
    "name" : "sms-win16",
    "add_date" : 1598417612000,
    "os_type" : "WINDOWS",
    "os_version" : "WINDOWS2016_64BIT",
    "oem_system" : false,
    "state" : "finished",
    "connected" : true,
    "cpu_quantity" : 1,
    "memory" : 2146553856,
    "current_task" : {
      "id" : "xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxx0001",
      "name" : "MigrationTask",
      "type" : "MIGRATE_BLOCK",
      "state" : "MIGRATE_SUCCESS",
      "estimate_complete_time" : null,
      "start_date" : 1598417627000,
      "speed_limit" : 0,
      "migrate_speed" : 0.0,
      "start_target_server" : true,
      "vm_template_id" : "xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxx0001",
      "region_id" : "region_id",
      "project_name" : "project_name",
      "project_id" : "xxxxxxxxxxxxxxxxxxxxxxxx00000001",
      "target_server" : {
        "vm_id" : "xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxx0001",
        "name" : "e2e-sms-win16"
      },
      "log_collect_status" : "INIT",
      "exist_server" : false,
      "use_public_ip" : true,
      "clone_server" : null,
      "remain_seconds" : null
    },
    "checks" : [ {
      "id" : 524050,
      "params" : [ "" ],
      "name" : "OS_VERSION",
      "result" : "OK",
      "error_code" : null,
      "error_params" : ""
    }, {
      "id" : 524051,
      "params" : [ "" ],
      "name" : "FIRMWARE",
      "result" : "OK",
      "error_code" : null,
      "error_params" : ""
    }, {
      "id" : 524052,
      "params" : [ "" ],
      "name" : "CPU",
      "result" : "OK",
      "error_code" : null,
      "error_params" : ""
    }, {
      "id" : 524053,
      "params" : [ "" ],
      "name" : "MEMORY",
      "result" : "OK",
      "error_code" : null,
      "error_params" : ""
    }, {
      "id" : 524054,
      "params" : [ "" ],
      "name" : "SYSTEM_ROOT",
      "result" : "OK",
      "error_code" : null,
      "error_params" : ""
    }, {
      "id" : 524055,
      "params" : [ "" ],
      "name" : "PARTITION_STYLE",
      "result" : "OK",
      "error_code" : null,
      "error_params" : ""
    }, {
      "id" : 524056,
      "params" : [ "" ],
      "name" : "FILE_SYSTEM",
      "result" : "OK",
      "error_code" : null,
      "error_params" : ""
    }, {
      "id" : 524057,
      "params" : [ "" ],
      "name" : "FREE_SPACE",
      "result" : "OK",
      "error_code" : null,
      "error_params" : ""
    }, {
      "id" : 524058,
      "params" : [ "" ],
      "name" : "OEM_SYSTEM",
      "result" : "OK",
      "error_code" : null,
      "error_params" : ""
    }, {
      "id" : 524059,
      "params" : [ "" ],
      "name" : "DRIVER_FILE",
      "result" : "OK",
      "error_code" : null,
      "error_params" : ""
    }, {
      "id" : 524060,
      "params" : [ "" ],
      "name" : "SERVICE",
      "result" : "OK",
      "error_code" : null,
      "error_params" : ""
    }, {
      "id" : 524061,
      "params" : [ "" ],
      "name" : "ACCOUNT_RIGHTS",
      "result" : "OK",
      "error_code" : null,
      "error_params" : ""
    } ],
    "init_target_server" : {
      "disks" : [ {
        "name" : "Disk 0",
        "size" : 42949672960,
        "device_use" : "OS"
      } ]
    },
    "replicatesize" : 0,
    "stage_action_time" : 1598419339661,
    "totalsize" : 0,
    "last_visit_time" : 1598434316810,
    "migration_cycle" : "cutovered",
    "state_action_time" : 1598419339661
  }, {
    "id" : "xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxx0001",
    "ip" : "192.168.77.77",
    "name" : "sms-centos",
    "add_date" : 1598417551000,
    "os_type" : "LINUX",
    "os_version" : "CENTOS_7_4_64BIT",
    "oem_system" : false,
    "state" : "error",
    "connected" : true,
    "cpu_quantity" : 1,
    "memory" : 1038716928,
    "current_task" : {
      "id" : "xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxx0001",
      "name" : "MigrationTask",
      "type" : "MIGRATE_BLOCK",
      "state" : "MIGRATE_FAIL",
      "estimate_complete_time" : null,
      "start_date" : 1598417588000,
      "speed_limit" : 0,
      "migrate_speed" : 0.0,
      "start_target_server" : true,
      "vm_template_id" : "xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxx0001",
      "region_id" : "region_id",
      "project_name" : "project_name",
      "project_id" : "xxxxxxxxxxxxxxxxxxxxxxxx00000001",
      "target_server" : {
        "vm_id" : "xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxx0001",
        "name" : "e2e-sms-centos"
      },
      "log_collect_status" : "INIT",
      "exist_server" : false,
      "use_public_ip" : true,
      "clone_server" : null,
      "remain_seconds" : null
    },
    "checks" : [ {
      "id" : 524038,
      "params" : [ "" ],
      "name" : "OS_VERSION",
      "result" : "OK",
      "error_code" : null,
      "error_params" : ""
    }, {
      "id" : 524039,
      "params" : [ "" ],
      "name" : "CPU",
      "result" : "OK",
      "error_code" : null,
      "error_params" : ""
    }, {
      "id" : 524040,
      "params" : [ "" ],
      "name" : "MEMORY",
      "result" : "OK",
      "error_code" : null,
      "error_params" : ""
    }, {
      "id" : 524041,
      "params" : [ "" ],
      "name" : "PARAVIRTUALIZATION",
      "result" : "OK",
      "error_code" : null,
      "error_params" : ""
    }, {
      "id" : 524042,
      "params" : [ "" ],
      "name" : "FIRMWARE",
      "result" : "OK",
      "error_code" : null,
      "error_params" : ""
    }, {
      "id" : 524043,
      "params" : [ "" ],
      "name" : "BOOT_LOADER",
      "result" : "OK",
      "error_code" : null,
      "error_params" : ""
    }, {
      "id" : 524044,
      "params" : [ "" ],
      "name" : "RSYNC",
      "result" : "OK",
      "error_code" : null,
      "error_params" : ""
    }, {
      "id" : 524045,
      "params" : [ "" ],
      "name" : "RAW_DEVICES",
      "result" : "OK",
      "error_code" : null,
      "error_params" : ""
    }, {
      "id" : 524046,
      "params" : [ "" ],
      "name" : "DISK_INFO",
      "result" : "OK",
      "error_code" : null,
      "error_params" : ""
    }, {
      "id" : 524047,
      "params" : [ "" ],
      "name" : "PARTITION_STYLE",
      "result" : "OK",
      "error_code" : null,
      "error_params" : ""
    }, {
      "id" : 524048,
      "params" : [ "" ],
      "name" : "FILE_SYSTEM",
      "result" : "OK",
      "error_code" : null,
      "error_params" : ""
    }, {
      "id" : 524049,
      "params" : [ "" ],
      "name" : "LINUX_BLOCK_SUPPORT",
      "result" : "OK",
      "error_code" : null,
      "error_params" : ""
    } ],
    "init_target_server" : {
      "disks" : [ {
        "name" : "/dev/vda",
        "size" : 42949672960,
        "device_use" : "BOOT"
      } ]
    },
    "replicatesize" : 42949672960,
    "stage_action_time" : 1598428182454,
    "totalsize" : 42949672960,
    "last_visit_time" : 1598434308889,
    "migration_cycle" : "syncing",
    "state_action_time" : 1598428182454
  }, {
    "id" : "xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxx0001",
    "ip" : "192.168.0.235",
    "name" : "sms-ubuntu",
    "add_date" : 1598417522000,
    "os_type" : "LINUX",
    "os_version" : "UBUNTU_18_4_64BIT",
    "oem_system" : false,
    "state" : "unavailable",
    "connected" : false,
    "cpu_quantity" : 1,
    "memory" : 1032556544,
    "current_task" : null,
    "checks" : [ ],
    "init_target_server" : {
      "disks" : [ {
        "name" : "/dev/vda",
        "size" : 42949672960,
        "device_use" : "BOOT"
      }, {
        "name" : "/dev/vdb",
        "size" : 21474836480,
        "device_use" : "NORMAL"
      } ]
    },
    "replicatesize" : 0,
    "stage_action_time" : 1598417521797,
    "totalsize" : 0,
    "last_visit_time" : 1598417521795,
    "migration_cycle" : "checking",
    "state_action_time" : null
  }, {
    "id" : "xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxx0001",
    "ip" : "192.168.178.214",
    "name" : "sms-sms2",
    "add_date" : 1598403465000,
    "os_type" : "WINDOWS",
    "os_version" : "WINDOWS2012_R2_64BIT",
    "oem_system" : false,
    "state" : "waiting",
    "connected" : false,
    "cpu_quantity" : 1,
    "memory" : 2146553856,
    "current_task" : null,
    "checks" : [ {
      "id" : 523970,
      "params" : [ "" ],
      "name" : "OS_VERSION",
      "result" : "OK",
      "error_code" : null,
      "error_params" : ""
    }, {
      "id" : 523971,
      "params" : [ "" ],
      "name" : "FIRMWARE",
      "result" : "OK",
      "error_code" : null,
      "error_params" : ""
    }, {
      "id" : 523972,
      "params" : [ "" ],
      "name" : "CPU",
      "result" : "OK",
      "error_code" : null,
      "error_params" : ""
    }, {
      "id" : 523973,
      "params" : [ "" ],
      "name" : "MEMORY",
      "result" : "OK",
      "error_code" : null,
      "error_params" : ""
    }, {
      "id" : 523974,
      "params" : [ "" ],
      "name" : "SYSTEM_ROOT",
      "result" : "OK",
      "error_code" : null,
      "error_params" : ""
    }, {
      "id" : 523975,
      "params" : [ "" ],
      "name" : "PARTITION_STYLE",
      "result" : "OK",
      "error_code" : null,
      "error_params" : ""
    }, {
      "id" : 523976,
      "params" : [ "" ],
      "name" : "FILE_SYSTEM",
      "result" : "OK",
      "error_code" : null,
      "error_params" : ""
    }, {
      "id" : 523977,
      "params" : [ "" ],
      "name" : "FREE_SPACE",
      "result" : "OK",
      "error_code" : null,
      "error_params" : ""
    }, {
      "id" : 523978,
      "params" : [ "" ],
      "name" : "OEM_SYSTEM",
      "result" : "OK",
      "error_code" : null,
      "error_params" : ""
    }, {
      "id" : 523979,
      "params" : [ "" ],
      "name" : "DRIVER_FILE",
      "result" : "OK",
      "error_code" : null,
      "error_params" : ""
    }, {
      "id" : 523980,
      "params" : [ "" ],
      "name" : "SERVICE",
      "result" : "OK",
      "error_code" : null,
      "error_params" : ""
    }, {
      "id" : 523981,
      "params" : [ "" ],
      "name" : "ACCOUNT_RIGHTS",
      "result" : "OK",
      "error_code" : null,
      "error_params" : ""
    } ],
    "init_target_server" : {
      "disks" : [ {
        "name" : "Disk 0",
        "size" : 42949672960,
        "device_use" : "OS"
      } ]
    },
    "replicatesize" : 0,
    "stage_action_time" : 1598403465315,
    "totalsize" : 0,
    "last_visit_time" : 1598403588140,
    "migration_cycle" : "checking",
    "state_action_time" : 1598403465414
  }, {
    "id" : "xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxx0001",
    "ip" : "192.168.0.1",
    "name" : "linux sources",
    "add_date" : 1598369476000,
    "os_type" : "LINUX",
    "os_version" : "REDHAT_7_3_64BIT",
    "oem_system" : false,
    "state" : "unavailable",
    "connected" : false,
    "cpu_quantity" : 4,
    "memory" : 8581140480,
    "current_task" : null,
    "checks" : [ ],
    "init_target_server" : {
      "disks" : [ {
        "name" : "sda",
        "size" : 85899345920,
        "device_use" : "BOOT|OS"
      }, {
        "name" : "sdb",
        "size" : 214748364800,
        "device_use" : "NORMAL"
      } ]
    },
    "replicatesize" : 0,
    "stage_action_time" : 1598369475726,
    "totalsize" : 0,
    "last_visit_time" : 1598369475725,
    "migration_cycle" : "checking",
    "state_action_time" : null
  }, {
    "id" : "xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxx0001",
    "ip" : "192.168.0.1",
    "name" : "linux sources",
    "add_date" : 1598351694000,
    "os_type" : "LINUX",
    "os_version" : "REDHAT_7_3_64BIT",
    "oem_system" : false,
    "state" : "unavailable",
    "connected" : false,
    "cpu_quantity" : 4,
    "memory" : 8581140480,
    "current_task" : null,
    "checks" : [ ],
    "init_target_server" : {
      "disks" : [ {
        "name" : "sda",
        "size" : 85899345920,
        "device_use" : "BOOT|OS"
      }, {
        "name" : "sdb",
        "size" : 214748364800,
        "device_use" : "NORMAL"
      } ]
    },
    "replicatesize" : 0,
    "stage_action_time" : 1598351693858,
    "totalsize" : 0,
    "last_visit_time" : 1598351693857,
    "migration_cycle" : "checking",
    "state_action_time" : null
  }, {
    "id" : "xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxx0001",
    "ip" : "192.168.0.1",
    "name" : "linux sources",
    "add_date" : 1598348080000,
    "os_type" : "LINUX",
    "os_version" : "REDHAT_7_3_64BIT",
    "oem_system" : false,
    "state" : "unavailable",
    "connected" : false,
    "cpu_quantity" : 4,
    "memory" : 8581140480,
    "current_task" : null,
    "checks" : [ ],
    "init_target_server" : {
      "disks" : [ {
        "name" : "sda",
        "size" : 85899345920,
        "device_use" : "BOOT|OS"
      }, {
        "name" : "sdb",
        "size" : 214748364800,
        "device_use" : "NORMAL"
      } ]
    },
    "replicatesize" : 0,
    "stage_action_time" : 1598348079782,
    "totalsize" : 0,
    "last_visit_time" : 1598348079781,
    "migration_cycle" : "checking",
    "state_action_time" : null
  }, {
    "id" : "xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxx0001",
    "ip" : "192.168.0.239",
    "name" : "sms-centos7",
    "add_date" : 1598326505000,
    "os_type" : "LINUX",
    "os_version" : "CENTOS_8_5_64BIT",
    "oem_system" : false,
    "state" : "unavailable",
    "connected" : false,
    "cpu_quantity" : 1,
    "memory" : 1926860800,
    "current_task" : null,
    "checks" : [ {
      "id" : 523794,
      "params" : [ "" ],
      "name" : "OS_VERSION",
      "result" : "ERROR",
      "error_code" : "SMS.6504",
      "error_params" : ""
    }, {
      "id" : 523795,
      "params" : [ "" ],
      "name" : "CPU",
      "result" : "OK",
      "error_code" : null,
      "error_params" : ""
    }, {
      "id" : 523796,
      "params" : [ "" ],
      "name" : "MEMORY",
      "result" : "OK",
      "error_code" : null,
      "error_params" : ""
    }, {
      "id" : 523797,
      "params" : [ "" ],
      "name" : "PARAVIRTUALIZATION",
      "result" : "OK",
      "error_code" : null,
      "error_params" : ""
    }, {
      "id" : 523798,
      "params" : [ "" ],
      "name" : "FIRMWARE",
      "result" : "OK",
      "error_code" : null,
      "error_params" : ""
    }, {
      "id" : 523799,
      "params" : [ "" ],
      "name" : "BOOT_LOADER",
      "result" : "OK",
      "error_code" : null,
      "error_params" : ""
    }, {
      "id" : 523800,
      "params" : [ "" ],
      "name" : "RSYNC",
      "result" : "OK",
      "error_code" : null,
      "error_params" : ""
    }, {
      "id" : 523801,
      "params" : [ "" ],
      "name" : "RAW_DEVICES",
      "result" : "OK",
      "error_code" : null,
      "error_params" : ""
    }, {
      "id" : 523802,
      "params" : [ "" ],
      "name" : "DISK_INFO",
      "result" : "OK",
      "error_code" : null,
      "error_params" : ""
    }, {
      "id" : 523803,
      "params" : [ "" ],
      "name" : "PARTITION_STYLE",
      "result" : "OK",
      "error_code" : null,
      "error_params" : ""
    }, {
      "id" : 523804,
      "params" : [ "" ],
      "name" : "FILE_SYSTEM",
      "result" : "OK",
      "error_code" : null,
      "error_params" : ""
    }, {
      "id" : 523805,
      "params" : [ "" ],
      "name" : "LINUX_BLOCK_SUPPORT",
      "result" : "OK",
      "error_code" : null,
      "error_params" : ""
    } ],
    "init_target_server" : {
      "disks" : [ {
        "name" : "/dev/vda",
        "size" : 42949672960,
        "device_use" : "BOOT"
      }, {
        "name" : "/dev/vdb",
        "size" : 42949672960,
        "device_use" : "NORMAL"
      } ]
    },
    "replicatesize" : 0,
    "stage_action_time" : 1598326505378,
    "totalsize" : 0,
    "last_visit_time" : 1598423828868,
    "migration_cycle" : "checking",
    "state_action_time" : 1598326505459
  }, {
    "id" : "xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxx0001",
    "ip" : "192.168.0.65",
    "name" : "smsc-test",
    "add_date" : 1598238727000,
    "os_type" : "LINUX",
    "os_version" : "CENTOS_6_5_64BIT",
    "oem_system" : false,
    "state" : "finished",
    "connected" : true,
    "cpu_quantity" : 1,
    "memory" : 1043931136,
    "current_task" : {
      "id" : "xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxx0001",
      "name" : "MigrationTask",
      "type" : "MIGRATE_FILE",
      "state" : "MIGRATE_SUCCESS",
      "estimate_complete_time" : null,
      "start_date" : 1598239243000,
      "speed_limit" : 0,
      "migrate_speed" : 0.0,
      "start_target_server" : true,
      "vm_template_id" : "xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxx0001",
      "region_id" : "region_id",
      "project_name" : "project_name",
      "project_id" : "xxxxxxxxxxxxxxxxxxxxxxxx00000001",
      "target_server" : {
        "vm_id" : "xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxx0001",
        "name" : "smsc-test"
      },
      "log_collect_status" : "INIT",
      "exist_server" : false,
      "use_public_ip" : true,
      "clone_server" : null,
      "remain_seconds" : null
    },
    "checks" : [ {
      "id" : 523686,
      "params" : [ "" ],
      "name" : "OS_VERSION",
      "result" : "OK",
      "error_code" : null,
      "error_params" : ""
    }, {
      "id" : 523687,
      "params" : [ "" ],
      "name" : "CPU",
      "result" : "OK",
      "error_code" : null,
      "error_params" : ""
    }, {
      "id" : 523688,
      "params" : [ "" ],
      "name" : "MEMORY",
      "result" : "OK",
      "error_code" : null,
      "error_params" : ""
    }, {
      "id" : 523689,
      "params" : [ "" ],
      "name" : "PARAVIRTUALIZATION",
      "result" : "OK",
      "error_code" : null,
      "error_params" : ""
    }, {
      "id" : 523690,
      "params" : [ "" ],
      "name" : "FIRMWARE",
      "result" : "OK",
      "error_code" : null,
      "error_params" : ""
    }, {
      "id" : 523691,
      "params" : [ "" ],
      "name" : "BOOT_LOADER",
      "result" : "OK",
      "error_code" : null,
      "error_params" : ""
    }, {
      "id" : 523692,
      "params" : [ "" ],
      "name" : "RSYNC",
      "result" : "OK",
      "error_code" : null,
      "error_params" : ""
    }, {
      "id" : 523693,
      "params" : [ "" ],
      "name" : "RAW_DEVICES",
      "result" : "OK",
      "error_code" : null,
      "error_params" : ""
    }, {
      "id" : 523694,
      "params" : [ "" ],
      "name" : "DISK_INFO",
      "result" : "OK",
      "error_code" : null,
      "error_params" : ""
    }, {
      "id" : 523695,
      "params" : [ "" ],
      "name" : "PARTITION_STYLE",
      "result" : "OK",
      "error_code" : null,
      "error_params" : ""
    }, {
      "id" : 523696,
      "params" : [ "" ],
      "name" : "FILE_SYSTEM",
      "result" : "OK",
      "error_code" : null,
      "error_params" : ""
    }, {
      "id" : 523697,
      "params" : [ "" ],
      "name" : "LINUX_BLOCK_SUPPORT",
      "result" : "WARN",
      "error_code" : "SMS.6617",
      "error_params" : ""
    } ],
    "init_target_server" : {
      "disks" : [ {
        "name" : "/dev/vda",
        "size" : 42949672960,
        "device_use" : "BOOT"
      }, {
        "name" : "/dev/vdb",
        "size" : 10737418240,
        "device_use" : "NORMAL"
      } ]
    },
    "replicatesize" : 0,
    "stage_action_time" : 1598240178677,
    "totalsize" : 0,
    "last_visit_time" : 1598434314748,
    "migration_cycle" : "cutovered",
    "state_action_time" : 1598240178677
  } ]
}

SDK代码示例

SDK代码示例如下。

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
package com.huaweicloud.sdk.test;

import com.huaweicloud.sdk.core.auth.ICredential;
import com.huaweicloud.sdk.core.auth.GlobalCredentials;
import com.huaweicloud.sdk.core.exception.ConnectionException;
import com.huaweicloud.sdk.core.exception.RequestTimeoutException;
import com.huaweicloud.sdk.core.exception.ServiceResponseException;
import com.huaweicloud.sdk.sms.v3.region.SmsRegion;
import com.huaweicloud.sdk.sms.v3.*;
import com.huaweicloud.sdk.sms.v3.model.*;


public class ListServersSolution {

    public static void main(String[] args) {
        // The AK and SK used for authentication are hard-coded or stored in plaintext, which has great security risks. It is recommended that the AK and SK be stored in ciphertext in configuration files or environment variables and decrypted during use to ensure security.
        // In this example, AK and SK are stored in environment variables for authentication. Before running this example, set environment variables CLOUD_SDK_AK and CLOUD_SDK_SK in the local environment
        String ak = System.getenv("CLOUD_SDK_AK");
        String sk = System.getenv("CLOUD_SDK_SK");

        ICredential auth = new GlobalCredentials()
                .withAk(ak)
                .withSk(sk);

        SmsClient client = SmsClient.newBuilder()
                .withCredential(auth)
                .withRegion(SmsRegion.valueOf("<YOUR REGION>"))
                .build();
        ListServersRequest request = new ListServersRequest();
        request.withState(ListServersRequest.StateEnum.fromValue("<state>"));
        request.withName("<name>");
        request.withId("<id>");
        request.withIp("<ip>");
        request.withMigproject("<migproject>");
        request.withLimit(<limit>);
        request.withOffset(<offset>);
        request.withMigrationCycle(ListServersRequest.MigrationCycleEnum.fromValue("<migration_cycle>"));
        request.withConnected(<connected>);
        request.withEnterpriseProjectId("<enterprise_project_id>");
        request.withIsConsistencyResultExist(<is_consistency_result_exist>);
        try {
            ListServersResponse response = client.listServers(request);
            System.out.println(response.toString());
        } catch (ConnectionException e) {
            e.printStackTrace();
        } catch (RequestTimeoutException e) {
            e.printStackTrace();
        } catch (ServiceResponseException e) {
            e.printStackTrace();
            System.out.println(e.getHttpStatusCode());
            System.out.println(e.getRequestId());
            System.out.println(e.getErrorCode());
            System.out.println(e.getErrorMsg());
        }
    }
}
 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
# coding: utf-8

import os
from huaweicloudsdkcore.auth.credentials import GlobalCredentials
from huaweicloudsdksms.v3.region.sms_region import SmsRegion
from huaweicloudsdkcore.exceptions import exceptions
from huaweicloudsdksms.v3 import *

if __name__ == "__main__":
    # The AK and SK used for authentication are hard-coded or stored in plaintext, which has great security risks. It is recommended that the AK and SK be stored in ciphertext in configuration files or environment variables and decrypted during use to ensure security.
    # In this example, AK and SK are stored in environment variables for authentication. Before running this example, set environment variables CLOUD_SDK_AK and CLOUD_SDK_SK in the local environment
    ak = os.environ["CLOUD_SDK_AK"]
    sk = os.environ["CLOUD_SDK_SK"]

    credentials = GlobalCredentials(ak, sk)

    client = SmsClient.new_builder() \
        .with_credentials(credentials) \
        .with_region(SmsRegion.value_of("<YOUR REGION>")) \
        .build()

    try:
        request = ListServersRequest()
        request.state = "<state>"
        request.name = "<name>"
        request.id = "<id>"
        request.ip = "<ip>"
        request.migproject = "<migproject>"
        request.limit = <limit>
        request.offset = <offset>
        request.migration_cycle = "<migration_cycle>"
        request.connected = <Connected>
        request.enterprise_project_id = "<enterprise_project_id>"
        request.is_consistency_result_exist = <IsConsistencyResultExist>
        response = client.list_servers(request)
        print(response)
    except exceptions.ClientRequestException as e:
        print(e.status_code)
        print(e.request_id)
        print(e.error_code)
        print(e.error_msg)
 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
package main

import (
	"fmt"
	"github.com/huaweicloud/huaweicloud-sdk-go-v3/core/auth/global"
    sms "github.com/huaweicloud/huaweicloud-sdk-go-v3/services/sms/v3"
	"github.com/huaweicloud/huaweicloud-sdk-go-v3/services/sms/v3/model"
    region "github.com/huaweicloud/huaweicloud-sdk-go-v3/services/sms/v3/region"
)

func main() {
    // The AK and SK used for authentication are hard-coded or stored in plaintext, which has great security risks. It is recommended that the AK and SK be stored in ciphertext in configuration files or environment variables and decrypted during use to ensure security.
    // In this example, AK and SK are stored in environment variables for authentication. Before running this example, set environment variables CLOUD_SDK_AK and CLOUD_SDK_SK in the local environment
    ak := os.Getenv("CLOUD_SDK_AK")
    sk := os.Getenv("CLOUD_SDK_SK")

    auth := global.NewCredentialsBuilder().
        WithAk(ak).
        WithSk(sk).
        Build()

    client := sms.NewSmsClient(
        sms.SmsClientBuilder().
            WithRegion(region.ValueOf("<YOUR REGION>")).
            WithCredential(auth).
            Build())

    request := &model.ListServersRequest{}
	stateRequest:= model.GetListServersRequestStateEnum().<STATE>
	request.State = &stateRequest
	nameRequest:= "<name>"
	request.Name = &nameRequest
	idRequest:= "<id>"
	request.Id = &idRequest
	ipRequest:= "<ip>"
	request.Ip = &ipRequest
	migprojectRequest:= "<migproject>"
	request.Migproject = &migprojectRequest
	limitRequest:= int32(<limit>)
	request.Limit = &limitRequest
	offsetRequest:= int32(<offset>)
	request.Offset = &offsetRequest
	migrationCycleRequest:= model.GetListServersRequestMigrationCycleEnum().<MIGRATION_CYCLE>
	request.MigrationCycle = &migrationCycleRequest
	connectedRequest:= <connected>
	request.Connected = &connectedRequest
	enterpriseProjectIdRequest:= "<enterprise_project_id>"
	request.EnterpriseProjectId = &enterpriseProjectIdRequest
	isConsistencyResultExistRequest:= <is_consistency_result_exist>
	request.IsConsistencyResultExist = &isConsistencyResultExistRequest
	response, err := client.ListServers(request)
	if err == nil {
        fmt.Printf("%+v\n", response)
    } else {
        fmt.Println(err)
    }
}

更多编程语言的SDK代码示例,请参见API Explorer的代码示例页签,可生成自动对应的SDK代码示例。

状态码

状态码

描述

200

查询源端服务器列表成功。

500

Internal Server Error

错误码

请参见错误码