@@ -204,24 +204,7 @@ export default {
204
204
this .networkDataOptions = networkDataOptions;
205
205
this .images = res .images .value ? .data ;
206
206
this .storageClass = res .storageClass .value ? .data ;
207
- this .networkOptions = (res .networks .value ? .data || []).filter ((O ) => O .metadata ? .annotations ? .[STORAGE_NETWORK ] !== ' true' ).map ((O ) => {
208
- let value;
209
- let label;
210
-
211
- try {
212
- const config = JSON .parse (O .spec .config );
213
-
214
- const id = config .vlan ;
215
-
216
- value = O .id ;
217
- label = ` ${ value } (vlanId=${ id } )` ;
218
- } catch (err) {}
219
-
220
- return {
221
- label,
222
- value
223
- };
224
- });
207
+ this .networks = res .networks .value ? .data ;
225
208
226
209
let systemNamespaces = (res .settings .value ? .data || []).filter ((x ) => x .id === SETTING .SYSTEM_NAMESPACES );
227
210
@@ -391,7 +374,7 @@ export default {
391
374
storageClass: [],
392
375
namespaces: [],
393
376
namespaceOptions: [],
394
- networkOptions : [],
377
+ networks : [],
395
378
userDataOptions: [],
396
379
networkDataOptions: [],
397
380
allNodeObjects: [],
@@ -440,6 +423,31 @@ export default {
440
423
}
441
424
},
442
425
426
+ networkOptions: {
427
+ get () {
428
+ return (this .networks || []).filter ((O ) => O .metadata ? .annotations ? .[STORAGE_NETWORK ] !== ' true' ).map ((O ) => {
429
+ let value;
430
+ let label;
431
+
432
+ try {
433
+ const config = JSON .parse (O .spec .config );
434
+ const id = config .vlan ;
435
+
436
+ value = O .id ;
437
+ label = ` ${ value } (vlanId=${ id } )` ;
438
+ } catch (err) {}
439
+
440
+ return {
441
+ label,
442
+ value
443
+ };
444
+ });
445
+ },
446
+ set (neu ) {
447
+ this .networks = neu;
448
+ }
449
+ },
450
+
443
451
namespaceDisabled () {
444
452
return this .disabledEdit || this .poolIndex > 0 ;
445
453
},
@@ -738,6 +746,21 @@ export default {
738
746
}
739
747
},
740
748
749
+ async getAvailableNetworks () {
750
+ try {
751
+ const clusterId = get (this .credential , ' decodedData.clusterId' );
752
+
753
+ if (clusterId) {
754
+ const url = ` /k8s/clusters/${ clusterId } /v1` ;
755
+ const res = await this .$store .dispatch (' cluster/request' , { url: ` ${ url } /k8s.cni.cncf.io.network-attachment-definitions` });
756
+
757
+ this .networks = res? .data ;
758
+ }
759
+ } catch (e) {
760
+ this .errors = exceptionToErrorsArray (e);
761
+ }
762
+ },
763
+
741
764
async getAvailableVGpuDevices () {
742
765
const clusterId = get (this .credential , ' decodedData.clusterId' );
743
766
@@ -1400,6 +1423,7 @@ export default {
1400
1423
: required= " true"
1401
1424
label- key= " cluster.credential.harvester.network.networkName"
1402
1425
: placeholder= " t('cluster.harvester.machinePool.network.placeholder')"
1426
+ @on- open= " getAvailableNetworks"
1403
1427
@update: value= " update"
1404
1428
/ >
1405
1429
< / div>
0 commit comments