Changes to add the read only cores and some fixes to bugs
for processing the config file.
Change-Id: I1393c05d4cbce215e97d1f17b13e044eda7ae472
diff --git a/afrouter/afrouter/backend.go b/afrouter/afrouter/backend.go
index 9262d43..8ec286e 100644
--- a/afrouter/afrouter/backend.go
+++ b/afrouter/afrouter/backend.go
@@ -78,6 +78,7 @@
strategy int
location int
field string // Used only if location is protobuf
+ key string
}
type beConnection struct {
@@ -125,7 +126,7 @@
var err error = nil
var rtrn_err bool = false
var be *backend
- log.Debug("Creating a backend cluster with %v", conf)
+ log.Debugf("Creating a backend cluster with %v", conf)
// Validate the configuration
if conf.Name == "" {
log.Error("A backend cluster must have a name")
@@ -598,6 +599,14 @@
rtrn_err = true
}
be.activeAssoc.field = conf.Association.Field
+
+ if conf.Association.Key == "" && be.activeAssoc.location == AL_HEADER {
+ log.Errorf("An association key must be provided if the backend "+
+ "type is active/active and the location is set to header "+
+ "for backend %s in cluster %s", conf.Name, clusterName)
+ rtrn_err = true
+ }
+ be.activeAssoc.key = conf.Association.Key
if rtrn_err {
return nil, errors.New("Backend configuration failed")
}
@@ -605,6 +614,15 @@
// Connections can consist of just a name. This allows for dynamic configuration
// at a later time.
// TODO: validate that there is one connection for all but active/active backends
+ if len(conf.Connections) > 1 && be.activeAssoc.strategy != BE_ACTIVE_ACTIVE {
+ log.Errorf("Only one connection must be specified if the association "+
+ "strategy is not set to 'active_active'")
+ rtrn_err = true
+ }
+ if len(conf.Connections) == 0 {
+ log.Errorf("At least one connection must be specified")
+ rtrn_err = true
+ }
for _,cnConf := range conf.Connections {
if cnConf.Name == "" {
log.Errorf("A connection must have a name for backend %s in cluster %s",
diff --git a/afrouter/afrouter/config.go b/afrouter/afrouter/config.go
index 528a3f7..a9a01eb 100644
--- a/afrouter/afrouter/config.go
+++ b/afrouter/afrouter/config.go
@@ -91,7 +91,7 @@
type OverrideConfig struct {
Methods []string `json:"methods"`
- Method []string `json:"method"`
+ Method string `json:"method"`
RouteField string `json:"routing_field"`
}
@@ -113,6 +113,7 @@
Strategy string `json:"strategy"`
Location string `json:"location"`
Field string `json:"field"`
+ Key string `json:"key"`
}
type ConnectionConfig struct {
@@ -183,7 +184,10 @@
return err
}
- json.Unmarshal(configBytes, conf)
+ if err := json.Unmarshal(configBytes, conf); err != nil {
+ log.Errorf("Unmarshaling of the configuratino file failed: %v", err)
+ return err
+ }
// Now resolve references to different config objects in the
// config file. Currently there are 2 possible references
diff --git a/afrouter/afrouter/helpers.go b/afrouter/afrouter/helpers.go
index 6235337..4d7362b 100644
--- a/afrouter/afrouter/helpers.go
+++ b/afrouter/afrouter/helpers.go
@@ -17,9 +17,11 @@
package afrouter
+//import "github.com/opencord/voltha-go/common/log"
+
func strIndex(ar []string, match string) int {
- for idx := range ar {
- if ar[idx] == match {
+ for idx,v := range ar {
+ if v == match {
return idx
}
}
diff --git a/afrouter/arouter.json b/afrouter/arouter.json
index 50e1d31..7b075ce 100644
--- a/afrouter/arouter.json
+++ b/afrouter/arouter.json
@@ -62,7 +62,7 @@
"name":"read_only",
"type":"round_robin",
"association":"round_robin",
- "backend_cluster":"vcore",
+ "backend_cluster":"ro_vcore",
"methods":[ "ListDevicePorts",
"ListDevicePmConfigs",
"GetImages",
@@ -75,6 +75,8 @@
"ListLogicalDeviceFlowGroups",
"ListDevices",
"GetDevice",
+ "ListLogicalDevices",
+ "GetLogicalDevices",
"GetDeviceType",
"GetDeviceGroup",
"GetLogicalDevice",
@@ -95,8 +97,11 @@
},
"backend_cluster":"vcore",
"methods":["StreamPacketsOut",
+ "ReceivePacketsIn",
+ "ReceiveChangeEvents",
"Subscribe",
"ListLogicalDevices",
+ "GetLogicalDevice",
"ListDeviceFlowGroups",
"ListLogicalDeviceFlowGroups",
"ListDeviceFlows",
@@ -143,7 +148,9 @@
"type":"active_active",
"association": {
"strategy":"serial_number",
- "location":"header"
+ "location":"header",
+ "_TODO":"The key below needs to be implemented, currently hard coded",
+ "key":"voltha_serial_number"
},
"connections": [ {
"name":"vcore21",
@@ -161,7 +168,9 @@
"type":"active_active",
"association": {
"strategy":"serial_number",
- "location":"header"
+ "location":"header",
+ "_TODO":"The key below needs to be implemented, currently hard coded",
+ "key":"voltha_serial_number"
},
"connections": [ {
"name":"vcore31",
@@ -174,6 +183,36 @@
"port":""
}]
}]
+ },
+ {
+ "name":"ro_vcore",
+ "backends":[ {
+ "name":"ro_vcore1",
+ "type":"server",
+ "connections": [ {
+ "name":"ro_vcore11",
+ "addr":"",
+ "port":""
+ }]
+ },
+ {
+ "name":"ro_vcore2",
+ "type":"server",
+ "connections": [ {
+ "name":"ro_vcore21",
+ "addr":"",
+ "port":""
+ }]
+ },
+ {
+ "name":"ro_vcore3",
+ "type":"server",
+ "connections": [ {
+ "name":"ro_vcore31",
+ "addr":"",
+ "port":""
+ }]
+ }]
}
],
"api": {