forked from huaweicloud/huaweicloud-sdk-go-v3
-
Notifications
You must be signed in to change notification settings - Fork 0
/
model_server.go
230 lines (178 loc) · 5.17 KB
/
model_server.go
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
package model
import (
"github.com/dysodeng/huaweicloud-sdk-go-v3/core/utils"
"errors"
"github.com/dysodeng/huaweicloud-sdk-go-v3/core/converter"
"strings"
)
// Server 源端服务器
type Server struct {
// 源端在SMS数据库中的ID
Id *string `json:"id,omitempty"`
// 源端服务器IP,注册源端时必选,更新非必选
Ip string `json:"ip"`
// 用来区分不同源端服务器的名称
Name string `json:"name"`
// 源端主机名,注册源端必选,更新非必选
Hostname *string `json:"hostname,omitempty"`
// 源端服务器的OS类型,分为Windows和Linux,注册必选,更新非必选
OsType ServerOsType `json:"os_type"`
// 操作系统版本,注册必选,更新非必选
OsVersion *string `json:"os_version,omitempty"`
// 源端服务器启动类型,如BIOS或者UEFI
Firmware *ServerFirmware `json:"firmware,omitempty"`
// CPU个数,单位vCPU
CpuQuantity *int32 `json:"cpu_quantity,omitempty"`
// 内存大小,单位MB
Memory *int64 `json:"memory,omitempty"`
// 源端服务器的磁盘信息
Disks *[]Disk `json:"disks,omitempty"`
// Linux 必选,源端的Btrfs信息。如果源端不存在Btrfs,则为[]
BtrfsList *[]BtrfsFileSystem `json:"btrfs_list,omitempty"`
// 源端服务器的网卡信息
Networks *[]NetWork `json:"networks,omitempty"`
// 租户的domainId
DomainId *string `json:"domain_id,omitempty"`
// 是否安装rsync组件,Linux系统此参数为必选
HasRsync *bool `json:"has_rsync,omitempty"`
// Linux场景必选,源端是否是半虚拟化
Paravirtualization *bool `json:"paravirtualization,omitempty"`
// Linux必选,裸设备列表
RawDevices *string `json:"raw_devices,omitempty"`
// Windows 必选,是否缺少驱动文件
DriverFiles *bool `json:"driver_files,omitempty"`
// Windows必选,是否存在不正常服务
SystemServices *bool `json:"system_services,omitempty"`
// Windows必选,权限是否满足要求
AccountRights *bool `json:"account_rights,omitempty"`
// Linux必选,系统引导类型,BOOT_LOADER(GRUB/LILO)
BootLoader *ServerBootLoader `json:"boot_loader,omitempty"`
// Windows必选,系统目录
SystemDir *string `json:"system_dir,omitempty"`
// Linux必选,如果没有卷组,输入[]
VolumeGroups *[]VolumeGroups `json:"volume_groups,omitempty"`
}
func (o Server) String() string {
data, err := utils.Marshal(o)
if err != nil {
return "Server struct{}"
}
return strings.Join([]string{"Server", string(data)}, " ")
}
type ServerOsType struct {
value string
}
type ServerOsTypeEnum struct {
WINDOWS ServerOsType
LINUX ServerOsType
}
func GetServerOsTypeEnum() ServerOsTypeEnum {
return ServerOsTypeEnum{
WINDOWS: ServerOsType{
value: "WINDOWS",
},
LINUX: ServerOsType{
value: "LINUX",
},
}
}
func (c ServerOsType) Value() string {
return c.value
}
func (c ServerOsType) MarshalJSON() ([]byte, error) {
return utils.Marshal(c.value)
}
func (c *ServerOsType) UnmarshalJSON(b []byte) error {
myConverter := converter.StringConverterFactory("string")
if myConverter == nil {
return errors.New("unsupported StringConverter type: string")
}
interf, err := myConverter.CovertStringToInterface(strings.Trim(string(b[:]), "\""))
if err != nil {
return err
}
if val, ok := interf.(string); ok {
c.value = val
return nil
} else {
return errors.New("convert enum data to string error")
}
}
type ServerFirmware struct {
value string
}
type ServerFirmwareEnum struct {
BIOS ServerFirmware
UEFI ServerFirmware
}
func GetServerFirmwareEnum() ServerFirmwareEnum {
return ServerFirmwareEnum{
BIOS: ServerFirmware{
value: "BIOS",
},
UEFI: ServerFirmware{
value: "UEFI",
},
}
}
func (c ServerFirmware) Value() string {
return c.value
}
func (c ServerFirmware) MarshalJSON() ([]byte, error) {
return utils.Marshal(c.value)
}
func (c *ServerFirmware) UnmarshalJSON(b []byte) error {
myConverter := converter.StringConverterFactory("string")
if myConverter == nil {
return errors.New("unsupported StringConverter type: string")
}
interf, err := myConverter.CovertStringToInterface(strings.Trim(string(b[:]), "\""))
if err != nil {
return err
}
if val, ok := interf.(string); ok {
c.value = val
return nil
} else {
return errors.New("convert enum data to string error")
}
}
type ServerBootLoader struct {
value string
}
type ServerBootLoaderEnum struct {
GRUB ServerBootLoader
LILO ServerBootLoader
}
func GetServerBootLoaderEnum() ServerBootLoaderEnum {
return ServerBootLoaderEnum{
GRUB: ServerBootLoader{
value: "GRUB",
},
LILO: ServerBootLoader{
value: "LILO",
},
}
}
func (c ServerBootLoader) Value() string {
return c.value
}
func (c ServerBootLoader) MarshalJSON() ([]byte, error) {
return utils.Marshal(c.value)
}
func (c *ServerBootLoader) UnmarshalJSON(b []byte) error {
myConverter := converter.StringConverterFactory("string")
if myConverter == nil {
return errors.New("unsupported StringConverter type: string")
}
interf, err := myConverter.CovertStringToInterface(strings.Trim(string(b[:]), "\""))
if err != nil {
return err
}
if val, ok := interf.(string); ok {
c.value = val
return nil
} else {
return errors.New("convert enum data to string error")
}
}