Updated on 2024-07-08 GMT+08:00

Registering a Source Server with SMS

Function

This API is automatically called by the Agent to report the basic information about the source server to SMS. After the source server is registered successfully, you can view the source server information on the SMS console.

Calling Method

For details, see Calling APIs.

URI

POST /v3/sources

Request

Table 1 Request header parameter

Parameter

Mandatory

Type

Description

X-Auth-Token

Yes

String

The user token.

It can be obtained by calling the IAM API (value of X-Subject-Token in the response header).

Minimum length: 1 character

Maximum length: 16,384 characters

Table 2 Request body parameters

Parameter

Mandatory

Type

Description

id

No

String

The ID of the source server in the SMS database.

Minimum length: 0 characters

Maximum length: 255 characters

ip

Yes

String

The IP address of the source server. This parameter is mandatory for registering the source server with SMS and optional for updating the information about the source server.

Minimum length: 0 characters

Maximum length: 255 characters

name

Yes

String

The name of the source server displayed on the SMS console.

Minimum length: 0 characters

Maximum length: 255 characters

hostname

No

String

The hostname of the source server. This parameter is mandatory for registering the source server with SMS and optional for updating the information about the source server.

Minimum length: 0 characters

Maximum length: 255 characters

os_type

Yes

String

The OS type of the source server. This parameter is mandatory for registering the source server with SMS and optional for updating the information about the source server.

Minimum length: 0 characters

Maximum length: 255 characters

The value can be:

  • WINDOWS
  • LINUX

os_version

No

String

The OS version. This parameter is mandatory for registration and optional for update.

Minimum length: 0 characters

Maximum length: 255 characters

virtualization_type

No

String

The OS virtualization type.

Minimum length: 0 characters

Maximum length: 255 characters

linux_block_check

No

String

The Linux block-level check.

Minimum length: 0 characters

Maximum length: 255 characters

firmware

No

String

The boot mode.

Minimum length: 0 characters

Maximum length: 255 characters

The value can be:

  • BIOS
  • UEFI

cpu_quantity

No

Integer

The number of CPUs.

Minimum value: 0

Maximum value: 65535

memory

No

Long

The memory size (MB).

Minimum value: 0

Maximum value: 9223372036854775807

disks

No

Array of ServerDisk objects

The disk information of the source server.

Array length: 0 to 65,535 characters

btrfs_list

No

Array of BtrfsFileSystem objects

The Btrfs information on the source server. This parameter is mandatory for Linux. If there are no Btrfs file systems on the source server, the value is an empty array [].

Array length: 0 to 65,535 characters

networks

No

Array of NetWork objects

The NIC information of the source server.

Array length: 0 to 65,535 characters

domain_id

No

String

The domain ID of a tenant.

Minimum length: 0 characters

Maximum length: 255 characters

has_rsync

No

Boolean

Specifies whether rsync is installed. This parameter is mandatory for Linux.

paravirtualization

No

Boolean

Specifies whether the source server is paravirtualized. This parameter is mandatory for Linux.

raw_devices

No

String

The list of raw devices. This parameter is mandatory for Linux.

Minimum length: 0 characters

Maximum length: 255 characters

driver_files

No

Boolean

Specifies whether any driver files are missing. This parameter is mandatory for Windows.

system_services

No

Boolean

Specifies whether there are abnormal services. This parameter is mandatory for Windows.

account_rights

No

Boolean

Specifies whether the account has the required permissions. This parameter is mandatory for Windows.

boot_loader

No

String

The system boot loader. This parameter is mandatory for Linux.

The value can be:

  • GRUB
  • LILO

system_dir

No

String

The system directory. This parameter is mandatory for Windows.

Minimum length: 0 characters

Maximum length: 255 characters

volume_groups

No

Array of VolumeGroups objects

This parameter is mandatory for Linux. If there are no volume groups, the value is an empty array [].

Array length: 0 to 65,535 characters

agent_version

Yes

String

The Agent version.

Minimum length: 0 characters

Maximum length: 255 characters

kernel_version

No

String

The Kernel version.

Minimum length: 0 characters

Maximum length: 255 characters

migration_cycle

No

String

The current migration stage of the source server.

The value can be:

  • cutovering
  • cutovered
  • checking
  • setting
  • replicating
  • syncing

state

No

String

The source server status.

Minimum length: 0 characters

Maximum length: 255 characters

The value can be:

  • unavailable
  • waiting
  • initialize
  • replicate
  • syncing
  • stopping
  • stopped
  • deleting
  • error
  • cloning
  • cutovering
  • finished

oem_system

No

Boolean

Whether the OS is an OEM version (Windows).

start_type

No

String

The startup mode. The value can be MANUAL, MGC, or an empty string ("").

The value can be:

  • MANUAL
  • MGC
Table 3 ServerDisk

Parameter

Mandatory

Type

Description

name

Yes

String

The disk name.

Minimum length: 0 characters

Maximum length: 255 characters

partition_style

No

String

The disk partition type. This parameter is mandatory for source server registration.

The value can be:

  • MBR
  • GPT

device_use

Yes

String

The disk function.

The value can be:

  • BOOT
  • OS

size

Yes

Long

The disk size, in bytes.

Minimum value: 0

Maximum value: 9223372036854775807

used_size

Yes

Long

The used disk space, in bytes.

Minimum value: 0

Maximum value: 9223372036854775807

physical_volumes

Yes

Array of PhysicalVolume objects

The physical partition information of the disk.

Array length: 0 to 65,535 characters

os_disk

No

Boolean

Specifies whether the disk is the system disk.

relation_name

No

String

The name of the corresponding disk on the target server running Linux.

Minimum length: 0 characters

Maximum length: 255 characters

inode_size

No

Integer

The number of inodes.

Minimum value: 0

Maximum value: 4294967296

Table 4 PhysicalVolume

Parameter

Mandatory

Type

Description

device_use

No

String

The partition function. The value can be NORMAL, BOOT, or OS.

Minimum length: 0 characters

Maximum length: 255 characters

file_system

No

String

The file system type.

Minimum length: 0 characters

Maximum length: 255 characters

index

No

Integer

The serial number of the volume.

Minimum value: 0

Maximum value: 2147483647

mount_point

No

String

The mount point.

Minimum length: 0 characters

Maximum length: 255 characters

name

No

String

The volume name. In Windows, it indicates the drive letter, and in Linux, it indicates the device ID.

Minimum length: 0 characters

Maximum length: 255 characters

size

No

Long

The volume size.

Minimum value: 0

Maximum value: 9223372036854775807

used_size

No

Long

The used space.

Minimum value: 0

Maximum value: 9223372036854775807

inode_size

No

Integer

The number of inodes.

Minimum value: 0

Maximum value: 4294967296

uuid

No

String

The GUID of the volume, which can be obtained from the source server.

Minimum length: 0 characters

Maximum length: 255 characters

size_per_cluster

No

Integer

The size of each cluster.

Minimum value: 0

Maximum value: 2147483647

Table 5 BtrfsFileSystem field description

Parameter

Mandatory

Type

Description

name

Yes

String

The file system name.

Minimum length: 0 characters

Maximum length: 255 characters

label

Yes

String

The file system tag. If no tag exists, the value is an empty string.

Minimum length: 0 characters

Maximum length: 255 characters

The UUID.

Yes

String

The UUID of the file system.

Minimum length: 0 characters

Maximum length: 255 characters

device

Yes

String

The device name in the Btrfs.

Minimum length: 0 characters

Maximum length: 255 characters

size

Yes

Long

The space occupied by the file system.

Minimum value: 0

Maximum value: 9223372036854775807

nodesize

Yes

Long

The size of the Btrfs node.

Minimum value: 0

Maximum value: 9223372036854775807

sectorsize

Yes

Integer

The sector size.

Minimum value: 0

Maximum value: 2147483647

data_profile

Yes

String

The data profile (RAD).

Minimum length: 0 characters

Maximum length: 255 characters

system_profile

Yes

String

The file system profile (RAD).

Minimum length: 0 characters

Maximum length: 255 characters

metadata_profile

Yes

String

The metadata profile (RAD).

Minimum length: 0 characters

Maximum length: 255 characters

global_reserve1

Yes

String

The Btrfs file system information.

Minimum length: 0 characters

Maximum length: 255 characters

g_vol_used_size

Yes

Long

The used space of the Btrfs volume.

Minimum value: 0

Maximum value: 9223372036854775807

default_subvolid

Yes

String

The ID of the default subvolume.

Minimum length: 0 characters

Maximum length: 255 characters

default_subvol_name

Yes

String

The name of the default subvolume.

Minimum length: 0 characters

Maximum length: 255 characters

default_subvol_mountpath

Yes

String

The mount path of the default subvolume or Btrfs file system.

Minimum length: 0 characters

Maximum length: 255 characters

subvolume

Yes

Array of BtrfsSubvolume objects

The subvolume information.

Array length: 0 to 65,535 characters

Table 6 BtrfsSubvolumn field description

Parameter

Mandatory

Type

Description

The UUID.

Yes

String

The UUID of the parent volume.

Minimum length: 0 characters

Maximum length: 255 characters

is_snapshot

Yes

String

Specifies whether the subvolume is a snapshot.

Minimum length: 0 characters

Maximum length: 255 characters

subvol_id

Yes

String

The subvolume ID.

Minimum length: 0 characters

Maximum length: 255 characters

parent_id

Yes

String

The parent volume ID.

Minimum length: 0 characters

Maximum length: 255 characters

subvol_name

Yes

String

The subvolume name.

Minimum length: 0 characters

Maximum length: 255 characters

subvol_mount_path

Yes

String

The mount path of the subvolume.

Minimum length: 0 characters

Maximum length: 255 characters

Table 7 NetWork field description

Parameter

Mandatory

Type

Description

name

Yes

String

The NIC name.

Minimum length: 0 characters

Maximum length: 255 characters

ip

Yes

String

The IP address bound to the NIC.

Minimum length: 0 characters

Maximum length: 255 characters

netmask

Yes

String

The subnet mask.

Minimum length: 0 characters

Maximum length: 255 characters

gateway

Yes

String

The gateway.

Minimum length: 0 characters

Maximum length: 255 characters

mtu

No

Integer

The NIC MTU. This parameter is mandatory for Linux.

Minimum value: 0

Maximum value: 2147483647

mac

Yes

String

The MAC address.

Minimum length: 0 characters

Maximum length: 255 characters

id

No

String

The database ID.

Minimum length: 0 characters

Maximum length: 255 characters

Table 8 VolumeGroups field description

Parameter

Mandatory

Type

Description

components

No

String

The physical volume information.

Minimum length: 0 characters

Maximum length: 255 characters

free_size

No

Long

The available space.

Minimum value: 0

Maximum value: 9223372036854775807

logical_volumes

No

Array of LogicalVolumes objects

The logical volume information.

Array length: 0 to 255 characters

name

No

String

The volume group name.

Minimum length: 0 characters

Maximum length: 255 characters

size

No

Long

The volume size.

Minimum value: 0

Maximum value: 9223372036854775807

Table 9 LogicalVolumes field description

Parameter

Mandatory

Type

Description

block_count

No

Integer

The number of blocks.

Minimum value: 0

Maximum value: 4294967296

Default value: 0

block_size

No

Long

The block size.

Minimum value: 0

Maximum value: 1048576

Default value: 0

file_system

Yes

String

The file system.

Minimum length: 0 characters

Maximum length: 255 characters

inode_size

Yes

Integer

The number of inodes.

Minimum value: 0

Maximum value: 4294967296

device_use

No

String

The partition function. The value can be NORMAL, BOOT, or OS.

Minimum length: 0 characters

Maximum length: 255 characters

mount_point

Yes

String

The mount point.

Minimum length: 0 characters

Maximum length: 256 characters

name

Yes

String

The volume group name.

Minimum length: 0 characters

Maximum length: 1,024 characters

size

Yes

Long

The volume size.

Minimum value: 0

Maximum value: 9223372036854775807

used_size

Yes

Long

The used space.

Minimum value: 0

Maximum value: 9223372036854775807

free_size

Yes

Long

The available space.

Minimum value: 0

Maximum value: 9223372036854775807

Response

Status code: 200

Table 10 Response body parameters

Parameter

Type

Description

id

String

The source server ID.

Minimum length: 0 characters

Maximum length: 255 characters

Example Request

This example reports information about a source server to SMS. The source server runs Linux SUSE12_64BIT_SP2, with the name of host-192-168-136-xxx, the IP address of 192.168.136.xxx, the BOOT system disk named /dev/vda, and the total size of the system disk of 42949672960 bytes. After the source server is reported, it will be displayed in the SMS server list.

POST https://{endpoint}/v3/sources

{
  "os_type" : "LINUX",
  "name" : "host-192-168-136-xxx",
  "os_version" : "SUSE12_64BIT_SP2",
  "linux_block_check" : "{\"release_type\": \"SUSE\", \"release_version\": \"12.2\", \"kernel_simplification\": \"4.4.21\", \"architecture\": \"x86_64\", \"kernel_version\": \"4.4.21-69-default\"}",
  "kernel_version" : "4.4.21-69-default",
  "virtualization_type" : "HVM",
  "paravirtualization" : true,
  "firmware" : "BIOS",
  "has_rsync" : true,
  "boot_loader" : "GRUB",
  "disks" : [ {
    "name" : "/dev/vda",
    "device_use" : "BOOT",
    "size" : 42949672960,
    "partition_style" : "MBR",
    "used_size" : 42948624384,
    "physical_volumes" : [ {
      "name" : "/dev/vda1",
      "size" : 2153775104,
      "device_use" : "NORMAL",
      "used_size" : 2153775104,
      "inode_size" : 0,
      "file_system" : "swap",
      "mount_point" : ""
    }, {
      "name" : "/dev/vda2",
      "size" : 16862150656,
      "device_use" : "BTRFS",
      "used_size" : 16862150656,
      "inode_size" : 0,
      "file_system" : "btrfs",
      "mount_point" : ""
    }, {
      "name" : "/dev/vda3",
      "size" : 23932698624,
      "device_use" : "NORMAL",
      "used_size" : 33988608,
      "inode_size" : 0,
      "file_system" : "xfs",
      "mount_point" : "/home"
    } ]
  }, {
    "name" : "/dev/vdb",
    "device_use" : "NORMAL",
    "size" : 21474836480,
    "partition_style" : "MBR",
    "used_size" : 21473787904,
    "physical_volumes" : [ {
      "name" : "/dev/vdb1",
      "size" : 21473787904,
      "device_use" : "VOLUME_GROUP",
      "used_size" : 21473787904,
      "inode_size" : 0,
      "file_system" : "LVM2_member",
      "mount_point" : ""
    } ]
  }, {
    "name" : "/dev/vdc",
    "device_use" : "VOLUME_GROUP",
    "size" : 21474836480,
    "partition_style" : "MBR",
    "used_size" : 0,
    "physical_volumes" : [ ]
  } ],
  "volume_groups" : [ {
    "name" : "vg1",
    "size" : 42948624384,
    "components" : "/dev/vdb1;/dev/vdc",
    "logical_volumes" : [ {
      "name" : "/dev/mapper/vg1-lv1",
      "device_use" : "NORMAL",
      "size" : 10737418240,
      "free_size" : 10713837568,
      "used_size" : 23580672,
      "file_system" : "ext4",
      "mount_point" : "/mnt/lv1",
      "inode_size" : "256"
    } ]
  } ],
  "btrfs_list" : [ {
    "name" : "/dev/vda2",
    "label" : "none",
    "uuid" : "51bc2b06-d675-4429-bef5-fedb11fe47f4",
    "device" : "/dev/vda2",
    "size" : "3.30GiB",
    "nodesize" : "16384",
    "sectorsize" : "4096",
    "data_profile" : "single",
    "system_profile" : "single",
    "metadata_profile" : "single",
    "global_reserve1" : "single",
    "g_vol_used_size" : "3894038528",
    "default_subvolid" : "259",
    "default_subvol_name" : "@/.snapshots/1/snapshot",
    "default_subvol_mountpath" : "/",
    "subvolumn" : [ {
      "uuid" : "51bc2b06-d675-4429-bef5-fedb11fe47f4",
      "is_snapshot" : "false",
      "subvol_id" : "257",
      "parent_id" : "5",
      "subvol_name" : "@",
      "subvol_mount_path" : "null"
    }, {
      "uuid" : "51bc2b06-d675-4429-bef5-fedb11fe47f4",
      "is_snapshot" : "false",
      "subvol_id" : "258",
      "parent_id" : "257",
      "subvol_name" : "@/.snapshots",
      "subvol_mount_path" : "/.snapshots"
    }, {
      "uuid" : "51bc2b06-d675-4429-bef5-fedb11fe47f4",
      "is_snapshot" : "true",
      "subvol_id" : "259",
      "parent_id" : "258",
      "subvol_name" : "@/.snapshots/1/snapshot",
      "subvol_mount_path" : "/"
    }, {
      "uuid" : "51bc2b06-d675-4429-bef5-fedb11fe47f4",
      "is_snapshot" : "false",
      "subvol_id" : "260",
      "parent_id" : "257",
      "subvol_name" : "@/boot/grub2/i386-pc",
      "subvol_mount_path" : "/boot/grub2/i386-pc"
    }, {
      "uuid" : "51bc2b06-d675-4429-bef5-fedb11fe47f4",
      "is_snapshot" : "false",
      "subvol_id" : "261",
      "parent_id" : "257",
      "subvol_name" : "@/boot/grub2/x86_64-efi",
      "subvol_mount_path" : "/boot/grub2/x86_64-efi"
    }, {
      "uuid" : "51bc2b06-d675-4429-bef5-fedb11fe47f4",
      "is_snapshot" : "false",
      "subvol_id" : "262",
      "parent_id" : "257",
      "subvol_name" : "@/opt",
      "subvol_mount_path" : "/opt"
    }, {
      "uuid" : "51bc2b06-d675-4429-bef5-fedb11fe47f4",
      "is_snapshot" : "false",
      "subvol_id" : "263",
      "parent_id" : "257",
      "subvol_name" : "@/srv",
      "subvol_mount_path" : "/srv"
    }, {
      "uuid" : "51bc2b06-d675-4429-bef5-fedb11fe47f4",
      "is_snapshot" : "false",
      "subvol_id" : "264",
      "parent_id" : "257",
      "subvol_name" : "@/tmp",
      "subvol_mount_path" : "/tmp"
    }, {
      "uuid" : "51bc2b06-d675-4429-bef5-fedb11fe47f4",
      "is_snapshot" : "false",
      "subvol_id" : "265",
      "parent_id" : "257",
      "subvol_name" : "@/usr/local",
      "subvol_mount_path" : "/usr/local"
    }, {
      "uuid" : "51bc2b06-d675-4429-bef5-fedb11fe47f4",
      "is_snapshot" : "false",
      "subvol_id" : "266",
      "parent_id" : "257",
      "subvol_name" : "@/var/cache",
      "subvol_mount_path" : "/var/cache"
    }, {
      "uuid" : "51bc2b06-d675-4429-bef5-fedb11fe47f4",
      "is_snapshot" : "false",
      "subvol_id" : "267",
      "parent_id" : "257",
      "subvol_name" : "@/var/crash",
      "subvol_mount_path" : "/var/crash"
    }, {
      "uuid" : "51bc2b06-d675-4429-bef5-fedb11fe47f4",
      "is_snapshot" : "false",
      "subvol_id" : "268",
      "parent_id" : "257",
      "subvol_name" : "@/var/lib/libvirt/images",
      "subvol_mount_path" : "/var/lib/libvirt/images"
    }, {
      "uuid" : "51bc2b06-d675-4429-bef5-fedb11fe47f4",
      "is_snapshot" : "false",
      "subvol_id" : "269",
      "parent_id" : "257",
      "subvol_name" : "@/var/lib/machines",
      "subvol_mount_path" : "/var/lib/machines"
    }, {
      "uuid" : "51bc2b06-d675-4429-bef5-fedb11fe47f4",
      "is_snapshot" : "false",
      "subvol_id" : "270",
      "parent_id" : "257",
      "subvol_name" : "@/var/lib/mailman",
      "subvol_mount_path" : "/var/lib/mailman"
    }, {
      "uuid" : "51bc2b06-d675-4429-bef5-fedb11fe47f4",
      "is_snapshot" : "false",
      "subvol_id" : "271",
      "parent_id" : "257",
      "subvol_name" : "@/var/lib/mariadb",
      "subvol_mount_path" : "/var/lib/mariadb"
    }, {
      "uuid" : "51bc2b06-d675-4429-bef5-fedb11fe47f4",
      "is_snapshot" : "false",
      "subvol_id" : "272",
      "parent_id" : "257",
      "subvol_name" : "@/var/lib/mysql",
      "subvol_mount_path" : "/var/lib/mysql"
    }, {
      "uuid" : "51bc2b06-d675-4429-bef5-fedb11fe47f4",
      "is_snapshot" : "false",
      "subvol_id" : "273",
      "parent_id" : "257",
      "subvol_name" : "@/var/lib/named",
      "subvol_mount_path" : "/var/lib/named"
    }, {
      "uuid" : "51bc2b06-d675-4429-bef5-fedb11fe47f4",
      "is_snapshot" : "false",
      "subvol_id" : "274",
      "parent_id" : "257",
      "subvol_name" : "@/var/lib/pgsql",
      "subvol_mount_path" : "/var/lib/pgsql"
    }, {
      "uuid" : "51bc2b06-d675-4429-bef5-fedb11fe47f4",
      "is_snapshot" : "false",
      "subvol_id" : "275",
      "parent_id" : "257",
      "subvol_name" : "@/var/log",
      "subvol_mount_path" : "/var/log"
    }, {
      "uuid" : "51bc2b06-d675-4429-bef5-fedb11fe47f4",
      "is_snapshot" : "false",
      "subvol_id" : "276",
      "parent_id" : "257",
      "subvol_name" : "@/var/opt",
      "subvol_mount_path" : "/var/opt"
    }, {
      "uuid" : "51bc2b06-d675-4429-bef5-fedb11fe47f4",
      "is_snapshot" : "false",
      "subvol_id" : "277",
      "parent_id" : "257",
      "subvol_name" : "@/var/spool",
      "subvol_mount_path" : "/var/spool"
    }, {
      "uuid" : "51bc2b06-d675-4429-bef5-fedb11fe47f4",
      "is_snapshot" : "false",
      "subvol_id" : "278",
      "parent_id" : "257",
      "subvol_name" : "@/var/tmp",
      "subvol_mount_path" : "/var/tmp"
    }, {
      "uuid" : "51bc2b06-d675-4429-bef5-fedb11fe47f4",
      "is_snapshot" : "true",
      "subvol_id" : "282",
      "parent_id" : "258",
      "subvol_name" : "@/.snapshots/2/snapshot",
      "subvol_mount_path" : "null"
    } ]
  } ],
  "cpu_quantity" : 1,
  "memory" : 934752256,
  "networks" : [ {
    "name" : "eth0",
    "ip" : "192.168.136.xxx",
    "netmask" : "netmask",
    "gateway" : "gateway",
    "mac" : "1a9660eb8a3ffcf4df6d7865b52eb54f7b0cd194029e0eadd8e2c7f1267d80c0"
  } ],
  "ip" : "192.168.136.xxx",
  "agent_version" : "2.2.1"
}

Example Response

Status code: 200

The source server has been registered with SMS.

{
  "id" : "8abda8635e09d185015e09d188dd0001xx"
}

SDK Sample Code

The sample code is as follows.

This example reports information about a source server to SMS. The source server runs Linux SUSE12_64BIT_SP2, with the name of host-192-168-136-xxx, the IP address of 192.168.136.xxx, the BOOT system disk named /dev/vda, and the total size of the system disk of 42949672960 bytes. After the source server is reported, it will be displayed in the SMS server list.

  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
 58
 59
 60
 61
 62
 63
 64
 65
 66
 67
 68
 69
 70
 71
 72
 73
 74
 75
 76
 77
 78
 79
 80
 81
 82
 83
 84
 85
 86
 87
 88
 89
 90
 91
 92
 93
 94
 95
 96
 97
 98
 99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
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.*;

import java.util.List;
import java.util.ArrayList;

public class RegisterServerSolution {

    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();
        RegisterServerRequest request = new RegisterServerRequest();
        PostSourceServerBody body = new PostSourceServerBody();
        List<LogicalVolumes> listVolumeGroupsLogicalVolumes = new ArrayList<>();
        listVolumeGroupsLogicalVolumes.add(
            new LogicalVolumes()
                .withFileSystem("ext4")
                .withInodeSize(256)
                .withDeviceUse("NORMAL")
                .withMountPoint("/mnt/lv1")
                .withName("/dev/mapper/vg1-lv1")
                .withSize(10737418240L)
                .withUsedSize(23580672L)
                .withFreeSize(10713837568L)
        );
        List<VolumeGroups> listbodyVolumeGroups = new ArrayList<>();
        listbodyVolumeGroups.add(
            new VolumeGroups()
                .withComponents("/dev/vdb1;/dev/vdc")
                .withLogicalVolumes(listVolumeGroupsLogicalVolumes)
                .withName("vg1")
                .withSize(42948624384L)
        );
        List<NetWork> listbodyNetworks = new ArrayList<>();
        listbodyNetworks.add(
            new NetWork()
                .withName("eth0")
                .withIp("192.168.136.xxx")
                .withNetmask("netmask")
                .withGateway("gateway")
                .withMac("1a9660eb8a3ffcf4df6d7865b52eb54f7b0cd194029e0eadd8e2c7f1267d80c0")
        );
        List<BtrfsSubvolumn> listBtrfsListSubvolumn = new ArrayList<>();
        listBtrfsListSubvolumn.add(
            new BtrfsSubvolumn()
                .withUuid("51bc2b06-d675-4429-bef5-fedb11fe47f4")
                .withIsSnapshot("false")
                .withSubvolId("257")
                .withParentId("5")
                .withSubvolName("@")
                .withSubvolMountPath("null")
        );
        listBtrfsListSubvolumn.add(
            new BtrfsSubvolumn()
                .withUuid("51bc2b06-d675-4429-bef5-fedb11fe47f4")
                .withIsSnapshot("false")
                .withSubvolId("258")
                .withParentId("257")
                .withSubvolName("@/.snapshots")
                .withSubvolMountPath("/.snapshots")
        );
        listBtrfsListSubvolumn.add(
            new BtrfsSubvolumn()
                .withUuid("51bc2b06-d675-4429-bef5-fedb11fe47f4")
                .withIsSnapshot("true")
                .withSubvolId("259")
                .withParentId("258")
                .withSubvolName("@/.snapshots/1/snapshot")
                .withSubvolMountPath("/")
        );
        listBtrfsListSubvolumn.add(
            new BtrfsSubvolumn()
                .withUuid("51bc2b06-d675-4429-bef5-fedb11fe47f4")
                .withIsSnapshot("false")
                .withSubvolId("260")
                .withParentId("257")
                .withSubvolName("@/boot/grub2/i386-pc")
                .withSubvolMountPath("/boot/grub2/i386-pc")
        );
        listBtrfsListSubvolumn.add(
            new BtrfsSubvolumn()
                .withUuid("51bc2b06-d675-4429-bef5-fedb11fe47f4")
                .withIsSnapshot("false")
                .withSubvolId("261")
                .withParentId("257")
                .withSubvolName("@/boot/grub2/x86_64-efi")
                .withSubvolMountPath("/boot/grub2/x86_64-efi")
        );
        listBtrfsListSubvolumn.add(
            new BtrfsSubvolumn()
                .withUuid("51bc2b06-d675-4429-bef5-fedb11fe47f4")
                .withIsSnapshot("false")
                .withSubvolId("262")
                .withParentId("257")
                .withSubvolName("@/opt")
                .withSubvolMountPath("/opt")
        );
        listBtrfsListSubvolumn.add(
            new BtrfsSubvolumn()
                .withUuid("51bc2b06-d675-4429-bef5-fedb11fe47f4")
                .withIsSnapshot("false")
                .withSubvolId("263")
                .withParentId("257")
                .withSubvolName("@/srv")
                .withSubvolMountPath("/srv")
        );
        listBtrfsListSubvolumn.add(
            new BtrfsSubvolumn()
                .withUuid("51bc2b06-d675-4429-bef5-fedb11fe47f4")
                .withIsSnapshot("false")
                .withSubvolId("264")
                .withParentId("257")
                .withSubvolName("@/tmp")
                .withSubvolMountPath("/tmp")
        );
        listBtrfsListSubvolumn.add(
            new BtrfsSubvolumn()
                .withUuid("51bc2b06-d675-4429-bef5-fedb11fe47f4")
                .withIsSnapshot("false")
                .withSubvolId("265")
                .withParentId("257")
                .withSubvolName("@/usr/local")
                .withSubvolMountPath("/usr/local")
        );
        listBtrfsListSubvolumn.add(
            new BtrfsSubvolumn()
                .withUuid("51bc2b06-d675-4429-bef5-fedb11fe47f4")
                .withIsSnapshot("false")
                .withSubvolId("266")
                .withParentId("257")
                .withSubvolName("@/var/cache")
                .withSubvolMountPath("/var/cache")
        );
        listBtrfsListSubvolumn.add(
            new BtrfsSubvolumn()
                .withUuid("51bc2b06-d675-4429-bef5-fedb11fe47f4")
                .withIsSnapshot("false")
                .withSubvolId("267")
                .withParentId("257")
                .withSubvolName("@/var/crash")
                .withSubvolMountPath("/var/crash")
        );
        listBtrfsListSubvolumn.add(
            new BtrfsSubvolumn()
                .withUuid("51bc2b06-d675-4429-bef5-fedb11fe47f4")
                .withIsSnapshot("false")
                .withSubvolId("268")
                .withParentId("257")
                .withSubvolName("@/var/lib/libvirt/images")
                .withSubvolMountPath("/var/lib/libvirt/images")
        );
        listBtrfsListSubvolumn.add(
            new BtrfsSubvolumn()
                .withUuid("51bc2b06-d675-4429-bef5-fedb11fe47f4")
                .withIsSnapshot("false")
                .withSubvolId("269")
                .withParentId("257")
                .withSubvolName("@/var/lib/machines")
                .withSubvolMountPath("/var/lib/machines")
        );
        listBtrfsListSubvolumn.add(
            new BtrfsSubvolumn()
                .withUuid("51bc2b06-d675-4429-bef5-fedb11fe47f4")
                .withIsSnapshot("false")
                .withSubvolId("270")
                .withParentId("257")
                .withSubvolName("@/var/lib/mailman")
                .withSubvolMountPath("/var/lib/mailman")
        );
        listBtrfsListSubvolumn.add(
            new BtrfsSubvolumn()
                .withUuid("51bc2b06-d675-4429-bef5-fedb11fe47f4")
                .withIsSnapshot("false")
                .withSubvolId("271")
                .withParentId("257")
                .withSubvolName("@/var/lib/mariadb")
                .withSubvolMountPath("/var/lib/mariadb")
        );
        listBtrfsListSubvolumn.add(
            new BtrfsSubvolumn()
                .withUuid("51bc2b06-d675-4429-bef5-fedb11fe47f4")
                .withIsSnapshot("false")
                .withSubvolId("272")
                .withParentId("257")
                .withSubvolName("@/var/lib/mysql")
                .withSubvolMountPath("/var/lib/mysql")
        );
        listBtrfsListSubvolumn.add(
            new BtrfsSubvolumn()
                .withUuid("51bc2b06-d675-4429-bef5-fedb11fe47f4")
                .withIsSnapshot("false")
                .withSubvolId("273")
                .withParentId("257")
                .withSubvolName("@/var/lib/named")
                .withSubvolMountPath("/var/lib/named")
        );
        listBtrfsListSubvolumn.add(
            new BtrfsSubvolumn()
                .withUuid("51bc2b06-d675-4429-bef5-fedb11fe47f4")
                .withIsSnapshot("false")
                .withSubvolId("274")
                .withParentId("257")
                .withSubvolName("@/var/lib/pgsql")
                .withSubvolMountPath("/var/lib/pgsql")
        );
        listBtrfsListSubvolumn.add(
            new BtrfsSubvolumn()
                .withUuid("51bc2b06-d675-4429-bef5-fedb11fe47f4")
                .withIsSnapshot("false")
                .withSubvolId("275")
                .withParentId("257")
                .withSubvolName("@/var/log")
                .withSubvolMountPath("/var/log")
        );
        listBtrfsListSubvolumn.add(
            new BtrfsSubvolumn()
                .withUuid("51bc2b06-d675-4429-bef5-fedb11fe47f4")
                .withIsSnapshot("false")
                .withSubvolId("276")
                .withParentId("257")
                .withSubvolName("@/var/opt")
                .withSubvolMountPath("/var/opt")
        );
        listBtrfsListSubvolumn.add(
            new BtrfsSubvolumn()
                .withUuid("51bc2b06-d675-4429-bef5-fedb11fe47f4")
                .withIsSnapshot("false")
                .withSubvolId("277")
                .withParentId("257")
                .withSubvolName("@/var/spool")
                .withSubvolMountPath("/var/spool")
        );
        listBtrfsListSubvolumn.add(
            new BtrfsSubvolumn()
                .withUuid("51bc2b06-d675-4429-bef5-fedb11fe47f4")
                .withIsSnapshot("false")
                .withSubvolId("278")
                .withParentId("257")
                .withSubvolName("@/var/tmp")
                .withSubvolMountPath("/var/tmp")
        );
        listBtrfsListSubvolumn.add(
            new BtrfsSubvolumn()
                .withUuid("51bc2b06-d675-4429-bef5-fedb11fe47f4")
                .withIsSnapshot("true")
                .withSubvolId("282")
                .withParentId("258")
                .withSubvolName("@/.snapshots/2/snapshot")
                .withSubvolMountPath("null")
        );
        List<BtrfsFileSystem> listbodyBtrfsList = new ArrayList<>();
        listbodyBtrfsList.add(
            new BtrfsFileSystem()
                .withName("/dev/vda2")
                .withLabel("none")
                .withUuid("51bc2b06-d675-4429-bef5-fedb11fe47f4")
                .withDevice("/dev/vda2")
                .withSize(3.30GiBL)
                .withNodesize(16384L)
                .withSectorsize(4096)
                .withDataProfile("single")
                .withSystemProfile("single")
                .withMetadataProfile("single")
                .withGlobalReserve1("single")
                .withGVolUsedSize(3894038528L)
                .withDefaultSubvolid("259")
                .withDefaultSubvolName("@/.snapshots/1/snapshot")
                .withDefaultSubvolMountpath("/")
                .withSubvolumn(listBtrfsListSubvolumn)
        );
        List<PhysicalVolume> listDisksPhysicalVolumes = new ArrayList<>();
        listDisksPhysicalVolumes.add(
            new PhysicalVolume()
                .withDeviceUse("VOLUME_GROUP")
                .withFileSystem("LVM2_member")
                .withMountPoint("")
                .withName("/dev/vdb1")
                .withSize(21473787904L)
                .withUsedSize(21473787904L)
                .withInodeSize(0)
        );
        List<PhysicalVolume> listDisksPhysicalVolumes1 = new ArrayList<>();
        listDisksPhysicalVolumes1.add(
            new PhysicalVolume()
                .withDeviceUse("NORMAL")
                .withFileSystem("swap")
                .withMountPoint("")
                .withName("/dev/vda1")
                .withSize(2153775104L)
                .withUsedSize(2153775104L)
                .withInodeSize(0)
        );
        listDisksPhysicalVolumes1.add(
            new PhysicalVolume()
                .withDeviceUse("BTRFS")
                .withFileSystem("btrfs")
                .withMountPoint("")
                .withName("/dev/vda2")
                .withSize(16862150656L)
                .withUsedSize(16862150656L)
                .withInodeSize(0)
        );
        listDisksPhysicalVolumes1.add(
            new PhysicalVolume()
                .withDeviceUse("NORMAL")
                .withFileSystem("xfs")
                .withMountPoint("/home")
                .withName("/dev/vda3")
                .withSize(23932698624L)
                .withUsedSize(33988608L)
                .withInodeSize(0)
        );
        List<ServerDisk> listbodyDisks = new ArrayList<>();
        listbodyDisks.add(
            new ServerDisk()
                .withName("/dev/vda")
                .withPartitionStyle(ServerDisk.PartitionStyleEnum.fromValue("MBR"))
                .withDeviceUse(ServerDisk.DeviceUseEnum.fromValue("BOOT"))
                .withSize(42949672960L)
                .withUsedSize(42948624384L)
                .withPhysicalVolumes(listDisksPhysicalVolumes1)
        );
        listbodyDisks.add(
            new ServerDisk()
                .withName("/dev/vdb")
                .withPartitionStyle(ServerDisk.PartitionStyleEnum.fromValue("MBR"))
                .withDeviceUse(ServerDisk.DeviceUseEnum.fromValue("NORMAL"))
                .withSize(21474836480L)
                .withUsedSize(21473787904L)
                .withPhysicalVolumes(listDisksPhysicalVolumes)
        );
        listbodyDisks.add(
            new ServerDisk()
                .withName("/dev/vdc")
                .withPartitionStyle(ServerDisk.PartitionStyleEnum.fromValue("MBR"))
                .withDeviceUse(ServerDisk.DeviceUseEnum.fromValue("VOLUME_GROUP"))
                .withSize(21474836480L)
                .withUsedSize(0L)
                .withPhysicalVolumes()
        );
        body.withKernelVersion("4.4.21-69-default");
        body.withAgentVersion("2.2.1");
        body.withVolumeGroups(listbodyVolumeGroups);
        body.withBootLoader(PostSourceServerBody.BootLoaderEnum.fromValue("GRUB"));
        body.withParavirtualization(true);
        body.withHasRsync(true);
        body.withNetworks(listbodyNetworks);
        body.withBtrfsList(listbodyBtrfsList);
        body.withDisks(listbodyDisks);
        body.withMemory(934752256L);
        body.withCpuQuantity(1);
        body.withFirmware(PostSourceServerBody.FirmwareEnum.fromValue("BIOS"));
        body.withLinuxBlockCheck("{"release_type": "SUSE", "release_version": "12.2", "kernel_simplification": "4.4.21", "architecture": "x86_64", "kernel_version": "4.4.21-69-default"}");
        body.withVirtualizationType("HVM");
        body.withOsVersion("SUSE12_64BIT_SP2");
        body.withOsType(PostSourceServerBody.OsTypeEnum.fromValue("LINUX"));
        body.withName("host-192-168-136-xxx");
        body.withIp("192.168.136.xxx");
        request.withBody(body);
        try {
            RegisterServerResponse response = client.registerServer(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());
        }
    }
}

This example reports information about a source server to SMS. The source server runs Linux SUSE12_64BIT_SP2, with the name of host-192-168-136-xxx, the IP address of 192.168.136.xxx, the BOOT system disk named /dev/vda, and the total size of the system disk of 42949672960 bytes. After the source server is reported, it will be displayed in the SMS server list.

  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
 58
 59
 60
 61
 62
 63
 64
 65
 66
 67
 68
 69
 70
 71
 72
 73
 74
 75
 76
 77
 78
 79
 80
 81
 82
 83
 84
 85
 86
 87
 88
 89
 90
 91
 92
 93
 94
 95
 96
 97
 98
 99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
# 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 = RegisterServerRequest()
        listLogicalVolumesVolumeGroups = [
            LogicalVolumes(
                file_system="ext4",
                inode_size=256,
                device_use="NORMAL",
                mount_point="/mnt/lv1",
                name="/dev/mapper/vg1-lv1",
                size=10737418240,
                used_size=23580672,
                free_size=10713837568
            )
        ]
        listVolumeGroupsbody = [
            VolumeGroups(
                components="/dev/vdb1;/dev/vdc",
                logical_volumes=listLogicalVolumesVolumeGroups,
                name="vg1",
                size=42948624384
            )
        ]
        listNetworksbody = [
            NetWork(
                name="eth0",
                ip="192.168.136.xxx",
                netmask="netmask",
                gateway="gateway",
                mac="1a9660eb8a3ffcf4df6d7865b52eb54f7b0cd194029e0eadd8e2c7f1267d80c0"
            )
        ]
        listSubvolumnBtrfsList = [
            BtrfsSubvolumn(
                uuid="51bc2b06-d675-4429-bef5-fedb11fe47f4",
                is_snapshot="false",
                subvol_id="257",
                parent_id="5",
                subvol_name="@",
                subvol_mount_path="null"
            ),
            BtrfsSubvolumn(
                uuid="51bc2b06-d675-4429-bef5-fedb11fe47f4",
                is_snapshot="false",
                subvol_id="258",
                parent_id="257",
                subvol_name="@/.snapshots",
                subvol_mount_path="/.snapshots"
            ),
            BtrfsSubvolumn(
                uuid="51bc2b06-d675-4429-bef5-fedb11fe47f4",
                is_snapshot="true",
                subvol_id="259",
                parent_id="258",
                subvol_name="@/.snapshots/1/snapshot",
                subvol_mount_path="/"
            ),
            BtrfsSubvolumn(
                uuid="51bc2b06-d675-4429-bef5-fedb11fe47f4",
                is_snapshot="false",
                subvol_id="260",
                parent_id="257",
                subvol_name="@/boot/grub2/i386-pc",
                subvol_mount_path="/boot/grub2/i386-pc"
            ),
            BtrfsSubvolumn(
                uuid="51bc2b06-d675-4429-bef5-fedb11fe47f4",
                is_snapshot="false",
                subvol_id="261",
                parent_id="257",
                subvol_name="@/boot/grub2/x86_64-efi",
                subvol_mount_path="/boot/grub2/x86_64-efi"
            ),
            BtrfsSubvolumn(
                uuid="51bc2b06-d675-4429-bef5-fedb11fe47f4",
                is_snapshot="false",
                subvol_id="262",
                parent_id="257",
                subvol_name="@/opt",
                subvol_mount_path="/opt"
            ),
            BtrfsSubvolumn(
                uuid="51bc2b06-d675-4429-bef5-fedb11fe47f4",
                is_snapshot="false",
                subvol_id="263",
                parent_id="257",
                subvol_name="@/srv",
                subvol_mount_path="/srv"
            ),
            BtrfsSubvolumn(
                uuid="51bc2b06-d675-4429-bef5-fedb11fe47f4",
                is_snapshot="false",
                subvol_id="264",
                parent_id="257",
                subvol_name="@/tmp",
                subvol_mount_path="/tmp"
            ),
            BtrfsSubvolumn(
                uuid="51bc2b06-d675-4429-bef5-fedb11fe47f4",
                is_snapshot="false",
                subvol_id="265",
                parent_id="257",
                subvol_name="@/usr/local",
                subvol_mount_path="/usr/local"
            ),
            BtrfsSubvolumn(
                uuid="51bc2b06-d675-4429-bef5-fedb11fe47f4",
                is_snapshot="false",
                subvol_id="266",
                parent_id="257",
                subvol_name="@/var/cache",
                subvol_mount_path="/var/cache"
            ),
            BtrfsSubvolumn(
                uuid="51bc2b06-d675-4429-bef5-fedb11fe47f4",
                is_snapshot="false",
                subvol_id="267",
                parent_id="257",
                subvol_name="@/var/crash",
                subvol_mount_path="/var/crash"
            ),
            BtrfsSubvolumn(
                uuid="51bc2b06-d675-4429-bef5-fedb11fe47f4",
                is_snapshot="false",
                subvol_id="268",
                parent_id="257",
                subvol_name="@/var/lib/libvirt/images",
                subvol_mount_path="/var/lib/libvirt/images"
            ),
            BtrfsSubvolumn(
                uuid="51bc2b06-d675-4429-bef5-fedb11fe47f4",
                is_snapshot="false",
                subvol_id="269",
                parent_id="257",
                subvol_name="@/var/lib/machines",
                subvol_mount_path="/var/lib/machines"
            ),
            BtrfsSubvolumn(
                uuid="51bc2b06-d675-4429-bef5-fedb11fe47f4",
                is_snapshot="false",
                subvol_id="270",
                parent_id="257",
                subvol_name="@/var/lib/mailman",
                subvol_mount_path="/var/lib/mailman"
            ),
            BtrfsSubvolumn(
                uuid="51bc2b06-d675-4429-bef5-fedb11fe47f4",
                is_snapshot="false",
                subvol_id="271",
                parent_id="257",
                subvol_name="@/var/lib/mariadb",
                subvol_mount_path="/var/lib/mariadb"
            ),
            BtrfsSubvolumn(
                uuid="51bc2b06-d675-4429-bef5-fedb11fe47f4",
                is_snapshot="false",
                subvol_id="272",
                parent_id="257",
                subvol_name="@/var/lib/mysql",
                subvol_mount_path="/var/lib/mysql"
            ),
            BtrfsSubvolumn(
                uuid="51bc2b06-d675-4429-bef5-fedb11fe47f4",
                is_snapshot="false",
                subvol_id="273",
                parent_id="257",
                subvol_name="@/var/lib/named",
                subvol_mount_path="/var/lib/named"
            ),
            BtrfsSubvolumn(
                uuid="51bc2b06-d675-4429-bef5-fedb11fe47f4",
                is_snapshot="false",
                subvol_id="274",
                parent_id="257",
                subvol_name="@/var/lib/pgsql",
                subvol_mount_path="/var/lib/pgsql"
            ),
            BtrfsSubvolumn(
                uuid="51bc2b06-d675-4429-bef5-fedb11fe47f4",
                is_snapshot="false",
                subvol_id="275",
                parent_id="257",
                subvol_name="@/var/log",
                subvol_mount_path="/var/log"
            ),
            BtrfsSubvolumn(
                uuid="51bc2b06-d675-4429-bef5-fedb11fe47f4",
                is_snapshot="false",
                subvol_id="276",
                parent_id="257",
                subvol_name="@/var/opt",
                subvol_mount_path="/var/opt"
            ),
            BtrfsSubvolumn(
                uuid="51bc2b06-d675-4429-bef5-fedb11fe47f4",
                is_snapshot="false",
                subvol_id="277",
                parent_id="257",
                subvol_name="@/var/spool",
                subvol_mount_path="/var/spool"
            ),
            BtrfsSubvolumn(
                uuid="51bc2b06-d675-4429-bef5-fedb11fe47f4",
                is_snapshot="false",
                subvol_id="278",
                parent_id="257",
                subvol_name="@/var/tmp",
                subvol_mount_path="/var/tmp"
            ),
            BtrfsSubvolumn(
                uuid="51bc2b06-d675-4429-bef5-fedb11fe47f4",
                is_snapshot="true",
                subvol_id="282",
                parent_id="258",
                subvol_name="@/.snapshots/2/snapshot",
                subvol_mount_path="null"
            )
        ]
        listBtrfsListbody = [
            BtrfsFileSystem(
                name="/dev/vda2",
                label="none",
                uuid="51bc2b06-d675-4429-bef5-fedb11fe47f4",
                device="/dev/vda2",
                size=3.30GiB,
                nodesize=16384,
                sectorsize=4096,
                data_profile="single",
                system_profile="single",
                metadata_profile="single",
                global_reserve1="single",
                g_vol_used_size=3894038528,
                default_subvolid="259",
                default_subvol_name="@/.snapshots/1/snapshot",
                default_subvol_mountpath="/",
                subvolumn=listSubvolumnBtrfsList
            )
        ]
        listPhysicalVolumesDisks = [
            PhysicalVolume(
                device_use="VOLUME_GROUP",
                file_system="LVM2_member",
                mount_point="",
                name="/dev/vdb1",
                size=21473787904,
                used_size=21473787904,
                inode_size=0
            )
        ]
        listPhysicalVolumesDisks1 = [
            PhysicalVolume(
                device_use="NORMAL",
                file_system="swap",
                mount_point="",
                name="/dev/vda1",
                size=2153775104,
                used_size=2153775104,
                inode_size=0
            ),
            PhysicalVolume(
                device_use="BTRFS",
                file_system="btrfs",
                mount_point="",
                name="/dev/vda2",
                size=16862150656,
                used_size=16862150656,
                inode_size=0
            ),
            PhysicalVolume(
                device_use="NORMAL",
                file_system="xfs",
                mount_point="/home",
                name="/dev/vda3",
                size=23932698624,
                used_size=33988608,
                inode_size=0
            )
        ]
        listDisksbody = [
            ServerDisk(
                name="/dev/vda",
                partition_style="MBR",
                device_use="BOOT",
                size=42949672960,
                used_size=42948624384,
                physical_volumes=listPhysicalVolumesDisks1
            ),
            ServerDisk(
                name="/dev/vdb",
                partition_style="MBR",
                device_use="NORMAL",
                size=21474836480,
                used_size=21473787904,
                physical_volumes=listPhysicalVolumesDisks
            ),
            ServerDisk(
                name="/dev/vdc",
                partition_style="MBR",
                device_use="VOLUME_GROUP",
                size=21474836480,
                used_size=0,
            )
        ]
        request.body = PostSourceServerBody(
            kernel_version="4.4.21-69-default",
            agent_version="2.2.1",
            volume_groups=listVolumeGroupsbody,
            boot_loader="GRUB",
            paravirtualization=True,
            has_rsync=True,
            networks=listNetworksbody,
            btrfs_list=listBtrfsListbody,
            disks=listDisksbody,
            memory=934752256,
            cpu_quantity=1,
            firmware="BIOS",
            linux_block_check="{"release_type": "SUSE", "release_version": "12.2", "kernel_simplification": "4.4.21", "architecture": "x86_64", "kernel_version": "4.4.21-69-default"}",
            virtualization_type="HVM",
            os_version="SUSE12_64BIT_SP2",
            os_type="LINUX",
            name="host-192-168-136-xxx",
            ip="192.168.136.xxx"
        )
        response = client.register_server(request)
        print(response)
    except exceptions.ClientRequestException as e:
        print(e.status_code)
        print(e.request_id)
        print(e.error_code)
        print(e.error_msg)

This example reports information about a source server to SMS. The source server runs Linux SUSE12_64BIT_SP2, with the name of host-192-168-136-xxx, the IP address of 192.168.136.xxx, the BOOT system disk named /dev/vda, and the total size of the system disk of 42949672960 bytes. After the source server is reported, it will be displayed in the SMS server list.

  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
 58
 59
 60
 61
 62
 63
 64
 65
 66
 67
 68
 69
 70
 71
 72
 73
 74
 75
 76
 77
 78
 79
 80
 81
 82
 83
 84
 85
 86
 87
 88
 89
 90
 91
 92
 93
 94
 95
 96
 97
 98
 99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
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.RegisterServerRequest{}
	deviceUseLogicalVolumes:= "NORMAL"
	var listLogicalVolumesVolumeGroups = []model.LogicalVolumes{
        {
            FileSystem: "ext4",
            InodeSize: int32(256),
            DeviceUse: &deviceUseLogicalVolumes,
            MountPoint: "/mnt/lv1",
            Name: "/dev/mapper/vg1-lv1",
            Size: int64(10737418240),
            UsedSize: int64(23580672),
            FreeSize: int64(10713837568),
        },
    }
	componentsVolumeGroups:= "/dev/vdb1;/dev/vdc"
	nameVolumeGroups:= "vg1"
	sizeVolumeGroups:= int64(42948624384)
	var listVolumeGroupsbody = []model.VolumeGroups{
        {
            Components: &componentsVolumeGroups,
            LogicalVolumes: &listLogicalVolumesVolumeGroups,
            Name: &nameVolumeGroups,
            Size: &sizeVolumeGroups,
        },
    }
	var listNetworksbody = []model.NetWork{
        {
            Name: "eth0",
            Ip: "192.168.136.xxx",
            Netmask: "netmask",
            Gateway: "gateway",
            Mac: "1a9660eb8a3ffcf4df6d7865b52eb54f7b0cd194029e0eadd8e2c7f1267d80c0",
        },
    }
	var listSubvolumnBtrfsList = []model.BtrfsSubvolumn{
        {
            Uuid: "51bc2b06-d675-4429-bef5-fedb11fe47f4",
            IsSnapshot: "false",
            SubvolId: "257",
            ParentId: "5",
            SubvolName: "@",
            SubvolMountPath: "null",
        },
        {
            Uuid: "51bc2b06-d675-4429-bef5-fedb11fe47f4",
            IsSnapshot: "false",
            SubvolId: "258",
            ParentId: "257",
            SubvolName: "@/.snapshots",
            SubvolMountPath: "/.snapshots",
        },
        {
            Uuid: "51bc2b06-d675-4429-bef5-fedb11fe47f4",
            IsSnapshot: "true",
            SubvolId: "259",
            ParentId: "258",
            SubvolName: "@/.snapshots/1/snapshot",
            SubvolMountPath: "/",
        },
        {
            Uuid: "51bc2b06-d675-4429-bef5-fedb11fe47f4",
            IsSnapshot: "false",
            SubvolId: "260",
            ParentId: "257",
            SubvolName: "@/boot/grub2/i386-pc",
            SubvolMountPath: "/boot/grub2/i386-pc",
        },
        {
            Uuid: "51bc2b06-d675-4429-bef5-fedb11fe47f4",
            IsSnapshot: "false",
            SubvolId: "261",
            ParentId: "257",
            SubvolName: "@/boot/grub2/x86_64-efi",
            SubvolMountPath: "/boot/grub2/x86_64-efi",
        },
        {
            Uuid: "51bc2b06-d675-4429-bef5-fedb11fe47f4",
            IsSnapshot: "false",
            SubvolId: "262",
            ParentId: "257",
            SubvolName: "@/opt",
            SubvolMountPath: "/opt",
        },
        {
            Uuid: "51bc2b06-d675-4429-bef5-fedb11fe47f4",
            IsSnapshot: "false",
            SubvolId: "263",
            ParentId: "257",
            SubvolName: "@/srv",
            SubvolMountPath: "/srv",
        },
        {
            Uuid: "51bc2b06-d675-4429-bef5-fedb11fe47f4",
            IsSnapshot: "false",
            SubvolId: "264",
            ParentId: "257",
            SubvolName: "@/tmp",
            SubvolMountPath: "/tmp",
        },
        {
            Uuid: "51bc2b06-d675-4429-bef5-fedb11fe47f4",
            IsSnapshot: "false",
            SubvolId: "265",
            ParentId: "257",
            SubvolName: "@/usr/local",
            SubvolMountPath: "/usr/local",
        },
        {
            Uuid: "51bc2b06-d675-4429-bef5-fedb11fe47f4",
            IsSnapshot: "false",
            SubvolId: "266",
            ParentId: "257",
            SubvolName: "@/var/cache",
            SubvolMountPath: "/var/cache",
        },
        {
            Uuid: "51bc2b06-d675-4429-bef5-fedb11fe47f4",
            IsSnapshot: "false",
            SubvolId: "267",
            ParentId: "257",
            SubvolName: "@/var/crash",
            SubvolMountPath: "/var/crash",
        },
        {
            Uuid: "51bc2b06-d675-4429-bef5-fedb11fe47f4",
            IsSnapshot: "false",
            SubvolId: "268",
            ParentId: "257",
            SubvolName: "@/var/lib/libvirt/images",
            SubvolMountPath: "/var/lib/libvirt/images",
        },
        {
            Uuid: "51bc2b06-d675-4429-bef5-fedb11fe47f4",
            IsSnapshot: "false",
            SubvolId: "269",
            ParentId: "257",
            SubvolName: "@/var/lib/machines",
            SubvolMountPath: "/var/lib/machines",
        },
        {
            Uuid: "51bc2b06-d675-4429-bef5-fedb11fe47f4",
            IsSnapshot: "false",
            SubvolId: "270",
            ParentId: "257",
            SubvolName: "@/var/lib/mailman",
            SubvolMountPath: "/var/lib/mailman",
        },
        {
            Uuid: "51bc2b06-d675-4429-bef5-fedb11fe47f4",
            IsSnapshot: "false",
            SubvolId: "271",
            ParentId: "257",
            SubvolName: "@/var/lib/mariadb",
            SubvolMountPath: "/var/lib/mariadb",
        },
        {
            Uuid: "51bc2b06-d675-4429-bef5-fedb11fe47f4",
            IsSnapshot: "false",
            SubvolId: "272",
            ParentId: "257",
            SubvolName: "@/var/lib/mysql",
            SubvolMountPath: "/var/lib/mysql",
        },
        {
            Uuid: "51bc2b06-d675-4429-bef5-fedb11fe47f4",
            IsSnapshot: "false",
            SubvolId: "273",
            ParentId: "257",
            SubvolName: "@/var/lib/named",
            SubvolMountPath: "/var/lib/named",
        },
        {
            Uuid: "51bc2b06-d675-4429-bef5-fedb11fe47f4",
            IsSnapshot: "false",
            SubvolId: "274",
            ParentId: "257",
            SubvolName: "@/var/lib/pgsql",
            SubvolMountPath: "/var/lib/pgsql",
        },
        {
            Uuid: "51bc2b06-d675-4429-bef5-fedb11fe47f4",
            IsSnapshot: "false",
            SubvolId: "275",
            ParentId: "257",
            SubvolName: "@/var/log",
            SubvolMountPath: "/var/log",
        },
        {
            Uuid: "51bc2b06-d675-4429-bef5-fedb11fe47f4",
            IsSnapshot: "false",
            SubvolId: "276",
            ParentId: "257",
            SubvolName: "@/var/opt",
            SubvolMountPath: "/var/opt",
        },
        {
            Uuid: "51bc2b06-d675-4429-bef5-fedb11fe47f4",
            IsSnapshot: "false",
            SubvolId: "277",
            ParentId: "257",
            SubvolName: "@/var/spool",
            SubvolMountPath: "/var/spool",
        },
        {
            Uuid: "51bc2b06-d675-4429-bef5-fedb11fe47f4",
            IsSnapshot: "false",
            SubvolId: "278",
            ParentId: "257",
            SubvolName: "@/var/tmp",
            SubvolMountPath: "/var/tmp",
        },
        {
            Uuid: "51bc2b06-d675-4429-bef5-fedb11fe47f4",
            IsSnapshot: "true",
            SubvolId: "282",
            ParentId: "258",
            SubvolName: "@/.snapshots/2/snapshot",
            SubvolMountPath: "null",
        },
    }
	var listBtrfsListbody = []model.BtrfsFileSystem{
        {
            Name: "/dev/vda2",
            Label: "none",
            Uuid: "51bc2b06-d675-4429-bef5-fedb11fe47f4",
            Device: "/dev/vda2",
            Size: int64(3.30GiB),
            Nodesize: int64(16384),
            Sectorsize: int32(4096),
            DataProfile: "single",
            SystemProfile: "single",
            MetadataProfile: "single",
            GlobalReserve1: "single",
            GVolUsedSize: int64(3894038528),
            DefaultSubvolid: "259",
            DefaultSubvolName: "@/.snapshots/1/snapshot",
            DefaultSubvolMountpath: "/",
            Subvolumn: listSubvolumnBtrfsList,
        },
    }
	deviceUsePhysicalVolumes:= "VOLUME_GROUP"
	fileSystemPhysicalVolumes:= "LVM2_member"
	mountPointPhysicalVolumes:= ""
	namePhysicalVolumes:= "/dev/vdb1"
	sizePhysicalVolumes:= int64(21473787904)
	usedSizePhysicalVolumes:= int64(21473787904)
	inodeSizePhysicalVolumes:= int32(0)
	var listPhysicalVolumesDisks = []model.PhysicalVolume{
        {
            DeviceUse: &deviceUsePhysicalVolumes,
            FileSystem: &fileSystemPhysicalVolumes,
            MountPoint: &mountPointPhysicalVolumes,
            Name: &namePhysicalVolumes,
            Size: &sizePhysicalVolumes,
            UsedSize: &usedSizePhysicalVolumes,
            InodeSize: &inodeSizePhysicalVolumes,
        },
    }
	deviceUsePhysicalVolumes1:= "NORMAL"
	fileSystemPhysicalVolumes1:= "swap"
	mountPointPhysicalVolumes1:= ""
	namePhysicalVolumes1:= "/dev/vda1"
	sizePhysicalVolumes1:= int64(2153775104)
	usedSizePhysicalVolumes1:= int64(2153775104)
	inodeSizePhysicalVolumes1:= int32(0)
	deviceUsePhysicalVolumes2:= "BTRFS"
	fileSystemPhysicalVolumes2:= "btrfs"
	mountPointPhysicalVolumes2:= ""
	namePhysicalVolumes2:= "/dev/vda2"
	sizePhysicalVolumes2:= int64(16862150656)
	usedSizePhysicalVolumes2:= int64(16862150656)
	inodeSizePhysicalVolumes2:= int32(0)
	deviceUsePhysicalVolumes3:= "NORMAL"
	fileSystemPhysicalVolumes3:= "xfs"
	mountPointPhysicalVolumes3:= "/home"
	namePhysicalVolumes3:= "/dev/vda3"
	sizePhysicalVolumes3:= int64(23932698624)
	usedSizePhysicalVolumes3:= int64(33988608)
	inodeSizePhysicalVolumes3:= int32(0)
	var listPhysicalVolumesDisks1 = []model.PhysicalVolume{
        {
            DeviceUse: &deviceUsePhysicalVolumes1,
            FileSystem: &fileSystemPhysicalVolumes1,
            MountPoint: &mountPointPhysicalVolumes1,
            Name: &namePhysicalVolumes1,
            Size: &sizePhysicalVolumes1,
            UsedSize: &usedSizePhysicalVolumes1,
            InodeSize: &inodeSizePhysicalVolumes1,
        },
        {
            DeviceUse: &deviceUsePhysicalVolumes2,
            FileSystem: &fileSystemPhysicalVolumes2,
            MountPoint: &mountPointPhysicalVolumes2,
            Name: &namePhysicalVolumes2,
            Size: &sizePhysicalVolumes2,
            UsedSize: &usedSizePhysicalVolumes2,
            InodeSize: &inodeSizePhysicalVolumes2,
        },
        {
            DeviceUse: &deviceUsePhysicalVolumes3,
            FileSystem: &fileSystemPhysicalVolumes3,
            MountPoint: &mountPointPhysicalVolumes3,
            Name: &namePhysicalVolumes3,
            Size: &sizePhysicalVolumes3,
            UsedSize: &usedSizePhysicalVolumes3,
            InodeSize: &inodeSizePhysicalVolumes3,
        },
    }
	partitionStyleDisks:= model.GetServerDiskPartitionStyleEnum().MBR
	partitionStyleDisks1:= model.GetServerDiskPartitionStyleEnum().MBR
	partitionStyleDisks2:= model.GetServerDiskPartitionStyleEnum().MBR
	var listDisksbody = []model.ServerDisk{
        {
            Name: "/dev/vda",
            PartitionStyle: &partitionStyleDisks,
            DeviceUse: model.GetServerDiskDeviceUseEnum().BOOT,
            Size: int64(42949672960),
            UsedSize: int64(42948624384),
            PhysicalVolumes: listPhysicalVolumesDisks1,
        },
        {
            Name: "/dev/vdb",
            PartitionStyle: &partitionStyleDisks1,
            DeviceUse: model.GetServerDiskDeviceUseEnum().NORMAL,
            Size: int64(21474836480),
            UsedSize: int64(21473787904),
            PhysicalVolumes: listPhysicalVolumesDisks,
        },
        {
            Name: "/dev/vdc",
            PartitionStyle: &partitionStyleDisks2,
            DeviceUse: model.GetServerDiskDeviceUseEnum().VOLUME_GROUP,
            Size: int64(21474836480),
            UsedSize: int64(0),
        },
    }
	kernelVersionPostSourceServerBody:= "4.4.21-69-default"
	bootLoaderPostSourceServerBody:= model.GetPostSourceServerBodyBootLoaderEnum().GRUB
	paravirtualizationPostSourceServerBody:= true
	hasRsyncPostSourceServerBody:= true
	memoryPostSourceServerBody:= int64(934752256)
	cpuQuantityPostSourceServerBody:= int32(1)
	firmwarePostSourceServerBody:= model.GetPostSourceServerBodyFirmwareEnum().BIOS
	linuxBlockCheckPostSourceServerBody:= "{"release_type": "SUSE", "release_version": "12.2", "kernel_simplification": "4.4.21", "architecture": "x86_64", "kernel_version": "4.4.21-69-default"}"
	virtualizationTypePostSourceServerBody:= "HVM"
	osVersionPostSourceServerBody:= "SUSE12_64BIT_SP2"
	request.Body = &model.PostSourceServerBody{
		KernelVersion: &kernelVersionPostSourceServerBody,
		AgentVersion: "2.2.1",
		VolumeGroups: &listVolumeGroupsbody,
		BootLoader: &bootLoaderPostSourceServerBody,
		Paravirtualization: &paravirtualizationPostSourceServerBody,
		HasRsync: &hasRsyncPostSourceServerBody,
		Networks: &listNetworksbody,
		BtrfsList: &listBtrfsListbody,
		Disks: &listDisksbody,
		Memory: &memoryPostSourceServerBody,
		CpuQuantity: &cpuQuantityPostSourceServerBody,
		Firmware: &firmwarePostSourceServerBody,
		LinuxBlockCheck: &linuxBlockCheckPostSourceServerBody,
		VirtualizationType: &virtualizationTypePostSourceServerBody,
		OsVersion: &osVersionPostSourceServerBody,
		OsType: model.GetPostSourceServerBodyOsTypeEnum().LINUX,
		Name: "host-192-168-136-xxx",
		Ip: "192.168.136.xxx",
	}
	response, err := client.RegisterServer(request)
	if err == nil {
        fmt.Printf("%+v\n", response)
    } else {
        fmt.Println(err)
    }
}

For more SDK sample code of programming languages, visit API Explorer and click the Sample Code tab. Example code can be automatically generated.

Status Codes

Status Code

Description

200

The source server has been registered with SMS.

Error Codes

For details, see Error Codes.