aboutsummaryrefslogtreecommitdiffstats
path: root/vnfs/DAaaS/collectd-operator/pkg
diff options
context:
space:
mode:
authorDileep Ranganathan <dileep.ranganathan@intel.com>2019-05-30 12:38:37 -0700
committerDileep Ranganathan <dileep.ranganathan@intel.com>2019-05-30 21:11:52 +0000
commit3d5a3e06530c1250d48f7d838c619f3bfbcd019d (patch)
tree349e370c43ce7318b3f7eb7736345de6872cbef2 /vnfs/DAaaS/collectd-operator/pkg
parent31802660dfe74a8671ae29789f0018f0f887ea1a (diff)
Refactor Distributed Analytics project structure
Modified the project structure to improve maintainability and to add future CI and integration test support. Change-Id: Id30bfb1f83f23785a6b5f99e81f42f752d59c0f8 Issue-ID: ONAPARC-280 Signed-off-by: Dileep Ranganathan <dileep.ranganathan@intel.com>
Diffstat (limited to 'vnfs/DAaaS/collectd-operator/pkg')
-rw-r--r--vnfs/DAaaS/collectd-operator/pkg/apis/addtoscheme_onap_v1alpha1.go10
-rw-r--r--vnfs/DAaaS/collectd-operator/pkg/apis/apis.go13
-rw-r--r--vnfs/DAaaS/collectd-operator/pkg/apis/onap/v1alpha1/collectdplugin_types.go56
-rw-r--r--vnfs/DAaaS/collectd-operator/pkg/apis/onap/v1alpha1/doc.go4
-rw-r--r--vnfs/DAaaS/collectd-operator/pkg/apis/onap/v1alpha1/register.go19
-rw-r--r--vnfs/DAaaS/collectd-operator/pkg/apis/onap/v1alpha1/zz_generated.deepcopy.go108
-rw-r--r--vnfs/DAaaS/collectd-operator/pkg/apis/onap/v1alpha1/zz_generated.openapi.go124
-rw-r--r--vnfs/DAaaS/collectd-operator/pkg/controller/add_collectdplugin.go10
-rw-r--r--vnfs/DAaaS/collectd-operator/pkg/controller/collectdplugin/collectdplugin_controller.go215
-rw-r--r--vnfs/DAaaS/collectd-operator/pkg/controller/controller.go18
10 files changed, 0 insertions, 577 deletions
diff --git a/vnfs/DAaaS/collectd-operator/pkg/apis/addtoscheme_onap_v1alpha1.go b/vnfs/DAaaS/collectd-operator/pkg/apis/addtoscheme_onap_v1alpha1.go
deleted file mode 100644
index 711a1182..00000000
--- a/vnfs/DAaaS/collectd-operator/pkg/apis/addtoscheme_onap_v1alpha1.go
+++ /dev/null
@@ -1,10 +0,0 @@
-package apis
-
-import (
- "demo/vnfs/DAaaS/collectd-operator/pkg/apis/onap/v1alpha1"
-)
-
-func init() {
- // Register the types with the Scheme so the components can map objects to GroupVersionKinds and back
- AddToSchemes = append(AddToSchemes, v1alpha1.SchemeBuilder.AddToScheme)
-}
diff --git a/vnfs/DAaaS/collectd-operator/pkg/apis/apis.go b/vnfs/DAaaS/collectd-operator/pkg/apis/apis.go
deleted file mode 100644
index 07dc9616..00000000
--- a/vnfs/DAaaS/collectd-operator/pkg/apis/apis.go
+++ /dev/null
@@ -1,13 +0,0 @@
-package apis
-
-import (
- "k8s.io/apimachinery/pkg/runtime"
-)
-
-// AddToSchemes may be used to add all resources defined in the project to a Scheme
-var AddToSchemes runtime.SchemeBuilder
-
-// AddToScheme adds all Resources to the Scheme
-func AddToScheme(s *runtime.Scheme) error {
- return AddToSchemes.AddToScheme(s)
-}
diff --git a/vnfs/DAaaS/collectd-operator/pkg/apis/onap/v1alpha1/collectdplugin_types.go b/vnfs/DAaaS/collectd-operator/pkg/apis/onap/v1alpha1/collectdplugin_types.go
deleted file mode 100644
index d29498e8..00000000
--- a/vnfs/DAaaS/collectd-operator/pkg/apis/onap/v1alpha1/collectdplugin_types.go
+++ /dev/null
@@ -1,56 +0,0 @@
-package v1alpha1
-
-import (
- corev1 "k8s.io/api/core/v1"
- metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
-)
-
-// EDIT THIS FILE! THIS IS SCAFFOLDING FOR YOU TO OWN!
-// NOTE: json tags are required. Any new fields you add must have json tags for the fields to be serialized.
-
-// CollectdPluginSpec defines the desired state of CollectdPlugin
-// +k8s:openapi-gen=true
-type CollectdPluginSpec struct {
- // INSERT ADDITIONAL SPEC FIELDS - desired state of cluster
- // Important: Run "operator-sdk generate k8s" to regenerate code after modifying this file
- // Add custom validation using kubebuilder tags: https://book.kubebuilder.io/beyond_basics/generating_crd.html
- PluginName string `json:"pluginName"`
- PluginConf string `json:"pluginConf"`
-}
-
-// CollectdPluginStatus defines the observed state of CollectdPlugin
-// +k8s:openapi-gen=true
-type CollectdPluginStatus struct {
- // INSERT ADDITIONAL STATUS FIELD - define observed state of cluster
- // Important: Run "operator-sdk generate k8s" to regenerate code after modifying this file
- // Add custom validation using kubebuilder tags: https://book.kubebuilder.io/beyond_basics/generating_crd.html
- // CollectdAgents are the collectd pods in the Daemonset
- CollectdAgents []string `json:"collectdAgents"`
- CollectdConf corev1.ConfigMap `json:"collectdConf"`
-}
-
-// +k8s:deepcopy-gen:interfaces=k8s.io/apimachinery/pkg/runtime.Object
-
-// CollectdPlugin is the Schema for the collectdplugins API
-// +k8s:openapi-gen=true
-// +kubebuilder:subresource:status
-type CollectdPlugin struct {
- metav1.TypeMeta `json:",inline"`
- metav1.ObjectMeta `json:"metadata,omitempty"`
-
- Spec CollectdPluginSpec `json:"spec,omitempty"`
- Status CollectdPluginStatus `json:"status,omitempty"`
-}
-
-// +k8s:deepcopy-gen:interfaces=k8s.io/apimachinery/pkg/runtime.Object
-
-// CollectdPluginList contains a list of CollectdPlugin
-type CollectdPluginList struct {
- metav1.TypeMeta `json:",inline"`
- metav1.ListMeta `json:"metadata,omitempty"`
- Items []CollectdPlugin `json:"items"`
-}
-
-func init() {
- SchemeBuilder.Register(&CollectdPlugin{}, &CollectdPluginList{})
-}
diff --git a/vnfs/DAaaS/collectd-operator/pkg/apis/onap/v1alpha1/doc.go b/vnfs/DAaaS/collectd-operator/pkg/apis/onap/v1alpha1/doc.go
deleted file mode 100644
index 29b3493e..00000000
--- a/vnfs/DAaaS/collectd-operator/pkg/apis/onap/v1alpha1/doc.go
+++ /dev/null
@@ -1,4 +0,0 @@
-// Package v1alpha1 contains API Schema definitions for the onap v1alpha1 API group
-// +k8s:deepcopy-gen=package,register
-// +groupName=onap.org
-package v1alpha1
diff --git a/vnfs/DAaaS/collectd-operator/pkg/apis/onap/v1alpha1/register.go b/vnfs/DAaaS/collectd-operator/pkg/apis/onap/v1alpha1/register.go
deleted file mode 100644
index c670eea4..00000000
--- a/vnfs/DAaaS/collectd-operator/pkg/apis/onap/v1alpha1/register.go
+++ /dev/null
@@ -1,19 +0,0 @@
-// NOTE: Boilerplate only. Ignore this file.
-
-// Package v1alpha1 contains API Schema definitions for the onap v1alpha1 API group
-// +k8s:deepcopy-gen=package,register
-// +groupName=onap.org
-package v1alpha1
-
-import (
- "k8s.io/apimachinery/pkg/runtime/schema"
- "sigs.k8s.io/controller-runtime/pkg/runtime/scheme"
-)
-
-var (
- // SchemeGroupVersion is group version used to register these objects
- SchemeGroupVersion = schema.GroupVersion{Group: "onap.org", Version: "v1alpha1"}
-
- // SchemeBuilder is used to add go types to the GroupVersionKind scheme
- SchemeBuilder = &scheme.Builder{GroupVersion: SchemeGroupVersion}
-)
diff --git a/vnfs/DAaaS/collectd-operator/pkg/apis/onap/v1alpha1/zz_generated.deepcopy.go b/vnfs/DAaaS/collectd-operator/pkg/apis/onap/v1alpha1/zz_generated.deepcopy.go
deleted file mode 100644
index 0fe1dcc3..00000000
--- a/vnfs/DAaaS/collectd-operator/pkg/apis/onap/v1alpha1/zz_generated.deepcopy.go
+++ /dev/null
@@ -1,108 +0,0 @@
-// +build !ignore_autogenerated
-
-// Code generated by deepcopy-gen. DO NOT EDIT.
-
-package v1alpha1
-
-import (
- runtime "k8s.io/apimachinery/pkg/runtime"
-)
-
-// DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil.
-func (in *CollectdPlugin) DeepCopyInto(out *CollectdPlugin) {
- *out = *in
- out.TypeMeta = in.TypeMeta
- in.ObjectMeta.DeepCopyInto(&out.ObjectMeta)
- out.Spec = in.Spec
- in.Status.DeepCopyInto(&out.Status)
- return
-}
-
-// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new CollectdPlugin.
-func (in *CollectdPlugin) DeepCopy() *CollectdPlugin {
- if in == nil {
- return nil
- }
- out := new(CollectdPlugin)
- in.DeepCopyInto(out)
- return out
-}
-
-// DeepCopyObject is an autogenerated deepcopy function, copying the receiver, creating a new runtime.Object.
-func (in *CollectdPlugin) DeepCopyObject() runtime.Object {
- if c := in.DeepCopy(); c != nil {
- return c
- }
- return nil
-}
-
-// DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil.
-func (in *CollectdPluginList) DeepCopyInto(out *CollectdPluginList) {
- *out = *in
- out.TypeMeta = in.TypeMeta
- out.ListMeta = in.ListMeta
- if in.Items != nil {
- in, out := &in.Items, &out.Items
- *out = make([]CollectdPlugin, len(*in))
- for i := range *in {
- (*in)[i].DeepCopyInto(&(*out)[i])
- }
- }
- return
-}
-
-// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new CollectdPluginList.
-func (in *CollectdPluginList) DeepCopy() *CollectdPluginList {
- if in == nil {
- return nil
- }
- out := new(CollectdPluginList)
- in.DeepCopyInto(out)
- return out
-}
-
-// DeepCopyObject is an autogenerated deepcopy function, copying the receiver, creating a new runtime.Object.
-func (in *CollectdPluginList) DeepCopyObject() runtime.Object {
- if c := in.DeepCopy(); c != nil {
- return c
- }
- return nil
-}
-
-// DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil.
-func (in *CollectdPluginSpec) DeepCopyInto(out *CollectdPluginSpec) {
- *out = *in
- return
-}
-
-// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new CollectdPluginSpec.
-func (in *CollectdPluginSpec) DeepCopy() *CollectdPluginSpec {
- if in == nil {
- return nil
- }
- out := new(CollectdPluginSpec)
- in.DeepCopyInto(out)
- return out
-}
-
-// DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil.
-func (in *CollectdPluginStatus) DeepCopyInto(out *CollectdPluginStatus) {
- *out = *in
- if in.CollectdAgents != nil {
- in, out := &in.CollectdAgents, &out.CollectdAgents
- *out = make([]string, len(*in))
- copy(*out, *in)
- }
- in.CollectdConf.DeepCopyInto(&out.CollectdConf)
- return
-}
-
-// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new CollectdPluginStatus.
-func (in *CollectdPluginStatus) DeepCopy() *CollectdPluginStatus {
- if in == nil {
- return nil
- }
- out := new(CollectdPluginStatus)
- in.DeepCopyInto(out)
- return out
-}
diff --git a/vnfs/DAaaS/collectd-operator/pkg/apis/onap/v1alpha1/zz_generated.openapi.go b/vnfs/DAaaS/collectd-operator/pkg/apis/onap/v1alpha1/zz_generated.openapi.go
deleted file mode 100644
index a1d401b7..00000000
--- a/vnfs/DAaaS/collectd-operator/pkg/apis/onap/v1alpha1/zz_generated.openapi.go
+++ /dev/null
@@ -1,124 +0,0 @@
-// +build !ignore_autogenerated
-
-// Code generated by openapi-gen. DO NOT EDIT.
-
-// This file was autogenerated by openapi-gen. Do not edit it manually!
-
-package v1alpha1
-
-import (
- spec "github.com/go-openapi/spec"
- common "k8s.io/kube-openapi/pkg/common"
-)
-
-func GetOpenAPIDefinitions(ref common.ReferenceCallback) map[string]common.OpenAPIDefinition {
- return map[string]common.OpenAPIDefinition{
- "demo/vnfs/DAaaS/collectd-operator/pkg/apis/onap/v1alpha1.CollectdPlugin": schema_pkg_apis_onap_v1alpha1_CollectdPlugin(ref),
- "demo/vnfs/DAaaS/collectd-operator/pkg/apis/onap/v1alpha1.CollectdPluginSpec": schema_pkg_apis_onap_v1alpha1_CollectdPluginSpec(ref),
- "demo/vnfs/DAaaS/collectd-operator/pkg/apis/onap/v1alpha1.CollectdPluginStatus": schema_pkg_apis_onap_v1alpha1_CollectdPluginStatus(ref),
- }
-}
-
-func schema_pkg_apis_onap_v1alpha1_CollectdPlugin(ref common.ReferenceCallback) common.OpenAPIDefinition {
- return common.OpenAPIDefinition{
- Schema: spec.Schema{
- SchemaProps: spec.SchemaProps{
- Description: "CollectdPlugin is the Schema for the collectdplugins API",
- Properties: map[string]spec.Schema{
- "kind": {
- SchemaProps: spec.SchemaProps{
- Description: "Kind is a string value representing the REST resource this object represents. Servers may infer this from the endpoint the client submits requests to. Cannot be updated. In CamelCase. More info: https://git.k8s.io/community/contributors/devel/api-conventions.md#types-kinds",
- Type: []string{"string"},
- Format: "",
- },
- },
- "apiVersion": {
- SchemaProps: spec.SchemaProps{
- Description: "APIVersion defines the versioned schema of this representation of an object. Servers should convert recognized schemas to the latest internal value, and may reject unrecognized values. More info: https://git.k8s.io/community/contributors/devel/api-conventions.md#resources",
- Type: []string{"string"},
- Format: "",
- },
- },
- "metadata": {
- SchemaProps: spec.SchemaProps{
- Ref: ref("k8s.io/apimachinery/pkg/apis/meta/v1.ObjectMeta"),
- },
- },
- "spec": {
- SchemaProps: spec.SchemaProps{
- Ref: ref("demo/vnfs/DAaaS/collectd-operator/pkg/apis/onap/v1alpha1.CollectdPluginSpec"),
- },
- },
- "status": {
- SchemaProps: spec.SchemaProps{
- Ref: ref("demo/vnfs/DAaaS/collectd-operator/pkg/apis/onap/v1alpha1.CollectdPluginStatus"),
- },
- },
- },
- },
- },
- Dependencies: []string{
- "demo/vnfs/DAaaS/collectd-operator/pkg/apis/onap/v1alpha1.CollectdPluginSpec", "demo/vnfs/DAaaS/collectd-operator/pkg/apis/onap/v1alpha1.CollectdPluginStatus", "k8s.io/apimachinery/pkg/apis/meta/v1.ObjectMeta"},
- }
-}
-
-func schema_pkg_apis_onap_v1alpha1_CollectdPluginSpec(ref common.ReferenceCallback) common.OpenAPIDefinition {
- return common.OpenAPIDefinition{
- Schema: spec.Schema{
- SchemaProps: spec.SchemaProps{
- Description: "CollectdPluginSpec defines the desired state of CollectdPlugin",
- Properties: map[string]spec.Schema{
- "pluginName": {
- SchemaProps: spec.SchemaProps{
- Description: "INSERT ADDITIONAL SPEC FIELDS - desired state of cluster Important: Run \"operator-sdk generate k8s\" to regenerate code after modifying this file Add custom validation using kubebuilder tags: https://book.kubebuilder.io/beyond_basics/generating_crd.html",
- Type: []string{"string"},
- Format: "",
- },
- },
- "pluginConf": {
- SchemaProps: spec.SchemaProps{
- Type: []string{"string"},
- Format: "",
- },
- },
- },
- Required: []string{"pluginName", "pluginConf"},
- },
- },
- Dependencies: []string{},
- }
-}
-
-func schema_pkg_apis_onap_v1alpha1_CollectdPluginStatus(ref common.ReferenceCallback) common.OpenAPIDefinition {
- return common.OpenAPIDefinition{
- Schema: spec.Schema{
- SchemaProps: spec.SchemaProps{
- Description: "CollectdPluginStatus defines the observed state of CollectdPlugin",
- Properties: map[string]spec.Schema{
- "collectdAgents": {
- SchemaProps: spec.SchemaProps{
- Description: "INSERT ADDITIONAL STATUS FIELD - define observed state of cluster Important: Run \"operator-sdk generate k8s\" to regenerate code after modifying this file Add custom validation using kubebuilder tags: https://book.kubebuilder.io/beyond_basics/generating_crd.html CollectdAgents are the collectd pods in the Daemonset",
- Type: []string{"array"},
- Items: &spec.SchemaOrArray{
- Schema: &spec.Schema{
- SchemaProps: spec.SchemaProps{
- Type: []string{"string"},
- Format: "",
- },
- },
- },
- },
- },
- "collectdConf": {
- SchemaProps: spec.SchemaProps{
- Ref: ref("k8s.io/api/core/v1.ConfigMap"),
- },
- },
- },
- Required: []string{"collectdAgents", "collectdConf"},
- },
- },
- Dependencies: []string{
- "k8s.io/api/core/v1.ConfigMap"},
- }
-}
diff --git a/vnfs/DAaaS/collectd-operator/pkg/controller/add_collectdplugin.go b/vnfs/DAaaS/collectd-operator/pkg/controller/add_collectdplugin.go
deleted file mode 100644
index da8d1e1d..00000000
--- a/vnfs/DAaaS/collectd-operator/pkg/controller/add_collectdplugin.go
+++ /dev/null
@@ -1,10 +0,0 @@
-package controller
-
-import (
- "demo/vnfs/DAaaS/collectd-operator/pkg/controller/collectdplugin"
-)
-
-func init() {
- // AddToManagerFuncs is a list of functions to create controllers and add them to a manager.
- AddToManagerFuncs = append(AddToManagerFuncs, collectdplugin.Add)
-}
diff --git a/vnfs/DAaaS/collectd-operator/pkg/controller/collectdplugin/collectdplugin_controller.go b/vnfs/DAaaS/collectd-operator/pkg/controller/collectdplugin/collectdplugin_controller.go
deleted file mode 100644
index 77d7e157..00000000
--- a/vnfs/DAaaS/collectd-operator/pkg/controller/collectdplugin/collectdplugin_controller.go
+++ /dev/null
@@ -1,215 +0,0 @@
-package collectdplugin
-
-import (
- "context"
- "crypto/sha256"
-
- onapv1alpha1 "demo/vnfs/DAaaS/collectd-operator/pkg/apis/onap/v1alpha1"
-
- corev1 "k8s.io/api/core/v1"
- extensionsv1beta1 "k8s.io/api/extensions/v1beta1"
- "k8s.io/apimachinery/pkg/api/errors"
- metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
- "k8s.io/apimachinery/pkg/runtime"
- "sigs.k8s.io/controller-runtime/pkg/client"
- "sigs.k8s.io/controller-runtime/pkg/controller"
- "sigs.k8s.io/controller-runtime/pkg/controller/controllerutil"
- "sigs.k8s.io/controller-runtime/pkg/handler"
- "sigs.k8s.io/controller-runtime/pkg/manager"
- "sigs.k8s.io/controller-runtime/pkg/reconcile"
- logf "sigs.k8s.io/controller-runtime/pkg/runtime/log"
- "sigs.k8s.io/controller-runtime/pkg/source"
-)
-
-var log = logf.Log.WithName("controller_collectdplugin")
-
-// ResourceMap to hold objects to update/reload
-type ResourceMap struct {
- configMap *corev1.ConfigMap
- daemonSet *extensionsv1beta1.DaemonSet
-}
-
-/**
-* USER ACTION REQUIRED: This is a scaffold file intended for the user to modify with their own Controller
-* business logic. Delete these comments after modifying this file.*
- */
-
-// Add creates a new CollectdPlugin Controller and adds it to the Manager. The Manager will set fields on the Controller
-// and Start it when the Manager is Started.
-func Add(mgr manager.Manager) error {
- return add(mgr, newReconciler(mgr))
-}
-
-// newReconciler returns a new reconcile.Reconciler
-func newReconciler(mgr manager.Manager) reconcile.Reconciler {
- return &ReconcileCollectdPlugin{client: mgr.GetClient(), scheme: mgr.GetScheme()}
-}
-
-// add adds a new Controller to mgr with r as the reconcile.Reconciler
-func add(mgr manager.Manager, r reconcile.Reconciler) error {
- // Create a new controller
- log.V(1).Info("Creating a new controller for CollectdPlugin")
- c, err := controller.New("collectdplugin-controller", mgr, controller.Options{Reconciler: r})
- if err != nil {
- return err
- }
-
- // Watch for changes to primary resource CollectdPlugin
- log.V(1).Info("Add watcher for primary resource CollectdPlugin")
- err = c.Watch(&source.Kind{Type: &onapv1alpha1.CollectdPlugin{}}, &handler.EnqueueRequestForObject{})
- if err != nil {
- return err
- }
-
- // TODO(user): Modify this to be the types you create that are owned by the primary resource
- // Watch for changes to secondary resource Pods and requeue the owner CollectdPlugin
- log.V(1).Info("Add watcher for secondary resource ConfigMap")
- err = c.Watch(&source.Kind{Type: &corev1.ConfigMap{}}, &handler.EnqueueRequestForOwner{
- IsController: true,
- OwnerType: &onapv1alpha1.CollectdPlugin{},
- })
- if err != nil {
- return err
- }
-
- err = c.Watch(&source.Kind{Type: &extensionsv1beta1.DaemonSet{}}, &handler.EnqueueRequestForOwner{
- IsController: true,
- OwnerType: &onapv1alpha1.CollectdPlugin{},
- })
- if err != nil {
- return err
- }
-
- return nil
-}
-
-// blank assignment to verify that ReconcileCollectdPlugin implements reconcile.Reconciler
-var _ reconcile.Reconciler = &ReconcileCollectdPlugin{}
-
-// ReconcileCollectdPlugin reconciles a CollectdPlugin object
-type ReconcileCollectdPlugin struct {
- // This client, initialized using mgr.Client() above, is a split client
- // that reads objects from the cache and writes to the apiserver
- client client.Client
- scheme *runtime.Scheme
-}
-
-// Reconcile reads that state of the cluster for a CollectdPlugin object and makes changes based on the state read
-// and what is in the CollectdPlugin.Spec
-// TODO(user): Modify this Reconcile function to implement your Controller logic. This example creates
-// a Pod as an example
-// Note:
-// The Controller will requeue the Request to be processed again if the returned error is non-nil or
-// Result.Requeue is true, otherwise upon completion it will remove the work from the queue.
-func (r *ReconcileCollectdPlugin) Reconcile(request reconcile.Request) (reconcile.Result, error) {
- reqLogger := log.WithValues("Request.Namespace", request.Namespace, "Request.Name", request.Name)
- reqLogger.Info("Reconciling CollectdPlugin")
-
- // Fetch the CollectdPlugin instance
- instance := &onapv1alpha1.CollectdPlugin{}
- err := r.client.Get(context.TODO(), request.NamespacedName, instance)
- if err != nil {
- if errors.IsNotFound(err) {
- // Request object not found, could have been deleted after reconcile request.
- // Owned objects are automatically garbage collected. For additional cleanup logic use finalizers.
- // Return and don't requeue
- reqLogger.V(1).Info("CollectdPlugin object Not found")
- return reconcile.Result{}, nil
- }
- // Error reading the object - requeue the request.
- reqLogger.V(1).Info("Error reading the CollectdPlugin object, Requeuing")
- return reconcile.Result{}, err
- }
-
- rmap, err := findResourceMapForCR(r, instance)
- if err != nil {
- reqLogger.Info("Skip reconcile: ConfigMap not found")
- return reconcile.Result{}, err
- }
-
- cm := rmap.configMap
- ds := rmap.daemonSet
- reqLogger.V(1).Info("Found ResourceMap")
- reqLogger.V(1).Info("ConfigMap.Namespace", cm.Namespace, "ConfigMap.Name", cm.Name)
- reqLogger.V(1).Info("DaemonSet.Namespace", ds.Namespace, "DaemonSet.Name", ds.Name)
- // Set CollectdPlugin instance as the owner and controller
- if err := controllerutil.SetControllerReference(instance, cm, r.scheme); err != nil {
- return reconcile.Result{}, err
- }
- // Set CollectdConf instance as the owner and controller
- if err := controllerutil.SetControllerReference(instance, ds, r.scheme); err != nil {
- return reconcile.Result{}, err
- }
-
- // Update the ConfigMap with new Spec and reload DaemonSets
- reqLogger.Info("Updating the ConfigMap", "ConfigMap.Namespace", cm.Namespace, "ConfigMap.Name", cm.Name)
- log.Info("Map: ", cm.Data)
- err = r.client.Update(context.TODO(), cm)
- if err != nil {
- return reconcile.Result{}, err
- }
-
- //Restart Collectd Pods
-
- ds.Spec.Template.SetLabels(map[string]string{
- "daaas-random": ComputeSHA256([]byte("TEST")),
- })
- // Reconcile success
- reqLogger.Info("Updated the ConfigMap", "ConfigMap.Namespace", cm.Namespace, "ConfigMap.Name", cm.Name)
- return reconcile.Result{}, nil
-}
-
-// ComputeSHA256 returns hash of data as string
-func ComputeSHA256(data []byte) string {
- hash := sha256.Sum256(data)
- return string(hash[:])
-}
-
-// findConfigMapForCR returns the configMap used by collectd Daemonset
-func findResourceMapForCR(r *ReconcileCollectdPlugin, cr *onapv1alpha1.CollectdPlugin) (ResourceMap, error) {
- cmList := &corev1.ConfigMapList{}
- opts := &client.ListOptions{}
- rmap := ResourceMap{}
-
- // Select ConfigMaps with label app=collectd
- opts.SetLabelSelector("app=collectd")
- opts.InNamespace(cr.Namespace)
- err := r.client.List(context.TODO(), opts, cmList)
- if err != nil {
- return rmap, err
- }
-
- // Select DaemonSets with label app=collectd
- dsList := &extensionsv1beta1.DaemonSet{}
- err = r.client.List(context.TODO(), opts, dsList)
- if err != nil {
- return rmap, err
- }
-
- rmap.configMap = &cmList.Items[0]
- rmap.daemonSet = dsList
- return rmap, err
-}
-
-// newPodForCR returns a busybox pod with the same name/namespace as the cr
-func newPodForCR(cr *onapv1alpha1.CollectdPlugin) *corev1.Pod {
- labels := map[string]string{
- "app": cr.Name,
- }
- return &corev1.Pod{
- ObjectMeta: metav1.ObjectMeta{
- Name: cr.Name + "-pod",
- Namespace: cr.Namespace,
- Labels: labels,
- },
- Spec: corev1.PodSpec{
- Containers: []corev1.Container{
- {
- Name: "busybox",
- Image: "busybox",
- Command: []string{"sleep", "3600"},
- },
- },
- },
- }
-}
diff --git a/vnfs/DAaaS/collectd-operator/pkg/controller/controller.go b/vnfs/DAaaS/collectd-operator/pkg/controller/controller.go
deleted file mode 100644
index 7c069f3e..00000000
--- a/vnfs/DAaaS/collectd-operator/pkg/controller/controller.go
+++ /dev/null
@@ -1,18 +0,0 @@
-package controller
-
-import (
- "sigs.k8s.io/controller-runtime/pkg/manager"
-)
-
-// AddToManagerFuncs is a list of functions to add all Controllers to the Manager
-var AddToManagerFuncs []func(manager.Manager) error
-
-// AddToManager adds all Controllers to the Manager
-func AddToManager(m manager.Manager) error {
- for _, f := range AddToManagerFuncs {
- if err := f(m); err != nil {
- return err
- }
- }
- return nil
-}