+//
+// 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.
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")
}
--- /dev/null
+/*
+ * 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
+}