@@ -28,9 +28,10 @@ type OvnChassis struct {
2828 UUID string
2929 Proto string
3030 }
31- Up int
32- Ports []string
33- Switches []string
31+ NbCfg int64 // Configuration sequence number from Chassis_Private table (0 if not present)
32+ NbCfgTimestamp int64 // Timestamp from Chassis_Private table (0 if not present)
33+ Ports []string
34+ Switches []string
3435}
3536
3637// GetChassis returns a list of OVN chassis.
@@ -134,6 +135,92 @@ func (cli *OvnClient) GetChassis() ([]*OvnChassis, error) {
134135 break
135136 }
136137 }
138+
139+ query = "SELECT chassis, name, nb_cfg, nb_cfg_timestamp FROM Chassis_Private"
140+ result , err = cli .Database .Southbound .Client .Transact (cli .Database .Southbound .Name , query )
141+ if err != nil {
142+ return chassis , nil
143+ }
144+
145+ // Create maps for chassis nb_cfg and nb_cfg_timestamp
146+ chassisNbCfgMap := make (map [string ]int64 )
147+ chassisTimestampMap := make (map [string ]int64 )
148+ if len (result .Rows ) > 0 {
149+ for _ , row := range result .Rows {
150+ var chassisUUID string
151+ var chassisName string
152+ var nbCfg int64
153+ var nbCfgTimestamp int64
154+
155+ // Get chassis UUID (reference to Chassis table)
156+ if r , dt , err := row .GetColumnValue ("chassis" , result .Columns ); err == nil && dt == "string" {
157+ chassisUUID = r .(string )
158+ }
159+
160+ // Get chassis name
161+ if r , dt , err := row .GetColumnValue ("name" , result .Columns ); err == nil && dt == "string" {
162+ chassisName = r .(string )
163+ }
164+
165+ // Get the nb_cfg
166+ if r , dt , err := row .GetColumnValue ("nb_cfg" , result .Columns ); err == nil {
167+ switch dt {
168+ case "int64" :
169+ nbCfg = r .(int64 )
170+ case "integer" :
171+ // GetColumnValue returns "integer" for float64 values after converting to int64
172+ nbCfg = r .(int64 )
173+ case "float64" :
174+ nbCfg = int64 (r .(float64 ))
175+ case "int" :
176+ nbCfg = int64 (r .(int ))
177+ }
178+ }
179+
180+ // Get the nb_cfg_timestamp
181+ if r , dt , err := row .GetColumnValue ("nb_cfg_timestamp" , result .Columns ); err == nil {
182+ switch dt {
183+ case "int64" :
184+ nbCfgTimestamp = r .(int64 )
185+ case "integer" :
186+ // GetColumnValue returns "integer" for float64 values after converting to int64
187+ nbCfgTimestamp = r .(int64 )
188+ case "float64" :
189+ nbCfgTimestamp = int64 (r .(float64 ))
190+ case "int" :
191+ nbCfgTimestamp = int64 (r .(int ))
192+ }
193+ }
194+
195+ // Store values by both UUID and name
196+ if chassisUUID != "" {
197+ chassisNbCfgMap [chassisUUID ] = nbCfg
198+ chassisTimestampMap [chassisUUID ] = nbCfgTimestamp
199+ }
200+ if chassisName != "" {
201+ chassisNbCfgMap [chassisName ] = nbCfg
202+ chassisTimestampMap [chassisName ] = nbCfgTimestamp
203+ }
204+ }
205+ }
206+
207+ // Set the NbCfg and NbCfgTimestamp fields for each chassis
208+ // Will be 0 if chassis has no entry in Chassis_Private
209+ for _ , c := range chassis {
210+ if nbCfg , exists := chassisNbCfgMap [c .UUID ]; exists {
211+ c .NbCfg = nbCfg
212+ } else if nbCfg , exists := chassisNbCfgMap [c .Name ]; exists {
213+ c .NbCfg = nbCfg
214+ }
215+
216+ if timestamp , exists := chassisTimestampMap [c .UUID ]; exists {
217+ c .NbCfgTimestamp = timestamp
218+ } else if timestamp , exists := chassisTimestampMap [c .Name ]; exists {
219+ c .NbCfgTimestamp = timestamp
220+ }
221+ // If no entry found, NbCfg and NbCfgTimestamp remain 0 (default)
222+ }
223+
137224 return chassis , nil
138225}
139226
0 commit comments