diff options
author | Ritu Sood <Ritu.Sood@intel.com> | 2020-09-01 21:18:45 +0000 |
---|---|---|
committer | Gerrit Code Review <gerrit@onap.org> | 2020-09-01 21:18:45 +0000 |
commit | e6277404b61f508d6af11b3e8bb067d716ba21c0 (patch) | |
tree | f146afe803c008576b07ea353a5bc05541e663db /src/ncm/pkg | |
parent | 65e4059d86a5f0dda682ebd879f409be18afa5b0 (diff) | |
parent | 645c6a331cd00043fcf9f567f5f261a9db070918 (diff) |
Merge "Enhance the status query API"
Diffstat (limited to 'src/ncm/pkg')
-rw-r--r-- | src/ncm/pkg/scheduler/scheduler.go | 35 |
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 +} |