...
The following figure depicts the hierarchical data store for runtime data. The notes in the figure is additional data stored in each type of node. Rsync uses this information to schedule resources. Status is updated by Rsync.
Creating AppContext
The following example shows how to create an AppContext for a CompositeApp with one App.
Code Block | ||||
---|---|---|---|---|
| ||||
func createAppContextWithOneApp(appName string)
{
context := appcontext.AppContext{}
ctxVal, err := context.InitAppContext()
if err != nil {
return nil
}
handle, err := context.CreateCompositeApp()
if err != nil {
return nil
}
appHandle, err := context.AddApp(handle, appName)
if err != nil {
return nil
}
// Iterate through cluster list and add all the clusters
for _, cluster := range clusterList {
clusterName := strings.Join([]string{cluster.ClusterProvider, "+", cluster.ClusterName}, "")
clusterHandle, err := context.AddCluster(appHandle, clusterName)
if err != nil {
return nil
}
// Add resource
_, err = context.AddResource(clusterHandle, nameofRes1, resYaml1)
if err != nil {
return nil
}
// Add resource
_, err = context.AddResource(clusterHandle, nameofRes2, resYaml2)
if err != nil {
return nil
}
// Add Resource Order
resOrder, err := json.Marshal(map[string][]string{"resorder": []string{nameofRes1, nameofRes2}})
if err != nil {
return nil
}
_, err = context.AddInstruction(clusterHandle, "resource", "order", string(resOrder))
if err != nil {
return nil
}
}
}
|
AppContext API
GoDoc: package appcontext // import "github.com/onap/multicloud-k8s/src/orchestrator/pkg/appcontext"
...