summaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorEric Multanen <eric.w.multanen@intel.com>2020-05-15 07:09:16 -0700
committerEric Multanen <eric.w.multanen@intel.com>2020-05-28 17:39:06 -0700
commit7fc603a5eedcd6a84860c881a1228309a308805f (patch)
treeb0cdded3dba4522ef213e0d76b765f91ee226d38 /src
parent0a7bf256bde5dfd4c518f960a3c13b7eddb9223a (diff)
Add appcontext instructions during intent apply
Create AppContext instruction records at the app and resource levels when handling the apply api for network and providernetwork intents. Issue-ID: MULTICLOUD-1029 Signed-off-by: Eric Multanen <eric.w.multanen@intel.com> Change-Id: I3c82087273278b2503959664f0a8ee4e34eb0cd2
Diffstat (limited to 'src')
-rw-r--r--src/ncm/pkg/module/cluster.go34
1 files changed, 34 insertions, 0 deletions
diff --git a/src/ncm/pkg/module/cluster.go b/src/ncm/pkg/module/cluster.go
index 7a35eb16..5d1f577f 100644
--- a/src/ncm/pkg/module/cluster.go
+++ b/src/ncm/pkg/module/cluster.go
@@ -18,6 +18,7 @@ package module
import (
"context"
+ "encoding/json"
"time"
"github.com/onap/multicloud-k8s/src/ncm/pkg/grpc"
@@ -503,6 +504,24 @@ func (v *ClusterClient) ApplyNetworkIntents(provider, name string) error {
return pkgerrors.Wrap(err, "Error adding App to AppContext")
}
+ // Add an app order instruction
+ appinstr := struct {
+ Apporder []string `json:"apporder"`
+ }{
+ []string{CONTEXT_CLUSTER_APP},
+ }
+ jinstr, _ := json.Marshal(appinstr)
+
+ appdepinstr := struct {
+ Appdep map[string]string `json:"appdependency"`
+ }{
+ map[string]string{CONTEXT_CLUSTER_APP: "go"},
+ }
+ jdep, _ := json.Marshal(appdepinstr)
+
+ _, err = ac.AddInstruction(handle, "app", "order", string(jinstr))
+ _, err = ac.AddInstruction(handle, "app", "dependency", string(jdep))
+
// Add a cluster to the app
clusterhandle, err := ac.AddCluster(apphandle, provider+SEPARATOR+name)
if err != nil {
@@ -517,7 +536,17 @@ func (v *ClusterClient) ApplyNetworkIntents(provider, name string) error {
}
// add the resources to the app context
+
+ var orderinstr struct {
+ Resorder []string `json:"resorder"`
+ }
+ var depinstr struct {
+ Resdep map[string]string `json:"resdependency"`
+ }
+ resdep := make(map[string]string)
for _, resource := range resources {
+ orderinstr.Resorder = append(orderinstr.Resorder, resource.name)
+ resdep[resource.name] = "go"
_, err = ac.AddResource(clusterhandle, resource.name, resource.value)
if err != nil {
cleanuperr := ac.DeleteCompositeApp()
@@ -531,6 +560,11 @@ func (v *ClusterClient) ApplyNetworkIntents(provider, name string) error {
return pkgerrors.Wrap(err, "Error adding Resource to AppContext")
}
}
+ jresord, _ := json.Marshal(orderinstr)
+ depinstr.Resdep = resdep
+ jresdep, _ := json.Marshal(depinstr)
+ _, err = ac.AddInstruction(clusterhandle, "resource", "order", string(jresord))
+ _, err = ac.AddInstruction(clusterhandle, "resource", "dependency", string(jresdep))
// save the context in the cluster db record
key := ClusterKey{