12
12
13
13
# https://docs.ksyun.com/read/latest/52/_book/oaRunInstances.html
14
14
client .run_instances (
15
- MaxCount = 50 , MinCount = 20 , ImageId = "3f3bddcf-4982-4ab4-a63d-795e8d74e9d5" ,
16
- SubnetId = "f1bd236b-7fd3-44d3-aef9-2d673a65466e" , InstancePassword = "Ksyun2017" ,
17
- SecurityGroupId = "2f43a9e4-1a3c-448e-b661-efa6d04b82fc" , DataDiskGb = 50 , ChargeType = "Monthly" ,
18
- InstanceType = "C1.1A" , PurchaseTime = 1 , InstanceName = "test" , InstanceNameSuffix = "1" )
15
+ MaxCount = 50 , MinCount = 20 , ImageId = "3f3bddcf-4982-4ab4-a63d-795e8d74e9d5" ,
16
+ SubnetId = "f1bd236b-7fd3-44d3-aef9-2d673a65466e" , InstancePassword = "Ksyun2017" ,
17
+ SecurityGroupId = "2f43a9e4-1a3c-448e-b661-efa6d04b82fc" , DataDiskGb = 50 , ChargeType = "Monthly" ,
18
+ InstanceType = "C1.1A" , PurchaseTime = 1 , InstanceName = "test" , InstanceNameSuffix = "1" )
19
19
20
20
# https://docs.ksyun.com/read/latest/52/_book/oaTerminateInstances.html
21
21
instances = ["2f43a9e4-1a3c-448e-b661-efa6d04b82fc" , "2f43a9e4-1a3c-448e-b661-efa6d04b82fc" ]
24
24
25
25
client .terminate_instances (** instances )
26
26
27
- #用户查询竞价实例历史价格列表
27
+ # 用户查询竞价实例历史价格列表
28
28
# pprint("-------------------------------用户查询竞价实例历史价格列表---------------------------------")
29
29
# _spot_price = client.describe_spot_price_history(InstanceType="E1.1A", AvailabilityZone="cn-shanghai-3a")
30
30
# pprint(_spot_price)
31
31
32
- #查看主机价格
32
+ # 查看主机价格
33
33
# pprint("-------------------------------查看主机价格---------------------------------")
34
34
# _instance_price = client.describe_price(InstanceType="N3.1A", ImageId="IMG-5a7cb0e5-d297-4259-9944-38b3c053a7dc", ChargeType="Daily", SriovNetSupport=True)
35
35
# pprint(_instance_price)
36
36
37
- #创建实例启动模板
37
+ # 创建实例启动模板
38
38
# pprint("-------------------------------创建实例启动模板---------------------------------")
39
39
# _instance_model = client.create_model(ImageId="IMG-5a7cb0e5-d297-4259-9944-38b3c053a7dc",
40
40
# SubnetId="afa859fc-65ea-410d-99f2-d686cf9da1d9",
43
43
# InstanceType="N3.1A")
44
44
# pprint(_instance_model)
45
45
46
- #删除实例启动模板
46
+ # 删除实例启动模板
47
47
# pprint("-------------------------------删除实例启动模板---------------------------------")
48
48
# models = ["0565ffc5-55e3-44e9-b242-5ed3de725ee0"]
49
49
# models = dict(("ModelId.{}".format(index), model) for index, model in enumerate(models, 1))
50
50
# _del_model = client.terminate_models(**models)
51
51
# pprint(_del_model)
52
52
53
- #查看实例启动模板
53
+ # 查看实例启动模板
54
54
# pprint("-------------------------------查看实例启动模板---------------------------------")
55
55
# _des_models = client.describe_models()
56
56
# pprint(_des_models)
57
57
58
- #云主机迁入容灾组
58
+ # 云主机迁入容灾组
59
59
# pprint("-------------------------------云主机迁入容灾组-------------------------------")
60
60
# instances = ["5e78a001-e472-44f5-9aa4-c822a8121319"]
61
61
# instances = dict(("InstanceId.{}".format(index), instance) for index, instance in enumerate(instances, 1))
62
62
# add_vm_into_data_guard = client.add_vm_into_data_guard(DataGuardId="ec148c88-5958-49dc-97a2-76fc21c4552a", **instances)
63
63
# pprint(add_vm_into_data_guard)
64
64
65
- #修改容灾分组名称
65
+ # 修改容灾分组名称
66
66
# pprint("-------------------------------修改容灾分组名称--------------------------------")
67
67
# mod_data_guard_group_name = client.modify_data_guard_groups(DataGuardId="ec148c88-5958-49dc-97a2-76fc21c4552a", DataGuardName="wyn_test")
68
68
# pprint(mod_data_guard_group_name)
69
69
70
- #查询用户某区域的容灾分组容量
70
+ # 查询用户某区域的容灾分组容量
71
71
# pprint("-------------------------------查询用户某区域的容灾分组容量--------------------------------")
72
72
# des_data_guard_capacity = client.describe_data_guard_capacity()
73
73
# pprint(des_data_guard_capacity)
74
74
75
- #创建容灾分组
75
+ # 创建容灾分组
76
76
# pprint("-------------------------------创建容灾分组---------------------------------")
77
77
# cre_data_guard_group = client.create_data_guard_group(DataGuardName="my_dataguard_test")
78
78
# pprint(cre_data_guard_group)
79
79
80
- #删除容灾分组
80
+ # 删除容灾分组
81
81
# pprint("-------------------------------删除容灾分组---------------------------------")
82
82
# data_guards = ["ec148c88-5958-49dc-97a2-76fc21c4552a"]
83
83
# data_guards = dict(("DataGuardId.{}".format(index), data_guard) for index, data_guard in enumerate(data_guards, 1))
84
84
# del_data_guard_groups = client.delete_data_guard_groups(**data_guards)
85
85
# pprint(del_data_guard_groups)
86
86
87
- #查询容灾组信息
87
+ # 查询容灾组信息
88
88
# pprint("-------------------------------查询容灾组信息---------------------------------")
89
89
# des_data_guard_group = client.describe_data_guard_group()
90
90
# pprint(des_data_guard_group)
91
91
92
- #云主机从容灾组中移除
92
+ # 云主机从容灾组中移除
93
93
# pprint("-------------------------------云主机从容灾组中移除---------------------------------")
94
94
# instances = ["5e78a001-e472-44f5-9aa4-c822a8121319"]
95
95
# instances = dict(("InstanceId.{}".format(index), instance) for index, instance in enumerate(instances, 1))
99
99
# #镜像导入
100
100
# client.import_image(ImageName="", Architecture="", Platform="", ImageUrl="", ImageFormat="")
101
101
102
- #镜像复制
102
+ # 镜像复制
103
103
# pprint("-------------------------------镜像复制---------------------------------")
104
104
# param = {
105
105
# "ImageId.1": "432eb1f8-72f3-4320-a0f7-572b33b32431",
108
108
# copy_image = client.copy_image(**param)
109
109
# pprint(copy_image)
110
110
111
- #查看镜像分享信息
111
+ # 查看镜像分享信息
112
112
# pprint("-------------------------------查看镜像分享信息---------------------------------")
113
113
# describe_image_share_permission = client.describe_image_share_permission(ImageId="e5b7d077-021c-4fb2-9d0e-fa4700f99b58")
114
114
# pprint(describe_image_share_permission)
115
115
116
- #修改镜像分享信息
116
+ # 修改镜像分享信息
117
117
# pprint("-------------------------------修改镜像分享信息---------------------------------")
118
118
# accounts = ["73403544"]
119
119
# accounts = dict(("AccountId.{}".format(index), account) for index, account in enumerate(accounts, 1))
120
120
# modify_image_share_permission = client.modify_image_share_permission(ImageId="e5b7d077-021c-4fb2-9d0e-fa4700f99b58", Permission="share", **accounts)
121
121
# pprint(modify_image_share_permission)
122
122
123
- #镜像预热
123
+ # 镜像预热
124
124
# pprint("-------------------------------镜像预热---------------------------------")
125
125
# enable_image_caching = client.enable_image_caching(ImageId="432eb1f8-72f3-4320-a0f7-572b33b32431")
126
126
# pprint(enable_image_caching)
127
127
128
- #取消镜像预热
128
+ # 取消镜像预热
129
129
# pprint("-------------------------------取消镜像预热---------------------------------")
130
130
# disable_image_caching = client.disable_image_caching(ImageId="432eb1f8-72f3-4320-a0f7-572b33b32431")
131
131
# pprint(disable_image_caching)
132
132
133
- #创建本地盘快照
133
+ # 创建本地盘快照
134
134
# pprint("-------------------------------创建本地盘快照---------------------------------")
135
135
# create_local_volume_snapshot = client.create_local_volume_snapshot(LocalVolumeId="58ce95e4-0e8f-44e1-8134-dca14697c103-a", LocalVolumeSnapshotName="wyn_test")
136
136
# pprint(create_local_volume_snapshot)
137
137
138
- #回滚快照
138
+ # 回滚快照
139
139
# pprint("-------------------------------回滚快照---------------------------------")
140
140
# rollback_local_volume = client.rollback_local_volume(LocalVolumeSnapshotId="6c08b3ff-34c2-4948-b81d-4c8cc9b7a084")
141
141
# pprint(rollback_local_volume)
142
142
143
- #删除快照
143
+ # 删除快照
144
144
# pprint("-------------------------------删除快照---------------------------------")
145
145
# local_volume_snapshots = ["6c08b3ff-34c2-4948-b81d-4c8cc9b7a084"]
146
146
# local_volume_snapshots = dict(("LocalVolumeSnapshotId.{}".format(index), local_volume_snapshot) for index, local_volume_snapshot in enumerate(local_volume_snapshots, 1))
147
147
# delete_local_volume_snapshot = client.delete_local_volume_snapshot(**local_volume_snapshots)
148
148
# pprint(delete_local_volume_snapshot)
149
149
150
- #主机绑定密钥
150
+ # 主机绑定密钥
151
151
# pprint("-------------------------------主机绑定密钥---------------------------------")
152
152
# param = {
153
153
# "InstanceId.1": "5e78a001-e472-44f5-9aa4-c822a8121319",
156
156
# attach_key = client.attach_key(**param)
157
157
# pprint(attach_key)
158
158
159
- #主机解绑密钥
159
+ # 主机解绑密钥
160
160
# pprint("-------------------------------主机解绑密钥---------------------------------")
161
161
# param = {
162
162
# "InstanceId.1": "5e78a001-e472-44f5-9aa4-c822a8121319",
163
163
# "KeyId.1": "c079a41f-beb4-4b73-a68c-69f25b9c8819"
164
164
# }
165
165
# detach_key = client.detach_key(**param)
166
- # pprint(detach_key)
166
+ # pprint(detach_key)
167
+
168
+ # 获取弹性伸缩配置
169
+ # pprint("-------------------------------获取弹性伸缩配置---------------------------------")
170
+ # list = client.describe_scaling_configuration()
171
+ # print(list)
172
+
173
+ # 创建弹性伸缩配置
174
+ # pprint("-------------------------------创建弹性伸缩配置---------------------------------")
175
+ # # API参数参见: https://docs.ksyun.com/documents/28246
176
+ # res = client.create_scaling_configuration(**{
177
+ # "ScalingConfigurationName": "test-scaling-configuration",
178
+ # "ImageId": "IMG-5465174a-6d71-4770-b8e1-917a0dd92466",
179
+ # "InstanceType": "N3.4B",
180
+ # "ChargeType": "HourlyInstantSettlement",
181
+ # "ProjectId": 0,
182
+ # "KeyId.1": "71c17c37-c9cb-4faf-a86e-d76d35f3c4d9",
183
+ # "DataDisk.1.Type": "SSD3.0",
184
+ # "DataDisk.1.Size": 50,
185
+ # "DataDisk.1.deleteWithInstance": True,
186
+ # "SystemDisk.DiskType": "SSD3.0",
187
+ # "SystemDisk.DiskSize": 40,
188
+ # })
189
+ # print(res)
190
+
191
+ # 编辑弹性伸缩配置
192
+ # pprint("-------------------------------编辑弹性伸缩配置---------------------------------")
193
+ # # API参数参见: https://docs.ksyun.com/documents/28247
194
+ # res = client.modify_scaling_configuration(**{
195
+ # "ScalingConfigurationId": res["ScalingConfigurationId"],
196
+ # "ScalingConfigurationName": "test-scaling-configuration123",
197
+ # })
198
+ # print(res)
199
+
200
+ # 删除弹性伸缩配置
201
+ # pprint("-------------------------------删除弹性伸缩配置---------------------------------")
202
+ # res = client.delete_scaling_configuration(**{
203
+ # "ScalingConfigurationId.1": res["ScalingConfigurationId"]
204
+ # })
205
+ # print(res)
0 commit comments