Beispiel #1
0
    def delete(self, condition=False):

        config.load_kube_config(config_file=self.kubeconfig)
        if ob.check_scaleoperatorobject_is_deployed():   # for edge cases if custom object is not deleted
            ob.delete_custom_object()
            ob.check_scaleoperatorobject_is_deleted()

        if scale_function.check_crd_exists(self.crd_version):
            scale_function.delete_crd(self.crd_version)
        scale_function.check_crd_deleted(self.crd_version)

        if scale_function.check_service_account_exists("ibm-spectrum-scale-csi-operator"):
            scale_function.delete_service_account("ibm-spectrum-scale-csi-operator")
        scale_function.check_service_account_deleted("ibm-spectrum-scale-csi-operator")

        if scale_function.check_cluster_role_binding_exists("ibm-spectrum-scale-csi-operator"):
            scale_function.delete_cluster_role_binding("ibm-spectrum-scale-csi-operator")
        scale_function.check_cluster_role_binding_deleted("ibm-spectrum-scale-csi-operator")

        if scale_function.check_cluster_role_exists("ibm-spectrum-scale-csi-operator"):
            scale_function.delete_cluster_role("ibm-spectrum-scale-csi-operator")
        scale_function.check_cluster_role_deleted("ibm-spectrum-scale-csi-operator")

        if scale_function.check_deployment_exists():
            scale_function.delete_deployment()
        scale_function.check_deployment_deleted()

        if scale_function.check_namespace_exists() and (condition is False):
            scale_function.delete_namespace()
            scale_function.check_namespace_deleted()
Beispiel #2
0
    def delete(self):

        config.load_kube_config(config_file=self.kubeconfig)

        if ob.check_scaleoperatorobject_is_deployed():
            ob.delete_custom_object()
        ob.check_scaleoperatorobject_is_deleted()

        if ob.check_secret_exists(self.secret_name):
            ob.delete_secret(self.secret_name)
        ob.check_secret_is_deleted(self.secret_name)

        for remote_secret_name in self.temp["remote_secret_names"]:
            if ob.check_secret_exists(remote_secret_name):
                ob.delete_secret(remote_secret_name)
            ob.check_secret_is_deleted(remote_secret_name)
        if check_key(self.temp, "local_cacert_name"):
            if ob.check_configmap_exists(self.temp["local_cacert_name"]):
                ob.delete_configmap(self.temp["local_cacert_name"])
            ob.check_configmap_is_deleted(self.temp["local_cacert_name"])

        for remote_cacert_name in self.temp["remote_cacert_names"]:
            if ob.check_configmap_exists(remote_cacert_name):
                ob.delete_configmap(remote_cacert_name)
            ob.check_configmap_is_deleted(remote_cacert_name)
Beispiel #3
0
    def delete(self, kubeconfig):

        config.load_kube_config(config_file=kubeconfig)

        if ob.check_scaleoperatorobject_is_deployed():
            ob.delete_custom_object()
        ob.check_scaleoperatorobject_is_deleted()

        if ob.check_secret_exists(self.secret_name):
            ob.delete_secret(self.secret_name)
        ob.check_secret_is_deleted(self.secret_name)

        if check_key(self.temp, "remote"):
            if ob.check_secret_exists(self.remote_secret_name):
                ob.delete_secret(self.remote_secret_name)
            ob.check_secret_is_deleted(self.remote_secret_name)

        if check_key(self.temp, "cacert_name"):
            if ob.check_configmap_exists(self.cacert_name):
                ob.delete_configmap(self.cacert_name)
            ob.check_configmap_is_deleted(self.cacert_name)

        if check_key(self.temp, "remote_cacert_name"):
            if ob.check_configmap_exists(self.remote_cacert_name):
                ob.delete_configmap(self.remote_cacert_name)
            ob.check_configmap_is_deleted(self.remote_cacert_name)
Beispiel #4
0
    def create(self):

        config.load_kube_config(config_file=self.kubeconfig)
        LOGGER.info(str(self.temp["custom_object_body"]["spec"]))

        if not(ob.check_secret_exists(self.secret_name)):
            ob.create_secret(self.secret_data, self.secret_name)
        else:
            ob.delete_secret(self.secret_name)
            ob.check_secret_is_deleted(self.secret_name)
            ob.create_secret(self.secret_data, self.secret_name)

        for remote_secret_name in self.temp["remote_secret_names"]:
            remote_secret_data = {"username": self.temp["remote_username"][remote_secret_name],
                                  "password": self.temp["remote_password"][remote_secret_name]}
            if not(ob.check_secret_exists(remote_secret_name)):
                ob.create_secret(remote_secret_data, remote_secret_name)
            else:
                ob.delete_secret(remote_secret_name)
                ob.check_secret_is_deleted(remote_secret_name)
                ob.create_secret(remote_secret_data, remote_secret_name)

        if check_key(self.temp, "local_cacert_name"):
            cacert_name = self.temp["local_cacert_name"]
            if not(check_key(self.temp, "make_cacert_wrong")):
                self.temp["make_cacert_wrong"] = False

            if not(ob.check_configmap_exists(cacert_name)):
                ob.create_configmap(
                    self.temp["cacert_path"], self.temp["make_cacert_wrong"], cacert_name)
            else:
                ob.delete_configmap(cacert_name)
                ob.check_configmap_is_deleted(cacert_name)
                ob.create_configmap(
                    self.temp["cacert_path"], self.temp["make_cacert_wrong"], cacert_name)

        for remote_cacert_name in self.temp["remote_cacert_names"]:

            if not(check_key(self.temp, "make_remote_cacert_wrong")):
                self.temp["make_remote_cacert_wrong"] = False

            if not(ob.check_configmap_exists(remote_cacert_name)):
                ob.create_configmap(
                    self.temp["remote_cacert_path"][remote_cacert_name], self.temp["make_remote_cacert_wrong"], remote_cacert_name)
            else:
                ob.delete_configmap(remote_cacert_name)
                ob.check_configmap_is_deleted(remote_cacert_name)
                ob.create_configmap(
                    self.temp["remote_cacert_path"][remote_cacert_name], self.temp["make_remote_cacert_wrong"], remote_cacert_name)

        if not(ob.check_scaleoperatorobject_is_deployed()):

            ob.create_custom_object(self.temp["custom_object_body"], self.stateful_set_not_created)
        else:
            ob.delete_custom_object()
            ob.check_scaleoperatorobject_is_deleted()
            ob.create_custom_object(self.temp["custom_object_body"], self.stateful_set_not_created)
Beispiel #5
0
    def create(self, kubeconfig):

        config.load_kube_config(config_file=kubeconfig)
        LOGGER.info(str(self.custom_object_spec))

        if not (ob.check_secret_exists(self.secret_name)):
            ob.create_secret(self.secret_data, self.secret_name)
        else:
            ob.delete_secret(self.secret_name)
            ob.check_secret_is_deleted(self.secret_name)
            ob.create_secret(self.secret_data, self.secret_name)

        if check_key(self.temp, "remote"):
            if not (ob.check_secret_exists(self.remote_secret_name)):
                ob.create_secret(self.remote_secret_data,
                                 self.remote_secret_name)
            else:
                ob.delete_secret(self.remote_secret_name)
                ob.check_secret_is_deleted(self.remote_secret_name)
                ob.create_secret(self.remote_secret_data,
                                 self.remote_secret_name)

        if check_key(self.temp, "cacert_name"):
            if not (check_key(self.temp, "make_cacert_wrong")):
                self.temp["make_cacert_wrong"] = False

            if not (ob.check_configmap_exists(self.cacert_name)):
                ob.create_configmap(self.temp["cacert_path"],
                                    self.temp["make_cacert_wrong"],
                                    self.cacert_name)
            else:
                ob.delete_configmap(self.cacert_name)
                ob.check_configmap_is_deleted(self.cacert_name)
                ob.create_configmap(self.temp["cacert_path"],
                                    self.temp["make_cacert_wrong"],
                                    self.cacert_name)

        if check_key(self.temp, "remote_cacert_name"):
            if not (check_key(self.temp, "make_remote_cacert_wrong")):
                self.temp["make_remote_cacert_wrong"] = False

            if not (ob.check_configmap_exists(self.remote_cacert_name)):
                ob.create_configmap(self.temp["remote_cacert_path"],
                                    self.temp["make_remote_cacert_wrong"],
                                    self.remote_cacert_name)
            else:
                ob.delete_configmap(self.remote_cacert_name)
                ob.check_configmap_is_deleted(self.remote_cacert_name)
                ob.create_configmap(self.temp["remote_cacert_path"],
                                    self.temp["make_remote_cacert_wrong"],
                                    self.remote_cacert_name)

        if not (ob.check_scaleoperatorobject_is_deployed()):

            ob.create_custom_object(self.custom_object_spec,
                                    self.stateful_set_not_created)
        else:
            ob.delete_custom_object()
            ob.check_scaleoperatorobject_is_deleted()
            ob.create_custom_object(self.custom_object_spec,
                                    self.stateful_set_not_created)