VOL-1465 : Integrate rw sync fixes into ro core

- Added new config-map for affinity router
- Removed some really verbose model logs
- Fail core when kv client cannot be established

Change-Id: I7f10c7ce3121abaf88fa622aecb3affd40813d67
diff --git a/k8s/affinity-router.yml b/k8s/affinity-router.yml
index 3fcdaa2..2bf537f 100644
--- a/k8s/affinity-router.yml
+++ b/k8s/affinity-router.yml
@@ -50,7 +50,7 @@
         ports:
         - containerPort: 55555
         command: ["/app/afrouter"]
-        args: ["-config", "/app/config/arouter.voltha3.json"]
+        args: ["-config", "/app/config/arouter.voltha.json"]
       - name: envoy
         image: volthacore/envoy
         volumeMounts:
diff --git a/k8s/afrouter-config.yml b/k8s/afrouter-config.yml
new file mode 100644
index 0000000..566ce68
--- /dev/null
+++ b/k8s/afrouter-config.yml
@@ -0,0 +1,466 @@
+# Copyright 2019-present Open Networking Foundation
+#
+# Licensed under the Apache License, Version 2.0 (the "License");
+# you may not use this file except in compliance with the License.
+# You may obtain a copy of the License at
+#
+# http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing, software
+# distributed under the License is distributed on an "AS IS" BASIS,
+# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+# See the License for the specific language governing permissions and
+# limitations under the License.
+apiVersion: v1
+data:
+  arouter.voltha.json: |
+      {
+        "servers": [
+          {
+            "name": "grpc_command",
+            "port": 55555,
+            "address": "",
+            "type": "grpc",
+            "routers": [
+              {
+                "_TODO": "Suport a router list, remove the package and service from the router",
+                "package": "voltha",
+                "service": "VolthaService",
+                "router": "vcore"
+              }
+            ]
+          }
+        ],
+        "routers": [
+          {
+            "name": "vcore",
+            "package": "voltha",
+            "service": "VolthaService",
+            "routes": [
+              {
+                "name": "dev_manager",
+                "proto_descriptor": "voltha.pb",
+                "type": "rpc_affinity_message",
+                "association": "round_robin",
+                "routing_field": "id",
+                "backend_cluster": "vcore",
+                "_COMMENT": "Methods here MUST be specified above, this overrides thier default beahvior",
+                "methods": [
+                  "CreateDevice",
+                  "GetCoreInstance",
+                  "EnableLogicalDevicePort",
+                  "DisableLogicalDevicePort",
+                  "EnableDevice",
+                  "DisableDevice",
+                  "RebootDevice",
+                  "DeleteDevice",
+                  "DownloadImage",
+                  "CancelImageDownload",
+                  "ActivateImageUpdate",
+                  "RevertImageUpdate",
+                  "UpdateDevicePmConfigs",
+                  "CreateAlarmFilter",
+                  "UpdateAlarmFilter",
+                  "DeleteAlarmFilter",
+                  "SelfTest"
+                ],
+                "nb_binding_methods": [
+                  "CreateDevice"
+                ],
+                "_TODO": "Overrides not implemented yet, config ignored",
+                "overrides": [
+                  {
+                    "methods": [
+                      "abc",
+                      "def"
+                    ],
+                    "routing_field": "id"
+                  },
+                  {
+                    "methods": [
+                      "ghi",
+                      "jkl"
+                    ]
+                  },
+                  {
+                    "method": "mno",
+                    "routing_field": "id"
+                  },
+                  {
+                    "method": "pqr"
+                  }
+                ]
+              },
+              {
+                "name": "read_only",
+                "type": "round_robin",
+                "association": "round_robin",
+                "backend_cluster": "ro_vcore",
+                "methods": [
+                  "ListDevicePorts",
+                  "ListDevicePmConfigs",
+                  "GetImages",
+                  "GetImageDownloadStatus",
+                  "GetImageDownload",
+                  "ListImageDownloads",
+                  "ListDeviceFlows",
+                  "ListDeviceFlowGroups",
+                  "ListLogicalDeviceFlows",
+                  "ListLogicalDeviceFlowGroups",
+                  "ListDevices",
+                  "GetDevice",
+                  "ListLogicalDevices",
+                  "GetLogicalDevices",
+                  "GetDeviceType",
+                  "GetDeviceGroup",
+                  "GetLogicalDevice",
+                  "GetAlarmFilter",
+                  "ListLogicalDevicePorts",
+                  "GetLogicalDevicePort",
+                  "ListAdapters"
+                ]
+              },
+              {
+                "name": "dev_manager_ofagent",
+                "type": "binding",
+                "_association": "round_robin",
+                "binding": {
+                  "type": "header",
+                  "field": "voltha_backend_name",
+                  "method": "Subscribe",
+                  "association": "round_robin"
+                },
+                "backend_cluster": "vcore",
+                "methods": [
+                  "StreamPacketsOut",
+                  "ReceivePacketsIn",
+                  "ReceiveChangeEvents",
+                  "Subscribe",
+                  "UpdateLogicalDeviceFlowTable",
+                  "UpdateLogicalDeviceFlowGroupTable",
+                  "GetLogicalDevice",
+                  "GetLogicalDevicePort",
+                  "EnableLogicalDevicePort",
+                  "DisableLogicalDevicePort",
+                  "ListLogicalDevices",
+                  "ListLogicalDeviceFlows",
+                  "ListLogicalDeviceFlowGroups",
+                  "ListLogicalDevicePorts"
+                ],
+                "_TODO": "Overrides not implemented yet, config ignored",
+                "overrides": [
+                  {
+                    "methods": [
+                      "abc",
+                      "def"
+                    ],
+                    "routing_field": "id"
+                  },
+                  {
+                    "methods": [
+                      "ghi",
+                      "jkl"
+                    ]
+                  },
+                  {
+                    "method": "mno",
+                    "routing_field": "id"
+                  },
+                  {
+                    "method": "pqr"
+                  }
+                ]
+              }
+            ]
+          }
+        ],
+        "backend_clusters": [
+          {
+            "name": "vcore",
+            "backends": [
+              {
+                "name": "vcore1",
+                "type": "active_active",
+                "association": {
+                  "strategy": "serial_number",
+                  "location": "header",
+                  "_TODO": "The key below needs to be implemented, currently hard coded",
+                  "key": "voltha_serial_number"
+                },
+                "connections": [
+                  {
+                    "name": "vcore11",
+                    "addr": "",
+                    "port": ""
+                  },
+                  {
+                    "name": "vcore12",
+                    "addr": "",
+                    "port": ""
+                  }
+                ]
+              },
+              {
+                "name": "vcore2",
+                "type": "active_active",
+                "association": {
+                  "strategy": "serial_number",
+                  "location": "header",
+                  "_TODO": "The key below needs to be implemented, currently hard coded",
+                  "key": "voltha_serial_number"
+                },
+                "connections": [
+                  {
+                    "name": "vcore21",
+                    "addr": "",
+                    "port": ""
+                  },
+                  {
+                    "name": "vcore22",
+                    "addr": "",
+                    "port": ""
+                  }
+                ]
+              },
+              {
+                "name": "vcore3",
+                "type": "active_active",
+                "association": {
+                  "strategy": "serial_number",
+                  "location": "header",
+                  "_TODO": "The key below needs to be implemented, currently hard coded",
+                  "key": "voltha_serial_number"
+                },
+                "connections": [
+                  {
+                    "name": "vcore31",
+                    "addr": "",
+                    "port": ""
+                  },
+                  {
+                    "name": "vcore32",
+                    "addr": "",
+                    "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": {
+          "_comment": "If this isn't defined then no api is available for dynamic configuration and queries",
+          "address": "",
+          "port": 55554
+        }
+      }
+
+  voltha-envoy-config.json: |
+      {
+        "listeners": [
+          {
+            "address": "tcp://0.0.0.0:8192",
+            "filters": [
+              {
+                "type": "read",
+                "name": "http_connection_manager",
+                "config": {
+                  "codec_type": "http1",
+                  "stat_prefix": "ingress_http1",
+                  "access_log": [
+                    {
+                      "path": "/envoy/voltha_access1_log.log"
+                    }
+                  ],
+                  "route_config": {
+                    "virtual_hosts": [
+                      {
+                        "name": "backend3",
+                        "domains": [
+                          "*"
+                        ],
+                        "routes": [
+                          {
+                            "timeout_ms": 0,
+                            "prefix": "/voltha.VolthaGlobalService/CreateDevice",
+                            "cluster": "voltha-grpc"
+                          },
+                          {
+                            "timeout_ms": 0,
+                            "prefix": "/voltha.VolthaGlobalService",
+                            "cluster": "voltha-grpc"
+                          },
+                          {
+                            "timeout_ms": 0,
+                            "prefix": "/voltha.HealthService",
+                            "cluster": "voltha-grpc"
+                          },
+                          {
+                            "timeout_ms": 0,
+                            "prefix": "/voltha.",
+                            "cluster": "voltha-grpc"
+                          },
+                          {
+                            "timeout_ms": 0,
+                            "prefix": "/schema.SchemaService",
+                            "cluster": "voltha-grpc"
+                          }
+                        ]
+                      }
+                    ]
+                  },
+                  "filters": [
+                    {
+                      "type": "both",
+                      "name": "grpc_json_transcoder",
+                      "config": {
+                        "proto_descriptor": "/envoy/voltha.pb",
+                        "services": [
+                          "voltha.VolthaService",
+                          "voltha.HealthService",
+                          "schema.SchemaService"
+                        ],
+                        "print_options": {
+                          "add_whitespace": false,
+                          "always_print_primitive_fields": true,
+                          "always_print_enums_as_ints": false,
+                          "preserve_proto_field_names": true
+                        }
+                      }
+                    },
+                    {
+                      "type": "decoder",
+                      "name": "router",
+                      "config": {}
+                    }
+                  ]
+                }
+              }
+            ]
+          },
+          {
+            "address": "tcp://0.0.0.0:50555",
+            "filters": [
+              {
+                "type": "read",
+                "name": "http_connection_manager",
+                "config": {
+                  "codec_type": "http2",
+                  "stat_prefix": "ingress_http2",
+                  "access_log": [
+                    {
+                      "path": "/envoy/voltha_access2_log.log"
+                    }
+                  ],
+                  "route_config": {
+                    "virtual_hosts": [
+                      {
+                        "name": "backend",
+                        "domains": [
+                          "*"
+                        ],
+                        "routes": [
+                          {
+                            "timeout_ms": 0,
+                            "prefix": "/voltha.VolthaGlobalService/CreateDevice",
+                            "cluster": "voltha-grpc"
+                          },
+                          {
+                            "timeout_ms": 0,
+                            "prefix": "/voltha.VolthaGlobalService",
+                            "cluster": "voltha-grpc"
+                          },
+                          {
+                            "timeout_ms": 0,
+                            "prefix": "/voltha.HealthService",
+                            "cluster": "voltha-grpc"
+                          },
+                          {
+                            "timeout_ms": 0,
+                            "prefix": "/voltha.",
+                            "cluster": "voltha-grpc"
+                          },
+                          {
+                            "timeout_ms": 0,
+                            "prefix": "/schema.SchemaService",
+                            "cluster": "voltha-grpc"
+                          }
+                        ]
+                      }
+                    ]
+                  },
+                  "filters": [
+                    {
+                      "type": "decoder",
+                      "name": "router",
+                      "config": {}
+                    }
+                  ]
+                }
+              }
+            ]
+          }
+        ],
+        "admin": {
+          "access_log_path": "/envoy/access.log",
+          "address": "tcp://0.0.0.0:8001"
+        },
+        "cluster_manager": {
+          "clusters": [
+            {
+              "name": "voltha-grpc",
+              "connect_timeout_ms": 250,
+              "type": "static",
+              "lb_type": "round_robin",
+              "features": "http2",
+              "hosts": [
+                {
+                  "url": "tcp://127.0.0.1:55555"
+                }
+              ]
+            }
+          ]
+        }
+      }
+      
+kind: ConfigMap
+metadata:
+  name: afrouter-config
+  namespace: voltha