Example #1
0
def run_deploy():

    args = Args()
    if not args.try_configure_connect_to_pg():
        sys.exit(1)

    if not Pooler.is_superuser():
        sys.stderr.write("ERROR: Bootstrap must be run by PostgreSQL superuser\n")
        sys.exit(1)

    try:
        for sql in CreateSchemaSQL.split(QuerySplit):
            if args.args.verbose:
                sys.stdout.write("\nExecuting query:\n{0}\n".format(sql))
            Pooler.query(sql)
    except Exception as e:
        sys.stderr.write("Query:\n{0}\nerror: {1}\n".format(sql, e))
        sys.exit(2)

    try:
        for sql in GrantsOnSchemaSQL.format(
            mamonsu_version.replace('.', '_'), args.args.mamonsu_username).split(QuerySplit):
            if args.args.verbose:
                sys.stdout.write("\nExecuting query:\n{0}\n".format(sql))
            Pooler.query(sql)
    except Exception as e:
        sys.stderr.write("Query:\n{0}\nerror: {1}\n".format(sql, e))
        sys.exit(2)

    sys.stdout.write("Bootstrap successfully completed\n")
Example #2
0
def run_deploy():
    args = Args()
    if not args.try_configure_connect_to_pg():
        sys.exit(1)

    if not Pooler.is_superuser():
        sys.stderr.write(
            "ERROR: Bootstrap must be run by PostgreSQL superuser\n")
        sys.exit(1)

    try:
        for sql in CreateSchemaSQL.format(
                mamonsu_version,
                mamonsu_version.replace('.', '_'),
                '[0-9A-F]{24}',
                'wal' if Pooler.server_version_greater('10.0') else 'xlog',
                'wal_lsn' if Pooler.server_version_greater('10.0') else 'xlog_location',
                'waiting' if Pooler.server_version_less('9.6.0') else 'case when wait_event_type is null then false '
                                                                      ' else true end  as waiting'
        ).split(QuerySplit):
            if args.args.verbose:
                sys.stdout.write("\nExecuting query:\n{0}\n".format(sql))
            Pooler.query(sql)
    except Exception as e:
        sys.stderr.write("Query:\n{0}\nerror: {1}\n".format(sql, e))
        sys.exit(2)
    try:
        for sql in GrantsOnSchemaSQL.format(
                mamonsu_version.replace('.', '_'),
                args.args.mamonsu_username,
                'wal' if Pooler.server_version_greater('10.0') else 'xlog'
        ).split(QuerySplit):
            if args.args.verbose:
                sys.stdout.write("\nExecuting query:\n{0}\n".format(sql))
            Pooler.query(sql)
    except Exception as e:
        sys.stderr.write("Query:\n{0}\nerror: {1}\n".format(sql, e))
        sys.exit(2)

    sys.stdout.write("Bootstrap successfully completed\n")