summaryrefslogtreecommitdiffstats
path: root/src/ncm/pkg
diff options
context:
space:
mode:
authorEric Multanen <eric.w.multanen@intel.com>2020-08-12 15:33:12 -0700
committerEric Multanen <eric.w.multanen@intel.com>2020-08-31 15:50:06 -0700
commit645c6a331cd00043fcf9f567f5f261a9db070918 (patch)
tree3298b48aca4d93d22680960bd2a27290799b5732 /src/ncm/pkg
parentce99856834a225f6f68b6eda725ae7122a2f8185 (diff)
Enhance the status query API
This patch enhances the status query API. - The ResourceBundleState CRD is modified to just use the k8s Pod structure instead of a customized struct. - Status queries can either present results showing the rsync status of the composite app and resources or from information received from the cluster via the ResourceBundleState CR - Query parameters are provided to the API call to customize the query and response - Support for querying status of cluster network intents is added Issue-ID: MULTICLOUD-1042 Signed-off-by: Eric Multanen <eric.w.multanen@intel.com> Change-Id: Icca4cdd901e2f2b446414fade256fc24d87594cd
Diffstat (limited to 'src/ncm/pkg')
-rw-r--r--src/ncm/pkg/scheduler/scheduler.go35
1 files changed, 35 insertions, 0 deletions
diff --git a/src/ncm/pkg/scheduler/scheduler.go b/src/ncm/pkg/scheduler/scheduler.go
index f2135974..516c0525 100644
--- a/src/ncm/pkg/scheduler/scheduler.go
+++ b/src/ncm/pkg/scheduler/scheduler.go
@@ -31,6 +31,7 @@ import (
log "github.com/onap/multicloud-k8s/src/orchestrator/pkg/infra/logutils"
"github.com/onap/multicloud-k8s/src/orchestrator/pkg/module/controller"
"github.com/onap/multicloud-k8s/src/orchestrator/pkg/state"
+ "github.com/onap/multicloud-k8s/src/orchestrator/pkg/status"
pkgerrors "github.com/pkg/errors"
)
@@ -41,6 +42,7 @@ const rsyncName = "rsync"
// ClusterManager is an interface exposes the Cluster functionality
type SchedulerManager interface {
ApplyNetworkIntents(clusterProvider, cluster string) error
+ NetworkIntentsStatus(clusterProvider, cluster, qInstance, qType, qOutput string, qApps, qClusters, qResources []string) (ClusterStatus, error)
TerminateNetworkIntents(clusterProvider, cluster string) error
}
@@ -63,6 +65,11 @@ func NewSchedulerClient() *SchedulerClient {
}
}
+// ClusterStatus holds the status data prepared for cluster network intent status queries
+type ClusterStatus struct {
+ status.StatusResult `json:",inline"`
+}
+
func deleteAppContext(ac appcontext.AppContext) {
err := ac.DeleteCompositeApp()
if err != nil {
@@ -303,3 +310,31 @@ func (v *SchedulerClient) TerminateNetworkIntents(clusterProvider, cluster strin
return nil
}
+
+/*
+NetworkIntentsStatus takes in cluster provider, cluster and query parameters.
+This method is responsible obtaining the status of
+the cluster network intents, which is made available in the appcontext
+*/
+func (c SchedulerClient) NetworkIntentsStatus(clusterProvider, cluster, qInstance, qType, qOutput string, qApps, qClusters, qResources []string) (ClusterStatus, error) {
+
+ s, err := clusterPkg.NewClusterClient().GetClusterState(clusterProvider, cluster)
+ if err != nil {
+ return ClusterStatus{}, pkgerrors.Wrap(err, "cluster state not found")
+ }
+
+ // Prepare the apps list (just one hardcoded value)
+ allApps := make([]string, 0)
+ allApps = append(allApps, nettypes.CONTEXT_CLUSTER_APP)
+
+ statusResponse, err := status.PrepareStatusResult(s, allApps, qInstance, qType, qOutput, qApps, qClusters, qResources)
+ if err != nil {
+ return ClusterStatus{}, err
+ }
+ statusResponse.Name = clusterProvider + "+" + cluster
+ clStatus := ClusterStatus{
+ StatusResult: statusResponse,
+ }
+
+ return clStatus, nil
+}