diff options
author | Eric Multanen <eric.w.multanen@intel.com> | 2020-09-30 22:38:59 -0700 |
---|---|---|
committer | Eric Multanen <eric.w.multanen@intel.com> | 2020-10-02 23:41:52 -0700 |
commit | 1fc90f15489ae3eafeb5994f5285f09750feae4c (patch) | |
tree | bb42ac610b2fbc13e5cfc746bb32f3b8ccabd2b3 /src/ovnaction/pkg | |
parent | d4b89af411ec7444b554a8b0ddeb7e239fa0fc73 (diff) |
Ovnaction and vfw updates for deploy api change
Update the ovnaction controller APIs to support
the api change of including the deployment intent
group in the URL. Also fixup:
- vfw and other test cases to support the change
- updates to emcoctl tool and examples
Issue-ID: MULTICLOUD-1218
Signed-off-by: Eric Multanen <eric.w.multanen@intel.com>
Change-Id: Icadacb5ec6d7c238bb3bf8a44a39c30692ecebee
Diffstat (limited to 'src/ovnaction/pkg')
-rw-r--r-- | src/ovnaction/pkg/module/chaining.go | 25 | ||||
-rw-r--r-- | src/ovnaction/pkg/module/netcontrolintent.go | 155 | ||||
-rw-r--r-- | src/ovnaction/pkg/module/workloadifintent.go | 25 | ||||
-rw-r--r-- | src/ovnaction/pkg/module/workloadintent.go | 25 |
4 files changed, 59 insertions, 171 deletions
diff --git a/src/ovnaction/pkg/module/chaining.go b/src/ovnaction/pkg/module/chaining.go index 45f061fa..bc2cac00 100644 --- a/src/ovnaction/pkg/module/chaining.go +++ b/src/ovnaction/pkg/module/chaining.go @@ -54,6 +54,7 @@ type ChainKey struct { Project string `json:"project"` CompositeApp string `json:"compositeapp"` CompositeAppVersion string `json:"compositeappversion"` + DigName string `json:"deploymentintentgroup"` NetControlIntent string `json:"netcontrolintent"` NetworkChain string `json:"networkchain"` } @@ -76,10 +77,10 @@ const ChainingKind = "NetworkChaining" // ChainManager is an interface exposing the Chain functionality type ChainManager interface { - CreateChain(ch Chain, pr, ca, caver, netctrlint string, exists bool) (Chain, error) - GetChain(name, pr, ca, caver, netctrlint string) (Chain, error) - GetChains(pr, ca, caver, netctrlint string) ([]Chain, error) - DeleteChain(name, pr, ca, caver, netctrlint string) error + CreateChain(ch Chain, pr, ca, caver, dig, netctrlint string, exists bool) (Chain, error) + GetChain(name, pr, ca, caver, dig, netctrlint string) (Chain, error) + GetChains(pr, ca, caver, dig, netctrlint string) ([]Chain, error) + DeleteChain(name, pr, ca, caver, dig, netctrlint string) error } // ChainClient implements the Manager @@ -100,24 +101,25 @@ func NewChainClient() *ChainClient { } // CreateChain - create a new Chain -func (v *ChainClient) CreateChain(ch Chain, pr, ca, caver, netctrlint string, exists bool) (Chain, error) { +func (v *ChainClient) CreateChain(ch Chain, pr, ca, caver, dig, netctrlint string, exists bool) (Chain, error) { //Construct key and tag to select the entry key := ChainKey{ Project: pr, CompositeApp: ca, CompositeAppVersion: caver, + DigName: dig, NetControlIntent: netctrlint, NetworkChain: ch.Metadata.Name, } //Check if the Network Control Intent exists - _, err := NewNetControlIntentClient().GetNetControlIntent(netctrlint, pr, ca, caver) + _, err := NewNetControlIntentClient().GetNetControlIntent(netctrlint, pr, ca, caver, dig) if err != nil { return Chain{}, pkgerrors.Errorf("Network Control Intent %v does not exist", netctrlint) } //Check if this Chain already exists - _, err = v.GetChain(ch.Metadata.Name, pr, ca, caver, netctrlint) + _, err = v.GetChain(ch.Metadata.Name, pr, ca, caver, dig, netctrlint) if err == nil && !exists { return Chain{}, pkgerrors.New("Chain already exists") } @@ -131,12 +133,13 @@ func (v *ChainClient) CreateChain(ch Chain, pr, ca, caver, netctrlint string, ex } // GetChain returns the Chain for corresponding name -func (v *ChainClient) GetChain(name, pr, ca, caver, netctrlint string) (Chain, error) { +func (v *ChainClient) GetChain(name, pr, ca, caver, dig, netctrlint string) (Chain, error) { //Construct key and tag to select the entry key := ChainKey{ Project: pr, CompositeApp: ca, CompositeAppVersion: caver, + DigName: dig, NetControlIntent: netctrlint, NetworkChain: name, } @@ -160,12 +163,13 @@ func (v *ChainClient) GetChain(name, pr, ca, caver, netctrlint string) (Chain, e } // GetChains returns all of the Chains for for the given network control intent -func (v *ChainClient) GetChains(pr, ca, caver, netctrlint string) ([]Chain, error) { +func (v *ChainClient) GetChains(pr, ca, caver, dig, netctrlint string) ([]Chain, error) { //Construct key and tag to select the entry key := ChainKey{ Project: pr, CompositeApp: ca, CompositeAppVersion: caver, + DigName: dig, NetControlIntent: netctrlint, NetworkChain: "", } @@ -189,13 +193,14 @@ func (v *ChainClient) GetChains(pr, ca, caver, netctrlint string) ([]Chain, erro } // DeleteChain deletes the Chain from the database -func (v *ChainClient) DeleteChain(name, pr, ca, caver, netctrlint string) error { +func (v *ChainClient) DeleteChain(name, pr, ca, caver, dig, netctrlint string) error { //Construct key and tag to select the entry key := ChainKey{ Project: pr, CompositeApp: ca, CompositeAppVersion: caver, + DigName: dig, NetControlIntent: netctrlint, NetworkChain: name, } diff --git a/src/ovnaction/pkg/module/netcontrolintent.go b/src/ovnaction/pkg/module/netcontrolintent.go index c005a935..eada4be1 100644 --- a/src/ovnaction/pkg/module/netcontrolintent.go +++ b/src/ovnaction/pkg/module/netcontrolintent.go @@ -17,17 +17,7 @@ package module 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" "github.com/onap/multicloud-k8s/src/orchestrator/pkg/infra/db" - log "github.com/onap/multicloud-k8s/src/orchestrator/pkg/infra/logutils" - "k8s.io/apimachinery/pkg/runtime" - "k8s.io/client-go/kubernetes/scheme" pkgerrors "github.com/pkg/errors" ) @@ -43,15 +33,15 @@ type NetControlIntentKey struct { Project string `json:"project"` CompositeApp string `json:"compositeapp"` CompositeAppVersion string `json:"compositeappversion"` + DigName string `json:"deploymentintentgroup"` } // Manager is an interface exposing the NetControlIntent functionality type NetControlIntentManager interface { - CreateNetControlIntent(nci NetControlIntent, project, compositeapp, compositeappversion string, exists bool) (NetControlIntent, error) - GetNetControlIntent(name, project, compositeapp, compositeappversion string) (NetControlIntent, error) - GetNetControlIntents(project, compositeapp, compositeappversion string) ([]NetControlIntent, error) - DeleteNetControlIntent(name, project, compositeapp, compositeappversion string) error - ApplyNetControlIntent(name, project, compositeapp, compositeappversion, appContextId string) error + CreateNetControlIntent(nci NetControlIntent, project, compositeapp, compositeappversion, dig string, exists bool) (NetControlIntent, error) + GetNetControlIntent(name, project, compositeapp, compositeappversion, dig string) (NetControlIntent, error) + GetNetControlIntents(project, compositeapp, compositeappversion, dig string) ([]NetControlIntent, error) + DeleteNetControlIntent(name, project, compositeapp, compositeappversion, dig string) error } // NetControlIntentClient implements the Manager @@ -72,7 +62,7 @@ func NewNetControlIntentClient() *NetControlIntentClient { } // CreateNetControlIntent - create a new NetControlIntent -func (v *NetControlIntentClient) CreateNetControlIntent(nci NetControlIntent, project, compositeapp, compositeappversion string, exists bool) (NetControlIntent, error) { +func (v *NetControlIntentClient) CreateNetControlIntent(nci NetControlIntent, project, compositeapp, compositeappversion, dig string, exists bool) (NetControlIntent, error) { //Construct key and tag to select the entry key := NetControlIntentKey{ @@ -80,10 +70,11 @@ func (v *NetControlIntentClient) CreateNetControlIntent(nci NetControlIntent, pr Project: project, CompositeApp: compositeapp, CompositeAppVersion: compositeappversion, + DigName: dig, } //Check if this NetControlIntent already exists - _, err := v.GetNetControlIntent(nci.Metadata.Name, project, compositeapp, compositeappversion) + _, err := v.GetNetControlIntent(nci.Metadata.Name, project, compositeapp, compositeappversion, dig) if err == nil && !exists { return NetControlIntent{}, pkgerrors.New("NetControlIntent already exists") } @@ -97,7 +88,7 @@ func (v *NetControlIntentClient) CreateNetControlIntent(nci NetControlIntent, pr } // GetNetControlIntent returns the NetControlIntent for corresponding name -func (v *NetControlIntentClient) GetNetControlIntent(name, project, compositeapp, compositeappversion string) (NetControlIntent, error) { +func (v *NetControlIntentClient) GetNetControlIntent(name, project, compositeapp, compositeappversion, dig string) (NetControlIntent, error) { //Construct key and tag to select the entry key := NetControlIntentKey{ @@ -105,6 +96,7 @@ func (v *NetControlIntentClient) GetNetControlIntent(name, project, compositeapp Project: project, CompositeApp: compositeapp, CompositeAppVersion: compositeappversion, + DigName: dig, } value, err := db.DBconn.Find(v.db.storeName, key, v.db.tagMeta) @@ -126,7 +118,7 @@ func (v *NetControlIntentClient) GetNetControlIntent(name, project, compositeapp } // GetNetControlIntentList returns all of the NetControlIntent for corresponding name -func (v *NetControlIntentClient) GetNetControlIntents(project, compositeapp, compositeappversion string) ([]NetControlIntent, error) { +func (v *NetControlIntentClient) GetNetControlIntents(project, compositeapp, compositeappversion, dig string) ([]NetControlIntent, error) { //Construct key and tag to select the entry key := NetControlIntentKey{ @@ -134,6 +126,7 @@ func (v *NetControlIntentClient) GetNetControlIntents(project, compositeapp, com Project: project, CompositeApp: compositeapp, CompositeAppVersion: compositeappversion, + DigName: dig, } var resp []NetControlIntent @@ -155,7 +148,7 @@ func (v *NetControlIntentClient) GetNetControlIntents(project, compositeapp, com } // Delete the NetControlIntent from database -func (v *NetControlIntentClient) DeleteNetControlIntent(name, project, compositeapp, compositeappversion string) error { +func (v *NetControlIntentClient) DeleteNetControlIntent(name, project, compositeapp, compositeappversion, dig string) error { //Construct key and tag to select the entry key := NetControlIntentKey{ @@ -163,6 +156,7 @@ func (v *NetControlIntentClient) DeleteNetControlIntent(name, project, composite Project: project, CompositeApp: compositeapp, CompositeAppVersion: compositeappversion, + DigName: dig, } err := db.DBconn.Remove(v.db.storeName, key) @@ -172,124 +166,3 @@ func (v *NetControlIntentClient) DeleteNetControlIntent(name, project, composite return nil } - -// (Test Routine) - Apply network-control-intent -func (v *NetControlIntentClient) ApplyNetControlIntent(name, project, compositeapp, compositeappversion, appContextId string) error { - // TODO: Handle all Network Chain Intents for the Network Control Intent - - // Handle all Workload Intents for the Network Control Intent - wis, err := NewWorkloadIntentClient().GetWorkloadIntents(project, compositeapp, compositeappversion, name) - if err != nil { - return pkgerrors.Wrapf(err, "Error getting Workload Intents for Network Control Intent %v for %v/%v%v not found", name, project, compositeapp, compositeappversion) - } - - // Setup the AppContext - var context appcontext.AppContext - _, err = context.LoadAppContext(appContextId) - if err != nil { - return pkgerrors.Wrapf(err, "Error getting AppContext with Id: %v for %v/%v%v", - appContextId, project, compositeapp, compositeappversion) - } - - // Handle all intents (currently just 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 := NewWorkloadIfIntentClient().GetWorkloadIfIntents(project, - compositeapp, - compositeappversion, - name, - 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, name, 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": name, - "workload intent": wi.Metadata.Name, - }) - continue - } - - // Get all clusters for the current App from the AppContext - clusters, err := context.GetClusterNames(wi.Spec.AppName) - for _, c := range clusters { - rh, err := context.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": name, - "workload name": wi.Metadata.Name, - "app": wi.Spec.AppName, - "resource": wi.Spec.WorkloadResource, - "resource type": wi.Spec.Type, - }) - continue - } - r, err := context.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", - } - AddNetworkAnnotation(robj, netAnnot) - - // Add nfn interface annotations to object - var newNfnIfs []WorkloadIfIntentSpec - for _, i := range wifs { - newNfnIfs = append(newNfnIfs, i.Spec) - } - 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 = context.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/module/workloadifintent.go b/src/ovnaction/pkg/module/workloadifintent.go index 55062564..cea336f6 100644 --- a/src/ovnaction/pkg/module/workloadifintent.go +++ b/src/ovnaction/pkg/module/workloadifintent.go @@ -41,6 +41,7 @@ type WorkloadIfIntentKey struct { Project string `json:"provider"` CompositeApp string `json:"compositeapp"` CompositeAppVersion string `json:"compositeappversion"` + DigName string `json:"deploymentintentgroup"` NetControlIntent string `json:"netcontrolintent"` WorkloadIntent string `json:"workloadintent"` WorkloadIfIntent string `json:"workloadifintent"` @@ -48,10 +49,10 @@ type WorkloadIfIntentKey struct { // Manager is an interface exposing the WorkloadIfIntent functionality type WorkloadIfIntentManager interface { - CreateWorkloadIfIntent(wi WorkloadIfIntent, project, compositeapp, compositeappversion, netcontrolintent, workloadintent string, exists bool) (WorkloadIfIntent, error) - GetWorkloadIfIntent(name, project, compositeapp, compositeappversion, netcontrolintent, workloadintent string) (WorkloadIfIntent, error) - GetWorkloadIfIntents(project, compositeapp, compositeappversion, netcontrolintent, workloadintent string) ([]WorkloadIfIntent, error) - DeleteWorkloadIfIntent(name, project, compositeapp, compositeappversion, netcontrolintent, workloadintent string) error + CreateWorkloadIfIntent(wi WorkloadIfIntent, project, compositeapp, compositeappversion, dig, netcontrolintent, workloadintent string, exists bool) (WorkloadIfIntent, error) + GetWorkloadIfIntent(name, project, compositeapp, compositeappversion, dig, netcontrolintent, workloadintent string) (WorkloadIfIntent, error) + GetWorkloadIfIntents(project, compositeapp, compositeappversion, dig, netcontrolintent, workloadintent string) ([]WorkloadIfIntent, error) + DeleteWorkloadIfIntent(name, project, compositeapp, compositeappversion, dig, netcontrolintent, workloadintent string) error } // WorkloadIfIntentClient implements the Manager @@ -72,26 +73,27 @@ func NewWorkloadIfIntentClient() *WorkloadIfIntentClient { } // CreateWorkloadIfIntent - create a new WorkloadIfIntent -func (v *WorkloadIfIntentClient) CreateWorkloadIfIntent(wif WorkloadIfIntent, project, compositeapp, compositeappversion, netcontrolintent, workloadintent string, exists bool) (WorkloadIfIntent, error) { +func (v *WorkloadIfIntentClient) CreateWorkloadIfIntent(wif WorkloadIfIntent, project, compositeapp, compositeappversion, dig, netcontrolintent, workloadintent string, exists bool) (WorkloadIfIntent, error) { //Construct key and tag to select the entry key := WorkloadIfIntentKey{ Project: project, CompositeApp: compositeapp, CompositeAppVersion: compositeappversion, + DigName: dig, NetControlIntent: netcontrolintent, WorkloadIntent: workloadintent, WorkloadIfIntent: wif.Metadata.Name, } //Check if the Workload Intent exists - _, err := NewWorkloadIntentClient().GetWorkloadIntent(workloadintent, project, compositeapp, compositeappversion, netcontrolintent) + _, err := NewWorkloadIntentClient().GetWorkloadIntent(workloadintent, project, compositeapp, compositeappversion, dig, netcontrolintent) if err != nil { return WorkloadIfIntent{}, pkgerrors.Errorf("Workload Intent %v does not exist", workloadintent) } //Check if this WorkloadIfIntent already exists - _, err = v.GetWorkloadIfIntent(wif.Metadata.Name, project, compositeapp, compositeappversion, netcontrolintent, workloadintent) + _, err = v.GetWorkloadIfIntent(wif.Metadata.Name, project, compositeapp, compositeappversion, dig, netcontrolintent, workloadintent) if err == nil && !exists { return WorkloadIfIntent{}, pkgerrors.New("WorkloadIfIntent already exists") } @@ -105,13 +107,14 @@ func (v *WorkloadIfIntentClient) CreateWorkloadIfIntent(wif WorkloadIfIntent, pr } // GetWorkloadIfIntent returns the WorkloadIfIntent for corresponding name -func (v *WorkloadIfIntentClient) GetWorkloadIfIntent(name, project, compositeapp, compositeappversion, netcontrolintent, workloadintent string) (WorkloadIfIntent, error) { +func (v *WorkloadIfIntentClient) GetWorkloadIfIntent(name, project, compositeapp, compositeappversion, dig, netcontrolintent, workloadintent string) (WorkloadIfIntent, error) { //Construct key and tag to select the entry key := WorkloadIfIntentKey{ Project: project, CompositeApp: compositeapp, CompositeAppVersion: compositeappversion, + DigName: dig, NetControlIntent: netcontrolintent, WorkloadIntent: workloadintent, WorkloadIfIntent: name, @@ -136,13 +139,14 @@ func (v *WorkloadIfIntentClient) GetWorkloadIfIntent(name, project, compositeapp } // GetWorkloadIfIntentList returns all of the WorkloadIfIntent for corresponding name -func (v *WorkloadIfIntentClient) GetWorkloadIfIntents(project, compositeapp, compositeappversion, netcontrolintent, workloadintent string) ([]WorkloadIfIntent, error) { +func (v *WorkloadIfIntentClient) GetWorkloadIfIntents(project, compositeapp, compositeappversion, dig, netcontrolintent, workloadintent string) ([]WorkloadIfIntent, error) { //Construct key and tag to select the entry key := WorkloadIfIntentKey{ Project: project, CompositeApp: compositeapp, CompositeAppVersion: compositeappversion, + DigName: dig, NetControlIntent: netcontrolintent, WorkloadIntent: workloadintent, WorkloadIfIntent: "", @@ -167,13 +171,14 @@ func (v *WorkloadIfIntentClient) GetWorkloadIfIntents(project, compositeapp, com } // Delete the WorkloadIfIntent from database -func (v *WorkloadIfIntentClient) DeleteWorkloadIfIntent(name, project, compositeapp, compositeappversion, netcontrolintent, workloadintent string) error { +func (v *WorkloadIfIntentClient) DeleteWorkloadIfIntent(name, project, compositeapp, compositeappversion, dig, netcontrolintent, workloadintent string) error { //Construct key and tag to select the entry key := WorkloadIfIntentKey{ Project: project, CompositeApp: compositeapp, CompositeAppVersion: compositeappversion, + DigName: dig, NetControlIntent: netcontrolintent, WorkloadIntent: workloadintent, WorkloadIfIntent: name, diff --git a/src/ovnaction/pkg/module/workloadintent.go b/src/ovnaction/pkg/module/workloadintent.go index e6916954..b1ca9d02 100644 --- a/src/ovnaction/pkg/module/workloadintent.go +++ b/src/ovnaction/pkg/module/workloadintent.go @@ -39,16 +39,17 @@ type WorkloadIntentKey struct { Project string `json:"provider"` CompositeApp string `json:"compositeapp"` CompositeAppVersion string `json:"compositeappversion"` + DigName string `json:"deploymentintentgroup"` NetControlIntent string `json:"netcontrolintent"` WorkloadIntent string `json:"workloadintent"` } // Manager is an interface exposing the WorkloadIntent functionality type WorkloadIntentManager interface { - CreateWorkloadIntent(wi WorkloadIntent, project, compositeapp, compositeappversion, netcontrolintent string, exists bool) (WorkloadIntent, error) - GetWorkloadIntent(name, project, compositeapp, compositeappversion, netcontrolintent string) (WorkloadIntent, error) - GetWorkloadIntents(project, compositeapp, compositeappversion, netcontrolintent string) ([]WorkloadIntent, error) - DeleteWorkloadIntent(name, project, compositeapp, compositeappversion, netcontrolintent string) error + CreateWorkloadIntent(wi WorkloadIntent, project, compositeapp, compositeappversion, dig, netcontrolintent string, exists bool) (WorkloadIntent, error) + GetWorkloadIntent(name, project, compositeapp, compositeappversion, dig, netcontrolintent string) (WorkloadIntent, error) + GetWorkloadIntents(project, compositeapp, compositeappversion, dig, netcontrolintent string) ([]WorkloadIntent, error) + DeleteWorkloadIntent(name, project, compositeapp, compositeappversion, dig, netcontrolintent string) error } // WorkloadIntentClient implements the Manager @@ -69,25 +70,26 @@ func NewWorkloadIntentClient() *WorkloadIntentClient { } // CreateWorkloadIntent - create a new WorkloadIntent -func (v *WorkloadIntentClient) CreateWorkloadIntent(wi WorkloadIntent, project, compositeapp, compositeappversion, netcontrolintent string, exists bool) (WorkloadIntent, error) { +func (v *WorkloadIntentClient) CreateWorkloadIntent(wi WorkloadIntent, project, compositeapp, compositeappversion, dig, netcontrolintent string, exists bool) (WorkloadIntent, error) { //Construct key and tag to select the entry key := WorkloadIntentKey{ Project: project, CompositeApp: compositeapp, CompositeAppVersion: compositeappversion, + DigName: dig, NetControlIntent: netcontrolintent, WorkloadIntent: wi.Metadata.Name, } //Check if the Network Control Intent exists - _, err := NewNetControlIntentClient().GetNetControlIntent(netcontrolintent, project, compositeapp, compositeappversion) + _, err := NewNetControlIntentClient().GetNetControlIntent(netcontrolintent, project, compositeapp, compositeappversion, dig) if err != nil { return WorkloadIntent{}, pkgerrors.Errorf("Network Control Intent %v does not exist", netcontrolintent) } //Check if this WorkloadIntent already exists - _, err = v.GetWorkloadIntent(wi.Metadata.Name, project, compositeapp, compositeappversion, netcontrolintent) + _, err = v.GetWorkloadIntent(wi.Metadata.Name, project, compositeapp, compositeappversion, dig, netcontrolintent) if err == nil && !exists { return WorkloadIntent{}, pkgerrors.New("WorkloadIntent already exists") } @@ -101,13 +103,14 @@ func (v *WorkloadIntentClient) CreateWorkloadIntent(wi WorkloadIntent, project, } // GetWorkloadIntent returns the WorkloadIntent for corresponding name -func (v *WorkloadIntentClient) GetWorkloadIntent(name, project, compositeapp, compositeappversion, netcontrolintent string) (WorkloadIntent, error) { +func (v *WorkloadIntentClient) GetWorkloadIntent(name, project, compositeapp, compositeappversion, dig, netcontrolintent string) (WorkloadIntent, error) { //Construct key and tag to select the entry key := WorkloadIntentKey{ Project: project, CompositeApp: compositeapp, CompositeAppVersion: compositeappversion, + DigName: dig, NetControlIntent: netcontrolintent, WorkloadIntent: name, } @@ -131,13 +134,14 @@ func (v *WorkloadIntentClient) GetWorkloadIntent(name, project, compositeapp, co } // GetWorkloadIntentList returns all of the WorkloadIntent for corresponding name -func (v *WorkloadIntentClient) GetWorkloadIntents(project, compositeapp, compositeappversion, netcontrolintent string) ([]WorkloadIntent, error) { +func (v *WorkloadIntentClient) GetWorkloadIntents(project, compositeapp, compositeappversion, dig, netcontrolintent string) ([]WorkloadIntent, error) { //Construct key and tag to select the entry key := WorkloadIntentKey{ Project: project, CompositeApp: compositeapp, CompositeAppVersion: compositeappversion, + DigName: dig, NetControlIntent: netcontrolintent, WorkloadIntent: "", } @@ -161,13 +165,14 @@ func (v *WorkloadIntentClient) GetWorkloadIntents(project, compositeapp, composi } // Delete the WorkloadIntent from database -func (v *WorkloadIntentClient) DeleteWorkloadIntent(name, project, compositeapp, compositeappversion, netcontrolintent string) error { +func (v *WorkloadIntentClient) DeleteWorkloadIntent(name, project, compositeapp, compositeappversion, dig, netcontrolintent string) error { //Construct key and tag to select the entry key := WorkloadIntentKey{ Project: project, CompositeApp: compositeapp, CompositeAppVersion: compositeappversion, + DigName: dig, NetControlIntent: netcontrolintent, WorkloadIntent: name, } |