|
6 | 6 | IsolateCluster, |
7 | 7 | ResetAccountPassword, |
8 | 8 | DescribeServerlessInstanceSpecs, |
9 | | - OfflineCluster, |
| 9 | + // OfflineCluster, |
| 10 | + OfflineInstance, |
10 | 11 | DescribeInstances, |
11 | 12 | OpenWan, |
12 | 13 | CloseWan, |
@@ -248,40 +249,45 @@ async function isolateCluster(capi, clusterId) { |
248 | 249 | * @param {*} clusterId cluster id |
249 | 250 | * @param {*} instanceId instance id |
250 | 251 | */ |
251 | | -async function offlineInstance(capi, clusterId, instanceId) { |
252 | | - console.log(`Start offlining CynosDB instance id: ${instanceId}`); |
253 | | - await OfflineCluster(capi, { |
254 | | - ClusterId: clusterId, |
255 | | - InstanceIdList: [instanceId], |
256 | | - }); |
257 | | - const detail = await waitResponse({ |
258 | | - callback: async () => getInstanceDetail(capi, clusterId), |
259 | | - targetResponse: undefined, |
260 | | - timeout: TIMEOUT, |
261 | | - }); |
262 | | - console.log(`Offlined CynosDB instance id: ${instanceId}`); |
263 | | - return detail; |
264 | | -} |
265 | | - |
266 | | -/** |
267 | | - * offline db cluster |
268 | | - * @param {object} capi capi client |
269 | | - * @param {string} clusterId cluster id |
270 | | - */ |
271 | 252 | async function offlineCluster(capi, clusterId) { |
272 | | - console.log(`Start offlining CynosDB cluster id: ${clusterId}`); |
273 | | - await OfflineCluster(capi, { |
| 253 | + // 1. get cluster instances |
| 254 | + const instances = await getClusterInstances(capi, clusterId); |
| 255 | + const instanceIds = instances.map((item) => item.InstanceId); |
| 256 | + console.log(`Start offlining CynosDB id: ${clusterId}`); |
| 257 | + |
| 258 | + await OfflineInstance(capi, { |
274 | 259 | ClusterId: clusterId, |
| 260 | + InstanceIdList: instanceIds, |
275 | 261 | }); |
| 262 | + |
276 | 263 | const detail = await waitResponse({ |
277 | 264 | callback: async () => getClusterDetail(capi, clusterId), |
278 | 265 | targetResponse: undefined, |
279 | 266 | timeout: TIMEOUT, |
280 | 267 | }); |
281 | | - console.log(`Offlined CynosDB cluster id: ${clusterId}.`); |
| 268 | + console.log(`Offlined CynosDB id: ${clusterId}`); |
282 | 269 | return detail; |
283 | 270 | } |
284 | 271 |
|
| 272 | +// /** |
| 273 | +// * offline db cluster |
| 274 | +// * @param {object} capi capi client |
| 275 | +// * @param {string} clusterId cluster id |
| 276 | +// */ |
| 277 | +// async function offlineCluster(capi, clusterId) { |
| 278 | +// console.log(`Start offlining CynosDB cluster id: ${clusterId}`); |
| 279 | +// await OfflineCluster(capi, { |
| 280 | +// ClusterId: clusterId, |
| 281 | +// }); |
| 282 | +// const detail = await waitResponse({ |
| 283 | +// callback: async () => getClusterDetail(capi, clusterId), |
| 284 | +// targetResponse: undefined, |
| 285 | +// timeout: TIMEOUT, |
| 286 | +// }); |
| 287 | +// console.log(`Offlined CynosDB cluster id: ${clusterId}.`); |
| 288 | +// return detail; |
| 289 | +// } |
| 290 | + |
285 | 291 | async function resetPwd(capi, inputs) { |
286 | 292 | console.log( |
287 | 293 | `Start reset password for CynosDB cluster id: ${inputs.clusterId}, account: ${inputs.adminName}`, |
@@ -358,7 +364,6 @@ module.exports = { |
358 | 364 | getClusterInstances, |
359 | 365 | isolateCluster, |
360 | 366 | offlineCluster, |
361 | | - offlineInstance, |
362 | 367 | getInstanceDetail, |
363 | 368 | openPublicAccess, |
364 | 369 | closePublicAccess, |
|
0 commit comments