@@ -34,9 +34,12 @@ export class FabricDashboardPanel extends BasePanel {
34
34
private superSpineStreamName = '' ;
35
35
private fabricStatusStreamName = '' ;
36
36
private initialized = false ;
37
+ private useFieldsQuery = false ;
37
38
38
39
private get fabricQueryBase ( ) : string {
39
- return '.namespace.resources.cr-status.fabrics_eda_nokia_com.v1alpha1.fabric.status' ;
40
+ return this . useFieldsQuery
41
+ ? '.namespace.resources.cr.fabrics_eda_nokia_com.v1alpha1.fabric'
42
+ : '.namespace.resources.cr-status.fabrics_eda_nokia_com.v1alpha1.fabric.status' ;
40
43
}
41
44
42
45
constructor ( context : vscode . ExtensionContext , title : string ) {
@@ -46,6 +49,9 @@ export class FabricDashboardPanel extends BasePanel {
46
49
} ) ;
47
50
48
51
this . edaClient = serviceManager . getClient < EdaClient > ( 'eda' ) ;
52
+ const specManager = ( this . edaClient as any ) [ 'specManager' ] ;
53
+ const apiVersion = specManager ?. getApiVersion ?.( ) ?? '0' ;
54
+ this . useFieldsQuery = this . isVersionAtLeast ( apiVersion , '25.8' ) ;
49
55
50
56
this . streamClient = this . createStreamClient ( ) ;
51
57
void this . streamClient . connect ( ) ;
@@ -114,6 +120,27 @@ export class FabricDashboardPanel extends BasePanel {
114
120
return client ;
115
121
}
116
122
123
+ private isVersionAtLeast ( version : string , target : string ) : boolean {
124
+ const parse = ( v : string ) =>
125
+ v
126
+ . replace ( / ^ [ ^ 0 - 9 ] * / , '' )
127
+ . split ( '.' )
128
+ . map ( n => {
129
+ const num = parseInt ( n , 10 ) ;
130
+ return Number . isNaN ( num ) ? 0 : num ;
131
+ } ) ;
132
+ const vParts = parse ( version ) ;
133
+ const tParts = parse ( target ) ;
134
+ const len = Math . max ( vParts . length , tParts . length ) ;
135
+ for ( let i = 0 ; i < len ; i ++ ) {
136
+ const vVal = vParts [ i ] ?? 0 ;
137
+ const tVal = tParts [ i ] ?? 0 ;
138
+ if ( vVal > tVal ) return true ;
139
+ if ( vVal < tVal ) return false ;
140
+ }
141
+ return true ;
142
+ }
143
+
117
144
protected getHtml ( ) : string {
118
145
return this . readWebviewFile ( 'dashboard' , 'fabric' , 'fabricDashboardPanel.html' ) ;
119
146
}
@@ -485,7 +512,10 @@ export class FabricDashboardPanel extends BasePanel {
485
512
await this . streamClient . closeEqlStream ( this . spineStreamName ) ;
486
513
const namespaces = ns === 'All Namespaces' ? undefined : ns ;
487
514
this . spineStreamName = `spine-${ namespaces ?? 'all' } -${ randomUUID ( ) } ` ;
488
- this . streamClient . setEqlQuery ( `${ this . fabricQueryBase } .spineNodes` , namespaces , this . spineStreamName ) ;
515
+ const query = this . useFieldsQuery
516
+ ? `${ this . fabricQueryBase } fields [ status.spineNodes[].node ]`
517
+ : `${ this . fabricQueryBase } .spineNodes` ;
518
+ this . streamClient . setEqlQuery ( query , namespaces , this . spineStreamName ) ;
489
519
this . streamClient . subscribeToStream ( this . spineStreamName ) ;
490
520
await this . streamClient . connect ( ) ;
491
521
const stats = this . computeFabricGroupStats ( ns , 'spines' ) ;
@@ -496,7 +526,10 @@ export class FabricDashboardPanel extends BasePanel {
496
526
await this . streamClient . closeEqlStream ( this . leafStreamName ) ;
497
527
const namespaces = ns === 'All Namespaces' ? undefined : ns ;
498
528
this . leafStreamName = `leaf-${ namespaces ?? 'all' } -${ randomUUID ( ) } ` ;
499
- this . streamClient . setEqlQuery ( `${ this . fabricQueryBase } .leafNodes` , namespaces , this . leafStreamName ) ;
529
+ const query = this . useFieldsQuery
530
+ ? `${ this . fabricQueryBase } fields [ status.leafNodes[].node ]`
531
+ : `${ this . fabricQueryBase } .leafNodes` ;
532
+ this . streamClient . setEqlQuery ( query , namespaces , this . leafStreamName ) ;
500
533
this . streamClient . subscribeToStream ( this . leafStreamName ) ;
501
534
await this . streamClient . connect ( ) ;
502
535
const stats = this . computeFabricGroupStats ( ns , 'leafs' ) ;
@@ -507,7 +540,10 @@ export class FabricDashboardPanel extends BasePanel {
507
540
await this . streamClient . closeEqlStream ( this . borderLeafStreamName ) ;
508
541
const namespaces = ns === 'All Namespaces' ? undefined : ns ;
509
542
this . borderLeafStreamName = `borderleaf-${ namespaces ?? 'all' } -${ randomUUID ( ) } ` ;
510
- this . streamClient . setEqlQuery ( `${ this . fabricQueryBase } .borderLeafNodes` , namespaces , this . borderLeafStreamName ) ;
543
+ const query = this . useFieldsQuery
544
+ ? `${ this . fabricQueryBase } fields [ status.borderLeafNodes[].node ]`
545
+ : `${ this . fabricQueryBase } .borderLeafNodes` ;
546
+ this . streamClient . setEqlQuery ( query , namespaces , this . borderLeafStreamName ) ;
511
547
this . streamClient . subscribeToStream ( this . borderLeafStreamName ) ;
512
548
await this . streamClient . connect ( ) ;
513
549
const stats = this . computeFabricGroupStats ( ns , 'borderleafs' ) ;
@@ -518,7 +554,10 @@ export class FabricDashboardPanel extends BasePanel {
518
554
await this . streamClient . closeEqlStream ( this . superSpineStreamName ) ;
519
555
const namespaces = ns === 'All Namespaces' ? undefined : ns ;
520
556
this . superSpineStreamName = `superspine-${ namespaces ?? 'all' } -${ randomUUID ( ) } ` ;
521
- this . streamClient . setEqlQuery ( `${ this . fabricQueryBase } .superSpineNodes` , namespaces , this . superSpineStreamName ) ;
557
+ const query = this . useFieldsQuery
558
+ ? `${ this . fabricQueryBase } fields [ status.superSpineNodes[].node ]`
559
+ : `${ this . fabricQueryBase } .superSpineNodes` ;
560
+ this . streamClient . setEqlQuery ( query , namespaces , this . superSpineStreamName ) ;
522
561
this . streamClient . subscribeToStream ( this . superSpineStreamName ) ;
523
562
await this . streamClient . connect ( ) ;
524
563
const stats = this . computeFabricGroupStats ( ns , 'superspines' ) ;
@@ -529,7 +568,10 @@ export class FabricDashboardPanel extends BasePanel {
529
568
await this . streamClient . closeEqlStream ( this . fabricStatusStreamName ) ;
530
569
const namespaces = ns === 'All Namespaces' ? undefined : ns ;
531
570
this . fabricStatusStreamName = `fabricstatus-${ namespaces ?? 'all' } -${ randomUUID ( ) } ` ;
532
- this . streamClient . setEqlQuery ( this . fabricQueryBase , namespaces , this . fabricStatusStreamName ) ;
571
+ const query = this . useFieldsQuery
572
+ ? `${ this . fabricQueryBase } fields [ status.health ]`
573
+ : this . fabricQueryBase ;
574
+ this . streamClient . setEqlQuery ( query , namespaces , this . fabricStatusStreamName ) ;
533
575
this . streamClient . subscribeToStream ( this . fabricStatusStreamName ) ;
534
576
await this . streamClient . connect ( ) ;
535
577
const health = this . computeFabricHealth ( ns ) ;
@@ -560,6 +602,33 @@ export class FabricDashboardPanel extends BasePanel {
560
602
this . updateNodeGroup ( msg , 'superspines' ) ;
561
603
}
562
604
605
+ private extractNodesFromRow (
606
+ data : any ,
607
+ key : 'leafs' | 'borderleafs' | 'spines' | 'superspines'
608
+ ) : string [ ] {
609
+ const status = data ?. status ;
610
+ if ( ! status ) return [ ] ;
611
+ let arr : any [ ] | undefined ;
612
+ switch ( key ) {
613
+ case 'spines' :
614
+ arr = status . spineNodes ;
615
+ break ;
616
+ case 'leafs' :
617
+ arr = status . leafNodes ;
618
+ break ;
619
+ case 'borderleafs' :
620
+ arr = status . borderLeafNodes ;
621
+ break ;
622
+ case 'superspines' :
623
+ arr = status . superSpineNodes ;
624
+ break ;
625
+ }
626
+ if ( ! Array . isArray ( arr ) ) return [ ] ;
627
+ return arr
628
+ . map ( n => n ?. node )
629
+ . filter ( ( n ) : n is string => typeof n === 'string' ) ;
630
+ }
631
+
563
632
private updateNodeGroup (
564
633
msg : any ,
565
634
key : 'leafs' | 'borderleafs' | 'spines' | 'superspines'
@@ -572,9 +641,7 @@ export class FabricDashboardPanel extends BasePanel {
572
641
if ( Array . isArray ( rows ) ) {
573
642
for ( const r of rows ) {
574
643
const ns = r . data ?. [ '.namespace.name' ] as string | undefined ;
575
- const name = r . data ?. node as string | undefined ;
576
- const id = r . id as number | undefined ;
577
- if ( ! ns || ! name || id === undefined ) continue ;
644
+ if ( ! ns ) continue ;
578
645
let stats = this . fabricMap . get ( ns ) ;
579
646
if ( ! stats ) {
580
647
stats = {
@@ -586,16 +653,27 @@ export class FabricDashboardPanel extends BasePanel {
586
653
} ;
587
654
this . fabricMap . set ( ns , stats ) ;
588
655
}
589
- stats [ key ] . nodes . set ( id , name ) ;
656
+ if ( this . useFieldsQuery ) {
657
+ const nodes = this . extractNodesFromRow ( r . data , key ) ;
658
+ stats [ key ] . nodes . clear ( ) ;
659
+ nodes . forEach ( ( n , idx ) => stats ! [ key ] . nodes . set ( idx , n ) ) ;
660
+ } else {
661
+ const name = r . data ?. node as string | undefined ;
662
+ const id = r . id as number | undefined ;
663
+ if ( ! name || id === undefined ) continue ;
664
+ stats [ key ] . nodes . set ( id , name ) ;
665
+ }
590
666
changed . add ( ns ) ;
591
667
}
592
668
}
593
- const delIds = op ?. delete ?. ids ;
594
- if ( Array . isArray ( delIds ) ) {
595
- for ( const delId of delIds ) {
596
- for ( const [ ns , stats ] of this . fabricMap ) {
597
- if ( stats [ key ] . nodes . delete ( delId ) ) {
598
- changed . add ( ns ) ;
669
+ if ( ! this . useFieldsQuery ) {
670
+ const delIds = op ?. delete ?. ids ;
671
+ if ( Array . isArray ( delIds ) ) {
672
+ for ( const delId of delIds ) {
673
+ for ( const [ ns , stats ] of this . fabricMap ) {
674
+ if ( stats [ key ] . nodes . delete ( delId ) ) {
675
+ changed . add ( ns ) ;
676
+ }
599
677
}
600
678
}
601
679
}
@@ -638,7 +716,9 @@ export class FabricDashboardPanel extends BasePanel {
638
716
this . fabricMap . set ( ns , stats ) ;
639
717
}
640
718
641
- const newHealth = Number ( data ?. health ?? 0 ) ;
719
+ const newHealth = Number (
720
+ data ?. health ?? data ?. status ?. health ?? 0
721
+ ) ;
642
722
if ( stats . health !== newHealth ) {
643
723
stats . health = newHealth ;
644
724
changed . add ( ns ) ;
0 commit comments