Support connecting to multiple OpenFlow controllers
Change-Id: I0989d5031fb2d4f5aa78ba0e4576e465f826a419
diff --git a/cmd/ofagent/config.go b/cmd/ofagent/config.go
index a33e1f2..9db89ea 100644
--- a/cmd/ofagent/config.go
+++ b/cmd/ofagent/config.go
@@ -18,11 +18,12 @@
import (
"flag"
"os"
+ "strings"
"time"
)
type Config struct {
- OFControllerEndPoint string
+ OFControllerEndPoints multiFlag
VolthaApiEndPoint string
LogLevel string
Banner bool
@@ -40,6 +41,17 @@
InstanceID string
}
+type multiFlag []string
+
+func (m *multiFlag) String() string {
+ return "[" + strings.Join(*m, ", ") + "]"
+}
+
+func (m *multiFlag) Set(value string) error {
+ *m = append(*m, value)
+ return nil
+}
+
func parseCommandLineArguments() (*Config, error) {
config := Config{}
@@ -51,13 +63,11 @@
"version",
false,
"display application version and exit")
- flag.StringVar(&(config.OFControllerEndPoint),
+ flag.Var(&config.OFControllerEndPoints,
"controller",
- "onos-openflow:6653",
"connection to the OF controller specified as host:port")
- flag.StringVar(&(config.OFControllerEndPoint),
+ flag.Var(&config.OFControllerEndPoints,
"O",
- "onos-openflow:6653",
"(short) connection to the OF controller specified as host:port")
flag.StringVar(&(config.VolthaApiEndPoint),
"voltha",