Skip to content
Snippets Groups Projects
Commit 28b20ec1 authored by S.H.'s avatar S.H.
Browse files

implement committing change event initiated by SetPathList(), enable...

implement committing change event initiated by SetPathList(), enable synchronizing interface DOWN/UP events by deriving bool value for interfaces/interface/config/enable
parent 5f66bb5b
Branches
Tags
No related merge requests found
Pipeline #262354 failed
......@@ -185,13 +185,11 @@ func (r *RtdtManager) updateMNECallback(event *event.Event) {
}
}
// MTU Change
if strings.HasPrefix(path, prefix) && strings.HasSuffix(path, suffixMTU) {
fmt.Println("--- CHANGE MTU TRIGGERED ---")
fmt.Println("Value of new MTU: ", value)
// TODO: ONLY APPLY THIS TO A RELEVANT TWIN
for _, twin := range r.rtdt_twins {
twin.SetGnmiPath(path, value, twinEntityID)
}
twin.SetGnmiPath(path, value, twinEntityID)
}
// Hostname change
if strings.HasPrefix(path, prefixHostname) {
......@@ -212,7 +210,12 @@ func (r *RtdtManager) updateMNECallback(event *event.Event) {
fmt.Println("Setting interface", match[1], "UP/DOWN")
fmt.Printf("match: %v\n", match)
path := "/interfaces/interface[name=" + match[1] + "]/config/enabled"
r.rtdt_twins[0].SetGnmiPath(path, value, twinEntityID)
if value == "DOWN" {
value = "false"
} else {
value = "true"
}
twin.SetGnmiPath(path, value, twinEntityID)
}
}
}
......
......@@ -222,6 +222,8 @@ func (v *VEnv) ConstructTopology() error {
func getTypedValue(value string) *gnmi.TypedValue {
if boolVal, err := strconv.ParseBool(value); err == nil {
return &gnmi.TypedValue{Value: &gnmi.TypedValue_BoolVal{BoolVal: boolVal}}
} else if uintVal, err := strconv.ParseUint(value, 10, 64); err == nil {
return &gnmi.TypedValue{Value: &gnmi.TypedValue_UintVal{UintVal: uintVal}}
} else if intVal, err := strconv.ParseInt(value, 10, 64); err == nil {
return &gnmi.TypedValue{Value: &gnmi.TypedValue_IntVal{IntVal: intVal}}
} else {
......@@ -256,10 +258,29 @@ func (v *VEnv) SetGnmiPath(path, value, mneid string) error {
ChangeRequest: changeRequests,
})
if err != nil {
fmt.Printf("Going to panic now, the 'setPathResponse' value is %v\n", setPathResponse.String())
panic(err)
fmt.Printf("Error: %v\n", err)
return err
}
fmt.Println("setPathResponse: ", setPathResponse.String())
// Now try to commit the change
fmt.Println("Now trying to commit change with ID:", setPathResponse.GetResponses()[0].GetId())
setChange := &networkelement.SetChange{
Cuid: setPathResponse.GetResponses()[0].GetId(),
Op: networkelement.Operation_OPERATION_COMMIT,
}
setChangeListRequest := networkelement.SetChangeListRequest{
Change: []*networkelement.SetChange{setChange},
Timestamp: util.Now(),
Pid: pid,
}
clResponse, err := mneService.SetChangeList(ctx, &setChangeListRequest)
if err != nil {
fmt.Println("Error, failed to commit changes:", err)
return err
} else {
fmt.Println("Successfully applied changes:", clResponse)
}
return nil
}
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment