VOL-3121 - Separated ports from devices.
Similar to flows/groups/meters/logical ports.
Also added ListDevicePorts and GetDevicePort to the adapter API.
Also removed unused `// +build integration` tests.
Change-Id: I586adb9f46a249c9430d4205ef5db2d105dbbe06
diff --git a/rw_core/core/device/logical_agent.go b/rw_core/core/device/logical_agent.go
index 6a14e5a..07f85e8 100644
--- a/rw_core/core/device/logical_agent.go
+++ b/rw_core/core/device/logical_agent.go
@@ -66,13 +66,14 @@
func newLogicalAgent(ctx context.Context, id string, sn string, deviceID string, ldeviceMgr *LogicalManager,
deviceMgr *Manager, dbProxy *model.Path, ldProxy *model.Proxy, defaultTimeout time.Duration) *LogicalAgent {
- agent := &LogicalAgent{
+ return &LogicalAgent{
logicalDeviceID: id,
serialNumber: sn,
rootDeviceID: deviceID,
deviceMgr: deviceMgr,
ldProxy: ldProxy,
ldeviceMgr: ldeviceMgr,
+ deviceRoutes: route.NewDeviceRoutes(id, deviceID, deviceMgr.listDevicePorts),
flowDecomposer: fd.NewFlowDecomposer(deviceMgr),
defaultTimeout: defaultTimeout,
requestQueue: coreutils.NewRequestQueue(),
@@ -82,8 +83,6 @@
meterLoader: meter.NewLoader(dbProxy.SubPath("logical_meters").Proxy(id)),
portLoader: port.NewLoader(dbProxy.SubPath("logical_ports").Proxy(id)),
}
- agent.deviceRoutes = route.NewDeviceRoutes(ctx, agent.logicalDeviceID, agent.deviceMgr.getDevice)
- return agent
}
// start creates the logical device and add it to the data model
@@ -123,9 +122,6 @@
ld.Desc = (proto.Clone(switchCap.Desc)).(*ofp.OfpDesc)
logger.Debugw(ctx, "Switch-capability", log.Fields{"Desc": ld.Desc, "fromAd": switchCap.Desc})
ld.SwitchFeatures = (proto.Clone(switchCap.SwitchFeatures)).(*ofp.OfpSwitchFeatures)
- ld.Flows = &ofp.Flows{Items: nil}
- ld.FlowGroups = &ofp.FlowGroups{Items: nil}
- ld.Ports = []*voltha.LogicalPort{}
// Save the logical device
if err := agent.ldProxy.Set(ctx, ld.Id, ld); err != nil {
@@ -160,6 +156,9 @@
// Update the last data
agent.logicalDevice = ld
+ // now that the root device is known, create DeviceRoutes with it
+ agent.deviceRoutes = route.NewDeviceRoutes(agent.logicalDeviceID, agent.rootDeviceID, agent.deviceMgr.listDevicePorts)
+
// load the flows, meters and groups from KV to cache
agent.flowLoader.Load(ctx)
agent.meterLoader.Load(ctx)