-
Notifications
You must be signed in to change notification settings - Fork 61
/
Copy pathepc.py
368 lines (324 loc) · 12.9 KB
/
epc.py
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
#!/usr/bin/python
# -*- encoding:utf-8 -*-
import json,pprint
from prettyprinter import prettyPrinter
from kscore.session import get_session
if __name__ == "__main__":
s = get_session()
region='cn-beijing-6'
epcClient = s.create_client("epc", region, use_ssl=True)
# 注:如果参数名中包含.请使用JSON格式数据,如参数名 HostId.N 、 Filter.N.Name 、 Filter.N.Value.1
# ------------------CreateEpc( 创建云物理主机)--------------------------
# param = {
# 'AvailabilityZone': 'cn-shanghai-3b',
# 'ImageId': 'f38624d3-0719-4e5d-970f-cad32095a7cf',
# 'HostName': 'test',
# 'NetworkInterfaceMode': 'single',
# 'SubnetId': '58c57698-4bf0-4af9-a984-fb152e54a866',
# 'SecurityGroupId.1': '251905f6-1316-4533-a599-ac8481a9afae',
# 'SecurityGroupId.2': 'fb76854b-f23a-4354-ac07-4a12aec29c71',
# 'KeyId': '66182581-fe49-41d8-b2c4-1c59ba6d200a',
# 'ChargeType': 'PostPaidByDay',
# 'Password': 'Test@Password1234',
# 'SecurityAgent': 'classic',
# 'CloudMonitorAgent': 'classic',
# 'Raid': 'Raid1',
# 'HostType': 'CAL'
# }
# resp=epcClient.create_epc(**param)
# print(resp)
# ------------------DeleteEpc(删除云物理主机)--------------------------
# param = {
# 'HostId': 'a0e64a51-2fb9-4dd6-b5c4-0dcd8ff79b87'
# }
# resp = epcClient.delete_epc(**param)
# # # 或者
# # resp = epcClient.delete_epc(HostId='a0e64a51-2fb9-4dd6-b5c4-0dcd8ff79b87')
# print(resp)
# ------------------ModifyEpc(更新云物理主机信息)--------------------------
# param = {
# 'HostId': 'a0e64a51-2fb9-4dd6-b5c4-0dcd8ff79b87',
# 'HostName': 'test1'
# }
# # resp = epcClient.modify_epc(**param)
# # # 或者
# # resp = epcClient.modify_epc(HostId='a0e64a51-2fb9-4dd6-b5c4-0dcd8ff79b87',HostName='test2')
# print(resp)
# ------------------DescribeEpcs(获取云物理主机列表信息)--------------------------
# 简单查询
# resp=epcClient.describe_epcs(MaxResults=7,NextToken=1)
# 复杂查询
param = {
'HostId.1': 'd25d1261-506b-427b-8637-2fc6f7fcc0e1',
'HostId.2': 'f3207312-8be0-44d5-af1c-96f899751711',
'Filter.1.Name': 'host-type',
'Filter.1.Value.1': 'CAL',
'Filter.1.Value.2': 'SSD',
'MaxResults': 20,
'NextToken': 1
}
resp=epcClient.describe_epcs(**param)
print(resp)
# ------------------StartEpc( 启动云物理主机)--------------------------
# param = {
# 'HostId': 'a0e64a51-2fb9-4dd6-b5c4-0dcd8ff79b87'
# }
# resp = epcClient.start_epc(**param)
# print(resp)
# ------------------StopEpc (关闭云物理主机)--------------------------
# param = {
# 'HostId': 'a0e64a51-2fb9-4dd6-b5c4-0dcd8ff79b87'
# }
# resp = epcClient.stop_epc(**param)
# print(resp)
# ------------------RebootEpc(重启云物理主机)--------------------------
# param = {
# 'HostId': 'a0e64a51-2fb9-4dd6-b5c4-0dcd8ff79b87'
# }
# resp = epcClient.reboot_epc(**param)
# print(resp)
# ------------------ReinstallEpc(重装云物理主机)--------------------------
# param = {
# 'HostId': 'a0e64a51-2fb9-4dd6-b5c4-0dcd8ff79b87',
# 'ImageId': '0b11b872-d8e6-11e8-803a-e8611f1450d8',
# 'KeyId':'66182581 - fe49 - 41d8 - b2c4 - 1c59ba6d200a',
# 'Password':'Test@Password1234',
# 'NetworkInterfaceMode':'bond4',
# 'SecurityAgent':'classic',
# 'CloudMonitorAgent':'classic',
# 'Raid':'Raid1'
# }
# resp = epcClient.reinstall_epc(**param)
# print(resp)
# ------------------ReinstallCustomerEpc(重装托管云物理主机)--------------------------
# param = {
# 'HostId': 'a0e64a51-2fb9-4dd6-b5c4-0dcd8ff79b87',
# 'ServerIp': '127.0.0.1',
# 'Path': '/linux.0'
# }
# resp = epcClient.reinstall_customer_epc(**param)
# print(resp)
# ------------------ReinstallCustomerEpc(重装托管云物理主机)--------------------------
# param = {
# 'HostId': 'a0e64a51-2fb9-4dd6-b5c4-0dcd8ff79b87',
# 'ServerIp': '127.0.0.1',
# 'Path': '/linux.0'
# }
# resp = epcClient.reinstall_customer_epc(**param)
# print(resp)
# ------------------CreateImage(创建自定义镜像)--------------------------
# param = {
# 'HostId': 'a0e64a51-2fb9-4dd6-b5c4-0dcd8ff79b87',
# 'ImageName': 'image-test'
# }
# resp = epcClient.create_image(**param)
# print(resp)
# ------------------ModifyImage(修改自定义镜像信息)--------------------------
# param = {
# 'ImageId': 'a0e64a51-2fb9-4dd6-b5c4-0dcd8ff79b87',
# 'ImageName': 'image-update'
# }
# resp = epcClient.modify_image(**param)
# print(resp)
# ------------------DeleteImage(删除自定义镜像)--------------------------
# param = {
# 'ImageId': 'a0e64a51-2fb9-4dd6-b5c4-0dcd8ff79b87'
# }
# resp = epcClient.delete_image(**param)
# print(resp)
# ------------------DescribeImages(查看云物理主机镜像信息)--------------------------
# param = {
# 'ImageId.1': '9841bf74-1503-11ec-8427-e8611f1450d8',
# 'ImageId.2':'8747e162-1503-11ec-8427-e8611f1450d8',
# 'ImageId.3':'prtba3010e4-b671-40d8-8252-2b77ae292d71',
# 'Filter.1.Name': 'image-type',
# 'Filter.1.Value.1': 'base',
# 'Filter.1.Value.2': 'private',
# 'Filter.2.Name': 'disk-type',
# 'Filter.2.Value.1': 'local',
# }
# resp = epcClient.describe_images(**param)
# print(resp)
# ------------------ModifyNetworkInterfaceAttribute(修改网卡信息)--------------------------
# param = {
# 'HostId': 'a0e64a51-2fb9-4dd6-b5c4-0dcd8ff79b87',
# 'NetworkInterfaceId': 'a0e64a51-2fb9-4dd6-b5c4-0dcd8ff79b87',
# 'SubnetId': '58c57698-4bf0-4af9-a984-fb152e54a866',
# 'IpAddress':'10.10.10.10',
# 'SecurityGroupId.1': '251905f6-1316-4533-a599-ac8481a9afae'
# }
# resp = epcClient.modify_network_interface_attribute(**param)
# print(resp)
# ------------------ModifyDns(修改网卡DNS信息)--------------------------
# param = {
# 'HostId': 'a0e64a51-2fb9-4dd6-b5c4-0dcd8ff79b87',
# 'NetworkInterfaceId': 'a0e64a51-2fb9-4dd6-b5c4-0dcd8ff79b87',
# 'DNS1': '10.10.10.10',
# 'DNS2': '10.10.10.10'
# }
# resp = epcClient.modify_dns(**param)
# print(resp)
# ------------------ModifySecurityGroup(修改网卡安全组信息)--------------------------
# param = {
# 'HostId': 'a0e64a51-2fb9-4dd6-b5c4-0dcd8ff79b87',
# 'NetworkInterfaceId': 'a0e64a51-2fb9-4dd6-b5c4-0dcd8ff79b87',
# 'SecurityGroupId.1': '251905f6-1316-4533-a599-ac8481a9afae'
# }
# resp = epcClient.modify_security_group(**param)
# print(resp)
# ------------------DescribePhysicalMonitor(获取硬件监控信息)--------------------------
# param = {
# 'HostId': 'a0e64a51-2fb9-4dd6-b5c4-0dcd8ff79b87'
# }
# resp = epcClient.describe_physical_monitor(**param)
# print(resp)
# ------------------CreateRemoteManagement(创建带外管理)--------------------------
# param = {
# 'PhoneNumber': '12345678901',
# 'Pin': '111111',
# 'Name': 'test'
# }
# resp = epcClient.create_remote_management(**param)
# print(resp)
# ------------------ModifyRemoteManagement(修改带外管理)--------------------------
# param = {
# 'RemoteManagementId': 'b75c6797-5562-4af4-b96f-38aeb0b4329f',
# 'Name': 'test2'
# }
# resp = epcClient.modify_remote_management(**param)
# print(resp)
# ------------------DeleteRemoteManagement(删除带外管理)--------------------------
# param = {
# 'RemoteManagementId': 'b75c6797-5562-4af4-b96f-38aeb0b4329f'
# }
# resp = epcClient.delete_remote_management(**param)
# print(resp)
# ------------------GetDynamicCode(获取验证码)--------------------------
# param = {
# 'RemoteManagementId': 'b75c6797-5562-4af4-b96f-38aeb0b4329f'
# }
# resp = epcClient.get_dynamic_code(**param)
# print(resp)
# ------------------DescribeRemoteManagements(查询带外管理信息)--------------------------
# param = {
# 'RemoteManagementId.1': '5d6620c1-6a23-40e4-bfd6-9be8ed7afc65'
# }
# resp = epcClient.describe_remote_managements(**param)
# print(resp)
# ------------------DescribeEpcManagements(查询ILO信息)--------------------------
# param = {
# 'RemoteManagementId': '5d6620c1-6a23-40e4-bfd6-9be8ed7afc65',
# 'DynamicCode': '123456',
# 'Pin': '111111',
# 'MaxResults': 20,
# 'NextToken': '1'
# }
# resp = epcClient.describe_epc_managements(**param)
# print(resp)
# ------------------DescribeVpns(查询VPN信息)--------------------------
# param = {
# 'RemoteManagementId': '5d6620c1-6a23-40e4-bfd6-9be8ed7afc65',
# 'DynamicCode': '123456',
# 'Pin': '111111'
# }
# resp = epcClient.describe_vpns(**param)
# print(resp)
# ------------------ModifyHyperThreading(修改超线程)--------------------------
# param = {
# 'HostId': 'a0e64a51-2fb9-4dd6-b5c4-0dcd8ff79b87',
# 'HyperThreadingStatus': 'start'
# }
# resp = epcClient.modify_hyper_threading(**param)
# print(resp)
# ------------------ResetPassword(重置密码)--------------------------
# param = {
# 'HostId': 'a0e64a51-2fb9-4dd6-b5c4-0dcd8ff79b87',
# 'Password': 'Test@Passwrod'
# }
# resp = epcClient.reset_password(**param)
# print(resp)
# ------------------DescribeEpcStocks(查询云物理主机的库存)--------------------------
# param = {
# 'Filter.1.Name': 'host-type',
# 'Filter.1.Value.1': 'CAL',
# 'Filter.1.Value.1': 'SSD'
# }
# resp = epcClient.describe_epc_stocks(**param)
# print(resp)
# ------------------DescribeEpcDeviceAttributes(获取云物理设备列表信息)--------------------------
# param = {
# 'Filter.1.Name': 'host-type',
# 'Filter.1.Value.1': 'CAL',
# 'Filter.1.Value.1': 'SSD'
# }
# resp = epcClient.describe_epc_device_attributes(**param)
# print(resp)
# ------------------DescribeProcesses(查询工单信息)--------------------------
# param = {
# 'OperationProcessId.1': '0a8b50f2-589a-445a-913a-b095fe60a726',
# 'Filter.1.Name': 'sn',
# 'Filter.1.Value.1': 'test-2-46',
# 'MaxResults': 20,
# 'NextToken': '1'
# }
# resp = epcClient.describe_processes(**param)
# print(resp)
# ------------------CreateProcess(创建故障替换工单)--------------------------
# param = {
# 'HostIdentificationType': 'sn',
# 'Confirm': '0',
# 'Content': 'test',
# 'Type': 'fix',
# 'AvailabilityZone': 'cn-shanghai-3b',
# 'Title': 'test',
# 'ProcessId': '79cd4aa4-8373-4387-a59f-ae5b31663671',
# 'Sn': 'PC0KCJXS',
# 'MachineCount': '1'
# }
# resp = epcClient.create_process(**param)
# print(resp)
# ------------------DeleteProcess(删除工单信息)--------------------------
# param = {
# 'OperationProcessId': '0a8b50f2-589a-445a-913a-b095fe60a726',
# }
# resp = epcClient.delete_process(**param)
# print(resp)
# ------------------ReplyProcess(回复工单信息)--------------------------
# param = {
# 'OperationProcessId': '0a8b50f2-589a-445a-913a-b095fe60a726',
# 'Remarks': 'test'
# }
# resp = epcClient.reply_process(**param)
# print(resp)
# ------------------DescribeInspections(物理机巡检信息)--------------------------
# param = {
# 'MaxResults': 20,
# 'NextToken': '1'
# }
# resp = epcClient.describe_inspections(**param)
# print(resp)
# ------------------CreateCabinet (创建机柜)-------------------------
# param = {
# 'CabinetName': 'test',
# 'ChargeType': 'PostPaidByDay',
# 'CabinetType': 'Reserved',
# 'AvailabilityZone': 'cn-shanghai-3a'
# }
# resp = epcClient.create_cabinet(**param)
# print(resp)
# ------------------DescribeCabinets(获取云物理主机托管机柜列表信息)--------------------------
# param = {
# 'CabinetId.1': '597f7731-0359-4604-b2cd-08586d2bcaf4',
# 'MaxResults': 20,
# 'NextToken': '1'
# }
# resp = epcClient.describe_cabinets(**param)
# print(resp)
# ------------------ModifySecurityGroup(修改网卡安全组信息)--------------------------
# param = {
# 'HostId': 'a0e64a51-2fb9-4dd6-b5c4-0dcd8ff79b87',
# 'NetworkInterfaceId': 'a0e64a51-2fb9-4dd6-b5c4-0dcd8ff79b87',
# 'SecurityGroupId.1': '251905f6-1316-4533-a599-ac8481a9afae'
# }
# resp = epcClient.modify_security_group(**param)
# print(resp)