This commit consists of:
1) Update the voltha.proto to remove duplicates between the voltha message and
the CoreInstance. Since all data will be stored into the clustered KV store
then it makes sense to use a clustered proto message instead of core specific.
Each core will hold a subset of the data, only those it is actively or passively
managing.
2) Add a Makefile into the adapters directory to clearly separate the build of
adapters to the core build. This is work in progress.
3) Add an initial readme.md into the adapters directory to show how to run ponsim
olt and onu adapters in containers
4) Minor cleanup, mostly around name consistency.
Change-Id: I55155c41b56e95877f8735b536873a87d6ca63b1
diff --git a/rw_core/core/device_agent.go b/rw_core/core/device_agent.go
index aa13748..805dd21 100644
--- a/rw_core/core/device_agent.go
+++ b/rw_core/core/device_agent.go
@@ -28,15 +28,15 @@
)
type DeviceAgent struct {
- deviceId string
- lastData *voltha.Device
- adapterProxy *AdapterProxy
- deviceMgr *DeviceManager
- localDataProxy *model.Proxy
- exitChannel chan int
+ deviceId string
+ lastData *voltha.Device
+ adapterProxy *AdapterProxy
+ deviceMgr *DeviceManager
+ clusterDataProxy *model.Proxy
+ exitChannel chan int
}
-func newDeviceAgent(ap *AdapterProxy, device *voltha.Device, deviceMgr *DeviceManager, ldProxy *model.Proxy) *DeviceAgent {
+func newDeviceAgent(ap *AdapterProxy, device *voltha.Device, deviceMgr *DeviceManager, cdProxy *model.Proxy) *DeviceAgent {
var agent DeviceAgent
device.Id = CreateDeviceId()
agent.deviceId = device.Id
@@ -44,14 +44,14 @@
agent.lastData = device
agent.deviceMgr = deviceMgr
agent.exitChannel = make(chan int, 1)
- agent.localDataProxy = ldProxy
+ agent.clusterDataProxy = cdProxy
return &agent
}
func (agent *DeviceAgent) start(ctx context.Context) {
log.Debugw("starting-device-agent", log.Fields{"device": agent.lastData})
// Add the initial device to the local model
- if added := agent.localDataProxy.Add("/devices", agent.lastData, ""); added == nil {
+ if added := agent.clusterDataProxy.Add("/devices", agent.lastData, ""); added == nil {
log.Errorw("failed-to-add-device", log.Fields{"deviceId": agent.deviceId})
}
log.Debug("device-agent-started")
@@ -72,7 +72,7 @@
cloned := reflect.ValueOf(device).Elem().Interface().(voltha.Device)
cloned.AdminState = voltha.AdminState_ENABLED
cloned.OperStatus = voltha.OperStatus_ACTIVATING
- if afterUpdate := agent.localDataProxy.Update("/devices/"+agent.deviceId, &cloned, false, ""); afterUpdate == nil {
+ if afterUpdate := agent.clusterDataProxy.Update("/devices/"+agent.deviceId, &cloned, false, ""); afterUpdate == nil {
return status.Errorf(codes.Internal, "failed-update-device:%s", agent.deviceId)
} else {
if err := agent.adapterProxy.AdoptDevice(ctx, &cloned); err != nil {
@@ -136,7 +136,7 @@
} else {
// store the changed data
cloned := (proto.Clone(device)).(*voltha.Device)
- afterUpdate := agent.localDataProxy.Update("/devices/"+device.Id, cloned, false, "")
+ afterUpdate := agent.clusterDataProxy.Update("/devices/"+device.Id, cloned, false, "")
if afterUpdate == nil {
return status.Errorf(codes.Internal, "%s", device.Id)
}
@@ -164,7 +164,7 @@
}
log.Debugw("DeviceStateUpdate-device", log.Fields{"device": cloned})
// Store the device
- if afterUpdate := agent.localDataProxy.Update("/devices/"+agent.deviceId, &cloned, false, ""); afterUpdate == nil {
+ if afterUpdate := agent.clusterDataProxy.Update("/devices/"+agent.deviceId, &cloned, false, ""); afterUpdate == nil {
return status.Errorf(codes.Internal, "%s", agent.deviceId)
}
// Perform the state transition
@@ -187,7 +187,7 @@
cp := proto.Clone(pmConfigs)
cloned.PmConfigs = cp.(*voltha.PmConfigs)
// Store the device
- afterUpdate := agent.localDataProxy.Update("/devices/"+agent.deviceId, &cloned, false, "")
+ afterUpdate := agent.clusterDataProxy.Update("/devices/"+agent.deviceId, &cloned, false, "")
if afterUpdate == nil {
return status.Errorf(codes.Internal, "%s", agent.deviceId)
}
@@ -210,7 +210,7 @@
cp := proto.Clone(port)
cloned.Ports = append(cloned.Ports, cp.(*voltha.Port))
// Store the device
- afterUpdate := agent.localDataProxy.Update("/devices/"+agent.deviceId, &cloned, false, "")
+ afterUpdate := agent.clusterDataProxy.Update("/devices/"+agent.deviceId, &cloned, false, "")
if afterUpdate == nil {
return status.Errorf(codes.Internal, "%s", agent.deviceId)
}
@@ -250,7 +250,7 @@
log.Debugw("update-field-status", log.Fields{"device": storeDevice, "name": name, "updated": updated})
// Save the data
cloned := reflect.ValueOf(storeDevice).Elem().Interface().(voltha.Device)
- if afterUpdate := agent.localDataProxy.Update("/devices/"+agent.deviceId, &cloned, false, ""); afterUpdate == nil {
+ if afterUpdate := agent.clusterDataProxy.Update("/devices/"+agent.deviceId, &cloned, false, ""); afterUpdate == nil {
log.Warnw("attribute-update-failed", log.Fields{"attribute": name, "value": value})
}
return