예제 #1
0
def config_rabbitmq(config, path, menu_return):
    action = "RabbitMQ Configuration"
    config = conf.load_config(path)
    rabbit_password = input(Colors.FG.Yellow + "RabbitMQ Password:"******"queue"] = {}
    config["queue"]["amqp"] = {}
    config["queue"]["amqp"]["host"] = "rabbitmq"
    config["queue"]["amqp"]["port"] = "5672"
    config["queue"]["amqp"]["user"] = "******"
    config["queue"]["amqp"]["password"] = rabbit_password
    config["queue"]["amqp"]["virtualhost"] = "/"
    config["queue"]["amqp"]["ssl"] = "false"
    config["queue"]["amqp"]["ssl_options"] = {}

    consumers = check_output(['php', path + '/bin/magento', 'queue:consumers:list'])


    if "cron_consumers_runner" in config:
        del config["cron_consumers_runner"]
    config["cron_consumers_runner"] = {}
    config["cron_consumers_runner"]["cron_run"] = "True"
    config["cron_consumers_runner"]["max_messages"] = 0
    config["cron_consumers_runner"]["consumers"] = consumers.decode("utf-8").splitlines()
    conf.save_config(config, path)
    print(Colors.FG.LightGreen + Colors.Bold + action + " Completed!" + Colors.Reset)
    if menu_return == 1:
        menu.rabbit_menu(config, path)
예제 #2
0
def config_cache(config, path):
    if "cache" in config:
        del config["cache"]

    config["cache"] = {}
    config["cache"]["frontend"] = {}
    config["cache"]["frontend"]["default"] = {}
    config["cache"]["frontend"]["default"][
        "backend"] = "Cm_Cache_Backend_Redis"
    config["cache"]["frontend"]["default"]["backend_options"] = {}
    config["cache"]["frontend"]["default"]["backend_options"][
        "server"] = "redis-config-cache"
    config["cache"]["frontend"]["default"]["backend_options"]["database"] = "0"
    config["cache"]["frontend"]["default"]["backend_options"]["port"] = "6381"
    config["cache"]["frontend"]["page_cache"] = {}
    config["cache"]["frontend"]["page_cache"][
        "backend"] = "Cm_Cache_Backend_Redis"
    config["cache"]["frontend"]["page_cache"]["backend_options"] = {}
    config["cache"]["frontend"]["page_cache"]["backend_options"][
        "server"] = "redis"
    config["cache"]["frontend"]["page_cache"]["backend_options"][
        "port"] = "6379"
    config["cache"]["frontend"]["page_cache"]["backend_options"][
        "database"] = "1"
    config["cache"]["frontend"]["page_cache"]["backend_options"][
        "compress_data"] = "1"
    Conf.save_config(config, path)
    Menu.main_menu(config, path)
예제 #3
0
def config_sessions(config, path):
    if "save" in config["session"]:
        del config["session"]["save"]
    config["session"] = {}
    config["session"]["save"] = "redis"
    config["session"]["redis"] = {}
    config["session"]["redis"]["host"] = "redis-session"
    config["session"]["redis"]["port"] = "6380"
    config["session"]["redis"]["password"] = ""
    config["session"]["redis"]["timeout"] = "2.5"
    config["session"]["redis"]["persistent_identifier"] = ""
    config["session"]["redis"]["database"] = "2"
    config["session"]["redis"]["compression_threshold"] = "2048"
    config["session"]["redis"]["compression_library"] = "gzip"
    config["session"]["redis"]["log_level"] = "1"
    config["session"]["redis"]["max_concurrency"] = "20"
    config["session"]["redis"]["break_after_frontend"] = "5"
    config["session"]["redis"]["break_after_adminhtml"] = "30"
    config["session"]["redis"]["first_lifetime"] = "600"
    config["session"]["redis"]["bot_first_lifetime"] = "60"
    config["session"]["redis"]["bot_lifetime"] = "7200"
    config["session"]["redis"]["disable_locking"] = "1"
    config["session"]["redis"]["min_lifetime"] = "60"
    config["session"]["redis"]["max_lifetime"] = "2592000"
    Conf.save_config(config, path)
    Menu.main_menu(config, path)
예제 #4
0
def config_rabbitmq(config, path):
    rabbit_password = input(Colors.WARNING + "RabbitMQ Password:"******"queue" in config:
        del config["queue"]
    config["queue"] = {}
    config["queue"]["amqp"] = {}
    config["queue"]["amqp"]["host"] = "rabbitmq"
    config["queue"]["amqp"]["port"] = "5672"
    config["queue"]["amqp"]["user"] = "******"
    config["queue"]["amqp"]["password"] = rabbit_password
    config["queue"]["amqp"]["virtualhost"] = "/"
    config["queue"]["amqp"]["ssl"] = "false"
    config["queue"]["amqp"]["ssl_options"] = {}

    consumers = check_output(
        ['php', path + '/bin/magento', 'queue:consumers:list'])

    if "cron_consumers_runner" in config:
        del config["cron_consumers_runner"]
    config["cron_consumers_runner"] = {}
    config["cron_consumers_runner"]["cron_run"] = "True"
    config["cron_consumers_runner"]["max_messages"] = 0
    config["cron_consumers_runner"]["consumers"] = consumers.decode(
        "utf-8").splitlines()
    Conf.save_config(config, path)
    Menu.main_menu(config, path)
예제 #5
0
def check_rabbitmq(config, path, menu_return):
    if "queue" not in config:
        config_rabbitmq(config, path, menu_return)
    elif "amqp" in config["queue"]:
        del config["queue"]
        conf.save_config(config, path)
        config_rabbitmq(config, path, menu_return)
    else:
        config_rabbitmq(config, path, menu_return)
예제 #6
0
def check_redis_sessions(config, path, menu_return):
    if "save" not in config:
        config_sessions(config, path, menu_return)
    elif "save" in config:
        del config["save"]
        conf.save_config(config, path)
        config_sessions(config, path, menu_return)
    else:
        config_sessions(config, path, menu_return)
예제 #7
0
def check_redis_cache(config, path, menu_return):
    if "cache" not in config:
        config_cache(config, path, menu_return)
    elif "cache" in config:
        del config["cache"]
        conf.save_config(config, path)
        config_cache(config, path, menu_return)
    else:
        config_cache(config, path, menu_return)
예제 #8
0
def check_varnish(config, path, menu_return):
    if "http_cache_hosts" not in config:
        config_varnish(config, path, menu_return)
    elif "http_cache_hosts" in config:
        del config["http_cache_hosts"]
        conf.save_config(config, path)
        config_varnish(config, path, menu_return)
    else:
        config_varnish(config, path, menu_return)
예제 #9
0
def update_mysql_credentials_from_system(config, path, menu_return):
    action = "Update MySQL Credentials"
    db_creds = get_mysql_credentials()
    if db_creds is not False:
        config["db"]["connection"]["default"]["host"] = "mysql"
        config["db"]["connection"]["default"]["dbname"] = db_creds["Name"]
        config["db"]["connection"]["default"]["username"] = db_creds[
            "Username"]
        config["db"]["connection"]["default"]["password"] = db_creds[
            "Password"]
        conf.save_config(config, path)
        print(Colors.FG.LightGreen + Colors.Bold + action + " Completed!" +
              Colors.Reset)
    else:
        print(Colors.FG.Red + Colors.Bold +
              "Error getting database credentials from Stratus CLI" +
              Colors.Reset)
        print(Colors.FG.Red + Colors.Bold + action +
              " not completed. Returning to Menu." + Colors.Reset)
    if menu_return == 1:
        menu.main_menu(path)