diff options
20 files changed, 299 insertions, 25 deletions
diff --git a/deployments/helm/v2/onap4k8s/clm/values.yaml b/deployments/helm/v2/onap4k8s/clm/values.yaml index 5c7bf8d4..7bbcdebe 100644 --- a/deployments/helm/v2/onap4k8s/clm/values.yaml +++ b/deployments/helm/v2/onap4k8s/clm/values.yaml @@ -23,8 +23,8 @@ global: ################################################################# # application image repository: registry.hub.docker.com -image: rtsood/emco:0.0.1 -pullPolicy: IfNotPresent +image: rtsood/emco:stable +pullPolicy: Always command: "/opt/emco/entrypoint" args: "clm" workingDir: /opt/emco diff --git a/deployments/helm/v2/onap4k8s/ncm/values.yaml b/deployments/helm/v2/onap4k8s/ncm/values.yaml index ce700e9b..e495cd61 100644 --- a/deployments/helm/v2/onap4k8s/ncm/values.yaml +++ b/deployments/helm/v2/onap4k8s/ncm/values.yaml @@ -23,8 +23,8 @@ global: ################################################################# # application image repository: registry.hub.docker.com -image: rtsood/emco:0.0.1 -pullPolicy: IfNotPresent +image: rtsood/emco:stable +pullPolicy: Always command: "/opt/emco/entrypoint" args: "ncm" workingDir: /opt/emco diff --git a/deployments/helm/v2/onap4k8s/orchestrator/values.yaml b/deployments/helm/v2/onap4k8s/orchestrator/values.yaml index 0ba1a9e8..2f8cd22b 100644 --- a/deployments/helm/v2/onap4k8s/orchestrator/values.yaml +++ b/deployments/helm/v2/onap4k8s/orchestrator/values.yaml @@ -23,8 +23,8 @@ global: ################################################################# # application image repository: registry.hub.docker.com -image: rtsood/emco:0.0.1 -pullPolicy: IfNotPresent +image: rtsood/emco:stable +pullPolicy: Always command: "/opt/emco/entrypoint" args: "orchestrator" workingDir: /opt/emco diff --git a/deployments/helm/v2/onap4k8s/ovnaction/values.yaml b/deployments/helm/v2/onap4k8s/ovnaction/values.yaml index 815f3fec..1773592f 100644 --- a/deployments/helm/v2/onap4k8s/ovnaction/values.yaml +++ b/deployments/helm/v2/onap4k8s/ovnaction/values.yaml @@ -23,8 +23,8 @@ global: ################################################################# # application image repository: registry.hub.docker.com -image: rtsood/emco:0.0.1 -pullPolicy: IfNotPresent +image: rtsood/emco:stable +pullPolicy: Always command: "/opt/emco/entrypoint" args: "ovnaction" workingDir: /opt/emco diff --git a/deployments/helm/v2/onap4k8s/rsync/values.yaml b/deployments/helm/v2/onap4k8s/rsync/values.yaml index 07e4b356..cbee8837 100644 --- a/deployments/helm/v2/onap4k8s/rsync/values.yaml +++ b/deployments/helm/v2/onap4k8s/rsync/values.yaml @@ -23,8 +23,8 @@ global: ################################################################# # application image repository: registry.hub.docker.com -image: rtsood/emco:0.0.1 -pullPolicy: IfNotPresent +image: rtsood/emco:stable +pullPolicy: Always command: "/opt/emco/entrypoint" args: "rsync" workingDir: /opt/emco diff --git a/deployments/kubernetes/Readme.md b/deployments/kubernetes/Readme.md index de082135..b5a99a65 100644 --- a/deployments/kubernetes/Readme.md +++ b/deployments/kubernetes/Readme.md @@ -12,3 +12,12 @@ **3. create ONAP4K8s v2 Microservices** `$ kubectl apply -f onap4k8s.yaml -n onap4k8s` + +### Steps to cleanup packages +**1. Cleanup ONAP4K8s v2 Microservies** + +`$ kubectl delete -f onap4k8s.yaml -n onap4k8s` + +**2. Cleanup v2 Microservices for Etcd and Mongo** + +`$ kubectl delete -f onap4k8sdb.yaml -n onap4k8s` diff --git a/deployments/kubernetes/onap4k8s.yaml b/deployments/kubernetes/onap4k8s.yaml index c27b9042..cbd21898 100644 --- a/deployments/kubernetes/onap4k8s.yaml +++ b/deployments/kubernetes/onap4k8s.yaml @@ -53,8 +53,8 @@ spec: spec: containers: - name: orchestrator - image: rtsood/emco:0.0.1 - imagePullPolicy: IfNotPresent + image: rtsood/emco:stable + imagePullPolicy: Always command: ["/opt/emco/entrypoint", "orchestrator"] workingDir: /opt/emco ports: @@ -125,8 +125,8 @@ spec: spec: containers: - name: ncm - image: rtsood/emco:0.0.1 - imagePullPolicy: IfNotPresent + image: rtsood/emco:stable + imagePullPolicy: Always command: ["/opt/emco/entrypoint", "ncm"] workingDir: /opt/emco ports: @@ -195,8 +195,8 @@ spec: spec: containers: - name: rsync - image: rtsood/emco:0.0.1 - imagePullPolicy: IfNotPresent + image: rtsood/emco:stable + imagePullPolicy: Always command: ["/opt/emco/entrypoint", "rsync"] workingDir: /opt/emco ports: @@ -270,8 +270,8 @@ spec: spec: containers: - name: ovnaction - image: rtsood/emco:0.0.1 - imagePullPolicy: IfNotPresent + image: rtsood/emco:stable + imagePullPolicy: Always command: ["/opt/emco/entrypoint", "ovnaction"] workingDir: /opt/emco ports: @@ -343,8 +343,8 @@ spec: spec: containers: - name: clm - image: rtsood/emco:0.0.1 - imagePullPolicy: IfNotPresent + image: rtsood/emco:stable + imagePullPolicy: Always command: ["/opt/emco/entrypoint", "clm"] workingDir: /opt/emco ports: diff --git a/kud/hosting_providers/vagrant/README.md b/kud/hosting_providers/vagrant/README.md index f0210149..3d0766b3 100644 --- a/kud/hosting_providers/vagrant/README.md +++ b/kud/hosting_providers/vagrant/README.md @@ -23,6 +23,14 @@ its usage. This script supports two Virtualization technologies $ sudo ./setup.sh -p libvirt +There is a `default.yml` in the `./config` directory which creates multiple controllers and nodes. +There are also sample configurations in the `./config/samples` directory. To use one of the samples, +copy it into the `./config` directory as `pdf.yml`. If a `pdf.yml` exists in the `./config` +directory it overrides the `default.yml` when the `vagrant up` command (in the next step) is run. +For example: + + $ cp ./config/samples/pdf.yml.aio ./config/pdf.yml + Once Vagrant is installed, it's possible to provision a cluster using the following instructions: diff --git a/kud/hosting_providers/vagrant/setup.sh b/kud/hosting_providers/vagrant/setup.sh index 00b6e86f..79bf60c4 100755 --- a/kud/hosting_providers/vagrant/setup.sh +++ b/kud/hosting_providers/vagrant/setup.sh @@ -107,7 +107,7 @@ case ${ID,,} in case $VAGRANT_DEFAULT_PROVIDER in virtualbox) - echo "deb http://download.virtualbox.org/virtualbox/debian trusty contrib" >> /etc/apt/sources.list + echo "deb http://download.virtualbox.org/virtualbox/debian bionic contrib" >> /etc/apt/sources.list wget -q https://www.virtualbox.org/download/oracle_vbox_2016.asc -O- | sudo apt-key add - wget -q https://www.virtualbox.org/download/oracle_vbox.asc -O- | sudo apt-key add - packages+=(virtualbox-5.1 dkms) diff --git a/src/orchestrator/api/api.go b/src/orchestrator/api/api.go index 5abbb96d..097b9ab3 100644 --- a/src/orchestrator/api/api.go +++ b/src/orchestrator/api/api.go @@ -57,6 +57,7 @@ func NewRouter(projectClient moduleLib.ProjectManager, } router.HandleFunc("/projects", projHandler.createHandler).Methods("POST") router.HandleFunc("/projects/{project-name}", projHandler.getHandler).Methods("GET") + router.HandleFunc("/projects", projHandler.getHandler).Methods("GET") router.HandleFunc("/projects/{project-name}", projHandler.deleteHandler).Methods("DELETE") //setting routes for compositeApp @@ -68,6 +69,7 @@ func NewRouter(projectClient moduleLib.ProjectManager, } router.HandleFunc("/projects/{project-name}/composite-apps", compAppHandler.createHandler).Methods("POST") router.HandleFunc("/projects/{project-name}/composite-apps/{composite-app-name}/{version}", compAppHandler.getHandler).Methods("GET") + router.HandleFunc("/projects/{project-name}/composite-apps", compAppHandler.getAllCompositeAppsHandler).Methods("GET") router.HandleFunc("/projects/{project-name}/composite-apps/{composite-app-name}/{version}", compAppHandler.deleteHandler).Methods("DELETE") if appClient == nil { @@ -126,7 +128,11 @@ func NewRouter(projectClient moduleLib.ProjectManager, client: genericPlacementIntentClient, } router.HandleFunc("/projects/{project-name}/composite-apps/{composite-app-name}/{composite-app-version}/generic-placement-intents", genericPlacementIntentHandler.createGenericPlacementIntentHandler).Methods("POST") + router.HandleFunc("/projects/{project-name}/composite-apps/{composite-app-name}/{composite-app-version}/generic-placement-intents/{intent-name}", genericPlacementIntentHandler.getGenericPlacementHandler).Methods("GET") + + router.HandleFunc("/projects/{project-name}/composite-apps/{composite-app-name}/{composite-app-version}/generic-placement-intents", genericPlacementIntentHandler.getAllGenericPlacementIntentsHandler).Methods("GET") + router.HandleFunc("/projects/{project-name}/composite-apps/{composite-app-name}/{composite-app-version}/generic-placement-intents/{intent-name}", genericPlacementIntentHandler.deleteGenericPlacementHandler).Methods("DELETE") //setting routes for AppIntent @@ -153,6 +159,9 @@ func NewRouter(projectClient moduleLib.ProjectManager, } router.HandleFunc("/projects/{project-name}/composite-apps/{composite-app-name}/{composite-app-version}/deployment-intent-groups", deploymentIntentGrpHandler.createDeploymentIntentGroupHandler).Methods("POST") router.HandleFunc("/projects/{project-name}/composite-apps/{composite-app-name}/{composite-app-version}/deployment-intent-groups/{deployment-intent-group-name}", deploymentIntentGrpHandler.getDeploymentIntentGroupHandler).Methods("GET") + + router.HandleFunc("/projects/{project-name}/composite-apps/{composite-app-name}/{composite-app-version}/deployment-intent-groups", deploymentIntentGrpHandler.getAllDeploymentIntentGroupsHandler).Methods("GET") + router.HandleFunc("/projects/{project-name}/composite-apps/{composite-app-name}/{composite-app-version}/deployment-intent-groups/{deployment-intent-group-name}", deploymentIntentGrpHandler.deleteDeploymentIntentGroupHandler).Methods("DELETE") // setting routes for AddingIntents diff --git a/src/orchestrator/api/composite_app_handler.go b/src/orchestrator/api/composite_app_handler.go index b54c488e..ab052f00 100644 --- a/src/orchestrator/api/composite_app_handler.go +++ b/src/orchestrator/api/composite_app_handler.go @@ -95,6 +95,32 @@ func (h compositeAppHandler) getHandler(w http.ResponseWriter, r *http.Request) } } +// getAllCompositeAppsHandler handles the GetAllComppositeApps, returns a list of compositeApps under a project +func (h compositeAppHandler) getAllCompositeAppsHandler(w http.ResponseWriter, r *http.Request) { + vars := mux.Vars(r) + pName := vars["project-name"] + + var caList []moduleLib.CompositeApp + + cApps, err := h.client.GetAllCompositeApps(pName) + if err != nil { + http.Error(w, err.Error(), http.StatusNotFound) + return + } + + for _, cApp := range cApps { + caList = append(caList, moduleLib.CompositeApp{Metadata: cApp.Metadata, Spec: cApp.Spec}) + } + w.Header().Set("Content-Type", "application/json") + w.WriteHeader(http.StatusOK) + err = json.NewEncoder(w).Encode(caList) + if err != nil { + http.Error(w, err.Error(), http.StatusNotFound) + return + } + return +} + // deleteHandler handles DELETE operations on a particular CompositeApp Name func (h compositeAppHandler) deleteHandler(w http.ResponseWriter, r *http.Request) { vars := mux.Vars(r) diff --git a/src/orchestrator/api/deployment_intent_groups_handler.go b/src/orchestrator/api/deployment_intent_groups_handler.go index 3f5b3969..7620737b 100644 --- a/src/orchestrator/api/deployment_intent_groups_handler.go +++ b/src/orchestrator/api/deployment_intent_groups_handler.go @@ -22,6 +22,7 @@ import ( "net/http" moduleLib "github.com/onap/multicloud-k8s/src/orchestrator/pkg/module" + "github.com/onap/multicloud-k8s/src/orchestrator/pkg/infra/validation" "github.com/gorilla/mux" ) @@ -116,6 +117,31 @@ func (h deploymentIntentGroupHandler) getDeploymentIntentGroupHandler(w http.Res } +func (h deploymentIntentGroupHandler) getAllDeploymentIntentGroupsHandler(w http.ResponseWriter, r *http.Request) { + vars := mux.Vars(r) + pList := []string{"project-name", "composite-app-name", "composite-app-version"} + err := validation.IsValidParameterPresent(vars, pList) + if err != nil { + http.Error(w, err.Error(), http.StatusBadRequest) + } + p := vars["project-name"] + ca := vars["composite-app-name"] + v := vars["composite-app-version"] + + diList, err := h.client.GetAllDeploymentIntentGroups(p, ca, v) + if err != nil { + http.Error(w, err.Error(), http.StatusNotFound) + return + } + w.Header().Set("Content-Type", "application/json") + w.WriteHeader(http.StatusOK) + err = json.NewEncoder(w).Encode(diList) + if err != nil { + http.Error(w, err.Error(), http.StatusNotFound) + return + } +} + func (h deploymentIntentGroupHandler) deleteDeploymentIntentGroupHandler(w http.ResponseWriter, r *http.Request) { vars := mux.Vars(r) diff --git a/src/orchestrator/api/generic_placement_intent_handler.go b/src/orchestrator/api/generic_placement_intent_handler.go index e186735c..02dbf0be 100644 --- a/src/orchestrator/api/generic_placement_intent_handler.go +++ b/src/orchestrator/api/generic_placement_intent_handler.go @@ -21,6 +21,7 @@ import ( "io" "net/http" + "github.com/onap/multicloud-k8s/src/orchestrator/pkg/infra/validation" moduleLib "github.com/onap/multicloud-k8s/src/orchestrator/pkg/module" "github.com/gorilla/mux" @@ -113,6 +114,31 @@ func (h genericPlacementIntentHandler) getGenericPlacementHandler(w http.Respons } } +func (h genericPlacementIntentHandler) getAllGenericPlacementIntentsHandler(w http.ResponseWriter, r *http.Request) { + vars := mux.Vars(r) + pList := []string{"project-name", "composite-app-name", "composite-app-version"} + err := validation.IsValidParameterPresent(vars, pList) + if err != nil { + http.Error(w, err.Error(), http.StatusBadRequest) + } + p := vars["project-name"] + ca := vars["composite-app-name"] + v := vars["composite-app-version"] + + gpList, err := h.client.GetAllGenericPlacementIntents(p, ca, v) + if err != nil { + http.Error(w, err.Error(), http.StatusNotFound) + return + } + w.Header().Set("Content-Type", "application/json") + w.WriteHeader(http.StatusOK) + err = json.NewEncoder(w).Encode(gpList) + if err != nil { + http.Error(w, err.Error(), http.StatusNotFound) + return + } +} + // deleteGenericPlacementHandler handles the delete operations on intent func (h genericPlacementIntentHandler) deleteGenericPlacementHandler(w http.ResponseWriter, r *http.Request) { vars := mux.Vars(r) diff --git a/src/orchestrator/api/projecthandler.go b/src/orchestrator/api/projecthandler.go index 1e78c676..09b24096 100644 --- a/src/orchestrator/api/projecthandler.go +++ b/src/orchestrator/api/projecthandler.go @@ -75,6 +75,31 @@ func (h projectHandler) getHandler(w http.ResponseWriter, r *http.Request) { vars := mux.Vars(r) name := vars["project-name"] + // handle for get all projects + if len(name) == 0 { + var pList []moduleLib.Project + + projects, err := h.client.GetAllProjects() + if err != nil { + http.Error(w, err.Error(), http.StatusInternalServerError) + return + } + + for _, p := range projects { + pList = append(pList, moduleLib.Project{MetaData: p.MetaData}) + } + + w.Header().Set("Content-Type", "application/json") + w.WriteHeader(http.StatusOK) + err = json.NewEncoder(w).Encode(pList) + if err != nil { + http.Error(w, err.Error(), http.StatusInternalServerError) + return + } + return + + } + ret, err := h.client.GetProject(name) if err != nil { http.Error(w, err.Error(), http.StatusInternalServerError) diff --git a/src/orchestrator/api/projecthandler_test.go b/src/orchestrator/api/projecthandler_test.go index 0212e57a..dae87e2b 100644 --- a/src/orchestrator/api/projecthandler_test.go +++ b/src/orchestrator/api/projecthandler_test.go @@ -60,6 +60,10 @@ func (m *mockProjectManager) DeleteProject(name string) error { return m.Err } +func (m *mockProjectManager) GetAllProjects() ([]moduleLib.Project, error) { + return []moduleLib.Project{}, m.Err +} + func TestProjectCreateHandler(t *testing.T) { testCases := []struct { label string diff --git a/src/orchestrator/pkg/module/compositeapp.go b/src/orchestrator/pkg/module/compositeapp.go index 70502367..5bf7ddec 100644 --- a/src/orchestrator/pkg/module/compositeapp.go +++ b/src/orchestrator/pkg/module/compositeapp.go @@ -64,6 +64,7 @@ func (cK CompositeAppKey) String() string { type CompositeAppManager interface { CreateCompositeApp(c CompositeApp, p string) (CompositeApp, error) GetCompositeApp(name string, version string, p string) (CompositeApp, error) + GetAllCompositeApps(p string) ([]CompositeApp, error) DeleteCompositeApp(name string, version string, p string) error } @@ -140,6 +141,38 @@ func (v *CompositeAppClient) GetCompositeApp(name string, version string, p stri return CompositeApp{}, pkgerrors.New("Error getting composite application") } +// GetAllCompositeApps returns all the compositeApp for a given project +func (v *CompositeAppClient) GetAllCompositeApps(p string) ([]CompositeApp, error) { + + _, err := NewProjectClient().GetProject(p) + if err != nil { + return []CompositeApp{}, pkgerrors.New("Unable to find the project") + } + + key := CompositeAppKey{ + CompositeAppName: "", + Version: "", + Project: p, + } + + var caList []CompositeApp + values, err := db.DBconn.Find(v.storeName, key, v.tagMeta) + if err != nil { + return []CompositeApp{}, pkgerrors.Wrap(err, "Getting CompositeApps") + } + + for _, value := range values { + ca := CompositeApp{} + err = db.DBconn.Unmarshal(value, &ca) + if err != nil { + return []CompositeApp{}, pkgerrors.Wrap(err, "Unmarshaling CompositeApp") + } + caList = append(caList, ca) + } + + return caList, nil +} + // DeleteCompositeApp deletes the CompositeApp from database func (v *CompositeAppClient) DeleteCompositeApp(name string, version string, p string) error { diff --git a/src/orchestrator/pkg/module/deployment_intent_groups.go b/src/orchestrator/pkg/module/deployment_intent_groups.go index 0decb68f..c7237032 100644 --- a/src/orchestrator/pkg/module/deployment_intent_groups.go +++ b/src/orchestrator/pkg/module/deployment_intent_groups.go @@ -64,6 +64,7 @@ type DeploymentIntentGroupManager interface { GetDeploymentIntentGroup(di string, p string, ca string, v string) (DeploymentIntentGroup, error) GetDeploymentIntentGroupContext(di string, p string, ca string, v string) (appcontext.AppContext, string, error) DeleteDeploymentIntentGroup(di string, p string, ca string, v string) error + GetAllDeploymentIntentGroups(p string, ca string, v string) ([]DeploymentIntentGroup, error) } // DeploymentIntentGroupKey consists of Name of the deployment group, project name, CompositeApp name, CompositeApp version @@ -106,7 +107,7 @@ func (c *DeploymentIntentGroupClient) CreateDeploymentIntentGroup(d DeploymentIn res, err := c.GetDeploymentIntentGroup(d.MetaData.Name, p, ca, v) if !reflect.DeepEqual(res, DeploymentIntentGroup{}) { - return DeploymentIntentGroup{}, pkgerrors.New("AppIntent already exists") + return DeploymentIntentGroup{}, pkgerrors.New("DeploymentIntent already exists") } //Check if project exists @@ -164,7 +165,47 @@ func (c *DeploymentIntentGroupClient) GetDeploymentIntentGroup(di string, p stri } -// GetDeploymentIntentGroup returns the DeploymentIntentGroup with a given name, project, compositeApp and version of compositeApp +// GetAllDeploymentIntentGroups returns all the deploymentIntentGroups under a specific project, compositeApp and version +func (c *DeploymentIntentGroupClient) GetAllDeploymentIntentGroups(p string, ca string, v string) ([]DeploymentIntentGroup, error) { + + key := DeploymentIntentGroupKey{ + Name: "", + Project: p, + CompositeApp: ca, + Version: v, + } + + //Check if project exists + _, err := NewProjectClient().GetProject(p) + if err != nil { + return []DeploymentIntentGroup{}, pkgerrors.Wrap(err, "Unable to find the project") + } + + //check if compositeApp exists + _, err = NewCompositeAppClient().GetCompositeApp(ca, v, p) + if err != nil { + return []DeploymentIntentGroup{}, pkgerrors.Wrap(err, "Unable to find the composite-app, check CompositeAppName and Version") + } + var diList []DeploymentIntentGroup + result, err := db.DBconn.Find(c.storeName, key, c.tagMetaData) + if err != nil { + return []DeploymentIntentGroup{}, pkgerrors.Wrap(err, "Get DeploymentIntentGroup error") + } + + for _, value := range result { + di := DeploymentIntentGroup{} + err = db.DBconn.Unmarshal(value, &di) + if err != nil { + return []DeploymentIntentGroup{}, pkgerrors.Wrap(err, "Unmarshaling DeploymentIntentGroup") + } + diList = append(diList, di) + } + + return diList, nil + +} + +// GetDeploymentIntentGroupContext returns the AppContent with a given DeploymentIntentname, project, compositeAppName and version of compositeApp func (c *DeploymentIntentGroupClient) GetDeploymentIntentGroupContext(di string, p string, ca string, v string) (appcontext.AppContext, string, error) { key := DeploymentIntentGroupKey{ diff --git a/src/orchestrator/pkg/module/generic_placement_intent.go b/src/orchestrator/pkg/module/generic_placement_intent.go index 73849474..fb00a6ab 100644 --- a/src/orchestrator/pkg/module/generic_placement_intent.go +++ b/src/orchestrator/pkg/module/generic_placement_intent.go @@ -50,6 +50,8 @@ type GenericPlacementIntentManager interface { compositeAppName string, version string) (GenericPlacementIntent, error) DeleteGenericPlacementIntent(intentName string, projectName string, compositeAppName string, version string) error + + GetAllGenericPlacementIntents(p string, ca string, v string) ([]GenericPlacementIntent, error) } // GenericPlacementIntentKey is used as the primary key @@ -148,6 +150,47 @@ func (c *GenericPlacementIntentClient) GetGenericPlacementIntent(i string, p str } +// GetAllGenericPlacementIntents returns all the generic placement intents for a given compsoite app name, composite app version and project. +func (c *GenericPlacementIntentClient) GetAllGenericPlacementIntents(p string, ca string, v string) ([]GenericPlacementIntent, error) { + + //Check if project exists + _, err := NewProjectClient().GetProject(p) + if err != nil { + return []GenericPlacementIntent{}, pkgerrors.Wrap(err, "Unable to find the project") + } + + // check if compositeApp exists + _, err = NewCompositeAppClient().GetCompositeApp(ca, v, p) + if err != nil { + return []GenericPlacementIntent{}, pkgerrors.Wrap(err, "Unable to find the composite-app, check compositeApp name and version") + } + + key := GenericPlacementIntentKey{ + Name: "", + Project: p, + CompositeApp: ca, + Version: v, + } + + var gpList []GenericPlacementIntent + values, err := db.DBconn.Find(c.storeName, key, c.tagMetaData) + if err != nil { + return []GenericPlacementIntent{}, pkgerrors.Wrap(err, "Getting GenericPlacementIntent") + } + + for _, value := range values { + gp := GenericPlacementIntent{} + err = db.DBconn.Unmarshal(value, &gp) + if err != nil { + return []GenericPlacementIntent{}, pkgerrors.Wrap(err, "Unmarshaling GenericPlacementIntent") + } + gpList = append(gpList, gp) + } + + return gpList, nil + +} + // DeleteGenericPlacementIntent the intent from the database func (c *GenericPlacementIntentClient) DeleteGenericPlacementIntent(i string, p string, ca string, v string) error { key := GenericPlacementIntentKey{ diff --git a/src/orchestrator/pkg/module/project.go b/src/orchestrator/pkg/module/project.go index a6f59254..02f6d827 100644 --- a/src/orchestrator/pkg/module/project.go +++ b/src/orchestrator/pkg/module/project.go @@ -58,6 +58,7 @@ type ProjectManager interface { CreateProject(pr Project) (Project, error) GetProject(name string) (Project, error) DeleteProject(name string) error + GetAllProjects() ([]Project, error) } // ProjectClient implements the ProjectManager @@ -123,6 +124,29 @@ func (v *ProjectClient) GetProject(name string) (Project, error) { return Project{}, pkgerrors.New("Error getting Project") } +// GetAllProjects returns all the projects +func (v *ProjectClient) GetAllProjects() ([]Project, error) { + key := ProjectKey{ + ProjectName: "", + } + + var res []Project + values, err := db.DBconn.Find(v.storeName, key, v.tagMeta) + if err != nil { + + } + + for _, value := range values { + p := Project{} + err = db.DBconn.Unmarshal(value, &p) + if err != nil { + return []Project{}, pkgerrors.Wrap(err, "Unmarshaling Project") + } + res = append(res, p) + } + return res, nil +} + // DeleteProject the Project from database func (v *ProjectClient) DeleteProject(name string) error { diff --git a/src/rsync/pkg/context/context.go b/src/rsync/pkg/context/context.go index 530802ab..cc7773b8 100644 --- a/src/rsync/pkg/context/context.go +++ b/src/rsync/pkg/context/context.go @@ -74,7 +74,7 @@ func terminateResource(ac appcontext.AppContext, c *kubeclient.Client, name stri } logutils.Info("Deleted::", logutils.Fields{ "cluster": cluster, - "resource": res, + "resource": name, }) return nil } @@ -124,7 +124,7 @@ func instantiateResource(ac appcontext.AppContext, c *kubeclient.Client, name st } logutils.Info("Installed::", logutils.Fields{ "cluster": cluster, - "resource": res, + "resource": name, }) return nil } |