From 645c6a331cd00043fcf9f567f5f261a9db070918 Mon Sep 17 00:00:00 2001 From: Eric Multanen Date: Wed, 12 Aug 2020 15:33:12 -0700 Subject: 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 Change-Id: Icca4cdd901e2f2b446414fade256fc24d87594cd --- src/ncm/pkg/scheduler/scheduler.go | 35 +++++++++++++++++++++++++++++++++++ 1 file changed, 35 insertions(+) (limited to 'src/ncm/pkg') 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 +} -- cgit 1.2.3-korg