[VOL-2318] - Fix for jenkins NBI Failure
This commit adds the latest devices and logical devices to the
device agents and logical device agents respectively. Any GET
is returned directly from these agents instead from the model.
And any create/update results in the data being sent to the KV
store via the model and also results in the latest data in the
agent being updated. If the Core dies and restart then the
latest data will be pulled from KV. These changes assumes
that a device or a logical device is always owned by one Core
only which is the case.
Change-Id: Ie671cd70b38a58a3b32fa476eced5f218aeadad9
diff --git a/rw_core/core/logical_device_manager.go b/rw_core/core/logical_device_manager.go
index 8c326a8..53711d7 100644
--- a/rw_core/core/logical_device_manager.go
+++ b/rw_core/core/logical_device_manager.go
@@ -119,7 +119,7 @@
func (ldMgr *LogicalDeviceManager) getLogicalDevice(id string) (*voltha.LogicalDevice, error) {
log.Debugw("getlogicalDevice", log.Fields{"logicaldeviceid": id})
if agent := ldMgr.getLogicalDeviceAgent(id); agent != nil {
- return agent.GetLogicalDevice()
+ return agent.GetLogicalDevice(), nil
}
return nil, status.Errorf(codes.NotFound, "%s", id)
}
@@ -129,7 +129,7 @@
result := &voltha.LogicalDevices{}
ldMgr.logicalDeviceAgents.Range(func(key, value interface{}) bool {
agent := value.(*LogicalDeviceAgent)
- if ld, _ := agent.GetLogicalDevice(); ld != nil {
+ if ld := agent.GetLogicalDevice(); ld != nil {
result.Items = append(result.Items, ld)
}
return true
@@ -336,7 +336,7 @@
func (ldMgr *LogicalDeviceManager) ListLogicalDeviceFlows(ctx context.Context, id string) (*openflow_13.Flows, error) {
log.Debugw("ListLogicalDeviceFlows", log.Fields{"logicaldeviceid": id})
if agent := ldMgr.getLogicalDeviceAgent(id); agent != nil {
- return agent.ListLogicalDeviceFlows()
+ return agent.ListLogicalDeviceFlows(), nil
}
return nil, status.Errorf(codes.NotFound, "%s", id)
}
@@ -345,7 +345,7 @@
func (ldMgr *LogicalDeviceManager) ListLogicalDeviceFlowGroups(ctx context.Context, id string) (*openflow_13.FlowGroups, error) {
log.Debugw("ListLogicalDeviceFlowGroups", log.Fields{"logicaldeviceid": id})
if agent := ldMgr.getLogicalDeviceAgent(id); agent != nil {
- return agent.ListLogicalDeviceFlowGroups()
+ return agent.ListLogicalDeviceFlowGroups(), nil
}
return nil, status.Errorf(codes.NotFound, "%s", id)
}
@@ -354,7 +354,7 @@
func (ldMgr *LogicalDeviceManager) ListLogicalDevicePorts(ctx context.Context, id string) (*voltha.LogicalPorts, error) {
log.Debugw("ListLogicalDevicePorts", log.Fields{"logicaldeviceid": id})
if agent := ldMgr.getLogicalDeviceAgent(id); agent != nil {
- return agent.ListLogicalDevicePorts()
+ return agent.ListLogicalDevicePorts(), nil
}
return nil, status.Errorf(codes.NotFound, "%s", id)
}
@@ -540,7 +540,7 @@
func (ldMgr *LogicalDeviceManager) ListLogicalDeviceMeters(ctx context.Context, id string) (*openflow_13.Meters, error) {
log.Debugw("ListLogicalDeviceMeters", log.Fields{"logicalDeviceId": id})
if agent := ldMgr.getLogicalDeviceAgent(id); agent != nil {
- return agent.ListLogicalDeviceMeters()
+ return agent.ListLogicalDeviceMeters(), nil
}
return nil, status.Errorf(codes.NotFound, "%s", id)
}