2023-10-03 00:41:09 +00:00
|
|
|
const toAnvilDetail = (data: AnvilListItem): APIAnvilDetail => {
|
|
|
|
const {
|
|
|
|
anvil_name: anvilName,
|
|
|
|
anvil_state: anvilState,
|
|
|
|
anvil_uuid: anvilUuid,
|
|
|
|
hosts: rHosts,
|
|
|
|
} = data;
|
|
|
|
|
|
|
|
const hosts = rHosts.reduce<APIAnvilDetail['hosts']>((previous, current) => {
|
|
|
|
const {
|
|
|
|
host_name: hostName,
|
|
|
|
host_uuid: hostUuid,
|
|
|
|
maintenance_mode: maintenance,
|
2023-10-03 06:56:36 +00:00
|
|
|
server_count: serverCount,
|
2023-10-03 00:41:09 +00:00
|
|
|
state,
|
|
|
|
state_percent: stateProgress,
|
|
|
|
} = current;
|
|
|
|
|
|
|
|
previous[hostUuid] = {
|
|
|
|
name: hostName,
|
|
|
|
maintenance,
|
2023-10-03 06:56:36 +00:00
|
|
|
serverCount,
|
2023-10-03 00:41:09 +00:00
|
|
|
state,
|
|
|
|
stateProgress,
|
|
|
|
uuid: hostUuid,
|
|
|
|
};
|
|
|
|
|
|
|
|
return previous;
|
|
|
|
}, {});
|
|
|
|
|
|
|
|
return {
|
|
|
|
hosts,
|
|
|
|
name: anvilName,
|
|
|
|
state: anvilState,
|
|
|
|
uuid: anvilUuid,
|
|
|
|
};
|
|
|
|
};
|
|
|
|
|
|
|
|
export default toAnvilDetail;
|