bfg-common 1.5.442 → 1.5.443
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/assets/localization/local_be.json +9 -3
- package/assets/localization/local_en.json +17 -11
- package/assets/localization/local_hy.json +9 -3
- package/assets/localization/local_kk.json +9 -3
- package/assets/localization/local_ru.json +9 -3
- package/assets/localization/local_zh.json +9 -3
- package/components/atoms/wizard/Wizard.vue +2 -2
- package/components/atoms/wizard/step/Step.vue +1 -1
- package/components/common/backup/storage/actions/add/Add.vue +5 -5
- package/components/common/backup/storage/actions/add/Old.vue +1 -1
- package/components/common/backup/storage/actions/add/lib/config/steps.ts +2 -2
- package/components/common/backup/storage/actions/add/lib/validations.ts +4 -4
- package/components/common/backup/storage/actions/add/steps/name/Name.vue +1 -1
- package/components/common/backup/storage/actions/add/steps/name/New.vue +1 -1
- package/components/common/backup/storage/actions/add/steps/name/Old.vue +1 -1
- package/components/common/backup/storage/actions/add/steps/nameAndConfigure/NameAndConfigure.vue +1 -1
- package/components/common/backup/storage/actions/add/steps/nameAndConfigure/NameAndConfigureNew.vue +1 -1
- package/components/common/backup/storage/actions/add/steps/nameAndConfigure/NameAndConfigureOld.vue +1 -1
- package/components/common/browse/blocks/lib/models/types.ts +1 -1
- package/components/common/browse/lib/models/interfaces.ts +5 -5
- package/components/common/countdownTimer/CountdownTimer.vue +26 -15
- package/components/common/diagramMain/lib/config/initial.ts +50 -50
- package/components/common/diagramMain/lib/models/types.ts +21 -21
- package/components/common/diagramMain/lib/utils/utils.ts +331 -331
- package/components/common/diagramMain/modals/lib/config/vmKernelAdapter.ts +90 -90
- package/components/common/diagramMain/modals/lib/mappers/mappers.ts +87 -87
- package/components/common/diagramMain/modals/lib/utils/index.ts +24 -24
- package/components/common/diagramMain/modals/migrateVmkernelAdapter/MigrateVmkernelAdapter.vue +5 -5
- package/components/common/diagramMain/modals/migrateVmkernelAdapter/lib/config/steps.ts +2 -2
- package/components/common/diagramMain/modals/migrateVmkernelAdapter/steps/ConnectionSettings.vue +2 -2
- package/components/common/diagramMain/modals/migrateVmkernelAdapter/validations/common.ts +14 -14
- package/components/common/diagramMain/modals/migrateVmkernelAdapter/validations/connectionSettings.ts +5 -5
- package/components/common/diagramMain/modals/migrateVmkernelAdapter/validations/selectVmkernelAdapter.ts +2 -2
- package/components/common/diagramMain/modals/migrateVmkernelAdapter/validations/validations.ts +19 -19
- package/components/common/diagramMain/port/Ports.vue +47 -47
- package/components/common/layout/theHeader/modals/{reconnect/Reconnect.vue → Reconnect.vue} +56 -43
- package/components/common/pages/backups/modals/Modals.vue +1 -1
- package/components/common/pages/backups/modals/createBackup/CreateBackup.vue +5 -2
- package/components/common/pages/backups/modals/createBackup/lib/config/steps.ts +2 -2
- package/components/common/pages/backups/modals/restore/Restore.vue +3 -3
- package/components/common/pages/backups/modals/restore/lib/config/steps.ts +2 -2
- package/components/common/vm/actions/add/Add.vue +5 -5
- package/components/common/vm/actions/add/New.vue +2 -2
- package/components/common/vm/actions/add/Old.vue +2 -2
- package/components/common/vm/actions/add/lib/config/steps.ts +2 -2
- package/components/common/vm/actions/clone/Clone.vue +5 -5
- package/components/common/vm/actions/clone/lib/config/steps.ts +2 -2
- package/components/common/vm/actions/clone/toTemplate/ToTemplate.vue +5 -5
- package/components/common/vm/actions/clone/toTemplate/lib/config/steps.ts +2 -2
- package/components/common/vm/actions/common/customizeHardware/virtualHardware/newHardDisk/maximumSize/MaximumSize.vue +23 -23
- package/components/common/vmt/actions/add/Add.vue +5 -5
- package/components/common/vmt/actions/add/New.vue +2 -3
- package/components/common/vmt/actions/add/Old.vue +2 -2
- package/components/common/vmt/actions/add/lib/config/steps.ts +2 -2
- package/components/common/wizards/datastore/add/Add.vue +2 -2
- package/components/common/wizards/datastore/add/Old.vue +2 -2
- package/components/common/wizards/datastore/add/lib/config/steps.ts +2 -2
- package/components/common/wizards/datastore/add/lib/utils.ts +1 -1
- package/components/common/wizards/datastore/add/lib/validations.ts +3 -3
- package/components/common/wizards/datastore/add/steps/_local/Local.vue +1 -1
- package/components/common/wizards/datastore/add/steps/_local/createName/CreateName.vue +1 -1
- package/components/common/wizards/datastore/add/steps/nameAndConfigure/NameAndConfigure.vue +2 -1
- package/components/common/wizards/datastore/add/steps/nameAndConfigure/NameAndConfigureNew.vue +1 -1
- package/components/common/wizards/datastore/add/steps/nameAndConfigure/NameAndConfigureOld.vue +1 -1
- package/components/common/wizards/datastore/add/steps/nameAndDevice/NameAndDevice.vue +1 -1
- package/components/common/wizards/datastore/add/steps/nameAndDevice/NameAndDeviceNew.vue +1 -1
- package/components/common/wizards/datastore/add/steps/nameAndDevice/NameAndDeviceOld.vue +1 -1
- package/components/common/wizards/network/add/Add.vue +109 -333
- package/components/common/wizards/network/add/AddNew.vue +514 -0
- package/components/common/wizards/network/add/AddOld.vue +457 -0
- package/components/common/wizards/network/add/lib/config/config.ts +11 -1
- package/components/common/wizards/network/add/lib/config/selectConnectionTypeStep.ts +31 -0
- package/components/common/wizards/network/add/lib/config/selectSwitch.ts +217 -0
- package/components/common/wizards/network/add/lib/config/steps.ts +5 -5
- package/components/common/wizards/network/add/lib/models/interfaces.ts +9 -0
- package/components/common/wizards/network/add/steps/ConnectionSettings.vue +2 -2
- package/components/common/wizards/network/add/steps/IpFourSettings.vue +2 -2
- package/components/common/wizards/network/add/steps/PortProperties.vue +2 -2
- package/components/common/wizards/network/add/steps/selectConnectionType/SelectConnectionType.vue +35 -0
- package/components/common/wizards/network/add/steps/selectConnectionType/SelectConnectionTypeNew.vue +104 -0
- package/components/common/wizards/network/add/steps/selectConnectionType/SelectConnectionTypeOld.vue +80 -0
- package/components/common/wizards/network/add/steps/selectTargetDevice/SelectTargetDevice.vue +183 -0
- package/components/common/wizards/network/add/steps/selectTargetDevice/SelectTargetDeviceNew.vue +393 -0
- package/components/common/wizards/network/add/steps/{SelectedTargetDevice.vue → selectTargetDevice/SelectTargetDeviceOld.vue} +42 -139
- package/components/common/wizards/network/add/steps/selectTargetDevice/modals/Modals.vue +55 -0
- package/components/common/wizards/network/add/steps/selectTargetDevice/modals/SelectNetwork.vue +64 -0
- package/components/common/wizards/network/add/steps/selectTargetDevice/modals/SelectStandardSwitch.vue +64 -0
- package/components/common/wizards/network/add/steps/selectTargetDevice/modals/SelectSwitch.vue +64 -0
- package/components/common/wizards/network/add/steps/selectTargetDevice/modals/new/SelectNetwork.vue +163 -0
- package/components/common/wizards/network/add/steps/selectTargetDevice/modals/new/SelectStandardSwitch.vue +163 -0
- package/components/common/wizards/network/add/steps/selectTargetDevice/modals/new/SelectSwitch.vue +163 -0
- package/components/common/wizards/network/add/{modals → steps/selectTargetDevice/modals/old}/SelectNetwork.vue +53 -56
- package/components/common/wizards/network/add/{modals → steps/selectTargetDevice/modals/old}/SelectStandardSwitch.vue +37 -52
- package/components/common/wizards/network/add/{modals → steps/selectTargetDevice/modals/old}/SelectSwitch.vue +38 -42
- package/components/common/wizards/network/add/validations/connectionSettings.ts +5 -5
- package/components/common/wizards/network/add/validations/createStandardSwitch.ts +4 -4
- package/components/common/wizards/network/add/validations/ipFourSettings.ts +5 -5
- package/components/common/wizards/network/add/validations/networkValidation.ts +4 -4
- package/components/common/wizards/network/add/validations/physicalAdapter.ts +4 -4
- package/components/common/wizards/network/add/validations/portProperties.ts +2 -2
- package/components/common/wizards/network/add/validations/targetDevice.ts +11 -10
- package/components/common/wizards/vm/migrate/Migrate.vue +2 -2
- package/components/common/wizards/vm/migrate/lib/config/steps.ts +2 -2
- package/components/common/wizards/vm/migrate/lib/validations.ts +3 -3
- package/components/common/wizards/vm/migrate/select/targetServer/new/New.vue +1 -1
- package/components/common/wizards/vm/migrate/select/targetServer/targetServer.vue +1 -1
- package/package.json +2 -2
- package/components/atoms/wizard/lib/models/enums.ts +0 -8
- package/components/atoms/wizard/lib/models/interfaces.ts +0 -59
- package/components/atoms/wizard/lib/utils/utils.ts +0 -954
- package/components/common/countdownTimer/CountdownTimerNew.vue +0 -53
- package/components/common/countdownTimer/CountdownTimerOld.vue +0 -33
- package/components/common/layout/theHeader/modals/reconnect/ReconnectNew.vue +0 -74
- package/components/common/layout/theHeader/modals/reconnect/ReconnectOld.vue +0 -67
- package/components/common/wizards/network/add/steps/SelectConnectionType.vue +0 -112
@@ -1,331 +1,331 @@
|
|
1
|
-
import type { UI_I_ItemsWithTotalCounts } from '~/lib/models/interfaces'
|
2
|
-
import type {
|
3
|
-
UI_I_Network,
|
4
|
-
UI_I_SelectedPort,
|
5
|
-
UI_I_NetworksWithPositions,
|
6
|
-
UI_I_AdaptersWithPositions,
|
7
|
-
UI_I_SelectedSwitchPositions,
|
8
|
-
UI_I_DiagramData,
|
9
|
-
UI_I_AdaptersHeight,
|
10
|
-
UI_I_Adapter,
|
11
|
-
UI_I_AdaptersPositions,
|
12
|
-
UI_I_AdapterStatus,
|
13
|
-
API_UI_I_SwitchItem,
|
14
|
-
UI_I_AvailableAdapters,
|
15
|
-
UI_I_SwitchAdapterItem,
|
16
|
-
UI_I_AdapterWithError,
|
17
|
-
} from '~/components/common/diagramMain/lib/models/interfaces'
|
18
|
-
import type { UI_T_Adapters } from '~/components/common/diagramMain/lib/models/types'
|
19
|
-
import {
|
20
|
-
UI_E_NetworkType,
|
21
|
-
UI_E_PositionsY,
|
22
|
-
} from '~/components/common/diagramMain/lib/models/enums'
|
23
|
-
import { NETWORK_POSITIONS } from '~/components/common/diagramMain/lib/config'
|
24
|
-
|
25
|
-
export const hasPortAndNetwork = (
|
26
|
-
selectedPort: UI_I_SelectedPort,
|
27
|
-
id: string
|
28
|
-
): boolean =>
|
29
|
-
selectedPort.portId !== '-1' &&
|
30
|
-
selectedPort.networkId !== '-1' &&
|
31
|
-
selectedPort.networkId === id
|
32
|
-
|
33
|
-
export const networksPositions = (
|
34
|
-
arr: number[],
|
35
|
-
net: UI_I_NetworksWithPositions
|
36
|
-
): number[] => {
|
37
|
-
if (net.ports.length === 0) return [...arr, net.connectLineY]
|
38
|
-
if (!net.toggle)
|
39
|
-
return [
|
40
|
-
...arr,
|
41
|
-
net.portsPosition + NETWORK_POSITIONS.EMPTY_PORTS_PADDING_BOTTOM,
|
42
|
-
]
|
43
|
-
|
44
|
-
return [
|
45
|
-
...arr,
|
46
|
-
net.portsPosition +
|
47
|
-
NETWORK_POSITIONS.FROM_VLAN_ID_TO_GROUP_NAME +
|
48
|
-
NETWORK_POSITIONS.BETWEEN_VMS_AND_PORTS,
|
49
|
-
net.networkType === UI_E_NetworkType.VCenter
|
50
|
-
? net.portsPosition +
|
51
|
-
NETWORK_POSITIONS.FROM_VLAN_ID_TO_GROUP_NAME +
|
52
|
-
NETWORK_POSITIONS.BETWEEN_V_CENTERS +
|
53
|
-
NETWORK_POSITIONS.V_CENTER_HEIGHT * (net.portsCount - 1)
|
54
|
-
: net.portsPosition +
|
55
|
-
NETWORK_POSITIONS.FROM_VLAN_ID_TO_GROUP_NAME +
|
56
|
-
NETWORK_POSITIONS.BETWEEN_VMS_AND_PORTS +
|
57
|
-
NETWORK_POSITIONS.VMS_AND_PORTS_HEIGHT * (net.portsCount - 1),
|
58
|
-
]
|
59
|
-
}
|
60
|
-
|
61
|
-
export const getSelectedPortLinePositions = (
|
62
|
-
selectedPortPosition: number | undefined,
|
63
|
-
selectedNetworkData: UI_I_Network
|
64
|
-
) =>
|
65
|
-
selectedPortPosition
|
66
|
-
? selectedNetworkData.networkType === UI_E_NetworkType.VCenter
|
67
|
-
? selectedPortPosition + 12.5
|
68
|
-
: selectedPortPosition + 7.5
|
69
|
-
: 0
|
70
|
-
|
71
|
-
const selectedNetworkDataFunc = (
|
72
|
-
networkId: string,
|
73
|
-
networksWithPositions: UI_I_NetworksWithPositions[]
|
74
|
-
): UI_I_NetworksWithPositions | undefined =>
|
75
|
-
networksWithPositions?.find(
|
76
|
-
(network: UI_I_Network): boolean => network.id === networkId
|
77
|
-
)
|
78
|
-
|
79
|
-
export const getSelectNetworkDataFunc = (
|
80
|
-
networkId: string,
|
81
|
-
networksWithPositions: UI_I_NetworksWithPositions[],
|
82
|
-
adaptersWithPositions: UI_I_AdaptersWithPositions
|
83
|
-
): UI_I_SelectedSwitchPositions | undefined => {
|
84
|
-
const selectedNetworkData: UI_I_NetworksWithPositions | undefined =
|
85
|
-
selectedNetworkDataFunc(networkId, networksWithPositions)
|
86
|
-
|
87
|
-
if (!selectedNetworkData) return
|
88
|
-
|
89
|
-
if (selectedNetworkData.state.state === 3)
|
90
|
-
return {
|
91
|
-
selectedSwitchLineY: {
|
92
|
-
y1: 0,
|
93
|
-
y2: 0,
|
94
|
-
},
|
95
|
-
selectedPort: {
|
96
|
-
networkId,
|
97
|
-
portId: '-1',
|
98
|
-
activeAdapters: [],
|
99
|
-
},
|
100
|
-
}
|
101
|
-
|
102
|
-
const activeAdapters: string[] = selectedNetworkData.activeAdapters
|
103
|
-
|
104
|
-
const adaptersPositions: number[] =
|
105
|
-
adaptersWithPositions.adapters
|
106
|
-
?.filter((adapter: UI_T_Adapters) => activeAdapters?.includes(adapter.id))
|
107
|
-
?.map((adapter: UI_T_Adapters) => adapter.adapterPosition + 7.5) || []
|
108
|
-
let selectedPositions: number[] = []
|
109
|
-
|
110
|
-
if (!adaptersWithPositions.toggle) {
|
111
|
-
selectedPositions = [
|
112
|
-
adaptersWithPositions.adaptersConnectLineY,
|
113
|
-
selectedNetworkData.connectLineY,
|
114
|
-
]
|
115
|
-
} else if (
|
116
|
-
adaptersWithPositions.adapters === null ||
|
117
|
-
adaptersWithPositions.adapters?.length === 0
|
118
|
-
) {
|
119
|
-
selectedPositions = [47.5, selectedNetworkData.connectLineY].sort(
|
120
|
-
(y1: number, y2: number) => y1 - y2
|
121
|
-
)
|
122
|
-
} else {
|
123
|
-
selectedPositions = [
|
124
|
-
...adaptersPositions,
|
125
|
-
selectedNetworkData.connectLineY,
|
126
|
-
].sort((y1: number, y2: number) => y1 - y2)
|
127
|
-
}
|
128
|
-
|
129
|
-
return {
|
130
|
-
selectedSwitchLineY: {
|
131
|
-
y1: selectedPositions[0],
|
132
|
-
y2: selectedPositions[selectedPositions.length - 1],
|
133
|
-
},
|
134
|
-
selectedPort: {
|
135
|
-
networkId,
|
136
|
-
portId: '-1',
|
137
|
-
activeAdapters: activeAdapters || [],
|
138
|
-
},
|
139
|
-
}
|
140
|
-
}
|
141
|
-
|
142
|
-
export const getSelectPortDataFunc = (
|
143
|
-
networkId: string,
|
144
|
-
portId: string,
|
145
|
-
networksWithPositions: UI_I_NetworksWithPositions[],
|
146
|
-
adaptersWithPositions: UI_I_AdaptersWithPositions
|
147
|
-
): UI_I_SelectedSwitchPositions | undefined => {
|
148
|
-
const selectedNetworkData: UI_I_NetworksWithPositions | undefined =
|
149
|
-
selectedNetworkDataFunc(networkId, networksWithPositions)
|
150
|
-
|
151
|
-
if (!selectedNetworkData) return
|
152
|
-
|
153
|
-
const activeAdapters: string[] = selectedNetworkData.activeAdapters
|
154
|
-
const adaptersPositions: number[] =
|
155
|
-
adaptersWithPositions.adapters
|
156
|
-
?.filter((adapter: UI_T_Adapters) => activeAdapters?.includes(adapter.id))
|
157
|
-
?.map((adapter: UI_T_Adapters) => adapter.adapterPosition + 7.5) || []
|
158
|
-
const selectedPortPosition: number | undefined =
|
159
|
-
selectedNetworkData.ports.find(
|
160
|
-
(el): boolean => el.id === portId
|
161
|
-
)?.portPosition
|
162
|
-
const selectedPortLinePosition: number = getSelectedPortLinePositions(
|
163
|
-
selectedPortPosition,
|
164
|
-
selectedNetworkData
|
165
|
-
)
|
166
|
-
let selectedPositions: number[] = []
|
167
|
-
|
168
|
-
if (!adaptersWithPositions.toggle) {
|
169
|
-
selectedPositions = [
|
170
|
-
adaptersWithPositions.adaptersConnectLineY,
|
171
|
-
selectedNetworkData.connectLineY,
|
172
|
-
selectedPortLinePosition,
|
173
|
-
]
|
174
|
-
} else {
|
175
|
-
selectedPositions = [...adaptersPositions, selectedPortLinePosition].sort(
|
176
|
-
(y1: number, y2: number) => y1 - y2
|
177
|
-
)
|
178
|
-
}
|
179
|
-
|
180
|
-
return {
|
181
|
-
selectedSwitchLineY: {
|
182
|
-
y1: selectedPositions[0],
|
183
|
-
y2: selectedPositions[selectedPositions.length - 1],
|
184
|
-
},
|
185
|
-
selectedPort: {
|
186
|
-
networkId,
|
187
|
-
portId,
|
188
|
-
activeAdapters: activeAdapters || [],
|
189
|
-
},
|
190
|
-
}
|
191
|
-
}
|
192
|
-
|
193
|
-
export const countAdaptersHeight = (
|
194
|
-
diagramData: UI_I_DiagramData | null
|
195
|
-
): UI_I_AdaptersHeight => {
|
196
|
-
const toggle: boolean = !!diagramData?.physicalAdapters?.toggle
|
197
|
-
const adaptersCount: number =
|
198
|
-
diagramData?.physicalAdapters?.adapters.length || 0
|
199
|
-
|
200
|
-
return {
|
201
|
-
height:
|
202
|
-
UI_E_PositionsY.ADAPTER_FROM_RECT_TOP +
|
203
|
-
(adaptersCount === 0
|
204
|
-
? UI_E_PositionsY.SINGLE_ADAPTER_HEIGHT
|
205
|
-
: toggle
|
206
|
-
? adaptersCount * UI_E_PositionsY.SINGLE_ADAPTER_HEIGHT
|
207
|
-
: 0) +
|
208
|
-
UI_E_PositionsY.SPACE_FROM_RECT_BOTTOM,
|
209
|
-
toggle,
|
210
|
-
adaptersCount,
|
211
|
-
}
|
212
|
-
}
|
213
|
-
|
214
|
-
export const getAdaptersPositions = (
|
215
|
-
diagramData: UI_I_DiagramData | null,
|
216
|
-
height: number
|
217
|
-
): UI_I_AdaptersPositions => {
|
218
|
-
const titlePosition: number =
|
219
|
-
UI_E_PositionsY.DIAGRAM_TOP +
|
220
|
-
UI_E_PositionsY.BETWEEN_RECTS +
|
221
|
-
UI_E_PositionsY.TITLE_FROM_RECT_TOP
|
222
|
-
|
223
|
-
const rectPosition: number =
|
224
|
-
UI_E_PositionsY.DIAGRAM_TOP + UI_E_PositionsY.BETWEEN_RECTS
|
225
|
-
|
226
|
-
const adaptersConnectLineY: number = rectPosition + height / 2
|
227
|
-
|
228
|
-
const adapters: UI_T_Adapters[] | null =
|
229
|
-
diagramData?.physicalAdapters?.adapters.map(
|
230
|
-
(adapter: UI_I_Adapter, index: number) => {
|
231
|
-
const adapterPosition: number =
|
232
|
-
UI_E_PositionsY.DIAGRAM_TOP +
|
233
|
-
UI_E_PositionsY.BETWEEN_RECTS +
|
234
|
-
UI_E_PositionsY.ADAPTER_FROM_RECT_TOP +
|
235
|
-
UI_E_PositionsY.SINGLE_ADAPTER_HEIGHT * index
|
236
|
-
|
237
|
-
return {
|
238
|
-
...adapter,
|
239
|
-
adapterPosition,
|
240
|
-
}
|
241
|
-
}
|
242
|
-
) || null
|
243
|
-
|
244
|
-
return {
|
245
|
-
titlePosition,
|
246
|
-
rectPosition,
|
247
|
-
adaptersConnectLineY,
|
248
|
-
adapters,
|
249
|
-
}
|
250
|
-
}
|
251
|
-
|
252
|
-
export const makeSwitchSendData = (
|
253
|
-
data: UI_I_DiagramData,
|
254
|
-
adapterStatus: UI_I_AdapterStatus
|
255
|
-
): API_UI_I_SwitchItem | null => {
|
256
|
-
if (!data.networking) return null
|
257
|
-
|
258
|
-
return {
|
259
|
-
id: data.id,
|
260
|
-
mtu: data.networking.mtu,
|
261
|
-
networks: data.networks.map((network: UI_I_Network) => network.title),
|
262
|
-
nics: adapterStatus,
|
263
|
-
security: {
|
264
|
-
promiscuous: data.networking.securityPolicy[0].value,
|
265
|
-
forged_transmits: data.networking.securityPolicy[1].value,
|
266
|
-
mac_change: data.networking.securityPolicy[2].value,
|
267
|
-
},
|
268
|
-
teaming: {
|
269
|
-
notify_switches: data.networking.nicTeamingPolicy[0].value,
|
270
|
-
mode: data.networking.nicTeamingPolicy[1].value,
|
271
|
-
link_detection_mode: data.networking.nicTeamingPolicy[2].value,
|
272
|
-
failback: data.networking.nicTeamingPolicy[3].value,
|
273
|
-
},
|
274
|
-
shaping: {
|
275
|
-
inherit: false,
|
276
|
-
enabled: !!data.networking.shapingPolicy[0].value,
|
277
|
-
average_bw: data.networking.average_bw,
|
278
|
-
peak_bw: data.networking.peak_bw,
|
279
|
-
burst_size: data.networking.burst_size,
|
280
|
-
},
|
281
|
-
}
|
282
|
-
}
|
283
|
-
|
284
|
-
export const getAvailableAdapters = (
|
285
|
-
nics: UI_I_ItemsWithTotalCounts<UI_I_SwitchAdapterItem>,
|
286
|
-
networkOrSwitchNics: UI_I_AdapterStatus
|
287
|
-
): UI_I_AvailableAdapters => {
|
288
|
-
const availableAdapters: UI_I_AvailableAdapters = {
|
289
|
-
activeAdapters: [],
|
290
|
-
standbyAdapters: [],
|
291
|
-
unusedAdapters: [],
|
292
|
-
}
|
293
|
-
|
294
|
-
if (nics?.items) {
|
295
|
-
networkOrSwitchNics?.active?.forEach(
|
296
|
-
(nic) =>
|
297
|
-
nics?.items.find(
|
298
|
-
(a: UI_I_SwitchAdapterItem): boolean => a.id === nic
|
299
|
-
) && availableAdapters.activeAdapters.push(nic)
|
300
|
-
)
|
301
|
-
networkOrSwitchNics?.standby?.forEach(
|
302
|
-
(nic) =>
|
303
|
-
nics?.items.find(
|
304
|
-
(a: UI_I_SwitchAdapterItem): boolean => a.id === nic
|
305
|
-
) && availableAdapters.standbyAdapters.push(nic)
|
306
|
-
)
|
307
|
-
networkOrSwitchNics?.unused?.forEach(
|
308
|
-
(nic) =>
|
309
|
-
nics?.items.find(
|
310
|
-
(a: UI_I_SwitchAdapterItem): boolean => a.id === nic
|
311
|
-
) && availableAdapters.unusedAdapters.push(nic)
|
312
|
-
)
|
313
|
-
}
|
314
|
-
|
315
|
-
return availableAdapters
|
316
|
-
}
|
317
|
-
|
318
|
-
export const createAdapterWithError = (
|
319
|
-
nic: string,
|
320
|
-
switchId: string
|
321
|
-
): UI_I_AdapterWithError => ({
|
322
|
-
fullName: nic,
|
323
|
-
id: nic,
|
324
|
-
name: nic,
|
325
|
-
networks: [],
|
326
|
-
state: { state: 1, errors: [] },
|
327
|
-
switch: switchId,
|
328
|
-
testId: `adapter-${nic}`,
|
329
|
-
carrier: false,
|
330
|
-
status: 'error',
|
331
|
-
})
|
1
|
+
import type { UI_I_ItemsWithTotalCounts } from '~/lib/models/interfaces'
|
2
|
+
import type {
|
3
|
+
UI_I_Network,
|
4
|
+
UI_I_SelectedPort,
|
5
|
+
UI_I_NetworksWithPositions,
|
6
|
+
UI_I_AdaptersWithPositions,
|
7
|
+
UI_I_SelectedSwitchPositions,
|
8
|
+
UI_I_DiagramData,
|
9
|
+
UI_I_AdaptersHeight,
|
10
|
+
UI_I_Adapter,
|
11
|
+
UI_I_AdaptersPositions,
|
12
|
+
UI_I_AdapterStatus,
|
13
|
+
API_UI_I_SwitchItem,
|
14
|
+
UI_I_AvailableAdapters,
|
15
|
+
UI_I_SwitchAdapterItem,
|
16
|
+
UI_I_AdapterWithError,
|
17
|
+
} from '~/components/common/diagramMain/lib/models/interfaces'
|
18
|
+
import type { UI_T_Adapters } from '~/components/common/diagramMain/lib/models/types'
|
19
|
+
import {
|
20
|
+
UI_E_NetworkType,
|
21
|
+
UI_E_PositionsY,
|
22
|
+
} from '~/components/common/diagramMain/lib/models/enums'
|
23
|
+
import { NETWORK_POSITIONS } from '~/components/common/diagramMain/lib/config'
|
24
|
+
|
25
|
+
export const hasPortAndNetwork = (
|
26
|
+
selectedPort: UI_I_SelectedPort,
|
27
|
+
id: string
|
28
|
+
): boolean =>
|
29
|
+
selectedPort.portId !== '-1' &&
|
30
|
+
selectedPort.networkId !== '-1' &&
|
31
|
+
selectedPort.networkId === id
|
32
|
+
|
33
|
+
export const networksPositions = (
|
34
|
+
arr: number[],
|
35
|
+
net: UI_I_NetworksWithPositions
|
36
|
+
): number[] => {
|
37
|
+
if (net.ports.length === 0) return [...arr, net.connectLineY]
|
38
|
+
if (!net.toggle)
|
39
|
+
return [
|
40
|
+
...arr,
|
41
|
+
net.portsPosition + NETWORK_POSITIONS.EMPTY_PORTS_PADDING_BOTTOM,
|
42
|
+
]
|
43
|
+
|
44
|
+
return [
|
45
|
+
...arr,
|
46
|
+
net.portsPosition +
|
47
|
+
NETWORK_POSITIONS.FROM_VLAN_ID_TO_GROUP_NAME +
|
48
|
+
NETWORK_POSITIONS.BETWEEN_VMS_AND_PORTS,
|
49
|
+
net.networkType === UI_E_NetworkType.VCenter
|
50
|
+
? net.portsPosition +
|
51
|
+
NETWORK_POSITIONS.FROM_VLAN_ID_TO_GROUP_NAME +
|
52
|
+
NETWORK_POSITIONS.BETWEEN_V_CENTERS +
|
53
|
+
NETWORK_POSITIONS.V_CENTER_HEIGHT * (net.portsCount - 1)
|
54
|
+
: net.portsPosition +
|
55
|
+
NETWORK_POSITIONS.FROM_VLAN_ID_TO_GROUP_NAME +
|
56
|
+
NETWORK_POSITIONS.BETWEEN_VMS_AND_PORTS +
|
57
|
+
NETWORK_POSITIONS.VMS_AND_PORTS_HEIGHT * (net.portsCount - 1),
|
58
|
+
]
|
59
|
+
}
|
60
|
+
|
61
|
+
export const getSelectedPortLinePositions = (
|
62
|
+
selectedPortPosition: number | undefined,
|
63
|
+
selectedNetworkData: UI_I_Network
|
64
|
+
) =>
|
65
|
+
selectedPortPosition
|
66
|
+
? selectedNetworkData.networkType === UI_E_NetworkType.VCenter
|
67
|
+
? selectedPortPosition + 12.5
|
68
|
+
: selectedPortPosition + 7.5
|
69
|
+
: 0
|
70
|
+
|
71
|
+
const selectedNetworkDataFunc = (
|
72
|
+
networkId: string,
|
73
|
+
networksWithPositions: UI_I_NetworksWithPositions[]
|
74
|
+
): UI_I_NetworksWithPositions | undefined =>
|
75
|
+
networksWithPositions?.find(
|
76
|
+
(network: UI_I_Network): boolean => network.id === networkId
|
77
|
+
)
|
78
|
+
|
79
|
+
export const getSelectNetworkDataFunc = (
|
80
|
+
networkId: string,
|
81
|
+
networksWithPositions: UI_I_NetworksWithPositions[],
|
82
|
+
adaptersWithPositions: UI_I_AdaptersWithPositions
|
83
|
+
): UI_I_SelectedSwitchPositions | undefined => {
|
84
|
+
const selectedNetworkData: UI_I_NetworksWithPositions | undefined =
|
85
|
+
selectedNetworkDataFunc(networkId, networksWithPositions)
|
86
|
+
|
87
|
+
if (!selectedNetworkData) return
|
88
|
+
|
89
|
+
if (selectedNetworkData.state.state === 3)
|
90
|
+
return {
|
91
|
+
selectedSwitchLineY: {
|
92
|
+
y1: 0,
|
93
|
+
y2: 0,
|
94
|
+
},
|
95
|
+
selectedPort: {
|
96
|
+
networkId,
|
97
|
+
portId: '-1',
|
98
|
+
activeAdapters: [],
|
99
|
+
},
|
100
|
+
}
|
101
|
+
|
102
|
+
const activeAdapters: string[] = selectedNetworkData.activeAdapters
|
103
|
+
|
104
|
+
const adaptersPositions: number[] =
|
105
|
+
adaptersWithPositions.adapters
|
106
|
+
?.filter((adapter: UI_T_Adapters) => activeAdapters?.includes(adapter.id))
|
107
|
+
?.map((adapter: UI_T_Adapters) => adapter.adapterPosition + 7.5) || []
|
108
|
+
let selectedPositions: number[] = []
|
109
|
+
|
110
|
+
if (!adaptersWithPositions.toggle) {
|
111
|
+
selectedPositions = [
|
112
|
+
adaptersWithPositions.adaptersConnectLineY,
|
113
|
+
selectedNetworkData.connectLineY,
|
114
|
+
]
|
115
|
+
} else if (
|
116
|
+
adaptersWithPositions.adapters === null ||
|
117
|
+
adaptersWithPositions.adapters?.length === 0
|
118
|
+
) {
|
119
|
+
selectedPositions = [47.5, selectedNetworkData.connectLineY].sort(
|
120
|
+
(y1: number, y2: number) => y1 - y2
|
121
|
+
)
|
122
|
+
} else {
|
123
|
+
selectedPositions = [
|
124
|
+
...adaptersPositions,
|
125
|
+
selectedNetworkData.connectLineY,
|
126
|
+
].sort((y1: number, y2: number) => y1 - y2)
|
127
|
+
}
|
128
|
+
|
129
|
+
return {
|
130
|
+
selectedSwitchLineY: {
|
131
|
+
y1: selectedPositions[0],
|
132
|
+
y2: selectedPositions[selectedPositions.length - 1],
|
133
|
+
},
|
134
|
+
selectedPort: {
|
135
|
+
networkId,
|
136
|
+
portId: '-1',
|
137
|
+
activeAdapters: activeAdapters || [],
|
138
|
+
},
|
139
|
+
}
|
140
|
+
}
|
141
|
+
|
142
|
+
export const getSelectPortDataFunc = (
|
143
|
+
networkId: string,
|
144
|
+
portId: string,
|
145
|
+
networksWithPositions: UI_I_NetworksWithPositions[],
|
146
|
+
adaptersWithPositions: UI_I_AdaptersWithPositions
|
147
|
+
): UI_I_SelectedSwitchPositions | undefined => {
|
148
|
+
const selectedNetworkData: UI_I_NetworksWithPositions | undefined =
|
149
|
+
selectedNetworkDataFunc(networkId, networksWithPositions)
|
150
|
+
|
151
|
+
if (!selectedNetworkData) return
|
152
|
+
|
153
|
+
const activeAdapters: string[] = selectedNetworkData.activeAdapters
|
154
|
+
const adaptersPositions: number[] =
|
155
|
+
adaptersWithPositions.adapters
|
156
|
+
?.filter((adapter: UI_T_Adapters) => activeAdapters?.includes(adapter.id))
|
157
|
+
?.map((adapter: UI_T_Adapters) => adapter.adapterPosition + 7.5) || []
|
158
|
+
const selectedPortPosition: number | undefined =
|
159
|
+
selectedNetworkData.ports.find(
|
160
|
+
(el): boolean => el.id === portId
|
161
|
+
)?.portPosition
|
162
|
+
const selectedPortLinePosition: number = getSelectedPortLinePositions(
|
163
|
+
selectedPortPosition,
|
164
|
+
selectedNetworkData
|
165
|
+
)
|
166
|
+
let selectedPositions: number[] = []
|
167
|
+
|
168
|
+
if (!adaptersWithPositions.toggle) {
|
169
|
+
selectedPositions = [
|
170
|
+
adaptersWithPositions.adaptersConnectLineY,
|
171
|
+
selectedNetworkData.connectLineY,
|
172
|
+
selectedPortLinePosition,
|
173
|
+
]
|
174
|
+
} else {
|
175
|
+
selectedPositions = [...adaptersPositions, selectedPortLinePosition].sort(
|
176
|
+
(y1: number, y2: number) => y1 - y2
|
177
|
+
)
|
178
|
+
}
|
179
|
+
|
180
|
+
return {
|
181
|
+
selectedSwitchLineY: {
|
182
|
+
y1: selectedPositions[0],
|
183
|
+
y2: selectedPositions[selectedPositions.length - 1],
|
184
|
+
},
|
185
|
+
selectedPort: {
|
186
|
+
networkId,
|
187
|
+
portId,
|
188
|
+
activeAdapters: activeAdapters || [],
|
189
|
+
},
|
190
|
+
}
|
191
|
+
}
|
192
|
+
|
193
|
+
export const countAdaptersHeight = (
|
194
|
+
diagramData: UI_I_DiagramData | null
|
195
|
+
): UI_I_AdaptersHeight => {
|
196
|
+
const toggle: boolean = !!diagramData?.physicalAdapters?.toggle
|
197
|
+
const adaptersCount: number =
|
198
|
+
diagramData?.physicalAdapters?.adapters.length || 0
|
199
|
+
|
200
|
+
return {
|
201
|
+
height:
|
202
|
+
UI_E_PositionsY.ADAPTER_FROM_RECT_TOP +
|
203
|
+
(adaptersCount === 0
|
204
|
+
? UI_E_PositionsY.SINGLE_ADAPTER_HEIGHT
|
205
|
+
: toggle
|
206
|
+
? adaptersCount * UI_E_PositionsY.SINGLE_ADAPTER_HEIGHT
|
207
|
+
: 0) +
|
208
|
+
UI_E_PositionsY.SPACE_FROM_RECT_BOTTOM,
|
209
|
+
toggle,
|
210
|
+
adaptersCount,
|
211
|
+
}
|
212
|
+
}
|
213
|
+
|
214
|
+
export const getAdaptersPositions = (
|
215
|
+
diagramData: UI_I_DiagramData | null,
|
216
|
+
height: number
|
217
|
+
): UI_I_AdaptersPositions => {
|
218
|
+
const titlePosition: number =
|
219
|
+
UI_E_PositionsY.DIAGRAM_TOP +
|
220
|
+
UI_E_PositionsY.BETWEEN_RECTS +
|
221
|
+
UI_E_PositionsY.TITLE_FROM_RECT_TOP
|
222
|
+
|
223
|
+
const rectPosition: number =
|
224
|
+
UI_E_PositionsY.DIAGRAM_TOP + UI_E_PositionsY.BETWEEN_RECTS
|
225
|
+
|
226
|
+
const adaptersConnectLineY: number = rectPosition + height / 2
|
227
|
+
|
228
|
+
const adapters: UI_T_Adapters[] | null =
|
229
|
+
diagramData?.physicalAdapters?.adapters.map(
|
230
|
+
(adapter: UI_I_Adapter, index: number) => {
|
231
|
+
const adapterPosition: number =
|
232
|
+
UI_E_PositionsY.DIAGRAM_TOP +
|
233
|
+
UI_E_PositionsY.BETWEEN_RECTS +
|
234
|
+
UI_E_PositionsY.ADAPTER_FROM_RECT_TOP +
|
235
|
+
UI_E_PositionsY.SINGLE_ADAPTER_HEIGHT * index
|
236
|
+
|
237
|
+
return {
|
238
|
+
...adapter,
|
239
|
+
adapterPosition,
|
240
|
+
}
|
241
|
+
}
|
242
|
+
) || null
|
243
|
+
|
244
|
+
return {
|
245
|
+
titlePosition,
|
246
|
+
rectPosition,
|
247
|
+
adaptersConnectLineY,
|
248
|
+
adapters,
|
249
|
+
}
|
250
|
+
}
|
251
|
+
|
252
|
+
export const makeSwitchSendData = (
|
253
|
+
data: UI_I_DiagramData,
|
254
|
+
adapterStatus: UI_I_AdapterStatus
|
255
|
+
): API_UI_I_SwitchItem | null => {
|
256
|
+
if (!data.networking) return null
|
257
|
+
|
258
|
+
return {
|
259
|
+
id: data.id,
|
260
|
+
mtu: data.networking.mtu,
|
261
|
+
networks: data.networks.map((network: UI_I_Network) => network.title),
|
262
|
+
nics: adapterStatus,
|
263
|
+
security: {
|
264
|
+
promiscuous: data.networking.securityPolicy[0].value,
|
265
|
+
forged_transmits: data.networking.securityPolicy[1].value,
|
266
|
+
mac_change: data.networking.securityPolicy[2].value,
|
267
|
+
},
|
268
|
+
teaming: {
|
269
|
+
notify_switches: data.networking.nicTeamingPolicy[0].value,
|
270
|
+
mode: data.networking.nicTeamingPolicy[1].value,
|
271
|
+
link_detection_mode: data.networking.nicTeamingPolicy[2].value,
|
272
|
+
failback: data.networking.nicTeamingPolicy[3].value,
|
273
|
+
},
|
274
|
+
shaping: {
|
275
|
+
inherit: false,
|
276
|
+
enabled: !!data.networking.shapingPolicy[0].value,
|
277
|
+
average_bw: data.networking.average_bw,
|
278
|
+
peak_bw: data.networking.peak_bw,
|
279
|
+
burst_size: data.networking.burst_size,
|
280
|
+
},
|
281
|
+
}
|
282
|
+
}
|
283
|
+
|
284
|
+
export const getAvailableAdapters = (
|
285
|
+
nics: UI_I_ItemsWithTotalCounts<UI_I_SwitchAdapterItem>,
|
286
|
+
networkOrSwitchNics: UI_I_AdapterStatus
|
287
|
+
): UI_I_AvailableAdapters => {
|
288
|
+
const availableAdapters: UI_I_AvailableAdapters = {
|
289
|
+
activeAdapters: [],
|
290
|
+
standbyAdapters: [],
|
291
|
+
unusedAdapters: [],
|
292
|
+
}
|
293
|
+
|
294
|
+
if (nics?.items) {
|
295
|
+
networkOrSwitchNics?.active?.forEach(
|
296
|
+
(nic) =>
|
297
|
+
nics?.items.find(
|
298
|
+
(a: UI_I_SwitchAdapterItem): boolean => a.id === nic
|
299
|
+
) && availableAdapters.activeAdapters.push(nic)
|
300
|
+
)
|
301
|
+
networkOrSwitchNics?.standby?.forEach(
|
302
|
+
(nic) =>
|
303
|
+
nics?.items.find(
|
304
|
+
(a: UI_I_SwitchAdapterItem): boolean => a.id === nic
|
305
|
+
) && availableAdapters.standbyAdapters.push(nic)
|
306
|
+
)
|
307
|
+
networkOrSwitchNics?.unused?.forEach(
|
308
|
+
(nic) =>
|
309
|
+
nics?.items.find(
|
310
|
+
(a: UI_I_SwitchAdapterItem): boolean => a.id === nic
|
311
|
+
) && availableAdapters.unusedAdapters.push(nic)
|
312
|
+
)
|
313
|
+
}
|
314
|
+
|
315
|
+
return availableAdapters
|
316
|
+
}
|
317
|
+
|
318
|
+
export const createAdapterWithError = (
|
319
|
+
nic: string,
|
320
|
+
switchId: string
|
321
|
+
): UI_I_AdapterWithError => ({
|
322
|
+
fullName: nic,
|
323
|
+
id: nic,
|
324
|
+
name: nic,
|
325
|
+
networks: [],
|
326
|
+
state: { state: 1, errors: [] },
|
327
|
+
switch: switchId,
|
328
|
+
testId: `adapter-${nic}`,
|
329
|
+
carrier: false,
|
330
|
+
status: 'error',
|
331
|
+
})
|