Пример #1
0
    def prompt_config(self):
        """Prompts for generation of configuration layer
        """
        check_fqdn_provided = False

        while True:
            if self.settings.get("global.fqdn") in (None, '') or check_fqdn_provided:
                self.settings.set("global.fqdn", click.prompt("Enter Hostname", default="demoexample.gluu.org"))

            regex_bool = re.match(
                '^(([a-zA-Z0-9]|[a-zA-Z0-9][a-zA-Z0-9\-]*[a-zA-Z0-9])\.){2,}([A-Za-z0-9]|[A-Za-z0-9][A-Za-z0-9\-]*[A-Za-z0-9]){2,}$',
                # noqa: W605
                self.settings.get("global.fqdn"))

            if regex_bool:
                break
            else:
                check_fqdn_provided = True
                logger.error("Input not FQDN structred. Please enter a FQDN with the format demoexample.gluu.org")

        if self.settings.get("config.countryCode") in (None, ''):
            self.settings.set("config.countryCode", click.prompt("Enter Country Code", default="US"))

        if self.settings.get("config.state") in (None, ''):
            self.settings.set("config.state", click.prompt("Enter State", default="TX"))

        if self.settings.get("config.city") in (None, ''):
            self.settings.set("config.city", click.prompt("Enter City", default="Austin"))

        if self.settings.get("config.email") in (None, ''):
            self.settings.set("config.email", click.prompt("Enter email", default="*****@*****.**"))

        if self.settings.get("config.orgName") in (None, ''):
            self.settings.set("config.orgName", click.prompt("Enter Organization", default="Gluu"))

        if self.settings.get("config.adminPassword") in (None, ''):
            self.settings.set("config.adminPassword", prompt_password("Admin GUI"))

        if self.settings.get("config.ldapPassword") in (None, ''):
            if self.settings.get("global.cnPersistenceType") in ("hybrid", "ldap"):
                self.settings.set("config.ldapPassword", prompt_password("OpenDJ"))
            else:
                self.settings.set("config.ldapPassword", self.settings.get("config.configmap.cnCouchbasePass"))

        if self.settings.get("global.storageClass.provisioner") in ("microk8s.io/hostpath", "k8s.io/minikube-hostpath"):
            self.settings.set("global.isFqdnRegistered", False)

        if self.settings.get("global.isFqdnRegistered") in (None, ''):
            self.settings.set("global.isFqdnRegistered", click.confirm("Are you using a globally resolvable FQDN"))

        logger.info("You can mount your FQDN certification and key by placing them inside "
                    "gluu.crt and gluu.key respectivley at the same location pygluu-kubernetes.pyz is at.")
Пример #2
0
    def prompt_redis(self):
        """Prompts for Redis
        """
        if self.settings.get("config.configmap.cnRedisType") in (None, ''):
            logger.info("STANDALONE, CLUSTER")
            self.settings.set("config.configmap.cnRedisType", click.prompt("Please enter redis type", default="CLUSTER"))

        if self.settings.get("installer-settings.redis.install"):
            logger.info("For the following prompt if placed [N] the Redis is assumed to be"
                        " installed or remotely provisioned")
            self.settings.set("installer-settings.redis.install", click.confirm("Install Redis using Bitnami helm chart"))

        if self.settings.get("installer-settings.redis.install"):
            if self.settings.get("installer-settings.redis.namespace") in (None, ''):
                namespace = click.prompt("Please enter a namespace for Redis cluster", default="gluu-redis-cluster")
                self.settings.set("installer-settings.redis.namespace", namespace)
                
            if self.settings.get("config.redisPassword") in (None, ''):
                self.settings.set("config.redisPassword", prompt_password("Redis"))

        if self.settings.get("config.configmap.cnRedisUrl") in (None, ''):
            if self.settings.get("installer-settings.redis.install"):
                redis_url_prompt = "redis-cluster.{}.svc.cluster.local:6379".format(
                    self.settings.get("installer-settings.redis.namespace"))
            else:
                logger.info(
                    "Redis URL can be : redis-cluster.gluu-redis-cluster.svc.cluster.local:6379 in a redis deployment")
                logger.info("Redis URL using AWS ElastiCach [Configuration Endpoint]: "
                            "clustercfg.testing-redis.icrbdv.euc1.cache.amazonaws.com:6379")
                logger.info("Redis URL using Google MemoryStore : <ip>:6379")
                redis_url_prompt = click.prompt(
                    "Please enter redis URL. If you are deploying redis",
                    default="redis-cluster.gluu-redis-cluster.svc.cluster.local:6379",
                )
            self.settings.set("config.configmap.cnRedisUrl", redis_url_prompt)
Пример #3
0
    def prompt_jackrabbit(self):
        """Prompts for Jackrabbit content repository
        """
        if self.settings.get("global.jackrabbit.enabled") in (None, ''):
            logger.info("Jackrabbit must be installed. If the following prompt is answered with N it is assumed "
                        "the jackrabbit content repository is either installed locally or remotely")
            self.settings.set("global.jackrabbit.enabled",
                              click.confirm("Install Jackrabbit content repository", default=True))

        jackrabbit_cluster_prompt = "Is"
        if self.settings.get("global.jackrabbit.enabled"):
            if self.settings.get("jackrabbit.storage.size") in (None, ''):
                self.settings.set("jackrabbit.storage.size", click.prompt(
                    "Size of Jackrabbit content repository volume storage", default="4Gi"))
            self.settings.set("config.configmap.cnJackrabbitUrl", "http://jackrabbit:8080")
            jackrabbit_cluster_prompt = "Enable"

        if self.settings.get("config.configmap.cnJackrabbitUrl") in (None, ''):
            self.settings.set("config.configmap.cnJackrabbitUrl", click.prompt("Please enter jackrabbit url.",
                                                                               default="http://jackrabbit:8080"))
        if self.settings.get("config.configmap.cnJackrabbitAdminId") in (None, ''):
            self.settings.set("config.configmap.cnJackrabbitAdminId",
                              click.prompt("Please enter Jackrabbit admin user", default="admin"))

        if self.settings.get("jackrabbit.secrets.cnJackrabbitAdminPassword") in (None, ''):
            self.settings.set("jackrabbit.secrets.cnJackrabbitAdminPassword", prompt_password("jackrabbit-admin", 24))

        if self.settings.get("installer-settings.jackrabbit.clusterMode") in (None, ''):
            self.settings.set("installer-settings.jackrabbit.clusterMode",
                              click.confirm("{} Jackrabbit in cluster mode[beta] "
                                            "Recommended in production"
                                            .format(jackrabbit_cluster_prompt), default=True))
        if self.settings.get("installer-settings.jackrabbit.clusterMode"):
            self.postgres.prompt_postgres()
            if self.settings.get("config.configmap.cnJackrabbitPostgresUser") in (None, ''):
                self.settings.set("config.configmap.cnJackrabbitPostgresUser",
                                  click.prompt("Please enter a user for jackrabbit postgres database",
                                               default="jackrabbit"))

            if self.settings.get("jackrabbit.secrets.cnJackrabbitPostgresPassword") in (None, ''):
                self.settings.set("jackrabbit.secrets.cnJackrabbitPostgresPassword",
                                  prompt_password("jackrabbit-postgres"))

            if self.settings.get("config.configmap.cnJackrabbitPostgresDatabaseName") in (None, ''):
                self.settings.set("config.configmap.cnJackrabbitPostgresDatabaseName",
                                  click.prompt("Please enter jackrabbit postgres database name",
                                               default="jackrabbit"))
Пример #4
0
    def prompt_redis(self):
        """Prompts for Redis
        """
        if self.settings.get("config.configmap.cnRedisType") in (None, ''):
            logger.info("STANDALONE, CLUSTER")
            self.settings.set("config.configmap.cnRedisType", click.prompt("Please enter redis type", default="CLUSTER"))

        if self.settings.get("installer-settings.redis.install"):
            logger.info("For the following prompt if placed [N] the Redis is assumed to be"
                        " installed or remotely provisioned")
            self.settings.set("installer-settings.redis.install", click.confirm("Install Redis using KubeDB operator"))

        if self.settings.get("installer-settings.redis.install"):
            if self.settings.get("installer-settings.redis.masterNodes") in (None, ''):
                self.settings.set("installer-settings.redis.masterNodes",
                                  click.prompt("The number of master node. Minimum is 3. "
                                               "Press enter if remote", default=3))

            if self.settings.get("installer-settings.redis.nodesPerMaster") in (None, ''):
                self.settings.set("installer-settings.redis.nodesPerMaster",
                                  click.prompt("The number of nodes per master node", default=2))

            if self.settings.get("installer-settings.redis.namespace") in (None, ''):
                self.settings.set("installer-settings.redis.namespace",
                                  click.prompt("Please enter a namespace for Redis cluster",
                                               default="gluu-redis-cluster"))
        else:
            # Placing password in kubedb is currently not supported. # Todo: Remove else once supported
            if self.settings.get("config.redisPassword") in (None, ''):
                self.settings.set("config.redisPassword", prompt_password("Redis"))

        if self.settings.get("config.configmap.cnRedisUrl") in (None, ''):
            if self.settings.get("installer-settings.redis.install"):
                redis_url_prompt = "redis-cluster.{}.svc.cluster.local:6379".format(
                    self.settings.get("installer-settings.redis.namespace"))
            else:
                logger.info(
                    "Redis URL can be : redis-cluster.gluu-redis-cluster.svc.cluster.local:6379 in a redis deployment")
                logger.info("Redis URL using AWS ElastiCach [Configuration Endpoint]: "
                            "clustercfg.testing-redis.icrbdv.euc1.cache.amazonaws.com:6379")
                logger.info("Redis URL using Google MemoryStore : <ip>:6379")
                redis_url_prompt = click.prompt(
                    "Please enter redis URL. If you are deploying redis",
                    default="redis-cluster.gluu-redis-cluster.svc.cluster.local:6379",
                )
            self.settings.set("config.configmap.cnRedisUrl", redis_url_prompt)
Пример #5
0
    def prompt_redis(self):
        """Prompts for Redis
        """
        if not self.settings.get("REDIS_TYPE"):
            logger.info("STANDALONE, CLUSTER")
            self.settings.set("REDIS_TYPE", click.prompt("Please enter redis type", default="CLUSTER"))

        if not self.settings.get("INSTALL_REDIS"):
            logger.info("For the following prompt if placed [N] the Redis is assumed to be"
                        " installed or remotely provisioned")
            self.settings.set("INSTALL_REDIS", confirm_yesno("Install Redis", default=True))

        if self.settings.get("INSTALL_REDIS") == "Y":
            if not self.settings.get("REDIS_MASTER_NODES"):
                self.settings.set("REDIS_MASTER_NODES",
                                  click.prompt("The number of master node. Minimum is 3", default=3))

            if not self.settings.get("REDIS_NODES_PER_MASTER"):
                self.settings.set("REDIS_NODES_PER_MASTER", click.prompt("The number of nodes per master node",
                                                                         default=2))

            if not self.settings.get("REDIS_NAMESPACE"):
                self.settings.set("REDIS_NAMESPACE", click.prompt("Please enter a namespace for Redis cluster",
                                                                  default="gluu-redis-cluster"))
        else:
            # Placing password in kubedb is currently not supported. # Todo: Remove else once supported
            if not self.settings.get("REDIS_PW"):
                self.settings.set("REDIS_PW", prompt_password("Redis"))

        if not self.settings.get("REDIS_URL"):
            if self.settings.get("INSTALL_REDIS") == "Y":
                redis_url_prompt = "redis-cluster.{}.svc.cluster.local:6379".format(
                    self.settings.get("REDIS_NAMESPACE"))
            else:
                logger.info(
                    "Redis URL can be : redis-cluster.gluu-redis-cluster.svc.cluster.local:6379 in a redis deployment")
                logger.info("Redis URL using AWS ElastiCach [Configuration Endpoint]: "
                            "clustercfg.testing-redis.icrbdv.euc1.cache.amazonaws.com:6379")
                logger.info("Redis URL using Google MemoryStore : <ip>:6379")
                redis_url_prompt = click.prompt(
                    "Please enter redis URL. If you are deploying redis",
                    default="redis-cluster.gluu-redis-cluster.svc.cluster.local:6379",
                )
            self.settings.set("REDIS_URL", redis_url_prompt)
    def prompt_openbanking(self):
        """Prompts for OpenBanking distribution .
        """

        if self.settings.get("global.cnObExtSigningJwksUri") in ("None", ''):
            self.settings.set("global.cnObExtSigningJwksUri",
                              click.prompt("Open banking external signing jwks uri. Used in SSA Validation.",
                                           default="https://keystore.openbankingtest.org.uk/keystore/openbanking.jwks"))

        if self.settings.get("global.cnObExtSigningJwksCrt") in ("None", ''):
            print(
                "Place the Open banking external signing jwks AS certificate string in a file named obsigning.pem. "
                "Used in SSA Validation. "
                " This will be encoded using base64 so please do not encode it.")
            encoded_obsigning_pem = read_file("./obsigning.pem")
            self.settings.set("global.cnObExtSigningJwksCrt", encoded_obsigning_pem)

        if self.settings.get("global.cnObExtSigningJwksKey") in ("None", ''):
            print(
                "Place the Open banking external signing jwks AS key string in a file named obsigning.key. Used in "
                "SSA Validation. "
                " This will be encoded using base64 so please do not encode it.")
            encoded_obsigning_pem = read_file("./obsigning.key")
            self.settings.set("global.cnObExtSigningJwksKey", encoded_obsigning_pem)

        # TODO: its possible that there is no passphrase for the key,
        # and hence the below prompt will always prompt which will affect CI/CD.
        # An installer param should be prompted for that case.
        if self.settings.get("global.cnObExtSigningJwksKeyPassPhrase") in ("None", ''):
            self.settings.set("global.cnObExtSigningJwksKeyPassPhrase",
                              click.prompt(
                                  "OOpen banking external signing jwks AS key passphrase to unlock provided key.",
                                  default=""))

        if self.settings.get("global.cnObExtSigningAlias") in ("None", ''):
            self.settings.set("global.cnObExtSigningAlias",
                              click.prompt("Open banking external signing AS Alias. "
                                           "This is a kid value.Used in SSA Validation, "
                                           "kid used while encoding a JWT sent to token URL",
                                           default="XkwIzWy44xWSlcWnMiEc8iq9s2G"))

        if self.settings.get("global.cnObStaticSigningKeyKid") in ("None", ''):
            self.settings.set("global.cnObStaticSigningKeyKid",
                              click.prompt("Open banking  signing AS kid to force the AS to use a specific signing key",
                                           default="Wy44xWSlcWnMiEc8iq9s2G"))

        if self.settings.get("global.cnObTransportCrt") in ("None", ''):
            print(
                "Place the Open banking AS transport certificate string in a file named obtransport.pem. Used in SSA "
                "Validation. "
                " This will be encoded using base64 so please do not encode it.")
            encoded_obtransport_pem = read_file("./obtransport.pem")
            self.settings.set("global.cnObTransportCrt", encoded_obtransport_pem)

        if self.settings.get("global.cnObTransportKey") in ("None", ''):
            print("Place the Open banking AS transport ke string in a file named obtransport.key. Used in SSA "
                  "Validation. "
                  " This will be encoded using base64 so please do not encode it.")
            encoded_obtransport_key = read_file("./obtransport.key")
            self.settings.set("global.cnObTransportKey", encoded_obtransport_key)

        # TODO: its possible that there is no passphrase for the key,
        # and hence the below prompt will always prompt which will affect CI/CD.
        # An installer param should be prompted for that case.
        if self.settings.get("global.cnObTransportKeyPassPhrase") in ("None", ''):
            self.settings.set("global.cnObTransportKeyPassPhrase",
                              click.prompt("Open banking AS transport key passphrase to unlock AS transport key.",
                                           default=""))

        if self.settings.get("global.cnObTransportAlias") in ("None", ''):
            self.settings.set("global.cnObTransportAlias",
                              click.prompt("Open banking transport Alias used inside the JVM",
                                           default="OpenBankingAsTransport"))

        if self.settings.get("installer-settings.openbanking.hasCnObTransportTrustStore") in ("None", ''):
            self.settings.set("installer-settings.openbanking.hasCnObTransportTrustStore",
                              click.confirm("Do you have the Open banking AS transport truststore crt. "
                                            "This is normally generated from the OB issuing CA, "
                                            "OB Root CA and Signing CA.",
                                            default=False))

        if self.settings.get("global.cnObTransportTrustStore") in ("None", ''):
            if self.settings.get("installer-settings.openbanking.hasCnObTransportTrustStore"):
                print("Place the Open banking AS transport truststore p12 in a file  "
                      "named obtransporttruststore.p12. Used in SSA "
                      "Validation. "
                      " This will be encoded using base64 so please do not encode it.")
                encoded_transport_truststore_pem = read_file_bytes("./obtransporttruststore.p12")
                self.settings.set("global.cnObTransportTrustStore", encoded_transport_truststore_pem)
            else:
                print("Place the Open banking issuing CA, OB Root CA and Signing CA string in one file "
                      "named obcas.pem. Example command: cat obissuingca.pem obrootca.pem obsigningca.pem > obcas.pem "
                      "This will be used to generate the ob transport truststore p12 file "
                      " This will be encoded using base64 so please do not encode it.")
                # check file is there
                read_file("./obcas.pem")
                if self.settings.get("installer-settings.openbanking.cnObTransportTrustStoreP12password") in ("None", ''):
                    self.settings.set("installer-settings.openbanking.cnObTransportTrustStoreP12password",
                                      prompt_password("Open Banking CAs"))
                try:
                    stdout, stderr, retcode = exec_cmd(
                        f'keytool -importcert -file obcas.pem -keystore ob-transport-truststore.p12 -noprompt '
                        f'-alias obkeystore  '
                        f'-storepass {self.settings.get("installer-settings.openbanking.cnObTransportTrustStoreP12password")}')
                except FileNotFoundError:
                    print("Please install keytool.")
                encoded_transport_truststore_pem = read_file_bytes("./ob-transport-truststore.p12")
                self.settings.set("global.cnObTransportTrustStore", encoded_transport_truststore_pem)
Пример #7
0
    def prompt_sql(self):
        """Prompts for SQL server
        """
        sql_dialect = {
            1: "mysql",
            2: "pgsql",
        }

        if self.settings.get(
                "config.configmap.cnSqlDbDialect") not in sql_dialect.values():
            print(
                "|------------------------------------------------------------------|"
            )
            print(
                "|                     SQL DIALECT                                  |"
            )
            print(
                "|------------------------------------------------------------------|"
            )
            print(
                "| [1] MySQL                                                        |"
            )
            print(
                "| [2] PostgreSQL                                                   |"
            )
            print(
                "|------------------------------------------------------------------|"
            )

            choice = click.prompt("SQL dialect", default=1)
            self.settings.set("config.configmap.cnSqlDbDialect",
                              sql_dialect.get(choice, "mysql"))

        if not self.settings.get("installer-settings.sql.install"):
            logger.info(
                "Install SQL dialect from Bitnamis charts.If the following prompt is answered with N it is assumed "
                "the SQL server is installed remotely or locally by the user."
                " A managed service such as Amazon Aurora or CloudSQL should be used in production setups."
            )
            self.settings.set(
                "installer-settings.sql.install",
                click.confirm("Install SQL dialect from Bitnamis charts",
                              default=True))

        if self.settings.get("installer-settings.sql.install"):
            self.settings.set("config.configmap.cnSqlDbPort", 3306)
            if not self.settings.get("installer-settings.sql.namespace"):
                self.settings.set(
                    "installer-settings.sql.namespace",
                    click.prompt("Please enter a namespace for the SQL server",
                                 default="sql"))

            self.settings.set(
                "config.configmap.cnSqlDbHost",
                f'gluu-mysql.{self.settings.get("installer-settings.sql.namespace")}.svc.cluster.local'
            )
            if self.settings.get("config.configmap.cnSqlDbDialect") == "pgsql":
                self.settings.set("installer-settings.postgres.install", True)
                self.settings.set(
                    "config.configmap.cnSqlDbHost",
                    f'gluu-postgresql.{self.settings.get("installer-settings.sql.namespace")}.svc.cluster.local'
                )
                self.settings.set("config.configmap.cnSqlDbPort", 5432)
        if not self.settings.get("config.configmap.cnSqlDbHost"):
            self.settings.set(
                "config.configmap.cnSqlDbHost",
                click.prompt(
                    "Please enter  SQL (remote or local) URL base name",
                    default="gluu.sql.svc.cluster.local"))
        if not self.settings.get("config.configmap.cnSqlDbPort"):
            self.settings.set(
                "config.configmap.cnSqlDbPort",
                click.prompt(
                    "Please enter  SQL (remote or local) port "
                    "number",
                    default=3306))
        if not self.settings.get("config.configmap.cnSqlDbUser"):
            self.settings.set(
                "config.configmap.cnSqlDbUser",
                click.prompt("Please enter a user for Gluu SQL database ",
                             default="gluu"))

        if not self.settings.get("config.configmap.cnSqldbUserPassword"):
            self.settings.set("config.configmap.cnSqldbUserPassword",
                              prompt_password("gluu-db-sql"))

        if not self.settings.get("config.configmap.cnSqlDbName"):
            self.settings.set(
                "config.configmap.cnSqlDbName",
                click.prompt("Please enter Gluu SQL database name",
                             default="gluu"))
Пример #8
0
    def prompt_couchbase(self):
        self.arch.prompt_arch()
        self.namespace.prompt_gluu_namespace()

        if self.settings.get("DEPLOYMENT_ARCH") not in ("microk8s",
                                                        "minikube"):
            self.backup.prompt_backup()

        if not self.settings.get("HOST_EXT_IP"):
            ip = gather_ip
            self.settings.set("HOST_EXT_IP", ip)

        if not self.settings.get("INSTALL_COUCHBASE"):
            logger.info(
                "For the following prompt  if placed [N] the couchbase is assumed to be"
                " installed or remotely provisioned")
            self.settings.set("INSTALL_COUCHBASE",
                              confirm_yesno("Install Couchbase", default=True))

        if self.settings.get("INSTALL_COUCHBASE") == "N":
            if not self.settings.get("COUCHBASE_CRT"):
                print(
                    "Place the Couchbase certificate authority certificate in a file called couchbase.crt at "
                    "the same location as the installation script.")
                print(
                    "This can also be found in your couchbase UI Security > Root Certificate"
                )
                _ = input("Hit 'enter' or 'return' when ready.")
                with open(Path("./couchbase.crt")) as content_file:
                    ca_crt = content_file.read()
                    encoded_ca_crt_bytes = base64.b64encode(
                        ca_crt.encode("utf-8"))
                    encoded_ca_crt_string = str(encoded_ca_crt_bytes, "utf-8")
                self.settings.set("COUCHBASE_CRT", encoded_ca_crt_string)
        else:
            self.settings.set("COUCHBASE_CRT", "")

        self.prompt_override_couchbase_files()

        if self.settings.get("DEPLOYMENT_ARCH") in ("microk8s", "minikube"):
            self.settings.set("COUCHBASE_USE_LOW_RESOURCES", "Y")

        if not self.settings.get("COUCHBASE_USE_LOW_RESOURCES"):
            self.settings.set(
                "COUCHBASE_USE_LOW_RESOURCES",
                confirm_yesno(
                    "Setup CB nodes using low resources for demo purposes"))

        if self.settings.get("COUCHBASE_USE_LOW_RESOURCES") == "N" and \
                self.settings.get("COUCHBASE_CLUSTER_FILE_OVERRIDE") == "N" and \
                self.settings.get("INSTALL_COUCHBASE") == "Y":
            self.prompt_couchbase_calculator()

        if not self.settings.get("COUCHBASE_NAMESPACE"):
            self.settings.set(
                "COUCHBASE_NAMESPACE",
                click.prompt("Please enter a namespace for CB objects.",
                             default="cbns"))

        if not self.settings.get("COUCHBASE_CLUSTER_NAME"):
            self.settings.set(
                "COUCHBASE_CLUSTER_NAME",
                click.prompt("Please enter a cluster name.", default="cbgluu"))

        if not self.settings.get("COUCHBASE_URL"):
            self.settings.set(
                "COUCHBASE_URL",
                click.prompt(
                    "Please enter  couchbase (remote or local) URL base name",
                    default=
                    f"{self.settings.get('COUCHBASE_CLUSTER_NAME')}.{self.settings.get('COUCHBASE_NAMESPACE')}.svc"
                    f".cluster.local",
                ))

        if not self.settings.get("COUCHBASE_INDEX_NUM_REPLICA"):
            self.settings.set(
                "COUCHBASE_INDEX_NUM_REPLICA",
                click.prompt(
                    "Please enter the number of replicas per index created. "
                    "Please note that the number of index nodes must be one greater than the number of replicas. "
                    "That means if your couchbase cluster only has 2 "
                    "index nodes you cannot place the number of replicas to be higher than 1.",
                    default="0",
                ))

        if not self.settings.get("COUCHBASE_SUPERUSER"):
            self.settings.set(
                "COUCHBASE_SUPERUSER",
                click.prompt("Please enter couchbase superuser username.",
                             default="admin"))

        if not self.settings.get("COUCHBASE_SUPERUSER_PASSWORD"):
            self.settings.set("COUCHBASE_SUPERUSER_PASSWORD",
                              prompt_password("Couchbase superuser"))

        if not self.settings.get("COUCHBASE_USER"):
            self.settings.set(
                "COUCHBASE_USER",
                click.prompt("Please enter gluu couchbase username.",
                             default="gluu"))

        if not self.settings.get("COUCHBASE_PASSWORD"):
            self.settings.set("COUCHBASE_PASSWORD",
                              prompt_password("Couchbase Gluu user"))

        self.find_couchbase_certs_or_set_san_cn()
Пример #9
0
    def prompt_gluu_gateway(self):
        """Prompts for Gluu Gateway
        """
        if not self.settings.get("INSTALL_GLUU_GATEWAY"):
            self.settings.set(
                "INSTALL_GLUU_GATEWAY",
                confirm_yesno("Install Gluu Gateway Database mode"))

        if self.settings.get("INSTALL_GLUU_GATEWAY") == "Y":
            self.enabled_services.append("gluu-gateway-ui")
            self.settings.set("ENABLED_SERVICES_LIST", self.enabled_services)
            self.settings.set("ENABLE_CLIENT_API", "Y")
            self.postgres.prompt_postgres()
            if not self.settings.get("KONG_NAMESPACE"):
                self.settings.set(
                    "KONG_NAMESPACE",
                    click.prompt("Please enter a namespace for Gluu Gateway",
                                 default="gluu-gateway"))

            if not self.settings.get("GLUU_GATEWAY_UI_NAMESPACE"):
                self.settings.set(
                    "GLUU_GATEWAY_UI_NAMESPACE",
                    click.prompt(
                        "Please enter a namespace for gluu gateway ui",
                        default="gg-ui"))

            if not self.settings.get("KONG_PG_USER"):
                self.settings.set(
                    "KONG_PG_USER",
                    click.prompt(
                        "Please enter a user for gluu-gateway postgres database",
                        default="kong"))

            if not self.settings.get("KONG_PG_PASSWORD"):
                self.settings.set("KONG_PG_PASSWORD",
                                  prompt_password("gluu-gateway-postgres"))

            if not self.settings.get("GLUU_GATEWAY_UI_PG_USER"):
                self.settings.set(
                    "GLUU_GATEWAY_UI_PG_USER",
                    click.prompt(
                        "Please enter a user for gluu-gateway-ui postgres database",
                        default="konga"))

            if not self.settings.get("GLUU_GATEWAY_UI_PG_PASSWORD"):
                self.settings.set("GLUU_GATEWAY_UI_PG_PASSWORD",
                                  prompt_password("gluu-gateway-ui-postgres"))

            if not self.settings.get("KONG_DATABASE"):
                self.settings.set(
                    "KONG_DATABASE",
                    click.prompt(
                        "Please enter gluu-gateway postgres database name",
                        default="kong"))

            if not self.settings.get("GLUU_GATEWAY_UI_DATABASE"):
                self.settings.set(
                    "GLUU_GATEWAY_UI_DATABASE",
                    click.prompt(
                        "Please enter gluu-gateway-ui postgres database name",
                        default="konga"))
Пример #10
0
    def prompt_config(self):
        """Prompts for generation of configuration layer
        """
        check_fqdn_provided = False

        while True:
            if not self.settings.get("CN_FQDN") or check_fqdn_provided:
                self.settings.set(
                    "CN_FQDN",
                    click.prompt("Enter Hostname",
                                 default="demoexample.gluu.org"))

            regex_bool = re.match(
                '^(([a-zA-Z0-9]|[a-zA-Z0-9][a-zA-Z0-9\-]*[a-zA-Z0-9])\.){2,}([A-Za-z0-9]|[A-Za-z0-9][A-Za-z0-9\-]*[A-Za-z0-9]){2,}$',
                # noqa: W605
                self.settings.get("CN_FQDN"))

            if regex_bool:
                break
            else:
                check_fqdn_provided = True
                logger.error(
                    "Input not FQDN structred. Please enter a FQDN with the format demoexample.gluu.org"
                )

        if not self.settings.get("COUNTRY_CODE"):
            self.settings.set("COUNTRY_CODE",
                              click.prompt("Enter Country Code", default="US"))

        if not self.settings.get("STATE"):
            self.settings.set("STATE", click.prompt("Enter State",
                                                    default="TX"))

        if not self.settings.get("CITY"):
            self.settings.set("CITY",
                              click.prompt("Enter City", default="Austin"))

        if not self.settings.get("EMAIL"):
            self.settings.set(
                "EMAIL", click.prompt("Enter email",
                                      default="*****@*****.**"))

        if not self.settings.get("ORG_NAME"):
            self.settings.set(
                "ORG_NAME", click.prompt("Enter Organization", default="Gluu"))

        if not self.settings.get("ADMIN_PW"):
            self.settings.set("ADMIN_PW", prompt_password("oxTrust"))

        if not self.settings.get("LDAP_PW"):
            if self.settings.get("PERSISTENCE_BACKEND") in ("hybrid", "ldap"):
                self.settings.set("LDAP_PW", prompt_password("LDAP"))
            else:
                self.settings.set("LDAP_PW",
                                  self.settings.get("COUCHBASE_PASSWORD"))

        if self.settings.get("DEPLOYMENT_ARCH") in ("microk8s", "minikube"):
            self.settings.set("IS_CN_FQDN_REGISTERED", "N")

        if not self.settings.get("IS_CN_FQDN_REGISTERED"):
            self.settings.set(
                "IS_CN_FQDN_REGISTERED",
                confirm_yesno("Are you using a globally resolvable FQDN"))

        if self.settings.get("IS_CN_FQDN_REGISTERED") == "N":
            self.enabled_services.append("update-lb-ip")
            self.settings.set("ENABLED_SERVICES_LIST", self.enabled_services)

        logger.info(
            "You can mount your FQDN certification and key by placing them inside "
            "gluu.crt and gluu.key respectivley at the same location pygluu-kubernetes.pyz is at."
        )
        self.generate_main_config()
Пример #11
0
    def prompt_couchbase(self):
        self.arch.prompt_arch()
        self.namespace.prompt_gluu_namespace()

        if self.settings.get("global.storageClass.provisioner") \
                not in ("microk8s.io/hostpath", "k8s.io/minikube-hostpath"):
            self.backup.prompt_backup()

        if self.settings.get("global.lbIp") in (None, ''):
            ip = gather_ip
            self.settings.set("global.lbIp", ip)

        if self.settings.get("installer-settings.couchbase.install") in (None, ''):
            logger.info("For the following prompt  if placed [N] the couchbase is assumed to be"
                        " installed or remotely provisioned")
            self.settings.set("installer-settings.couchbase.install", click.confirm("Install Couchbase",
                                                                                    default=True))

        if not self.settings.get("installer-settings.couchbase.install"):
            if self.settings.get("config.configmap.cnCouchbaseCrt") in (None, ''):
                print("Place the Couchbase certificate authority certificate in a file called couchbase.crt at "
                      "the same location as the installation script.")
                print("This can also be found in your couchbase UI Security > Root Certificate")
                _ = input("Hit 'enter' or 'return' when ready.")
                with open(Path("./couchbase.crt")) as content_file:
                    ca_crt = content_file.read()
                    encoded_ca_crt_bytes = base64.b64encode(ca_crt.encode("utf-8"))
                    encoded_ca_crt_string = str(encoded_ca_crt_bytes, "utf-8")
                self.settings.set("config.configmap.cnCouchbaseCrt", encoded_ca_crt_string)
        else:
            self.settings.set("config.configmap.cnCouchbaseCrt", "")

        self.prompt_override_couchbase_files()

        if self.settings.get("global.storageClass.provisioner") \
                in ("microk8s.io/hostpath", "k8s.io/minikube-hostpath"):
            self.settings.set("installer-settings.couchbase.lowResourceInstall", True)

        if self.settings.get("installer-settings.couchbase.lowResourceInstall") in (None, ''):
            self.settings.set("installer-settings.couchbase.lowResourceInstall", click.confirm(
                "Setup CB nodes using low resources for demo purposes"))

        if not self.settings.get("installer-settings.couchbase.lowResourceInstall") and \
                not self.settings.get("installer-settings.couchbase.customFileOverride") and \
                self.settings.get("installer-settings.couchbase.install"):
            self.prompt_couchbase_yaml()

        if self.settings.get("installer-settings.couchbase.namespace") in (None, ''):
            self.settings.set("installer-settings.couchbase.namespace",
                              click.prompt("Please enter a namespace for CB objects.", default="cbns"))

        if self.settings.get("installer-settings.couchbase.clusterName") in (None, ''):
            self.settings.set("installer-settings.couchbase.clusterName",
                              click.prompt("Please enter a cluster name.", default="cbgluu"))

        if self.settings.get("config.configmap.cnCouchbaseUrl") in (None, ''):
            self.settings.set("config.configmap.cnCouchbaseUrl", click.prompt(
                "Please enter  couchbase (remote or local) URL base name",
                default=f"{self.settings.get('installer-settings.couchbase.clusterName')}."
                        f"{self.settings.get('installer-settings.couchbase.namespace')}.svc.cluster.local",
            ))

        if self.settings.get("config.configmap.cnCouchbaseBucketPrefix") in (None, ''):
            self.settings.set("config.configmap.cnCouchbaseBucketPrefix", click.prompt(
                "Please enter a  prefix name for all couchbase gluu buckets",
                default="gluu"
            ))

        if self.settings.get("config.configmap.cnCouchbaseIndexNumReplica") in (None, ''):
            self.settings.set("config.configmap.cnCouchbaseIndexNumReplica", click.prompt(
                "Please enter the number of replicas per index created. "
                "Please note that the number of index nodes must be one greater than the number of replicas. "
                "That means if your couchbase cluster only has 2 "
                "index nodes you cannot place the number of replicas to be higher than 1.",
                default="0",
            ))

        if self.settings.get("config.configmap.cnCouchbaseSuperUser") in (None, ''):
            self.settings.set("config.configmap.cnCouchbaseSuperUser",
                              click.prompt("Please enter couchbase superuser username.", default="admin"))

        if self.settings.get("config.configmap.cnCouchbaseSuperUserPassword") in (None, ''):
            self.settings.set("config.configmap.cnCouchbaseSuperUserPassword", prompt_password("Couchbase superuser"))

        if self.settings.get("config.configmap.cnCouchbaseUser") in (None, ''):
            self.settings.set("config.configmap.cnCouchbaseUser",
                              click.prompt("Please enter gluu couchbase username.", default="gluu"))

        if self.settings.get("config.configmap.cnCouchbasePassword") in (None, ''):
            self.settings.set("config.configmap.cnCouchbasePassword", prompt_password("Couchbase Gluu user"))

        self.find_couchbase_certs_or_set_san_cn()
Пример #12
0
    def prompt_jackrabbit(self):
        """Prompts for Jackrabbit content repository
        """
        if not self.settings.get("INSTALL_JACKRABBIT"):
            logger.info(
                "Jackrabbit must be installed. If the following prompt is answered with N it is assumed "
                "the jackrabbit content repository is either installed locally or remotely"
            )
            self.settings.set(
                "INSTALL_JACKRABBIT",
                confirm_yesno("Install Jackrabbit content repository",
                              default=True))

        jackrabbit_cluster_prompt = "Is"
        if self.settings.get("INSTALL_JACKRABBIT") == "Y":
            if not self.settings.get("JACKRABBIT_STORAGE_SIZE"):
                self.settings.set(
                    "JACKRABBIT_STORAGE_SIZE",
                    click.prompt(
                        "Size of Jackrabbit content repository volume storage",
                        default="4Gi"))
            self.settings.set("JACKRABBIT_URL", "http://jackrabbit:8080")
            jackrabbit_cluster_prompt = "Enable"

        if not self.settings.get("JACKRABBIT_URL"):
            self.settings.set(
                "JACKRABBIT_URL",
                click.prompt("Please enter jackrabbit url.",
                             default="http://jackrabbit:8080"))
        if not self.settings.get("JACKRABBIT_ADMIN_ID"):
            self.settings.set(
                "JACKRABBIT_ADMIN_ID",
                click.prompt("Please enter Jackrabit admin user",
                             default="admin"))

        if not self.settings.get("JACKRABBIT_ADMIN_PASSWORD"):
            self.settings.set("JACKRABBIT_ADMIN_PASSWORD",
                              prompt_password("jackrabbit-admin", 24))

        if not self.settings.get("JACKRABBIT_CLUSTER"):
            self.settings.set(
                "JACKRABBIT_CLUSTER",
                confirm_yesno("{} Jackrabbit in cluster mode[beta] "
                              "Recommended in production".format(
                                  jackrabbit_cluster_prompt),
                              default=True))
        if self.settings.get("JACKRABBIT_CLUSTER") == "Y":
            self.postgres.prompt_postgres()
            if not self.settings.get("JACKRABBIT_PG_USER"):
                self.settings.set(
                    "JACKRABBIT_PG_USER",
                    click.prompt(
                        "Please enter a user for jackrabbit postgres "
                        "database",
                        default="jackrabbit"))

            if not self.settings.get("JACKRABBIT_PG_PASSWORD"):
                self.settings.set("JACKRABBIT_PG_PASSWORD",
                                  prompt_password("jackrabbit-postgres"))

            if not self.settings.get("JACKRABBIT_DATABASE"):
                self.settings.set(
                    "JACKRABBIT_DATABASE",
                    click.prompt(
                        "Please enter jackrabbit postgres database name",
                        default="jackrabbit"))
Пример #13
0
    def prompt_config(self):
        """Prompts for generation of configuration layer
        """
        check_fqdn_provided = False

        while True:
            if self.settings.get("global.fqdn") in (None,
                                                    '') or check_fqdn_provided:
                self.settings.set(
                    "global.fqdn",
                    click.prompt("Enter Hostname",
                                 default="demoexample.gluu.org"))

            regex_bool = re.match(
                '^(([a-zA-Z0-9]|[a-zA-Z0-9][a-zA-Z0-9\\-]*[a-zA-Z0-9])\\.){2,}([A-Za-z0-9]|[A-Za-z0-9][A-Za-z0-9\\-]*[A-Za-z0-9]){2,}$',
                # noqa: W605
                self.settings.get("global.fqdn"))

            if regex_bool:
                break
            else:
                check_fqdn_provided = True
                logger.error(
                    "Input not FQDN structured. Please enter a FQDN with the format demoexample.gluu.org"
                )

        if self.settings.get("config.countryCode") in (None, ''):
            self.settings.set("config.countryCode",
                              click.prompt("Enter Country Code", default="US"))

        if self.settings.get("config.state") in (None, ''):
            self.settings.set("config.state",
                              click.prompt("Enter State", default="TX"))

        if self.settings.get("config.city") in (None, ''):
            self.settings.set("config.city",
                              click.prompt("Enter City", default="Austin"))

        if self.settings.get("config.email") in (None, ''):
            self.settings.set(
                "config.email",
                click.prompt("Enter email", default="*****@*****.**"))

        if self.settings.get("config.orgName") in (None, ''):
            self.settings.set(
                "config.orgName",
                click.prompt("Enter Organization", default="Gluu"))

        if self.settings.get("config.adminPassword") in (None, ''):
            self.settings.set("config.adminPassword",
                              prompt_password("Admin GUI"))

        if self.settings.get("config.ldapPassword") in (None, ''):
            if self.settings.get("global.cnPersistenceType") in ("hybrid",
                                                                 "ldap"):
                self.settings.set("config.ldapPassword",
                                  prompt_password("OpenDJ"))
            else:
                self.settings.set(
                    "config.ldapPassword",
                    self.settings.get("config.configmap.cnCouchbasePass"))

        if self.settings.get("global.storageClass.provisioner") in (
                "microk8s.io/hostpath", "k8s.io/minikube-hostpath"):
            self.settings.set("global.isFqdnRegistered", False)

        if self.settings.get("global.isFqdnRegistered") in (None, ''):
            self.settings.set(
                "global.isFqdnRegistered",
                click.confirm("Are you using a globally resolvable FQDN"))

        if self.settings.get("config.migration.enabled") in (None, ''):
            self.settings.set(
                "config.migration.enabled",
                click.confirm(
                    "Are you migrating from the Gluu community edition (VM base)"
                ))

        if self.settings.get("config.migration.enabled"):
            if self.settings.get("config.migration.migrationDir") in (None,
                                                                      ''):
                self.settings.set(
                    "config.migration.migrationDir",
                    click.prompt(
                        "Directory holding the community edition migration files",
                        default="./ce-migration"))

            if self.settings.get("config.migration.migrationDataFormat") in (
                    None, ''):
                while self.settings.get("config.migration.migrationDataFormat"
                                        ) not in ("ldif", "couchbase+json",
                                                  "spanner+avro",
                                                  "postgresql+json",
                                                  "mysql+json"):
                    logger.info(
                        "Supported data formats are ldif, couchbase+json, spanner+avro, "
                        "postgresql+json, and mysql+json ")
                    self.settings.set(
                        "config.migration.migrationDataFormat",
                        click.prompt(
                            "Migration data-format depending on persistence backend. "
                            "Supported data formats are ldif, couchbase+json, spanner+avro, "
                            "postgresql+json, and mysql+json ",
                            default="ldif"))
        logger.info(
            "You can mount your FQDN certification and key by placing them inside "
            "gluu.crt and gluu.key respectively at the same location pygluu-kubernetes.pyz is at."
        )