aboutsummaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorEric Multanen <eric.w.multanen@intel.com>2020-04-23 12:55:38 -0700
committerEric Multanen <eric.w.multanen@intel.com>2020-06-03 17:17:21 -0700
commite80f462ab1621090dd9cf7a2c648eb168aaafa5e (patch)
treea94b336dcb30929756077e80dd8ed581b1455088 /src
parent8e7a20777f2100324526a34b4b6c943b512df0fb (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')
-rw-r--r--src/orchestrator/api/api.go1
-rw-r--r--src/orchestrator/go.mod3
-rw-r--r--src/orchestrator/go.sum22
-rw-r--r--src/orchestrator/pkg/grpc/contextupdate/contextupdate.pb.go295
-rw-r--r--src/orchestrator/pkg/grpc/contextupdate/contextupdate.proto1
-rw-r--r--src/orchestrator/pkg/grpc/contextupdateclient/client.go62
-rw-r--r--[-rwxr-xr-x]src/orchestrator/pkg/infra/rpc/rpc.go0
-rw-r--r--src/orchestrator/pkg/module/deployment_intent_groups.go3
-rw-r--r--src/ovnaction/cmd/main.go6
-rw-r--r--src/ovnaction/go.mod1
-rw-r--r--src/ovnaction/go.sum18
-rw-r--r--src/ovnaction/internal/action/action.go158
-rw-r--r--src/ovnaction/pkg/grpc/contextupdateserver/contextupdateserver.go21
13 files changed, 492 insertions, 99 deletions
diff --git a/src/orchestrator/api/api.go b/src/orchestrator/api/api.go
index 5703226f..2470a1be 100644
--- a/src/orchestrator/api/api.go
+++ b/src/orchestrator/api/api.go
@@ -116,6 +116,7 @@ func NewRouter(projectClient moduleLib.ProjectManager,
router.HandleFunc("/controllers/{controller-name}", controlHandler.putHandler).Methods("PUT")
router.HandleFunc("/controllers/{controller-name}", controlHandler.getHandler).Methods("GET")
router.HandleFunc("/controllers/{controller-name}", controlHandler.deleteHandler).Methods("DELETE")
+
//setting routes for genericPlacementIntent
if genericPlacementIntentClient == nil {
genericPlacementIntentClient = moduleClient.GenericPlacementIntent
diff --git a/src/orchestrator/go.mod b/src/orchestrator/go.mod
index 0cead9a4..223dc068 100644
--- a/src/orchestrator/go.mod
+++ b/src/orchestrator/go.mod
@@ -13,7 +13,7 @@ require (
github.com/exponent-io/jsonpath v0.0.0-20151013193312-d6023ce2651d // indirect
github.com/ghodss/yaml v1.0.0
github.com/gobwas/glob v0.2.3 // indirect
- github.com/golang/protobuf v1.3.4
+ github.com/golang/protobuf v1.4.1
github.com/gorilla/handlers v1.3.0
github.com/gorilla/mux v1.7.3
github.com/huandu/xstrings v1.3.1 // indirect
@@ -34,6 +34,7 @@ require (
go.mongodb.org/mongo-driver v1.0.0
golang.org/x/net v0.0.0-20200301022130-244492dfa37a
google.golang.org/grpc v1.27.1
+ google.golang.org/protobuf v1.24.0
gopkg.in/square/go-jose.v2 v2.5.1 // indirect
gopkg.in/yaml.v3 v3.0.0-20200506231410-2ff61e1afc86
k8s.io/apiextensions-apiserver v0.0.0-00010101000000-000000000000 // indirect
diff --git a/src/orchestrator/go.sum b/src/orchestrator/go.sum
index 6bd6e8bd..f2169a5e 100644
--- a/src/orchestrator/go.sum
+++ b/src/orchestrator/go.sum
@@ -224,6 +224,15 @@ github.com/golang/protobuf v1.3.2/go.mod h1:6lQm79b+lXiMfvg/cZm0SGofjICqVBUtrP5y
github.com/golang/protobuf v1.3.3/go.mod h1:vzj43D7+SQXF/4pzW/hwtAqwc6iTitCiVSaWz5lYuqw=
github.com/golang/protobuf v1.3.4 h1:87PNWwrRvUSnqS4dlcBU/ftvOIBep4sYuBLlh6rX2wk=
github.com/golang/protobuf v1.3.4/go.mod h1:vzj43D7+SQXF/4pzW/hwtAqwc6iTitCiVSaWz5lYuqw=
+github.com/golang/protobuf v1.4.0-rc.1/go.mod h1:ceaxUfeHdC40wWswd/P6IGgMaK3YpKi5j83Wpe3EHw8=
+github.com/golang/protobuf v1.4.0-rc.1.0.20200221234624-67d41d38c208/go.mod h1:xKAWHe0F5eneWXFV3EuXVDTCmh+JuBKY0li0aMyXATA=
+github.com/golang/protobuf v1.4.0-rc.2/go.mod h1:LlEzMj4AhA7rCAGe4KMBDvJI+AwstrUpVNzEA03Pprs=
+github.com/golang/protobuf v1.4.0-rc.4.0.20200313231945-b860323f09d0/go.mod h1:WU3c8KckQ9AFe+yFwt9sWVRKCVIyN9cPHBJSNnbL67w=
+github.com/golang/protobuf v1.4.0/go.mod h1:jodUvKwWbYaEsadDk5Fwe5c77LiNKVO9IDvqG2KuDX0=
+github.com/golang/protobuf v1.4.1 h1:ZFgWrT+bLgsYPirOnRfKLYJLvssAegOj/hgyMFdJZe0=
+github.com/golang/protobuf v1.4.1/go.mod h1:U8fpvMrcmy5pZrNK1lt4xCsGvpyWQ/VVv6QDs8UjoX8=
+github.com/golang/protobuf v1.4.2 h1:+Z5KGCizgyZCbGh1KZqA0fcLLkwbsjIzS4aV2v7wJX0=
+github.com/golang/protobuf v1.4.2/go.mod h1:oDoupMAO8OvCJWAcko0GGGIgR6R6ocIYbsSw735rRwI=
github.com/golang/snappy v0.0.0-20180518054509-2e65f85255db h1:woRePGFeVFfLKN/pOkfl+p/TAqKOfFu+7KPlMVpok/w=
github.com/golang/snappy v0.0.0-20180518054509-2e65f85255db/go.mod h1:/XxbfmMg8lxefKM7IXC3fBNl/7bRcc72aCRzEWrmP2Q=
github.com/golang/snappy v0.0.1 h1:Qgr9rKW7uDUkrbSmQeiDsGa8SjGyCOGtuasMWwvp2P4=
@@ -797,6 +806,8 @@ google.golang.org/genproto v0.0.0-20190819201941-24fa4b261c55 h1:gSJIx1SDwno+2El
google.golang.org/genproto v0.0.0-20190819201941-24fa4b261c55/go.mod h1:DMBHOl98Agz4BDEuKkezgsaosCRResVns1a3J2ZsMNc=
google.golang.org/genproto v0.0.0-20200305110556-506484158171 h1:xes2Q2k+d/+YNXVw0FpZkIDJiaux4OVrRKXRAzH6A0U=
google.golang.org/genproto v0.0.0-20200305110556-506484158171/go.mod h1:55QSHmfGQM9UVYDPBsyGGes0y52j32PQ3BqQfXhyH3c=
+google.golang.org/genproto v0.0.0-20200526211855-cb27e3aa2013 h1:+kGHl1aib/qcwaRi1CbqBZ1rk19r85MNUf8HaBghugY=
+google.golang.org/genproto v0.0.0-20200526211855-cb27e3aa2013/go.mod h1:NbSheEEYHJ7i3ixzK3sjbqSGDJWnxyFXZblF3eUsNvo=
google.golang.org/grpc v1.17.0/go.mod h1:6QZJwpn2B+Zp71q/5VxRsJ6NXXVCE5NRUHRo+f3cWCs=
google.golang.org/grpc v1.19.0 h1:cfg4PD8YEdSFnm7qLV4++93WcmhH2nIUhMjhdCvl3j8=
google.golang.org/grpc v1.19.0/go.mod h1:mqu4LbDTu4XGKhr4mRzUsmM4RtVoemTSY81AxZiDr8c=
@@ -810,6 +821,17 @@ google.golang.org/grpc v1.26.0/go.mod h1:qbnxyOmOxrQa7FizSgH+ReBfzJrCY1pSN7KXBS8
google.golang.org/grpc v1.27.0/go.mod h1:qbnxyOmOxrQa7FizSgH+ReBfzJrCY1pSN7KXBS8abTk=
google.golang.org/grpc v1.27.1 h1:zvIju4sqAGvwKspUQOhwnpcqSbzi7/H6QomNNjTL4sk=
google.golang.org/grpc v1.27.1/go.mod h1:qbnxyOmOxrQa7FizSgH+ReBfzJrCY1pSN7KXBS8abTk=
+google.golang.org/protobuf v0.0.0-20200109180630-ec00e32a8dfd/go.mod h1:DFci5gLYBciE7Vtevhsrf46CRTquxDuWsQurQQe4oz8=
+google.golang.org/protobuf v0.0.0-20200221191635-4d8936d0db64/go.mod h1:kwYJMbMJ01Woi6D6+Kah6886xMZcty6N08ah7+eCXa0=
+google.golang.org/protobuf v0.0.0-20200228230310-ab0ca4ff8a60/go.mod h1:cfTl7dwQJ+fmap5saPgwCLgHXTUD7jkjRqWcaiX5VyM=
+google.golang.org/protobuf v1.20.1-0.20200309200217-e05f789c0967/go.mod h1:A+miEFZTKqfCUM6K7xSMQL9OKL/b6hQv+e19PK+JZNE=
+google.golang.org/protobuf v1.21.0/go.mod h1:47Nbq4nVaFHyn7ilMalzfO3qCViNmqZ2kzikPIcrTAo=
+google.golang.org/protobuf v1.22.0/go.mod h1:EGpADcykh3NcUnDUJcl1+ZksZNG86OlYog2l/sGQquU=
+google.golang.org/protobuf v1.23.0 h1:4MY060fB1DLGMB/7MBTLnwQUY6+F09GEiz6SsrNqyzM=
+google.golang.org/protobuf v1.23.0/go.mod h1:EGpADcykh3NcUnDUJcl1+ZksZNG86OlYog2l/sGQquU=
+google.golang.org/protobuf v1.23.1-0.20200526195155-81db48ad09cc/go.mod h1:EGpADcykh3NcUnDUJcl1+ZksZNG86OlYog2l/sGQquU=
+google.golang.org/protobuf v1.24.0 h1:UhZDfRO8JRQru4/+LlLE0BRKGF8L+PICnvYZmx/fEGA=
+google.golang.org/protobuf v1.24.0/go.mod h1:r/3tXBNzIEhYS9I1OUVjXDlt8tc493IdKGjtUeSXeh4=
gopkg.in/alecthomas/kingpin.v2 v2.2.6/go.mod h1:FMv+mEhP44yOT+4EoQTLFTRgOQ1FBLkstjWtayDeSgw=
gopkg.in/check.v1 v0.0.0-20161208181325-20d25e280405/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0=
gopkg.in/check.v1 v1.0.0-20180628173108-788fd7840127 h1:qIbj1fsPNlZgppZ+VLlY7N33q108Sa+fhmuc+sWQYwY=
diff --git a/src/orchestrator/pkg/grpc/contextupdate/contextupdate.pb.go b/src/orchestrator/pkg/grpc/contextupdate/contextupdate.pb.go
index 72226224..24a405ca 100644
--- a/src/orchestrator/pkg/grpc/contextupdate/contextupdate.pb.go
+++ b/src/orchestrator/pkg/grpc/contextupdate/contextupdate.pb.go
@@ -1,137 +1,262 @@
+//
+// Copyright 2020 Intel Corporation, Inc
+//
+// 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.
+
// Code generated by protoc-gen-go. DO NOT EDIT.
+// versions:
+// protoc-gen-go v1.24.0
+// protoc v3.11.4
// source: contextupdate.proto
package contextupdate
import (
context "context"
- fmt "fmt"
proto "github.com/golang/protobuf/proto"
grpc "google.golang.org/grpc"
codes "google.golang.org/grpc/codes"
status "google.golang.org/grpc/status"
- math "math"
+ protoreflect "google.golang.org/protobuf/reflect/protoreflect"
+ protoimpl "google.golang.org/protobuf/runtime/protoimpl"
+ reflect "reflect"
+ sync "sync"
)
-// Reference imports to suppress errors if they are not otherwise used.
-var _ = proto.Marshal
-var _ = fmt.Errorf
-var _ = math.Inf
+const (
+ // Verify that this generated code is sufficiently up-to-date.
+ _ = protoimpl.EnforceVersion(20 - protoimpl.MinVersion)
+ // Verify that runtime/protoimpl is sufficiently up-to-date.
+ _ = protoimpl.EnforceVersion(protoimpl.MaxVersion - 20)
+)
-// This is a compile-time assertion to ensure that this generated file
-// is compatible with the proto package it is being compiled against.
-// A compilation error at this line likely means your copy of the
-// proto package needs to be updated.
-const _ = proto.ProtoPackageIsVersion3 // please upgrade the proto package
+// This is a compile-time assertion that a sufficiently up-to-date version
+// of the legacy proto package is being used.
+const _ = proto.ProtoPackageIsVersion4
type ContextUpdateRequest struct {
- AppContext string `protobuf:"bytes,1,opt,name=app_context,json=appContext,proto3" json:"app_context,omitempty"`
- XXX_NoUnkeyedLiteral struct{} `json:"-"`
- XXX_unrecognized []byte `json:"-"`
- XXX_sizecache int32 `json:"-"`
-}
+ state protoimpl.MessageState
+ sizeCache protoimpl.SizeCache
+ unknownFields protoimpl.UnknownFields
-func (m *ContextUpdateRequest) Reset() { *m = ContextUpdateRequest{} }
-func (m *ContextUpdateRequest) String() string { return proto.CompactTextString(m) }
-func (*ContextUpdateRequest) ProtoMessage() {}
-func (*ContextUpdateRequest) Descriptor() ([]byte, []int) {
- return fileDescriptor_8ebb57f5310873be, []int{0}
+ AppContext string `protobuf:"bytes,1,opt,name=app_context,json=appContext,proto3" json:"app_context,omitempty"`
+ IntentName string `protobuf:"bytes,2,opt,name=intent_name,json=intentName,proto3" json:"intent_name,omitempty"`
}
-func (m *ContextUpdateRequest) XXX_Unmarshal(b []byte) error {
- return xxx_messageInfo_ContextUpdateRequest.Unmarshal(m, b)
-}
-func (m *ContextUpdateRequest) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) {
- return xxx_messageInfo_ContextUpdateRequest.Marshal(b, m, deterministic)
+func (x *ContextUpdateRequest) Reset() {
+ *x = ContextUpdateRequest{}
+ if protoimpl.UnsafeEnabled {
+ mi := &file_contextupdate_proto_msgTypes[0]
+ ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))
+ ms.StoreMessageInfo(mi)
+ }
}
-func (m *ContextUpdateRequest) XXX_Merge(src proto.Message) {
- xxx_messageInfo_ContextUpdateRequest.Merge(m, src)
+
+func (x *ContextUpdateRequest) String() string {
+ return protoimpl.X.MessageStringOf(x)
}
-func (m *ContextUpdateRequest) XXX_Size() int {
- return xxx_messageInfo_ContextUpdateRequest.Size(m)
+
+func (*ContextUpdateRequest) ProtoMessage() {}
+
+func (x *ContextUpdateRequest) ProtoReflect() protoreflect.Message {
+ mi := &file_contextupdate_proto_msgTypes[0]
+ if protoimpl.UnsafeEnabled && x != nil {
+ ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))
+ if ms.LoadMessageInfo() == nil {
+ ms.StoreMessageInfo(mi)
+ }
+ return ms
+ }
+ return mi.MessageOf(x)
}
-func (m *ContextUpdateRequest) XXX_DiscardUnknown() {
- xxx_messageInfo_ContextUpdateRequest.DiscardUnknown(m)
+
+// Deprecated: Use ContextUpdateRequest.ProtoReflect.Descriptor instead.
+func (*ContextUpdateRequest) Descriptor() ([]byte, []int) {
+ return file_contextupdate_proto_rawDescGZIP(), []int{0}
}
-var xxx_messageInfo_ContextUpdateRequest proto.InternalMessageInfo
+func (x *ContextUpdateRequest) GetAppContext() string {
+ if x != nil {
+ return x.AppContext
+ }
+ return ""
+}
-func (m *ContextUpdateRequest) GetAppContext() string {
- if m != nil {
- return m.AppContext
+func (x *ContextUpdateRequest) GetIntentName() string {
+ if x != nil {
+ return x.IntentName
}
return ""
}
type ContextUpdateResponse struct {
- AppContextUpdated bool `protobuf:"varint,1,opt,name=app_context_updated,json=appContextUpdated,proto3" json:"app_context_updated,omitempty"`
- AppContextUpdateMessage string `protobuf:"bytes,2,opt,name=app_context_update_message,json=appContextUpdateMessage,proto3" json:"app_context_update_message,omitempty"`
- XXX_NoUnkeyedLiteral struct{} `json:"-"`
- XXX_unrecognized []byte `json:"-"`
- XXX_sizecache int32 `json:"-"`
-}
+ state protoimpl.MessageState
+ sizeCache protoimpl.SizeCache
+ unknownFields protoimpl.UnknownFields
-func (m *ContextUpdateResponse) Reset() { *m = ContextUpdateResponse{} }
-func (m *ContextUpdateResponse) String() string { return proto.CompactTextString(m) }
-func (*ContextUpdateResponse) ProtoMessage() {}
-func (*ContextUpdateResponse) Descriptor() ([]byte, []int) {
- return fileDescriptor_8ebb57f5310873be, []int{1}
+ AppContextUpdated bool `protobuf:"varint,1,opt,name=app_context_updated,json=appContextUpdated,proto3" json:"app_context_updated,omitempty"`
+ AppContextUpdateMessage string `protobuf:"bytes,2,opt,name=app_context_update_message,json=appContextUpdateMessage,proto3" json:"app_context_update_message,omitempty"`
}
-func (m *ContextUpdateResponse) XXX_Unmarshal(b []byte) error {
- return xxx_messageInfo_ContextUpdateResponse.Unmarshal(m, b)
-}
-func (m *ContextUpdateResponse) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) {
- return xxx_messageInfo_ContextUpdateResponse.Marshal(b, m, deterministic)
-}
-func (m *ContextUpdateResponse) XXX_Merge(src proto.Message) {
- xxx_messageInfo_ContextUpdateResponse.Merge(m, src)
+func (x *ContextUpdateResponse) Reset() {
+ *x = ContextUpdateResponse{}
+ if protoimpl.UnsafeEnabled {
+ mi := &file_contextupdate_proto_msgTypes[1]
+ ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))
+ ms.StoreMessageInfo(mi)
+ }
}
-func (m *ContextUpdateResponse) XXX_Size() int {
- return xxx_messageInfo_ContextUpdateResponse.Size(m)
+
+func (x *ContextUpdateResponse) String() string {
+ return protoimpl.X.MessageStringOf(x)
}
-func (m *ContextUpdateResponse) XXX_DiscardUnknown() {
- xxx_messageInfo_ContextUpdateResponse.DiscardUnknown(m)
+
+func (*ContextUpdateResponse) ProtoMessage() {}
+
+func (x *ContextUpdateResponse) ProtoReflect() protoreflect.Message {
+ mi := &file_contextupdate_proto_msgTypes[1]
+ if protoimpl.UnsafeEnabled && x != nil {
+ ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))
+ if ms.LoadMessageInfo() == nil {
+ ms.StoreMessageInfo(mi)
+ }
+ return ms
+ }
+ return mi.MessageOf(x)
}
-var xxx_messageInfo_ContextUpdateResponse proto.InternalMessageInfo
+// Deprecated: Use ContextUpdateResponse.ProtoReflect.Descriptor instead.
+func (*ContextUpdateResponse) Descriptor() ([]byte, []int) {
+ return file_contextupdate_proto_rawDescGZIP(), []int{1}
+}
-func (m *ContextUpdateResponse) GetAppContextUpdated() bool {
- if m != nil {
- return m.AppContextUpdated
+func (x *ContextUpdateResponse) GetAppContextUpdated() bool {
+ if x != nil {
+ return x.AppContextUpdated
}
return false
}
-func (m *ContextUpdateResponse) GetAppContextUpdateMessage() string {
- if m != nil {
- return m.AppContextUpdateMessage
+func (x *ContextUpdateResponse) GetAppContextUpdateMessage() string {
+ if x != nil {
+ return x.AppContextUpdateMessage
}
return ""
}
-func init() {
- proto.RegisterType((*ContextUpdateRequest)(nil), "ContextUpdateRequest")
- proto.RegisterType((*ContextUpdateResponse)(nil), "ContextUpdateResponse")
+var File_contextupdate_proto protoreflect.FileDescriptor
+
+var file_contextupdate_proto_rawDesc = []byte{
+ 0x0a, 0x13, 0x63, 0x6f, 0x6e, 0x74, 0x65, 0x78, 0x74, 0x75, 0x70, 0x64, 0x61, 0x74, 0x65, 0x2e,
+ 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x22, 0x58, 0x0a, 0x14, 0x43, 0x6f, 0x6e, 0x74, 0x65, 0x78, 0x74,
+ 0x55, 0x70, 0x64, 0x61, 0x74, 0x65, 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x12, 0x1f, 0x0a,
+ 0x0b, 0x61, 0x70, 0x70, 0x5f, 0x63, 0x6f, 0x6e, 0x74, 0x65, 0x78, 0x74, 0x18, 0x01, 0x20, 0x01,
+ 0x28, 0x09, 0x52, 0x0a, 0x61, 0x70, 0x70, 0x43, 0x6f, 0x6e, 0x74, 0x65, 0x78, 0x74, 0x12, 0x1f,
+ 0x0a, 0x0b, 0x69, 0x6e, 0x74, 0x65, 0x6e, 0x74, 0x5f, 0x6e, 0x61, 0x6d, 0x65, 0x18, 0x02, 0x20,
+ 0x01, 0x28, 0x09, 0x52, 0x0a, 0x69, 0x6e, 0x74, 0x65, 0x6e, 0x74, 0x4e, 0x61, 0x6d, 0x65, 0x22,
+ 0x84, 0x01, 0x0a, 0x15, 0x43, 0x6f, 0x6e, 0x74, 0x65, 0x78, 0x74, 0x55, 0x70, 0x64, 0x61, 0x74,
+ 0x65, 0x52, 0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x12, 0x2e, 0x0a, 0x13, 0x61, 0x70, 0x70,
+ 0x5f, 0x63, 0x6f, 0x6e, 0x74, 0x65, 0x78, 0x74, 0x5f, 0x75, 0x70, 0x64, 0x61, 0x74, 0x65, 0x64,
+ 0x18, 0x01, 0x20, 0x01, 0x28, 0x08, 0x52, 0x11, 0x61, 0x70, 0x70, 0x43, 0x6f, 0x6e, 0x74, 0x65,
+ 0x78, 0x74, 0x55, 0x70, 0x64, 0x61, 0x74, 0x65, 0x64, 0x12, 0x3b, 0x0a, 0x1a, 0x61, 0x70, 0x70,
+ 0x5f, 0x63, 0x6f, 0x6e, 0x74, 0x65, 0x78, 0x74, 0x5f, 0x75, 0x70, 0x64, 0x61, 0x74, 0x65, 0x5f,
+ 0x6d, 0x65, 0x73, 0x73, 0x61, 0x67, 0x65, 0x18, 0x02, 0x20, 0x01, 0x28, 0x09, 0x52, 0x17, 0x61,
+ 0x70, 0x70, 0x43, 0x6f, 0x6e, 0x74, 0x65, 0x78, 0x74, 0x55, 0x70, 0x64, 0x61, 0x74, 0x65, 0x4d,
+ 0x65, 0x73, 0x73, 0x61, 0x67, 0x65, 0x32, 0x54, 0x0a, 0x0d, 0x63, 0x6f, 0x6e, 0x74, 0x65, 0x78,
+ 0x74, 0x75, 0x70, 0x64, 0x61, 0x74, 0x65, 0x12, 0x43, 0x0a, 0x10, 0x55, 0x70, 0x64, 0x61, 0x74,
+ 0x65, 0x41, 0x70, 0x70, 0x43, 0x6f, 0x6e, 0x74, 0x65, 0x78, 0x74, 0x12, 0x15, 0x2e, 0x43, 0x6f,
+ 0x6e, 0x74, 0x65, 0x78, 0x74, 0x55, 0x70, 0x64, 0x61, 0x74, 0x65, 0x52, 0x65, 0x71, 0x75, 0x65,
+ 0x73, 0x74, 0x1a, 0x16, 0x2e, 0x43, 0x6f, 0x6e, 0x74, 0x65, 0x78, 0x74, 0x55, 0x70, 0x64, 0x61,
+ 0x74, 0x65, 0x52, 0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x22, 0x00, 0x62, 0x06, 0x70, 0x72,
+ 0x6f, 0x74, 0x6f, 0x33,
+}
+
+var (
+ file_contextupdate_proto_rawDescOnce sync.Once
+ file_contextupdate_proto_rawDescData = file_contextupdate_proto_rawDesc
+)
+
+func file_contextupdate_proto_rawDescGZIP() []byte {
+ file_contextupdate_proto_rawDescOnce.Do(func() {
+ file_contextupdate_proto_rawDescData = protoimpl.X.CompressGZIP(file_contextupdate_proto_rawDescData)
+ })
+ return file_contextupdate_proto_rawDescData
}
-func init() {
- proto.RegisterFile("contextupdate.proto", fileDescriptor_8ebb57f5310873be)
+var file_contextupdate_proto_msgTypes = make([]protoimpl.MessageInfo, 2)
+var file_contextupdate_proto_goTypes = []interface{}{
+ (*ContextUpdateRequest)(nil), // 0: ContextUpdateRequest
+ (*ContextUpdateResponse)(nil), // 1: ContextUpdateResponse
+}
+var file_contextupdate_proto_depIdxs = []int32{
+ 0, // 0: contextupdate.UpdateAppContext:input_type -> ContextUpdateRequest
+ 1, // 1: contextupdate.UpdateAppContext:output_type -> ContextUpdateResponse
+ 1, // [1:2] is the sub-list for method output_type
+ 0, // [0:1] is the sub-list for method input_type
+ 0, // [0:0] is the sub-list for extension type_name
+ 0, // [0:0] is the sub-list for extension extendee
+ 0, // [0:0] is the sub-list for field type_name
}
-var fileDescriptor_8ebb57f5310873be = []byte{
- // 176 bytes of a gzipped FileDescriptorProto
- 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0xe2, 0x12, 0x4e, 0xce, 0xcf, 0x2b,
- 0x49, 0xad, 0x28, 0x29, 0x2d, 0x48, 0x49, 0x2c, 0x49, 0xd5, 0x2b, 0x28, 0xca, 0x2f, 0xc9, 0x57,
- 0x32, 0xe7, 0x12, 0x71, 0x86, 0x08, 0x87, 0x82, 0x85, 0x83, 0x52, 0x0b, 0x4b, 0x53, 0x8b, 0x4b,
- 0x84, 0xe4, 0xb9, 0xb8, 0x13, 0x0b, 0x0a, 0xe2, 0xa1, 0x5a, 0x24, 0x18, 0x15, 0x18, 0x35, 0x38,
- 0x83, 0xb8, 0x12, 0x0b, 0x0a, 0xa0, 0xaa, 0x95, 0x5a, 0x18, 0xb9, 0x44, 0xd1, 0x74, 0x16, 0x17,
- 0xe4, 0xe7, 0x15, 0xa7, 0x0a, 0xe9, 0x71, 0x09, 0x23, 0x69, 0x8d, 0x87, 0x58, 0x97, 0x02, 0x36,
- 0x82, 0x23, 0x48, 0x10, 0x61, 0x04, 0x44, 0x5b, 0x8a, 0x90, 0x35, 0x97, 0x14, 0xa6, 0xfa, 0xf8,
- 0xdc, 0xd4, 0xe2, 0xe2, 0xc4, 0xf4, 0x54, 0x09, 0x26, 0xb0, 0xcd, 0xe2, 0xe8, 0xda, 0x7c, 0x21,
- 0xd2, 0x46, 0x21, 0x5c, 0xbc, 0x28, 0xde, 0x12, 0x72, 0xe6, 0x12, 0x80, 0xa8, 0x70, 0x84, 0xeb,
- 0x10, 0x12, 0xd5, 0xc3, 0xe6, 0x47, 0x29, 0x31, 0x3d, 0xac, 0x1e, 0x50, 0x62, 0x48, 0x62, 0x03,
- 0x07, 0x8e, 0x31, 0x20, 0x00, 0x00, 0xff, 0xff, 0x75, 0x78, 0xc0, 0x4d, 0x33, 0x01, 0x00, 0x00,
+func init() { file_contextupdate_proto_init() }
+func file_contextupdate_proto_init() {
+ if File_contextupdate_proto != nil {
+ return
+ }
+ if !protoimpl.UnsafeEnabled {
+ file_contextupdate_proto_msgTypes[0].Exporter = func(v interface{}, i int) interface{} {
+ switch v := v.(*ContextUpdateRequest); i {
+ case 0:
+ return &v.state
+ case 1:
+ return &v.sizeCache
+ case 2:
+ return &v.unknownFields
+ default:
+ return nil
+ }
+ }
+ file_contextupdate_proto_msgTypes[1].Exporter = func(v interface{}, i int) interface{} {
+ switch v := v.(*ContextUpdateResponse); i {
+ case 0:
+ return &v.state
+ case 1:
+ return &v.sizeCache
+ case 2:
+ return &v.unknownFields
+ default:
+ return nil
+ }
+ }
+ }
+ type x struct{}
+ out := protoimpl.TypeBuilder{
+ File: protoimpl.DescBuilder{
+ GoPackagePath: reflect.TypeOf(x{}).PkgPath(),
+ RawDescriptor: file_contextupdate_proto_rawDesc,
+ NumEnums: 0,
+ NumMessages: 2,
+ NumExtensions: 0,
+ NumServices: 1,
+ },
+ GoTypes: file_contextupdate_proto_goTypes,
+ DependencyIndexes: file_contextupdate_proto_depIdxs,
+ MessageInfos: file_contextupdate_proto_msgTypes,
+ }.Build()
+ File_contextupdate_proto = out.File
+ file_contextupdate_proto_rawDesc = nil
+ file_contextupdate_proto_goTypes = nil
+ file_contextupdate_proto_depIdxs = nil
}
// Reference imports to suppress errors if they are not otherwise used.
@@ -177,7 +302,7 @@ type ContextupdateServer interface {
type UnimplementedContextupdateServer struct {
}
-func (*UnimplementedContextupdateServer) UpdateAppContext(ctx context.Context, req *ContextUpdateRequest) (*ContextUpdateResponse, error) {
+func (*UnimplementedContextupdateServer) UpdateAppContext(context.Context, *ContextUpdateRequest) (*ContextUpdateResponse, error) {
return nil, status.Errorf(codes.Unimplemented, "method UpdateAppContext not implemented")
}
diff --git a/src/orchestrator/pkg/grpc/contextupdate/contextupdate.proto b/src/orchestrator/pkg/grpc/contextupdate/contextupdate.proto
index ac305ba6..de8c4b16 100644
--- a/src/orchestrator/pkg/grpc/contextupdate/contextupdate.proto
+++ b/src/orchestrator/pkg/grpc/contextupdate/contextupdate.proto
@@ -24,6 +24,7 @@ service contextupdate {
message ContextUpdateRequest {
string app_context = 1;
+ string intent_name = 2;
}
message ContextUpdateResponse {
diff --git a/src/orchestrator/pkg/grpc/contextupdateclient/client.go b/src/orchestrator/pkg/grpc/contextupdateclient/client.go
new file mode 100644
index 00000000..d89a1bca
--- /dev/null
+++ b/src/orchestrator/pkg/grpc/contextupdateclient/client.go
@@ -0,0 +1,62 @@
+/*
+Copyright 2020 Intel Corporation.
+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.
+*/
+
+package contextupdateclient
+
+import (
+ "context"
+ "time"
+
+ 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/orchestrator/pkg/infra/rpc"
+ pkgerrors "github.com/pkg/errors"
+)
+
+// InvokeContextUpdate will make the grpc call to the specified controller
+// The controller will take the specified intentName and update the AppContext
+// appropriatly based on its operation as a placement or action controller.
+func InvokeContextUpdate(controllerName, intentName, appContextId string) error {
+ var err error
+ var rpcClient contextpb.ContextupdateClient
+ var updateRes *contextpb.ContextUpdateResponse
+ ctx, cancel := context.WithTimeout(context.Background(), 10*time.Second)
+ defer cancel()
+
+ conn := rpc.GetRpcConn(controllerName)
+
+ if conn != nil {
+ rpcClient = contextpb.NewContextupdateClient(conn)
+ updateReq := new(contextpb.ContextUpdateRequest)
+ updateReq.AppContext = appContextId
+ updateReq.IntentName = intentName
+ updateRes, err = rpcClient.UpdateAppContext(ctx, updateReq)
+ } else {
+ return pkgerrors.Errorf("ContextUpdate Failed - Could not get ContextupdateClient: %v", controllerName)
+ }
+
+ if err == nil {
+ if updateRes.AppContextUpdated {
+ log.Info("ContextUpdate Passed", log.Fields{
+ "Controller": controllerName,
+ "Intent": intentName,
+ "AppContext": appContextId,
+ "Message": updateRes.AppContextUpdateMessage,
+ })
+ return nil
+ } else {
+ return pkgerrors.Errorf("ContextUpdate Failed: %v", updateRes.AppContextUpdateMessage)
+ }
+ }
+ return err
+}
diff --git a/src/orchestrator/pkg/infra/rpc/rpc.go b/src/orchestrator/pkg/infra/rpc/rpc.go
index a9c97bff..a9c97bff 100755..100644
--- a/src/orchestrator/pkg/infra/rpc/rpc.go
+++ b/src/orchestrator/pkg/infra/rpc/rpc.go
diff --git a/src/orchestrator/pkg/module/deployment_intent_groups.go b/src/orchestrator/pkg/module/deployment_intent_groups.go
index cfbf53e2..16a14c7b 100644
--- a/src/orchestrator/pkg/module/deployment_intent_groups.go
+++ b/src/orchestrator/pkg/module/deployment_intent_groups.go
@@ -18,9 +18,10 @@ package module
import (
"encoding/json"
- "github.com/onap/multicloud-k8s/src/orchestrator/pkg/infra/db"
"reflect"
+ "github.com/onap/multicloud-k8s/src/orchestrator/pkg/infra/db"
+
pkgerrors "github.com/pkg/errors"
)
diff --git a/src/ovnaction/cmd/main.go b/src/ovnaction/cmd/main.go
index 1f33af25..9e791cd1 100644
--- a/src/ovnaction/cmd/main.go
+++ b/src/ovnaction/cmd/main.go
@@ -26,7 +26,6 @@ import (
"time"
"github.com/gorilla/handlers"
- "github.com/onap/multicloud-k8s/src/ncm/pkg/grpc/contextupdateserver"
updatepb "github.com/onap/multicloud-k8s/src/orchestrator/pkg/grpc/contextupdate"
"github.com/onap/multicloud-k8s/src/orchestrator/pkg/infra/auth"
"github.com/onap/multicloud-k8s/src/orchestrator/pkg/infra/config"
@@ -34,6 +33,7 @@ import (
"github.com/onap/multicloud-k8s/src/orchestrator/pkg/infra/db"
"github.com/onap/multicloud-k8s/src/ovnaction/api"
register "github.com/onap/multicloud-k8s/src/ovnaction/pkg/grpc"
+ "github.com/onap/multicloud-k8s/src/ovnaction/pkg/grpc/contextupdateserver"
"google.golang.org/grpc"
"google.golang.org/grpc/credentials"
"google.golang.org/grpc/testdata"
@@ -73,10 +73,10 @@ func startGrpcServer() error {
grpcServer := grpc.NewServer(opts...)
updatepb.RegisterContextupdateServer(grpcServer, contextupdateserver.NewContextupdateServer())
- log.Println("Starting Network Configuration Manager gRPC Server")
+ log.Println("Starting OVN Network Action Controller gRPC Server")
err = grpcServer.Serve(lis)
if err != nil {
- log.Fatalf("ncm grpc server is not serving %v", err)
+ log.Fatalf("ovnaction grpc server is not serving %v", err)
}
return err
}
diff --git a/src/ovnaction/go.mod b/src/ovnaction/go.mod
index 1050fe83..06b4d581 100644
--- a/src/ovnaction/go.mod
+++ b/src/ovnaction/go.mod
@@ -5,7 +5,6 @@ require (
github.com/gorilla/handlers v1.3.0
github.com/gorilla/mux v1.7.3
github.com/k8snetworkplumbingwg/network-attachment-definition-client v0.0.0-20200127152046-0ee521d56061
- github.com/onap/multicloud-k8s/src/ncm v0.0.0-20200515060444-c77850a75eee
github.com/onap/multicloud-k8s/src/orchestrator v0.0.0-20200601021239-7959bd4c6fd4
github.com/pkg/errors v0.8.1
google.golang.org/grpc v1.27.1
diff --git a/src/ovnaction/go.sum b/src/ovnaction/go.sum
index ee1c7287..0f8e80de 100644
--- a/src/ovnaction/go.sum
+++ b/src/ovnaction/go.sum
@@ -203,6 +203,13 @@ github.com/golang/protobuf v1.3.2/go.mod h1:6lQm79b+lXiMfvg/cZm0SGofjICqVBUtrP5y
github.com/golang/protobuf v1.3.3/go.mod h1:vzj43D7+SQXF/4pzW/hwtAqwc6iTitCiVSaWz5lYuqw=
github.com/golang/protobuf v1.3.4 h1:87PNWwrRvUSnqS4dlcBU/ftvOIBep4sYuBLlh6rX2wk=
github.com/golang/protobuf v1.3.4/go.mod h1:vzj43D7+SQXF/4pzW/hwtAqwc6iTitCiVSaWz5lYuqw=
+github.com/golang/protobuf v1.4.0-rc.1/go.mod h1:ceaxUfeHdC40wWswd/P6IGgMaK3YpKi5j83Wpe3EHw8=
+github.com/golang/protobuf v1.4.0-rc.1.0.20200221234624-67d41d38c208/go.mod h1:xKAWHe0F5eneWXFV3EuXVDTCmh+JuBKY0li0aMyXATA=
+github.com/golang/protobuf v1.4.0-rc.2/go.mod h1:LlEzMj4AhA7rCAGe4KMBDvJI+AwstrUpVNzEA03Pprs=
+github.com/golang/protobuf v1.4.0-rc.4.0.20200313231945-b860323f09d0/go.mod h1:WU3c8KckQ9AFe+yFwt9sWVRKCVIyN9cPHBJSNnbL67w=
+github.com/golang/protobuf v1.4.0/go.mod h1:jodUvKwWbYaEsadDk5Fwe5c77LiNKVO9IDvqG2KuDX0=
+github.com/golang/protobuf v1.4.1 h1:ZFgWrT+bLgsYPirOnRfKLYJLvssAegOj/hgyMFdJZe0=
+github.com/golang/protobuf v1.4.1/go.mod h1:U8fpvMrcmy5pZrNK1lt4xCsGvpyWQ/VVv6QDs8UjoX8=
github.com/golang/snappy v0.0.0-20180518054509-2e65f85255db/go.mod h1:/XxbfmMg8lxefKM7IXC3fBNl/7bRcc72aCRzEWrmP2Q=
github.com/golang/snappy v0.0.1 h1:Qgr9rKW7uDUkrbSmQeiDsGa8SjGyCOGtuasMWwvp2P4=
github.com/golang/snappy v0.0.1/go.mod h1:/XxbfmMg8lxefKM7IXC3fBNl/7bRcc72aCRzEWrmP2Q=
@@ -787,6 +794,8 @@ google.golang.org/genproto v0.0.0-20190819201941-24fa4b261c55 h1:gSJIx1SDwno+2El
google.golang.org/genproto v0.0.0-20190819201941-24fa4b261c55/go.mod h1:DMBHOl98Agz4BDEuKkezgsaosCRResVns1a3J2ZsMNc=
google.golang.org/genproto v0.0.0-20200305110556-506484158171 h1:xes2Q2k+d/+YNXVw0FpZkIDJiaux4OVrRKXRAzH6A0U=
google.golang.org/genproto v0.0.0-20200305110556-506484158171/go.mod h1:55QSHmfGQM9UVYDPBsyGGes0y52j32PQ3BqQfXhyH3c=
+google.golang.org/genproto v0.0.0-20200526211855-cb27e3aa2013 h1:+kGHl1aib/qcwaRi1CbqBZ1rk19r85MNUf8HaBghugY=
+google.golang.org/genproto v0.0.0-20200526211855-cb27e3aa2013/go.mod h1:NbSheEEYHJ7i3ixzK3sjbqSGDJWnxyFXZblF3eUsNvo=
google.golang.org/grpc v1.17.0/go.mod h1:6QZJwpn2B+Zp71q/5VxRsJ6NXXVCE5NRUHRo+f3cWCs=
google.golang.org/grpc v1.19.0 h1:cfg4PD8YEdSFnm7qLV4++93WcmhH2nIUhMjhdCvl3j8=
google.golang.org/grpc v1.19.0/go.mod h1:mqu4LbDTu4XGKhr4mRzUsmM4RtVoemTSY81AxZiDr8c=
@@ -800,6 +809,15 @@ google.golang.org/grpc v1.26.0/go.mod h1:qbnxyOmOxrQa7FizSgH+ReBfzJrCY1pSN7KXBS8
google.golang.org/grpc v1.27.0/go.mod h1:qbnxyOmOxrQa7FizSgH+ReBfzJrCY1pSN7KXBS8abTk=
google.golang.org/grpc v1.27.1 h1:zvIju4sqAGvwKspUQOhwnpcqSbzi7/H6QomNNjTL4sk=
google.golang.org/grpc v1.27.1/go.mod h1:qbnxyOmOxrQa7FizSgH+ReBfzJrCY1pSN7KXBS8abTk=
+google.golang.org/protobuf v0.0.0-20200109180630-ec00e32a8dfd/go.mod h1:DFci5gLYBciE7Vtevhsrf46CRTquxDuWsQurQQe4oz8=
+google.golang.org/protobuf v0.0.0-20200221191635-4d8936d0db64/go.mod h1:kwYJMbMJ01Woi6D6+Kah6886xMZcty6N08ah7+eCXa0=
+google.golang.org/protobuf v0.0.0-20200228230310-ab0ca4ff8a60/go.mod h1:cfTl7dwQJ+fmap5saPgwCLgHXTUD7jkjRqWcaiX5VyM=
+google.golang.org/protobuf v1.20.1-0.20200309200217-e05f789c0967/go.mod h1:A+miEFZTKqfCUM6K7xSMQL9OKL/b6hQv+e19PK+JZNE=
+google.golang.org/protobuf v1.21.0/go.mod h1:47Nbq4nVaFHyn7ilMalzfO3qCViNmqZ2kzikPIcrTAo=
+google.golang.org/protobuf v1.22.0/go.mod h1:EGpADcykh3NcUnDUJcl1+ZksZNG86OlYog2l/sGQquU=
+google.golang.org/protobuf v1.23.1-0.20200526195155-81db48ad09cc/go.mod h1:EGpADcykh3NcUnDUJcl1+ZksZNG86OlYog2l/sGQquU=
+google.golang.org/protobuf v1.24.0 h1:UhZDfRO8JRQru4/+LlLE0BRKGF8L+PICnvYZmx/fEGA=
+google.golang.org/protobuf v1.24.0/go.mod h1:r/3tXBNzIEhYS9I1OUVjXDlt8tc493IdKGjtUeSXeh4=
gopkg.in/alecthomas/kingpin.v2 v2.2.6/go.mod h1:FMv+mEhP44yOT+4EoQTLFTRgOQ1FBLkstjWtayDeSgw=
gopkg.in/check.v1 v0.0.0-20161208181325-20d25e280405/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0=
gopkg.in/check.v1 v1.0.0-20180628173108-788fd7840127/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0=
diff --git a/src/ovnaction/internal/action/action.go b/src/ovnaction/internal/action/action.go
new file mode 100644
index 00000000..c9b912fa
--- /dev/null
+++ b/src/ovnaction/internal/action/action.go
@@ -0,0 +1,158 @@
+/*
+ * Copyright 2020 Intel Corporation, Inc
+ *
+ * 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.
+ */
+
+package action
+
+import (
+ "encoding/json"
+ "strings"
+
+ jyaml "github.com/ghodss/yaml"
+
+ nettypes "github.com/k8snetworkplumbingwg/network-attachment-definition-client/pkg/apis/k8s.cni.cncf.io/v1"
+ "github.com/onap/multicloud-k8s/src/orchestrator/pkg/appcontext"
+ log "github.com/onap/multicloud-k8s/src/orchestrator/pkg/infra/logutils"
+ "github.com/onap/multicloud-k8s/src/ovnaction/pkg/module"
+ "k8s.io/apimachinery/pkg/runtime"
+ "k8s.io/client-go/kubernetes/scheme"
+
+ pkgerrors "github.com/pkg/errors"
+)
+
+// Action applies the supplied intent against the given AppContext ID
+func UpdateAppContext(intentName, appContextId string) error {
+ var ac appcontext.AppContext
+ _, err := ac.LoadAppContext(appContextId)
+ if err != nil {
+ return pkgerrors.Wrapf(err, "Error getting AppContext with Id: %v", appContextId)
+ }
+ caMeta, err := ac.GetCompositeAppMeta()
+ if err != nil {
+ return pkgerrors.Wrapf(err, "Error getting metadata for AppContext with Id: %v", appContextId)
+ }
+
+ project := caMeta.Project
+ compositeapp := caMeta.CompositeApp
+ compositeappversion := caMeta.Version
+
+ // Handle all Workload Intents for the Network Control Intent
+ wis, err := module.NewWorkloadIntentClient().GetWorkloadIntents(project, compositeapp, compositeappversion, intentName)
+ if err != nil {
+ return pkgerrors.Wrapf(err, "Error getting Workload Intents for Network Control Intent %v for %v/%v%v not found", intentName, project, compositeapp, compositeappversion)
+ }
+
+ // Handle all intents (currently just Workload Interface intents) for each Workload Intent
+ for _, wi := range wis {
+ // The app/resource identified in the workload intent needs to be updated with two annotations.
+ // 1 - The "k8s.v1.cni.cncf.io/networks" annotation will have {"name": "ovn-networkobj", "namespace": "default"} added
+ // to it (preserving any existing values for this annotation.
+ // 2 - The "k8s.plugin.opnfv.org/nfn-network" annotation will add any network interfaces that are provided by the
+ // workload/interfaces intents.
+
+ // Prepare the list of interfaces from the workload intent
+ wifs, err := module.NewWorkloadIfIntentClient().GetWorkloadIfIntents(project,
+ compositeapp,
+ compositeappversion,
+ intentName,
+ wi.Metadata.Name)
+ if err != nil {
+ return pkgerrors.Wrapf(err,
+ "Error getting Workload Interface Intents for Workload Intent %v under Network Control Intent %v for %v/%v%v not found",
+ wi.Metadata.Name, intentName, project, compositeapp, compositeappversion)
+ }
+ if len(wifs) == 0 {
+ log.Warn("No interface intents provided for workload intent", log.Fields{
+ "project": project,
+ "composite app": compositeapp,
+ "composite app version": compositeappversion,
+ "network control intent": intentName,
+ "workload intent": wi.Metadata.Name,
+ })
+ continue
+ }
+
+ // Get all clusters for the current App from the AppContext
+ clusters, err := ac.GetClusterNames(wi.Spec.AppName)
+ for _, c := range clusters {
+ rh, err := ac.GetResourceHandle(wi.Spec.AppName, c,
+ strings.Join([]string{wi.Spec.WorkloadResource, wi.Spec.Type}, "+"))
+ if err != nil {
+ log.Warn("App Context resource handle not found", log.Fields{
+ "project": project,
+ "composite app": compositeapp,
+ "composite app version": compositeappversion,
+ "network control intent": intentName,
+ "workload name": wi.Metadata.Name,
+ "app": wi.Spec.AppName,
+ "resource": wi.Spec.WorkloadResource,
+ "resource type": wi.Spec.Type,
+ })
+ continue
+ }
+ r, err := ac.GetValue(rh)
+ if err != nil {
+ log.Error("Error retrieving resource from App Context", log.Fields{
+ "error": err,
+ "resource handle": rh,
+ })
+ }
+
+ // Unmarshal resource to K8S object
+ robj, err := runtime.Decode(scheme.Codecs.UniversalDeserializer(), []byte(r.(string)))
+
+ // Add network annotation to object
+ netAnnot := nettypes.NetworkSelectionElement{
+ Name: "ovn-networkobj",
+ Namespace: "default",
+ }
+ module.AddNetworkAnnotation(robj, netAnnot)
+
+ // Add nfn interface annotations to object
+ var newNfnIfs []module.WorkloadIfIntentSpec
+ for _, i := range wifs {
+ newNfnIfs = append(newNfnIfs, i.Spec)
+ }
+ module.AddNfnAnnotation(robj, newNfnIfs)
+
+ // Marshal object back to yaml format (via json - seems to eliminate most clutter)
+ j, err := json.Marshal(robj)
+ if err != nil {
+ log.Error("Error marshalling resource to JSON", log.Fields{
+ "error": err,
+ })
+ continue
+ }
+ y, err := jyaml.JSONToYAML(j)
+ if err != nil {
+ log.Error("Error marshalling resource to YAML", log.Fields{
+ "error": err,
+ })
+ continue
+ }
+
+ // Update resource in AppContext
+ err = ac.UpdateResourceValue(rh, string(y))
+ if err != nil {
+ log.Error("Network updating app context resource handle", log.Fields{
+ "error": err,
+ "resource handle": rh,
+ })
+ }
+ }
+ }
+
+ return nil
+}
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