def install_couchbase_backup(self): try: self.queue.put(('Installation in progress', 'ONPROGRESS')) couchbase = Couchbase() couchbase.setup_backup_couchbase() self.queue.put(('Installation 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())
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 ...")
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 ...")
def main(): parser = create_parser() args = parser.parse_args(sys.argv[1:]) if not args.subparser_name: parser.print_help() return if args.subparser_name == "version": from pygluu.kubernetes import __version__ logger.info(f"pygluu installer version is : {__version__}") return copy_templates() # Prepare override-values.yaml for parsing shutil.copy(Path("./helm/gluu/values.yaml"), Path("./helm/gluu/override-values.yaml")) settings = ValuesHandler() settings.load() prompts = Prompt() prompts.prompt() settings = ValuesHandler() try: if args.subparser_name == "uninstall-gluu": gluu = Gluu() gluu.uninstall_gluu() if settings.get("installer-settings.redis.install"): # TODO: Make sure remove redis or postgres if installled by Gluu logger.info("remove me after implementing TODO") 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 postgres is installed. gluu = Gluu() if settings.get("installer-settings.jackrabbit.clusterMode") and \ settings.get("installer-settings.postgres.install"): # TODO: Make sure postgres is installed logger.info("remove me after implementing TODO") prompt_upgrade = PromptUpgrade(settings) prompt_upgrade.prompt_upgrade() logger.info("Patching values.yaml for helm upgrade...") 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 == "generate-settings": logger.info("settings.json has been generated") elif args.subparser_name == "install": gluu = Gluu() if settings.get("installer-settings.postgres.install"): from pygluu.kubernetes.postgres import Postgres postgres = Postgres() postgres.install_postgres() if settings.get("installer-settings.redis.install"): from pygluu.kubernetes.redis import Redis redis = Redis() redis.uninstall_redis() redis.install_redis() if settings.get("installer-settings.sql.install") and \ settings.get("config.configmap.cnSqlDbDialect") == "mysql": from pygluu.kubernetes.mysql import MySQL sql = MySQL() sql.install_mysql() gluu.install_gluu() elif args.subparser_name == "uninstall": gluu = Gluu() gluu.uninstall_gluu() gluu.uninstall_nginx_ingress() logger.info("Please wait...") elif args.subparser_name == "install-gluu": gluu = Gluu() gluu.uninstall_gluu() gluu.install_gluu(install_ingress=False) except KeyboardInterrupt: print("\n[I] Canceled by user; exiting ...")