-
Notifications
You must be signed in to change notification settings - Fork 54
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
42 changed files
with
3,753 additions
and
18 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
49 changes: 49 additions & 0 deletions
49
dbm-ui/frontend/src/hooks/useTicketCloneInfo/generateCloneData/redis/migrateCluster.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,49 @@ | ||
/* | ||
* TencentBlueKing is pleased to support the open source community by making 蓝鲸智云-DB管理系统(BlueKing-BK-DBM) available. | ||
* | ||
* Copyright (C) 2017-2023 THL A29 Limited, a Tencent company. All rights reserved. | ||
* | ||
* Licensed under the MIT License (the "License"); you may not use this file except in compliance with the License. | ||
* You may obtain a copy of the License at https://opensource.org/licenses/MIT | ||
* | ||
* Unless required by applicable law or agreed to in writing, software distributed under the License is distributed | ||
* on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for | ||
* the specific language governing permissions and limitations under the License. | ||
*/ | ||
import type { RedisClusterMigrate } from '@services/model/ticket/details/redis'; | ||
import TicketModel from '@services/model/ticket/ticket'; | ||
|
||
import { random } from '@utils'; | ||
|
||
// Redis 集群迁移 | ||
export async function generateRedisMigrateClusterCloneData(ticketData: TicketModel<RedisClusterMigrate>) { | ||
const { infos, clusters, specs } = ticketData.details; | ||
const tableDataList = infos.map((infoItem) => { | ||
const clusterItem = clusters[infoItem.cluster_id]; | ||
const specItem = specs[infoItem.resource_spec.backend_group.spec_id]; | ||
return { | ||
rowKey: random(), | ||
isLoading: false, | ||
spanData: { | ||
isStart: false, | ||
isGeneral: true, | ||
rowSpan: 1, | ||
}, | ||
clusterData: { | ||
instance: infoItem.display_info.instance, | ||
domain: clusterItem.immute_domain, | ||
clusterId: clusterItem.id, | ||
clusterType: clusterItem.cluster_type, | ||
specId: specItem.id, | ||
specName: specItem.name, | ||
}, | ||
master: infoItem.old_nodes.master[0], | ||
slave: infoItem.old_nodes.slave[0], | ||
}; | ||
}); | ||
|
||
return { | ||
tableDataList, | ||
remark: ticketData.remark, | ||
}; | ||
} |
76 changes: 76 additions & 0 deletions
76
dbm-ui/frontend/src/hooks/useTicketCloneInfo/generateCloneData/redis/migrateSingle.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,76 @@ | ||
/* | ||
* TencentBlueKing is pleased to support the open source community by making 蓝鲸智云-DB管理系统(BlueKing-BK-DBM) available. | ||
* | ||
* Copyright (C) 2017-2023 THL A29 Limited, a Tencent company. All rights reserved. | ||
* | ||
* Licensed under the MIT License (the "License"); you may not use this file except in compliance with the License. | ||
* You may obtain a copy of the License at https://opensource.org/licenses/MIT | ||
* | ||
* Unless required by applicable law or agreed to in writing, software distributed under the License is distributed | ||
* on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for | ||
* the specific language governing permissions and limitations under the License. | ||
*/ | ||
import type { RedisSingleMigrate } from '@services/model/ticket/details/redis'; | ||
import TicketModel from '@services/model/ticket/ticket'; | ||
|
||
import { random } from '@utils'; | ||
|
||
// Redis 主从迁移 | ||
export async function generateRedisMigrateSingleCloneData(ticketData: TicketModel<RedisSingleMigrate>) { | ||
const { infos, clusters } = ticketData.details; | ||
const isDomain = infos[0].display_info.migrate_type === 'domain'; | ||
const mapKey = isDomain ? 'domain' : 'ip'; | ||
|
||
const rowMap = infos.reduce<Record<string, RedisSingleMigrate['infos']>>((prevMap, infoItem) => { | ||
if (prevMap[infoItem.display_info[mapKey]]) { | ||
return Object.assign({}, prevMap, { | ||
[infoItem.display_info[mapKey]]: prevMap[infoItem.display_info[mapKey]].concat(infoItem), | ||
}); | ||
} | ||
return Object.assign({}, prevMap, { | ||
[infoItem.display_info[mapKey]]: [infoItem], | ||
}); | ||
}, {}); | ||
const tableDataList = Object.values(rowMap).map((infoList) => { | ||
const rowItem = infoList[0]; | ||
const clusterItem = clusters[rowItem.cluster_id]; | ||
const relatedInstanceList = infoList.map((infoItem) => { | ||
const masterItem = infoItem.old_nodes.master[0]; | ||
return { | ||
bk_biz_id: window.PROJECT_CONFIG.BIZ_ID, | ||
bk_cloud_id: masterItem.bk_cloud_id, | ||
bk_host_id: masterItem.bk_host_id, | ||
ip: masterItem.ip, | ||
port: masterItem.port, | ||
instance: `${masterItem.ip}:${masterItem.port}`, | ||
}; | ||
}); | ||
|
||
const clusterData = isDomain | ||
? { | ||
domain: rowItem.display_info.domain, | ||
cloudId: clusterItem.bk_cloud_id, | ||
clusterType: clusterItem.cluster_type, | ||
clusterId: rowItem.cluster_id, | ||
relatedInstance: relatedInstanceList, | ||
} | ||
: { | ||
ip: rowItem.display_info.ip, | ||
cloudId: clusterItem.bk_cloud_id, | ||
clusterType: clusterItem.cluster_type, | ||
relatedInstance: relatedInstanceList, | ||
}; | ||
return { | ||
rowKey: random(), | ||
isLoading: false, | ||
clusterData, | ||
targetSpecId: rowItem.resource_spec.backend_group.spec_id, | ||
targetVersion: rowItem.db_version, | ||
}; | ||
}); | ||
return { | ||
tableDataList, | ||
remark: ticketData.remark, | ||
isDomain, | ||
}; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.