diff options
author | Eric Multanen <eric.w.multanen@intel.com> | 2020-04-23 12:55:38 -0700 |
---|---|---|
committer | Eric Multanen <eric.w.multanen@intel.com> | 2020-06-03 17:17:21 -0700 |
commit | e80f462ab1621090dd9cf7a2c648eb168aaafa5e (patch) | |
tree | a94b336dcb30929756077e80dd8ed581b1455088 /src/ovnaction/pkg | |
parent | 8e7a20777f2100324526a34b4b6c943b512df0fb (diff) |
Add grpc contextupdate client call to orchestrator
Adds a contextupdate client function that can
be invoked for any action or placement controller
to process intents for that controller.
Adds the corresponding server side handling for
the ovnaction controller.
Issue-ID: MULTICLOUD-1019
Signed-off-by: Eric Multanen <eric.w.multanen@intel.com>
Change-Id: Ifdfc99e522288a530735bc4c1402d45449f6d057
Diffstat (limited to 'src/ovnaction/pkg')
-rw-r--r-- | src/ovnaction/pkg/grpc/contextupdateserver/contextupdateserver.go | 21 |
1 files changed, 13 insertions, 8 deletions
diff --git a/src/ovnaction/pkg/grpc/contextupdateserver/contextupdateserver.go b/src/ovnaction/pkg/grpc/contextupdateserver/contextupdateserver.go index fc548ccc..d0ab95f6 100644 --- a/src/ovnaction/pkg/grpc/contextupdateserver/contextupdateserver.go +++ b/src/ovnaction/pkg/grpc/contextupdateserver/contextupdateserver.go @@ -15,10 +15,11 @@ package contextupdateserver import ( "context" - "encoding/json" - "log" + "fmt" contextpb "github.com/onap/multicloud-k8s/src/orchestrator/pkg/grpc/contextupdate" + log "github.com/onap/multicloud-k8s/src/orchestrator/pkg/infra/logutils" + "github.com/onap/multicloud-k8s/src/ovnaction/internal/action" //"google.golang.org/grpc/codes" //"google.golang.org/grpc/status" ) @@ -28,14 +29,18 @@ type contextupdateServer struct { } func (cs *contextupdateServer) UpdateAppContext(ctx context.Context, req *contextpb.ContextUpdateRequest) (*contextpb.ContextUpdateResponse, error) { - contextUpdateReq, _ := json.Marshal(req) - log.Println("GRPC Server received contextupdateRequest: ", string(contextUpdateReq)) + log.Info("Received Update App Context request", log.Fields{ + "AppContextId": req.AppContext, + "IntentName": req.IntentName, + }) - // Insert call to Server Functionality here - // - // + err := action.UpdateAppContext(req.IntentName, req.AppContext) - return &contextpb.ContextUpdateResponse{AppContextUpdated: true}, nil + if err != nil { + return &contextpb.ContextUpdateResponse{AppContextUpdated: false, AppContextUpdateMessage: err.Error()}, nil + } + + return &contextpb.ContextUpdateResponse{AppContextUpdated: true, AppContextUpdateMessage: fmt.Sprintf("Successful application of intent %v to %v", req.IntentName, req.AppContext)}, nil } // NewContextUpdateServer exported |