VOL-1399: The value of the metadata field used by OFAgent & Arouter
should not be hard-coded
- Added grpc-timeout and core-binding-key options to OFAgent run command
- Added core_binding_key option to rw_core run command
Change-Id: Icf5fe226d17a1a5fcd9459a85e41c434fc7ac8b9
diff --git a/rw_core/core/grpc_nbi_api_handler.go b/rw_core/core/grpc_nbi_api_handler.go
index 0bbe5de..7b486bd 100644
--- a/rw_core/core/grpc_nbi_api_handler.go
+++ b/rw_core/core/grpc_nbi_api_handler.go
@@ -32,9 +32,6 @@
"time"
)
-//TODO: Move this Tag into the proto file
-const OF_CONTROLLER_TAG= "voltha_backend_name"
-
const (
IMAGE_DOWNLOAD = iota
CANCEL_IMAGE_DOWNLOAD = iota
@@ -124,10 +121,10 @@
// isOFControllerRequest is a helper function to determine if a request was initiated
// from the OpenFlow controller (or its proxy, e.g. OFAgent)
-func isOFControllerRequest(ctx context.Context) bool {
+func (handler *APIHandler) isOFControllerRequest(ctx context.Context) bool {
if md, ok := metadata.FromIncomingContext(ctx); ok {
// Metadata in context
- if _, ok = md[OF_CONTROLLER_TAG]; ok {
+ if _, ok = md[handler.core.config.CoreBindingKey]; ok {
// OFAgent field in metadata
return true
}
@@ -271,7 +268,7 @@
}
if handler.competeForTransaction() {
- if !isOFControllerRequest(ctx) { // No need to acquire the transaction as request is sent to one core only
+ if !handler.isOFControllerRequest(ctx) { // No need to acquire the transaction as request is sent to one core only
if txn, err := handler.acquireTransaction(ctx, &logicalDeviceID{id:flow.Id}); err != nil {
return new(empty.Empty), err
} else {
@@ -294,7 +291,7 @@
}
if handler.competeForTransaction() {
- if !isOFControllerRequest(ctx) { // No need to acquire the transaction as request is sent to one core only
+ if !handler.isOFControllerRequest(ctx) { // No need to acquire the transaction as request is sent to one core only
if txn, err := handler.acquireTransaction(ctx, &logicalDeviceID{id:flow.Id}); err != nil {
return new(empty.Empty), err
} else {