Support connecting to multiple OpenFlow controllers
Change-Id: I0989d5031fb2d4f5aa78ba0e4576e465f826a419
diff --git a/internal/pkg/ofagent/ofagent.go b/internal/pkg/ofagent/ofagent.go
index 1d225b2..419a988 100644
--- a/internal/pkg/ofagent/ofagent.go
+++ b/internal/pkg/ofagent/ofagent.go
@@ -44,7 +44,7 @@
type OFAgent struct {
VolthaApiEndPoint string
- OFControllerEndPoint string
+ OFControllerEndPoints []string
DeviceListRefreshInterval time.Duration
ConnectionMaxRetries int
ConnectionRetryDelay time.Duration
@@ -63,7 +63,7 @@
func NewOFAgent(config *OFAgent) (*OFAgent, error) {
ofa := OFAgent{
VolthaApiEndPoint: config.VolthaApiEndPoint,
- OFControllerEndPoint: config.OFControllerEndPoint,
+ OFControllerEndPoints: config.OFControllerEndPoints,
DeviceListRefreshInterval: config.DeviceListRefreshInterval,
ConnectionMaxRetries: config.ConnectionMaxRetries,
ConnectionRetryDelay: config.ConnectionRetryDelay,
@@ -99,7 +99,7 @@
logger.Debugw("Starting GRPC - VOLTHA client",
log.Fields{
"voltha-endpoint": ofa.VolthaApiEndPoint,
- "controller-endpoint": ofa.OFControllerEndPoint})
+ "controller-endpoint": ofa.OFControllerEndPoints})
// If the context contains a k8s probe then register services
p := probe.GetProbeFromContext(ctx)
diff --git a/internal/pkg/ofagent/refresh.go b/internal/pkg/ofagent/refresh.go
index d50b3ec..835e551 100644
--- a/internal/pkg/ofagent/refresh.go
+++ b/internal/pkg/ofagent/refresh.go
@@ -90,14 +90,14 @@
ofc := ofa.clientMap[deviceID]
if ofc == nil {
ofc = openflow.NewOFClient(&openflow.OFClient{
- DeviceID: deviceID,
- OFControllerEndPoint: ofa.OFControllerEndPoint,
- VolthaClient: ofa.volthaClient,
- PacketOutChannel: ofa.packetOutChannel,
- ConnectionMaxRetries: ofa.ConnectionMaxRetries,
- ConnectionRetryDelay: ofa.ConnectionRetryDelay,
+ DeviceID: deviceID,
+ OFControllerEndPoints: ofa.OFControllerEndPoints,
+ VolthaClient: ofa.volthaClient,
+ PacketOutChannel: ofa.packetOutChannel,
+ ConnectionMaxRetries: ofa.ConnectionMaxRetries,
+ ConnectionRetryDelay: ofa.ConnectionRetryDelay,
})
- go ofc.Run(context.Background())
+ ofc.Run(context.Background())
ofa.clientMap[deviceID] = ofc
}
ofa.mapLock.Unlock()