Esempio n. 1
0
def test_helm_ldap_multi_cluster_name(monkeypatch, settings):
    from pygluu.kubernetes.terminal.helm import PromptHelm

    monkeypatch.setattr("click.confirm", lambda x, default: True)

    settings.set("CN_HELM_RELEASE_NAME", "gluu")
    settings.set("NGINX_INGRESS_RELEASE_NAME", "ningress")
    settings.set("NGINX_INGRESS_NAMESPACE", "ingress-nginx")
    settings.set("INSTALL_GLUU_GATEWAY", "N")
    settings.set("CN_LDAP_MULTI_CLUSTER", "Y")
    settings.set("CN_LDAP_SERF_PORT", "30946")
    settings.set("CN_LDAP_ADVERTISE_ADDRESS", "demoexample.gluu.org:30946")
    settings.set("CN_LDAP_ADVERTISE_ADMIN_PORT", "30444")
    settings.set("CN_LDAP_ADVERTISE_LDAPS_PORT", "30636")
    settings.set("CN_LDAP_ADVERTISE_REPLICATION_PORT", "30989")
    settings.set("CN_LDAP_SECONDARY_CLUSTER", "Y")
    settings.set("CN_LDAP_SERF_PEERS", "[firstldap.gluu.org:30946]")
    prompt = PromptHelm(settings)
    prompt.prompt_helm()
    assert settings.get("CN_LDAP_MULTI_CLUSTER") == "Y"
    assert settings.get("CN_LDAP_SERF_PORT") == "30946"
    assert settings.get(
        "CN_LDAP_ADVERTISE_ADDRESS") == "demoexample.gluu.org:30946"
    assert settings.get("CN_LDAP_ADVERTISE_ADMIN_PORT") == "30444"
    assert settings.get("CN_LDAP_ADVERTISE_LDAPS_PORT") == "30636"
    assert settings.get("CN_LDAP_ADVERTISE_REPLICATION_PORT") == "30989"
    assert settings.get("CN_LDAP_SECONDARY_CLUSTER") == "Y"
    assert settings.get("CN_LDAP_SERF_PEERS") == "[firstldap.gluu.org:30946]"
def test_aws_arn(monkeypatch, settings, given, expected):
    from pygluu.kubernetes.terminal.helm import PromptHelm

    monkeypatch.setattr("click.confirm", lambda x: given)
    settings.set("global.cnPersistenceType", "ldap")
    settings.set("opendj.multiCluster.enabled", False)
    prompt = PromptHelm(settings)
    prompt.prompt_helm()
    assert settings.get("opendj.multiCluster.enabled") == expected
Esempio n. 3
0
def test_helm_release_name(monkeypatch, settings, given, expected):
    from pygluu.kubernetes.terminal.helm import PromptHelm

    monkeypatch.setattr("click.prompt", lambda x, default: given or expected)

    settings.set("NGINX_INGRESS_RELEASE_NAME", "ningress")
    settings.set("NGINX_INGRESS_NAMESPACE", "ingress-nginx")
    settings.set("INSTALL_GLUU_GATEWAY", "N")

    prompt = PromptHelm(settings)
    prompt.prompt_helm()
    assert settings.get("CN_HELM_RELEASE_NAME") == expected
def test_helm_release_name(monkeypatch, settings, given, expected):
    from pygluu.kubernetes.terminal.helm import PromptHelm

    monkeypatch.setattr("click.prompt", lambda x, default: given or expected)

    settings.set("installer-settings.nginxIngress.releaseName", "ningress")
    settings.set("installer-settings.nginxIngress.namespace", "ingress-nginx")
    settings.set("opendj.multiCluster.enabled", False)
    settings.set("installer-settings.releaseName", "")

    prompt = PromptHelm(settings)
    prompt.prompt_helm()
    assert settings.get("installer-settings.releaseName") == expected
Esempio n. 5
0
 def uninstall_gg_dbmode(self):
     try:
         self.queue.put(('Uninstalling...', 'ONPROGRESS'))
         from pygluu.kubernetes.terminal.helm import PromptHelm
         from pygluu.kubernetes.postgres import Postgres
         from pygluu.kubernetes.gluugateway import GluuGateway
         prompt_helm = PromptHelm(gluu_settings)
         prompt_helm.prompt_helm()
         postgres = Postgres()
         postgres.uninstall_postgres()
         gluugateway = GluuGateway()
         gluugateway.uninstall_gluu_gateway_dbmode()
         gluugateway.uninstall_gluu_gateway_ui()
         self.queue.put(('Uninstall is complete', 'COMPLETED'))
     except SystemExit:
         if self.queue:
             self.queue.put(("Oops! Something went wrong", "ERROR"))
         else:
             logger.error("***** Error caught in main loop *****")
             logger.error(traceback.format_exc())
Esempio n. 6
0
def main():
    parser = create_parser()
    args = parser.parse_args(sys.argv[1:])

    if not args.subparser_name:
        parser.print_help()
        return
    copy_templates()
    settings = SettingsHandler()
    settings.validate()
    if not settings.validate():
        for error in settings.errors:
            logger.error(error)
        sys.exit()

    prompts = Prompt()
    prompts.prompt()

    timeout = 120
    if args.subparser_name == "install-no-wait":
        timeout = 0
    try:
        if args.subparser_name == "install" or args.subparser_name == "install-no-wait":
            kustomize = Kustomize(timeout)
            kustomize.uninstall()
            if settings.get("INSTALL_REDIS") == "Y" or \
                    settings.get("INSTALL_GLUU_GATEWAY") == "Y" or \
                    settings.get("JACKRABBIT_CLUSTER") == "Y":
                helm = Helm()
                helm.uninstall_kubedb()
                helm.install_kubedb()
            kustomize.install()

        if args.subparser_name == "install-ldap-backup":
            kustomize = Kustomize(timeout)
            kustomize.setup_backup_ldap()

        elif args.subparser_name == "uninstall":
            logger.info("Removing all Gluu resources...")
            kustomize = Kustomize(timeout)
            kustomize.uninstall()
            if settings.get("INSTALL_REDIS") == "Y" or settings.get("INSTALL_GLUU_GATEWAY") == "Y":
                helm = Helm()
                helm.uninstall_kubedb()

        elif args.subparser_name == "upgrade":
            from pygluu.kubernetes.terminal.upgrade import PromptUpgrade
            # New feature in 4.2 compared to 4.1 and hence if enabled should make sure kubedb is installed.
            if settings.get("JACKRABBIT_CLUSTER") == "Y":
                helm = Helm()
                helm.uninstall_kubedb()
                helm.install_kubedb()
            prompt_upgrade = PromptUpgrade(settings)
            logger.info("Starting upgrade...")
            prompt_upgrade.prompt_upgrade()
            kustomize = Kustomize(timeout)
            kustomize.upgrade()

        elif args.subparser_name == "upgrade-values-yaml":
            from pygluu.kubernetes.terminal.upgrade import PromptUpgrade
            # New feature in 4.2 compared to 4.1 and hence if enabled should make sure kubedb is installed.
            helm = Helm()
            if settings.get("JACKRABBIT_CLUSTER") == "Y":
                helm.uninstall_kubedb()
                helm.install_kubedb()
            prompt_upgrade = PromptUpgrade(settings)
            prompt_upgrade.prompt_upgrade()
            helm = Helm()
            logger.info("Patching values.yaml for helm upgrade...")
            helm.analyze_global_values()
            logger.info("Please find your patched values.yaml at the location ./helm/gluu/values.yaml."
                        "Continue with the steps found at https://gluu.org/docs/gluu-server/latest/upgrade/#helm")

        elif args.subparser_name == "restore":
            kustomize = Kustomize(timeout)
            kustomize.copy_configs_before_restore()
            kustomize.uninstall(restore=True)
            kustomize.install(install_couchbase=False, restore=True)

        elif args.subparser_name == "install-couchbase":
            from pygluu.kubernetes.terminal.couchbase import PromptCouchbase
            prompt_couchbase = PromptCouchbase(settings)
            prompt_couchbase.prompt_couchbase()
            couchbase = Couchbase()
            couchbase.install()

        elif args.subparser_name == "install-couchbase-backup":
            from pygluu.kubernetes.terminal.couchbase import PromptCouchbase
            prompt_couchbase = PromptCouchbase(settings)
            prompt_couchbase.prompt_couchbase()
            couchbase = Couchbase()
            couchbase.setup_backup_couchbase()

        elif args.subparser_name == "uninstall-couchbase":
            from pygluu.kubernetes.terminal.couchbase import PromptCouchbase
            prompt_couchbase = PromptCouchbase(settings)
            prompt_couchbase.prompt_couchbase()
            couchbase = Couchbase()
            couchbase.uninstall()

        elif args.subparser_name == "install-gg-dbmode":
            from pygluu.kubernetes.terminal.gluugateway import PromptGluuGateway
            prompt_gluu_gateway = PromptGluuGateway(settings)
            prompt_gluu_gateway.prompt_gluu_gateway()
            kustomize = Kustomize(timeout)
            kustomize.install_gluu_gateway_dbmode()

        elif args.subparser_name == "install-kubedb":
            helm = Helm()
            helm.install_kubedb()

        elif args.subparser_name == "uninstall-gg-dbmode":
            kustomize = Kustomize(timeout)
            kustomize.uninstall_kong()
            kustomize.uninstall_gluu_gateway_ui()

        elif args.subparser_name == "generate-settings":
            logger.info("settings.json has been generated")

        elif args.subparser_name == "helm-install":
            from pygluu.kubernetes.terminal.helm import PromptHelm
            prompt_helm = PromptHelm(settings)
            prompt_helm.prompt_helm()
            helm = Helm()
            if settings.get("INSTALL_REDIS") == "Y" or \
                    settings.get("INSTALL_GLUU_GATEWAY") == "Y" or \
                    settings.get("JACKRABBIT_CLUSTER") == "Y":
                helm.uninstall_kubedb()
                helm.install_kubedb()
            if settings.get("JACKRABBIT_CLUSTER") == "Y":
                kustomize = Kustomize(timeout)
                kustomize.deploy_postgres()
            if settings.get("INSTALL_REDIS") == "Y":
                kustomize = Kustomize(timeout)
                kustomize.uninstall_redis()
                kustomize.deploy_redis()
            helm.install_gluu()

        elif args.subparser_name == "helm-uninstall":
            from pygluu.kubernetes.terminal.helm import PromptHelm
            prompt_helm = PromptHelm(settings)
            prompt_helm.prompt_helm()
            kustomize = Kustomize(timeout)
            helm = Helm()
            helm.uninstall_gluu()
            helm.uninstall_nginx_ingress()
            helm.uninstall_gluu_gateway_dbmode()
            helm.uninstall_gluu_gateway_ui()
            logger.info("Please wait...")
            time.sleep(30)
            kustomize.uninstall()
            helm.uninstall_kubedb()

        elif args.subparser_name == "helm-install-gluu":
            from pygluu.kubernetes.terminal.helm import PromptHelm
            prompt_helm = PromptHelm(settings)
            prompt_helm.prompt_helm()
            helm = Helm()
            helm.uninstall_gluu()
            helm.install_gluu(install_ingress=False)

        elif args.subparser_name == "helm-install-gg-dbmode":
            from pygluu.kubernetes.terminal.helm import PromptHelm
            prompt_helm = PromptHelm(settings)
            prompt_helm.prompt_helm()
            kustomize = Kustomize(timeout)
            kustomize.patch_or_deploy_postgres()
            helm = Helm()
            helm.install_gluu_gateway_dbmode()
            helm.install_gluu_gateway_ui()

        elif args.subparser_name == "helm-uninstall-gg-dbmode":
            from pygluu.kubernetes.terminal.helm import PromptHelm
            prompt_helm = PromptHelm(settings)
            prompt_helm.prompt_helm()
            kustomize = Kustomize(timeout)
            kustomize.uninstall_postgres()
            helm = Helm()
            helm.uninstall_gluu_gateway_dbmode()
            helm.uninstall_gluu_gateway_ui()

        elif args.subparser_name == "helm-uninstall-gluu":
            from pygluu.kubernetes.terminal.helm import PromptHelm
            prompt_helm = PromptHelm(settings)
            prompt_helm.prompt_helm()
            helm = Helm()
            helm.uninstall_gluu()

    except KeyboardInterrupt:
        print("\n[I] Canceled by user; exiting ...")
Esempio n. 7
0
 def helm(self):
     self.load_settings()
     helm = PromptHelm(self.settings)
     helm.prompt_helm()
Esempio n. 8
0
def main():
    parser = create_parser()
    args = parser.parse_args(sys.argv[1:])

    if not args.subparser_name:
        parser.print_help()
        return
    copy_templates()
    settings = SettingsHandler()
    settings.validate()
    if not settings.validate():
        for error in settings.errors:
            logger.error(error)
        sys.exit()

    prompts = Prompt()
    prompts.prompt()
    settings = SettingsHandler()

    try:
        if args.subparser_name == "install-ldap-backup":
            gluu = Gluu()
            gluu.install_ldap_backup()

        elif args.subparser_name == "uninstall-gluu":
            from pygluu.kubernetes.terminal.helm import PromptHelm
            prompt_helm = PromptHelm(settings)
            prompt_helm.prompt_helm()
            gluu = Gluu()
            gluu.uninstall_gluu()
            if settings.get("INSTALL_REDIS") == "Y" or settings.get("INSTALL_GLUU_GATEWAY") == "Y":
                from pygluu.kubernetes.kubedb import Kubedb
                kubedb = Kubedb()
                kubedb.uninstall_kubedb()

        elif args.subparser_name == "upgrade-values-yaml":
            from pygluu.kubernetes.terminal.upgrade import PromptUpgrade
            # New feature in 4.2 compared to 4.1 and hence if enabled should make sure kubedb is installed.
            gluu = Gluu()
            if settings.get("JACKRABBIT_CLUSTER") == "Y":
                from pygluu.kubernetes.kubedb import Kubedb
                kubedb = Kubedb()
                kubedb.uninstall_kubedb()
                kubedb.install_kubedb()
            prompt_upgrade = PromptUpgrade(settings)
            prompt_upgrade.prompt_upgrade()
            gluu = Gluu()
            logger.info("Patching values.yaml for helm upgrade...")
            gluu.analyze_global_values()
            logger.info("Please find your patched values.yaml at the location ./helm/gluu/values.yaml."
                        "Continue with the steps found at https://gluu.org/docs/gluu-server/latest/upgrade/#helm")

        elif args.subparser_name == "install-couchbase":
            from pygluu.kubernetes.terminal.couchbase import PromptCouchbase
            prompt_couchbase = PromptCouchbase(settings)
            prompt_couchbase.prompt_couchbase()
            couchbase = Couchbase()
            couchbase.install()

        elif args.subparser_name == "install-couchbase-backup":
            from pygluu.kubernetes.terminal.couchbase import PromptCouchbase
            prompt_couchbase = PromptCouchbase(settings)
            prompt_couchbase.prompt_couchbase()
            couchbase = Couchbase()
            couchbase.setup_backup_couchbase()

        elif args.subparser_name == "uninstall-couchbase":
            from pygluu.kubernetes.terminal.couchbase import PromptCouchbase
            prompt_couchbase = PromptCouchbase(settings)
            prompt_couchbase.prompt_couchbase()
            couchbase = Couchbase()
            couchbase.uninstall()

        elif args.subparser_name == "install-kubedb":
            from pygluu.kubernetes.kubedb import Kubedb
            kubedb = Kubedb()
            kubedb.install_kubedb()

        elif args.subparser_name == "generate-settings":
            logger.info("settings.json has been generated")

        elif args.subparser_name == "install":
            from pygluu.kubernetes.terminal.helm import PromptHelm
            prompt_helm = PromptHelm(settings)
            prompt_helm.prompt_helm()
            gluu = Gluu()
            if settings.get("INSTALL_REDIS") == "Y" or \
                    settings.get("INSTALL_GLUU_GATEWAY") == "Y" or \
                    settings.get("JACKRABBIT_CLUSTER") == "Y":
                from pygluu.kubernetes.kubedb import Kubedb
                kubedb = Kubedb()
                kubedb.uninstall_kubedb()
                kubedb.install_kubedb()
            if settings.get("JACKRABBIT_CLUSTER") == "Y":
                from pygluu.kubernetes.postgres import Postgres
                postgres = Postgres()
                postgres.install_postgres()
            if settings.get("INSTALL_REDIS") == "Y":
                from pygluu.kubernetes.redis import Redis
                redis = Redis()
                redis.uninstall_redis()
                redis.install_redis()
            gluu.install_gluu()

        elif args.subparser_name == "uninstall":
            from pygluu.kubernetes.terminal.helm import PromptHelm
            from pygluu.kubernetes.kubedb import Kubedb
            from pygluu.kubernetes.gluugateway import GluuGateway
            prompt_helm = PromptHelm(settings)
            prompt_helm.prompt_helm()
            gluu = Gluu()
            gluugateway = GluuGateway()
            gluu.uninstall_gluu()
            gluu.uninstall_nginx_ingress()
            gluugateway.uninstall_gluu_gateway_dbmode()
            gluugateway.uninstall_gluu_gateway_ui()
            logger.info("Please wait...")
            time.sleep(30)
            kubedb = Kubedb()
            kubedb.uninstall_kubedb()

        elif args.subparser_name == "install-gluu":
            from pygluu.kubernetes.terminal.helm import PromptHelm
            prompt_helm = PromptHelm(settings)
            prompt_helm.prompt_helm()
            gluu = Gluu()
            gluu.uninstall_gluu()
            gluu.install_gluu(install_ingress=False)

        elif args.subparser_name == "install-gg-dbmode":
            from pygluu.kubernetes.terminal.helm import PromptHelm
            from pygluu.kubernetes.postgres import Postgres
            from pygluu.kubernetes.gluugateway import GluuGateway
            prompt_helm = PromptHelm(settings)
            prompt_helm.prompt_helm()
            postgres = Postgres()
            postgres.patch_or_install_postgres()
            gluugateway = GluuGateway()
            gluugateway.install_gluu_gateway_dbmode()
            gluugateway.install_gluu_gateway_ui()

        elif args.subparser_name == "uninstall-gg-dbmode":
            from pygluu.kubernetes.terminal.helm import PromptHelm
            from pygluu.kubernetes.postgres import Postgres
            from pygluu.kubernetes.gluugateway import GluuGateway
            prompt_helm = PromptHelm(settings)
            prompt_helm.prompt_helm()
            postgres = Postgres()
            postgres.uninstall_postgres()
            gluugateway = GluuGateway()
            gluugateway.uninstall_gluu_gateway_dbmode()
            gluugateway.uninstall_gluu_gateway_ui()


    except KeyboardInterrupt:
        print("\n[I] Canceled by user; exiting ...")