bfg-common 1.0.16 → 1.0.18

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.
Files changed (28) hide show
  1. package/components/common/adapterManager/AdapterManager.vue +9 -9
  2. package/components/common/adapterManager/ui/table/Table.vue +2 -2
  3. package/components/common/addNetworking/AddNetworking.vue +2 -2
  4. package/components/common/addNetworking/config/sendData.ts +1 -1
  5. package/components/common/addNetworking/mappers/mappers.ts +1 -1
  6. package/components/common/diagramMain/DiagramMain.vue +2 -2
  7. package/components/common/diagramMain/config/initial.ts +1 -1
  8. package/components/common/diagramMain/modals/ManagePhysicalAdaptersModal.vue +236 -236
  9. package/components/common/diagramMain/modals/config/initial.ts +31 -45
  10. package/components/common/diagramMain/modals/editSettings/EditSettings.vue +6 -5
  11. package/components/common/diagramMain/modals/editSettings/tabs/Security.vue +183 -178
  12. package/components/common/diagramMain/modals/editSettings/tabs/TeamingFailover.vue +2 -1
  13. package/components/common/diagramMain/modals/editSettings/tabs/TrafficShaping.vue +393 -392
  14. package/components/common/diagramMain/models/interfaces.ts +53 -74
  15. package/components/common/diagramMain/models/types.ts +1 -1
  16. package/components/common/monitor/models/interfaces.ts +1 -0
  17. package/components/common/vm/actions/add/customizeHardware/virtualHardware/cpu/Cpu.vue +371 -371
  18. package/components/common/vm/actions/add/customizeHardware/virtualHardware/cpu/MaxCpu.vue +105 -105
  19. package/components/common/vm/actions/add/customizeHardware/virtualHardware/cpu/Sa.vue +102 -102
  20. package/components/common/vm/actions/add/customizeHardware/virtualHardware/cpu/shares/Shares.vue +155 -155
  21. package/components/common/vm/actions/add/customizeHardware/virtualHardware/limit/Limit.vue +214 -214
  22. package/components/common/vm/actions/add/customizeHardware/virtualHardware/memory/Memory.vue +282 -282
  23. package/components/common/vm/actions/add/customizeHardware/virtualHardware/newHardDisk/NewHardDisk.vue +451 -451
  24. package/components/common/vm/actions/add/customizeHardware/virtualHardware/newHardDisk/limitIops/LimitIops.vue +151 -151
  25. package/components/common/vm/actions/add/customizeHardware/vmoptions/remoteConsoleOptions/RemoteConsoleOptions.vue +230 -230
  26. package/components/common/vm/actions/add/select/compatibility/Compatibility.vue +151 -151
  27. package/package.json +1 -1
  28. package/public/spice-console/network/spicechannel.js +1 -1
@@ -1,371 +1,371 @@
1
- <template>
2
- <div class="hardware-cpu">
3
- <atoms-stack-block :has-children="true">
4
- <template #stackBlockKey>
5
- <div id="vm-wizard-toggle-block-cpu" class="flex-align-center">
6
- <span>{{ localization.cpu }}</span>
7
- <atoms-the-icon
8
- v-show="cpuInvalid"
9
- width="24px"
10
- height="24px"
11
- class="is-error tooltip-trigger"
12
- name="info"
13
- />
14
- </div>
15
- </template>
16
- <template #stackBlockContent>
17
- <div class="flex-align-center flex-space-between">
18
- <div class="flex-align-center">
19
- <atoms-tooltip-error
20
- :has-error="!!vcpusLocalAndApiErrorsTexts"
21
- selector="#vm-wizard-vcpus-field input"
22
- @remove="onRemoveValidationError"
23
- >
24
- <template #elem>
25
- <atoms-combobox
26
- id="vm-wizard-vcpus-field"
27
- v-model.number="selectedCpu"
28
- :items="cpuOptions"
29
- :disabled="isCpuDisabled"
30
- @click.stop
31
- />
32
- </template>
33
- <template #content>{{ vcpusLocalAndApiErrorsTexts }}</template>
34
- </atoms-tooltip-error>
35
- </div>
36
-
37
- <common-vm-actions-add-customize-hardware-virtual-hardware-cpu-tooltip
38
- :vm-cpu-help-text-second="props.vmCpuHelpTextSecond"
39
- />
40
- </div>
41
- </template>
42
- <template #stackChildren>
43
- <common-vm-actions-add-customize-hardware-virtual-hardware-cpu-cores-per-socket
44
- v-model:selected-core-per-socket="selectedCorePerSocket"
45
- :selected-cpu="selectedCpu"
46
- :cpu-options="cpuOptions"
47
- :is-edit="props.isEdit"
48
- :disabled="isDisabled"
49
- :error-validation-fields="props.errorValidationFields"
50
- @remove-error-by-title="emits('remove-error-by-title', $event)"
51
- />
52
- <common-vm-actions-add-customize-hardware-virtual-hardware-cpu-hot-plug
53
- v-model:enable-cpu-hot-add="enableCpuHotAdd"
54
- :disabled="enableCpuHotAddDisabled"
55
- />
56
- <common-vm-actions-add-customize-hardware-virtual-hardware-cpu-max-cpu
57
- v-show="enableCpuHotAdd"
58
- v-model:selected-max-cpu.number="selectedMaxCpu"
59
- :cpu-options="maxCpuOptions"
60
- :error-validation-fields="props.errorValidationFields"
61
- :disabled="isDisabled"
62
- @invalid="maxCpuInvalid = $event"
63
- @remove-error-by-title="emits('remove-error-by-title', $event)"
64
- />
65
- <common-vm-actions-add-customize-hardware-virtual-hardware-reservation
66
- v-model:reservation="reservation"
67
- v-model:reservation-type="reservationType"
68
- :error-validation-fields="props.errorValidationFields"
69
- :disabled="isDisabled"
70
- type="mhz"
71
- component-type="cpu"
72
- @invalid="reservationInvalid = $event"
73
- @remove-error-by-title="emits('remove-error-by-title', $event)"
74
- />
75
- <common-vm-actions-add-customize-hardware-virtual-hardware-limit
76
- v-model:limit="limit"
77
- v-model:limit-type="limitType"
78
- :error-validation-fields="props.errorValidationFields"
79
- :disabled="isDisabled"
80
- type="mhz"
81
- component-type="cpu"
82
- @invalid="limitInvalid = $event"
83
- @remove-error-by-title="emits('remove-error-by-title', $event)"
84
- />
85
- <common-vm-actions-add-customize-hardware-virtual-hardware-cpu-shares
86
- v-model:shares="shares"
87
- v-model:shares-type="sharesType"
88
- :error-validation-fields="props.errorValidationFields"
89
- :disabled="isDisabled"
90
- @remove-error-by-title="emits('remove-error-by-title', $event)"
91
- @invalid="sharesInvalid = $event"
92
- />
93
- <!-- <common-vm-actions-add-customize-hardware-virtual-hardware-cpu-hv-->
94
- <!-- v-model:hardwareVirtualization="hardwareVirtualization"-->
95
- <!-- />-->
96
- <!-- <common-vm-actions-add-customize-hardware-virtual-hardware-cpu-pc-->
97
- <!-- v-model:performanceCounters="performanceCounters"-->
98
- <!-- />-->
99
- <!-- <common-vm-actions-add-customize-hardware-virtual-hardware-cpu-sa-->
100
- <!-- v-model:schedulingAffinity="schedulingAffinity"-->
101
- <!-- />-->
102
- <!-- <common-vm-actions-add-customize-hardware-virtual-hardware-cpu-iommu-->
103
- <!-- v-model:iommu="iommu"-->
104
- <!-- />-->
105
- <common-vm-actions-add-customize-hardware-virtual-hardware-cpu-model
106
- v-model:cpu-model="cpuModel"
107
- v-model:passthrough-host-cpu="passthroughHostCpu"
108
- v-model:host-model-cpu="hostModelCpu"
109
- :cpu-models="props.cpuModels"
110
- :is-edit="props.isEdit"
111
- :error-validation-fields="props.errorValidationFields"
112
- :disabled="isDisabled"
113
- @remove-error-by-title="emits('remove-error-by-title', $event)"
114
- />
115
- </template>
116
- </atoms-stack-block>
117
- </div>
118
- </template>
119
-
120
- <script setup lang="ts">
121
- import { UI_I_SendDataCpu } from '~/components/common/vm/actions/add/customizeHardware/virtualHardware/models/interfaces'
122
- import { UI_I_Localization } from '~/models/interfaces'
123
- import { UI_I_ErrorValidationField } from '~/models/store/interfaces'
124
- import { UI_I_OptionItem } from '~/components/atoms/models/interfaces'
125
- import { API_UI_I_VmEditCpu } from '~/models/store/vm/interfaces'
126
- import { cpuOptionsFunc } from '~/components/common/vm/actions/add/customizeHardware/virtualHardware/cpu/config/cpuOptions'
127
-
128
- const props = defineProps<{
129
- maxCpus: number
130
- cpuModels: UI_I_OptionItem[]
131
- isEdit: boolean
132
- errorValidationFields: UI_I_ErrorValidationField<string>[]
133
- vmCpuHelpTextSecond?: string
134
- state?: string
135
- cpu?: API_UI_I_VmEditCpu
136
- }>()
137
- const emits = defineEmits<{
138
- (event: 'send-data', value: UI_I_SendDataCpu): void
139
- (event: 'invalid', value: boolean): void
140
- (event: 'remove-error-by-title', value: string): void
141
- }>()
142
-
143
- const localization = computed<UI_I_Localization>(() => useLocal())
144
-
145
- const isDisabled = computed<boolean>(() => {
146
- return props.state === '1'
147
- })
148
-
149
- const cpuOptions = computed<UI_I_OptionItem[]>(() =>
150
- cpuOptionsFunc(localization.value, 1, props.maxCpus)
151
- )
152
-
153
- const enableCpuHotAdd = ref<boolean>(false)
154
- const enableCpuHotAddDisabled = computed<boolean>(
155
- () => selectedCpu.value >= props.maxCpus || isDisabled.value
156
- )
157
- watch(enableCpuHotAdd, (newValue) => {
158
- if (newValue) return
159
-
160
- maxCpuInvalid.value = false
161
- selectedMaxCpu.value = cpuOptions.value.at(-1)?.value
162
- })
163
-
164
- const selectedCpu = ref<number>(
165
- isDisabled.value && enableCpuHotAdd.value ? props.maxCpus : 2
166
- )
167
- const isCpuDisabled = computed<boolean>(
168
- () => isDisabled.value && !enableCpuHotAdd.value
169
- )
170
- watch(selectedCpu, (newValue) => {
171
- selectedCpu.value = Math.floor(+newValue)
172
- if (!(selectedCpu.value % selectedCorePerSocket.value)) return
173
- selectedCorePerSocket.value = 1
174
- })
175
- const maxCpuOptions = computed<UI_I_OptionItem[]>(() =>
176
- cpuOptionsFunc(localization.value, selectedCpu.value + 1, props.maxCpus)
177
- )
178
- watch(selectedCpu, (newValue) => {
179
- if (newValue >= props.maxCpus) {
180
- enableCpuHotAdd.value = false
181
- }
182
- selectedMaxCpu.value =
183
- selectedMaxCpu.value <= newValue ? newValue + 1 : selectedMaxCpu.value
184
- if (selectedMaxCpu.value > props.maxCpus) selectedMaxCpu.value = props.maxCpus
185
- })
186
- const selectedMaxCpu = ref<number>(cpuOptions.value.at(-1)?.value)
187
- watch(
188
- () => props.maxCpus,
189
- (newValue) => {
190
- selectedMaxCpu.value = newValue
191
- }
192
- )
193
-
194
- const selectedCorePerSocket = ref<number>(1)
195
-
196
- const cpuErrorLocalText = computed<string>(() => {
197
- const validValue = /^\d+(\.\d+)?$/.test(selectedCpu.value + '')
198
- if (!validValue) {
199
- return localization.value.inputContainsInvalidCharacters
200
- }
201
-
202
- const min = cpuOptions.value[0].value
203
- const max = cpuOptions.value[1].value
204
- if (selectedCpu.value < min || selectedCpu.value > max) {
205
- return localization.value.memoryMustBe
206
- .replace('{0}', min)
207
- .replace('{1}', max)
208
- }
209
-
210
- return ''
211
- })
212
-
213
- const apiVcpusError = computed<string>(() => {
214
- return (
215
- props.errorValidationFields?.find(
216
- (message) => message.field === 'cpu.vcpus'
217
- )?.error_message || ''
218
- )
219
- })
220
-
221
- const vcpusLocalAndApiErrorsTexts = computed<string>(() => {
222
- const localError = cpuErrorLocalText.value
223
- const apiError = apiVcpusError.value
224
-
225
- let result = ''
226
- if (localError && !apiError) result = localError
227
- if (!localError && apiError) result = apiError
228
- if (localError && apiError) result = localError + ', ' + apiError
229
- if (!localError && apiError) result = apiError
230
-
231
- return result
232
- })
233
- const reservationInvalid = ref<boolean>(false)
234
- const limitInvalid = ref<boolean>(false)
235
- const sharesInvalid = ref<boolean>(false)
236
- const maxCpuInvalid = ref<boolean>(false)
237
- const cpuInvalid = computed<boolean>(
238
- () =>
239
- !!cpuErrorLocalText.value ||
240
- reservationInvalid.value ||
241
- limitInvalid.value ||
242
- sharesInvalid.value ||
243
- (selectedCpu.value < props.maxCpus && maxCpuInvalid.value)
244
- )
245
- watch(
246
- cpuInvalid,
247
- (newValue: boolean) => {
248
- emits('invalid', newValue)
249
- },
250
- { immediate: true }
251
- )
252
-
253
- const reservation = ref<string>('1')
254
- const reservationType = ref<string>('mhz')
255
-
256
- const limit = ref<string>('Unlimited')
257
- const limitType = ref<string>('mhz')
258
-
259
- const shares = ref<string>('2000')
260
- const sharesType = ref<string>('2000')
261
-
262
- // const hardwareVirtualization = ref<boolean>(false)
263
- //
264
- // const performanceCounters = ref<boolean>(false)
265
- //
266
- // const schedulingAffinity = ref<string>('')
267
- //
268
- // const iommu = ref<boolean>(false)
269
-
270
- const cpuModel = ref<string>(props.cpuModels[0]?.value || '')
271
- watch(
272
- () => props.cpuModels,
273
- (newValue) => {
274
- cpuModel.value = newValue[0].value
275
- }
276
- )
277
- const passthroughHostCpu = ref<boolean>(false)
278
- const hostModelCpu = ref<boolean>(false)
279
-
280
- // const isShowCpuHelp = ref<boolean>(false)
281
-
282
- const { $binary } = useNuxtApp()
283
- watch(
284
- [
285
- reservation,
286
- reservationType,
287
- limit,
288
- shares,
289
- selectedCpu,
290
- selectedMaxCpu,
291
- selectedCorePerSocket,
292
- enableCpuHotAdd,
293
- cpuModel,
294
- passthroughHostCpu,
295
- hostModelCpu,
296
- ],
297
- () => {
298
- const reservationInMhz =
299
- reservationType.value === 'ghz'
300
- ? $binary.ghzToMhz(+reservation.value)
301
- : +reservation.value
302
- const limitInMhz =
303
- limit.value === 'Unlimited'
304
- ? limit.value
305
- : limitType.value === 'ghz'
306
- ? $binary.ghzToMhz(+limit.value)
307
- : +limit.value
308
- const model = passthroughHostCpu.value
309
- ? 'host-passthrough'
310
- : hostModelCpu.value
311
- ? 'host-model'
312
- : cpuModel.value
313
-
314
- emits('send-data', {
315
- model,
316
- vcpus: selectedCpu.value,
317
- max_vcpus: enableCpuHotAdd.value ? selectedMaxCpu.value : 0,
318
- core_per_socket: selectedCorePerSocket.value,
319
- reservation_mhz: reservationInMhz,
320
- limit_mhz: limitInMhz,
321
- shares: +shares.value,
322
- hotplug: enableCpuHotAdd.value,
323
- })
324
- },
325
- {
326
- immediate: true,
327
- }
328
- )
329
-
330
- // Добавляем данные для редактирования
331
- watch(
332
- () => props.cpu,
333
- (newValue) => {
334
- if (!newValue) return
335
-
336
- enableCpuHotAdd.value = newValue.hotplug
337
- selectedCpu.value = newValue.vcpus
338
- selectedMaxCpu.value = newValue.max_vcpus
339
- selectedCorePerSocket.value = newValue.core_per_socket
340
- reservation.value = '' + newValue.reservation_mhz
341
- limit.value = '' + newValue.limit_mhz
342
- shares.value = '' + newValue.shares
343
- cpuModel.value =
344
- props.cpuModels.find((model) => model.text === props.cpu?.model)?.value ||
345
- cpuModel.value
346
- },
347
- { immediate: true }
348
- )
349
-
350
- const onRemoveValidationError = (): void => {
351
- emits('remove-error-by-title', 'cpu.vcpus')
352
- }
353
- </script>
354
-
355
- <style scoped lang="scss">
356
- h3.cpu-help-title {
357
- margin-top: 7px;
358
- font-size: 22px;
359
- color: #565656;
360
- }
361
- p.cpu-help-text {
362
- width: 310px;
363
- margin-top: 24px;
364
- font-size: 14px;
365
- color: #565656;
366
- }
367
- a.cpu-more-info {
368
- color: #00648f;
369
- font-size: 14px;
370
- }
371
- </style>
1
+ <template>
2
+ <div class="hardware-cpu">
3
+ <atoms-stack-block :has-children="true">
4
+ <template #stackBlockKey>
5
+ <div id="vm-wizard-toggle-block-cpu" class="flex-align-center">
6
+ <span>{{ localization.cpu }}</span>
7
+ <atoms-the-icon
8
+ v-show="cpuInvalid"
9
+ width="24px"
10
+ height="24px"
11
+ class="is-error tooltip-trigger"
12
+ name="info"
13
+ />
14
+ </div>
15
+ </template>
16
+ <template #stackBlockContent>
17
+ <div class="flex-align-center flex-space-between">
18
+ <div class="flex-align-center">
19
+ <atoms-tooltip-error
20
+ :has-error="!!vcpusLocalAndApiErrorsTexts"
21
+ selector="#vm-wizard-vcpus-field input"
22
+ @remove="onRemoveValidationError"
23
+ >
24
+ <template #elem>
25
+ <atoms-combobox
26
+ id="vm-wizard-vcpus-field"
27
+ v-model.number="selectedCpu"
28
+ :items="cpuOptions"
29
+ :disabled="isCpuDisabled"
30
+ @click.stop
31
+ />
32
+ </template>
33
+ <template #content>{{ vcpusLocalAndApiErrorsTexts }}</template>
34
+ </atoms-tooltip-error>
35
+ </div>
36
+
37
+ <common-vm-actions-add-customize-hardware-virtual-hardware-cpu-tooltip
38
+ :vm-cpu-help-text-second="props.vmCpuHelpTextSecond"
39
+ />
40
+ </div>
41
+ </template>
42
+ <template #stackChildren>
43
+ <common-vm-actions-add-customize-hardware-virtual-hardware-cpu-cores-per-socket
44
+ v-model:selected-core-per-socket="selectedCorePerSocket"
45
+ :selected-cpu="selectedCpu"
46
+ :cpu-options="cpuOptions"
47
+ :is-edit="props.isEdit"
48
+ :disabled="isDisabled"
49
+ :error-validation-fields="props.errorValidationFields"
50
+ @remove-error-by-title="emits('remove-error-by-title', $event)"
51
+ />
52
+ <common-vm-actions-add-customize-hardware-virtual-hardware-cpu-hot-plug
53
+ v-model:enable-cpu-hot-add="enableCpuHotAdd"
54
+ :disabled="enableCpuHotAddDisabled"
55
+ />
56
+ <common-vm-actions-add-customize-hardware-virtual-hardware-cpu-max-cpu
57
+ v-show="enableCpuHotAdd"
58
+ v-model:selected-max-cpu.number="selectedMaxCpu"
59
+ :cpu-options="maxCpuOptions"
60
+ :error-validation-fields="props.errorValidationFields"
61
+ :disabled="isDisabled"
62
+ @invalid="maxCpuInvalid = $event"
63
+ @remove-error-by-title="emits('remove-error-by-title', $event)"
64
+ />
65
+ <common-vm-actions-add-customize-hardware-virtual-hardware-reservation
66
+ v-model:reservation="reservation"
67
+ v-model:reservation-type="reservationType"
68
+ :error-validation-fields="props.errorValidationFields"
69
+ :disabled="isDisabled"
70
+ type="mhz"
71
+ component-type="cpu"
72
+ @invalid="reservationInvalid = $event"
73
+ @remove-error-by-title="emits('remove-error-by-title', $event)"
74
+ />
75
+ <common-vm-actions-add-customize-hardware-virtual-hardware-limit
76
+ v-model:limit="limit"
77
+ v-model:limit-type="limitType"
78
+ :error-validation-fields="props.errorValidationFields"
79
+ :disabled="isDisabled"
80
+ type="mhz"
81
+ component-type="cpu"
82
+ @invalid="limitInvalid = $event"
83
+ @remove-error-by-title="emits('remove-error-by-title', $event)"
84
+ />
85
+ <common-vm-actions-add-customize-hardware-virtual-hardware-cpu-shares
86
+ v-model:shares="shares"
87
+ v-model:shares-type="sharesType"
88
+ :error-validation-fields="props.errorValidationFields"
89
+ :disabled="isDisabled"
90
+ @remove-error-by-title="emits('remove-error-by-title', $event)"
91
+ @invalid="sharesInvalid = $event"
92
+ />
93
+ <!-- <common-vm-actions-add-customize-hardware-virtual-hardware-cpu-hv-->
94
+ <!-- v-model:hardwareVirtualization="hardwareVirtualization"-->
95
+ <!-- />-->
96
+ <!-- <common-vm-actions-add-customize-hardware-virtual-hardware-cpu-pc-->
97
+ <!-- v-model:performanceCounters="performanceCounters"-->
98
+ <!-- />-->
99
+ <!-- <common-vm-actions-add-customize-hardware-virtual-hardware-cpu-sa-->
100
+ <!-- v-model:schedulingAffinity="schedulingAffinity"-->
101
+ <!-- />-->
102
+ <!-- <common-vm-actions-add-customize-hardware-virtual-hardware-cpu-iommu-->
103
+ <!-- v-model:iommu="iommu"-->
104
+ <!-- />-->
105
+ <common-vm-actions-add-customize-hardware-virtual-hardware-cpu-model
106
+ v-model:cpu-model="cpuModel"
107
+ v-model:passthrough-host-cpu="passthroughHostCpu"
108
+ v-model:host-model-cpu="hostModelCpu"
109
+ :cpu-models="props.cpuModels"
110
+ :is-edit="props.isEdit"
111
+ :error-validation-fields="props.errorValidationFields"
112
+ :disabled="isDisabled"
113
+ @remove-error-by-title="emits('remove-error-by-title', $event)"
114
+ />
115
+ </template>
116
+ </atoms-stack-block>
117
+ </div>
118
+ </template>
119
+
120
+ <script setup lang="ts">
121
+ import { UI_I_SendDataCpu } from '~/components/common/vm/actions/add/customizeHardware/virtualHardware/models/interfaces'
122
+ import { UI_I_Localization } from '~/models/interfaces'
123
+ import { UI_I_ErrorValidationField } from '~/models/store/interfaces'
124
+ import { UI_I_OptionItem } from '~/components/atoms/models/interfaces'
125
+ import { API_UI_I_VmEditCpu } from '~/models/store/vm/interfaces'
126
+ import { cpuOptionsFunc } from '~/components/common/vm/actions/add/customizeHardware/virtualHardware/cpu/config/cpuOptions'
127
+
128
+ const props = defineProps<{
129
+ maxCpus: number
130
+ cpuModels: UI_I_OptionItem[]
131
+ isEdit: boolean
132
+ errorValidationFields: UI_I_ErrorValidationField<string>[]
133
+ vmCpuHelpTextSecond?: string
134
+ state?: string
135
+ cpu?: API_UI_I_VmEditCpu
136
+ }>()
137
+ const emits = defineEmits<{
138
+ (event: 'send-data', value: UI_I_SendDataCpu): void
139
+ (event: 'invalid', value: boolean): void
140
+ (event: 'remove-error-by-title', value: string): void
141
+ }>()
142
+
143
+ const localization = computed<UI_I_Localization>(() => useLocal())
144
+
145
+ const isDisabled = computed<boolean>(() => {
146
+ return props.state === '1'
147
+ })
148
+
149
+ const cpuOptions = computed<UI_I_OptionItem[]>(() =>
150
+ cpuOptionsFunc(localization.value, 1, props.maxCpus)
151
+ )
152
+
153
+ const enableCpuHotAdd = ref<boolean>(false)
154
+ const enableCpuHotAddDisabled = computed<boolean>(
155
+ () => selectedCpu.value >= props.maxCpus || isDisabled.value
156
+ )
157
+ watch(enableCpuHotAdd, (newValue) => {
158
+ if (newValue) return
159
+
160
+ maxCpuInvalid.value = false
161
+ selectedMaxCpu.value = cpuOptions.value.at(-1)?.value
162
+ })
163
+
164
+ const selectedCpu = ref<number>(
165
+ isDisabled.value && enableCpuHotAdd.value ? props.maxCpus : 2
166
+ )
167
+ const isCpuDisabled = computed<boolean>(
168
+ () => isDisabled.value && !enableCpuHotAdd.value
169
+ )
170
+ watch(selectedCpu, (newValue) => {
171
+ selectedCpu.value = Math.floor(+newValue)
172
+ if (!(selectedCpu.value % selectedCorePerSocket.value)) return
173
+ selectedCorePerSocket.value = 1
174
+ })
175
+ const maxCpuOptions = computed<UI_I_OptionItem[]>(() =>
176
+ cpuOptionsFunc(localization.value, selectedCpu.value + 1, props.maxCpus)
177
+ )
178
+ watch(selectedCpu, (newValue) => {
179
+ if (newValue >= props.maxCpus) {
180
+ enableCpuHotAdd.value = false
181
+ }
182
+ selectedMaxCpu.value =
183
+ selectedMaxCpu.value <= newValue ? newValue + 1 : selectedMaxCpu.value
184
+ if (selectedMaxCpu.value > props.maxCpus) selectedMaxCpu.value = props.maxCpus
185
+ })
186
+ const selectedMaxCpu = ref<number>(cpuOptions.value.at(-1)?.value)
187
+ watch(
188
+ () => props.maxCpus,
189
+ (newValue) => {
190
+ selectedMaxCpu.value = newValue
191
+ }
192
+ )
193
+
194
+ const selectedCorePerSocket = ref<number>(1)
195
+
196
+ const cpuErrorLocalText = computed<string>(() => {
197
+ const validValue = /^\d+(\.\d+)?$/.test(selectedCpu.value + '')
198
+ if (!validValue) {
199
+ return localization.value.inputContainsInvalidCharacters
200
+ }
201
+
202
+ const min = cpuOptions.value[0].value
203
+ const max = cpuOptions.value[1].value
204
+ if (selectedCpu.value < min || selectedCpu.value > max) {
205
+ return localization.value.memoryMustBe
206
+ .replace('{0}', min)
207
+ .replace('{1}', max)
208
+ }
209
+
210
+ return ''
211
+ })
212
+
213
+ const apiVcpusError = computed<string>(() => {
214
+ return (
215
+ props.errorValidationFields?.find(
216
+ (message) => message.field === 'cpu.vcpus'
217
+ )?.error_message || ''
218
+ )
219
+ })
220
+
221
+ const vcpusLocalAndApiErrorsTexts = computed<string>(() => {
222
+ const localError = cpuErrorLocalText.value
223
+ const apiError = apiVcpusError.value
224
+
225
+ let result = ''
226
+ if (localError && !apiError) result = localError
227
+ if (!localError && apiError) result = apiError
228
+ if (localError && apiError) result = localError + ', ' + apiError
229
+ if (!localError && apiError) result = apiError
230
+
231
+ return result
232
+ })
233
+ const reservationInvalid = ref<boolean>(false)
234
+ const limitInvalid = ref<boolean>(false)
235
+ const sharesInvalid = ref<boolean>(false)
236
+ const maxCpuInvalid = ref<boolean>(false)
237
+ const cpuInvalid = computed<boolean>(
238
+ () =>
239
+ !!cpuErrorLocalText.value ||
240
+ reservationInvalid.value ||
241
+ limitInvalid.value ||
242
+ sharesInvalid.value ||
243
+ (selectedCpu.value < props.maxCpus && maxCpuInvalid.value)
244
+ )
245
+ watch(
246
+ cpuInvalid,
247
+ (newValue: boolean) => {
248
+ emits('invalid', newValue)
249
+ },
250
+ { immediate: true }
251
+ )
252
+
253
+ const reservation = ref<string>('1')
254
+ const reservationType = ref<string>('mhz')
255
+
256
+ const limit = ref<string>('Unlimited')
257
+ const limitType = ref<string>('mhz')
258
+
259
+ const shares = ref<string>('2000')
260
+ const sharesType = ref<string>('2000')
261
+
262
+ // const hardwareVirtualization = ref<boolean>(false)
263
+ //
264
+ // const performanceCounters = ref<boolean>(false)
265
+ //
266
+ // const schedulingAffinity = ref<string>('')
267
+ //
268
+ // const iommu = ref<boolean>(false)
269
+
270
+ const cpuModel = ref<string>(props.cpuModels[0]?.value || '')
271
+ watch(
272
+ () => props.cpuModels,
273
+ (newValue) => {
274
+ cpuModel.value = newValue[0].value
275
+ }
276
+ )
277
+ const passthroughHostCpu = ref<boolean>(false)
278
+ const hostModelCpu = ref<boolean>(false)
279
+
280
+ // const isShowCpuHelp = ref<boolean>(false)
281
+
282
+ const { $binary } = useNuxtApp()
283
+ watch(
284
+ [
285
+ reservation,
286
+ reservationType,
287
+ limit,
288
+ shares,
289
+ selectedCpu,
290
+ selectedMaxCpu,
291
+ selectedCorePerSocket,
292
+ enableCpuHotAdd,
293
+ cpuModel,
294
+ passthroughHostCpu,
295
+ hostModelCpu,
296
+ ],
297
+ () => {
298
+ const reservationInMhz =
299
+ reservationType.value === 'ghz'
300
+ ? $binary.ghzToMhz(+reservation.value)
301
+ : +reservation.value
302
+ const limitInMhz =
303
+ limit.value === 'Unlimited'
304
+ ? limit.value
305
+ : limitType.value === 'ghz'
306
+ ? $binary.ghzToMhz(+limit.value)
307
+ : +limit.value
308
+ const model = passthroughHostCpu.value
309
+ ? 'host-passthrough'
310
+ : hostModelCpu.value
311
+ ? 'host-model'
312
+ : cpuModel.value
313
+
314
+ emits('send-data', {
315
+ model,
316
+ vcpus: selectedCpu.value,
317
+ max_vcpus: enableCpuHotAdd.value ? selectedMaxCpu.value : 0,
318
+ core_per_socket: selectedCorePerSocket.value,
319
+ reservation_mhz: reservationInMhz,
320
+ limit_mhz: limitInMhz,
321
+ shares: +shares.value,
322
+ hotplug: enableCpuHotAdd.value,
323
+ })
324
+ },
325
+ {
326
+ immediate: true,
327
+ }
328
+ )
329
+
330
+ // Добавляем данные для редактирования
331
+ watch(
332
+ () => props.cpu,
333
+ (newValue) => {
334
+ if (!newValue) return
335
+
336
+ enableCpuHotAdd.value = newValue.hotplug
337
+ selectedCpu.value = newValue.vcpus
338
+ selectedMaxCpu.value = newValue.max_vcpus
339
+ selectedCorePerSocket.value = newValue.core_per_socket
340
+ reservation.value = '' + newValue.reservation_mhz
341
+ limit.value = '' + newValue.limit_mhz
342
+ shares.value = '' + newValue.shares
343
+ cpuModel.value =
344
+ props.cpuModels.find((model) => model.text === props.cpu?.model)?.value ||
345
+ cpuModel.value
346
+ },
347
+ { immediate: true }
348
+ )
349
+
350
+ const onRemoveValidationError = (): void => {
351
+ emits('remove-error-by-title', 'cpu.vcpus')
352
+ }
353
+ </script>
354
+
355
+ <style scoped lang="scss">
356
+ h3.cpu-help-title {
357
+ margin-top: 7px;
358
+ font-size: 22px;
359
+ color: #565656;
360
+ }
361
+ p.cpu-help-text {
362
+ width: 310px;
363
+ margin-top: 24px;
364
+ font-size: 14px;
365
+ color: #565656;
366
+ }
367
+ a.cpu-more-info {
368
+ color: #00648f;
369
+ font-size: 14px;
370
+ }
371
+ </style>