aboutsummaryrefslogtreecommitdiffstats
path: root/src/ncm/pkg/scheduler/scheduler.go
diff options
context:
space:
mode:
Diffstat (limited to 'src/ncm/pkg/scheduler/scheduler.go')
-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
+}