예제 #1
0
    def setUpClass(cls):
        # The rule to evaluate number as boolean is inspired by C++11 implementation
        # All numbers but 0 and True or true will be evaluated as True
        cls.logging = re.search(r'^-?[1-9][0-9]*$|^[Tt]rue$',
                                os.getenv("LOG_TO_STDOUT", "False")) != None
        path = os.getenv("CONFIG_YAML", DEFAULT_CONFIG_YAML)
        cls.account = read_yaml_file(path)
        cls.account["credentials"] = (lookup_values(
            cls.account.get("credentials_keys")))
        if "resources" in cls.account:
            cls.resource_data = cls.account.get("resources")
        else:
            cls.resource_data = [{
                "resource":
                cls.account.get("resource"),
                "expected_metrics":
                cls.account.get("expected_metrics")
            }]

        cls.runner = Flexer()
        cfg = load_config(cfg_file=CONFIG_FILE)["regions"]["default"]
        client = CmpClient(url=cfg["cmp_url"],
                           auth=(cfg['cmp_api_key'], cfg['cmp_api_secret']))
        cls.context = FlexerContext(cmp_client=client)
        secrets = (lookup_values(cls.account.get("secrets_keys")))
        cls.context.secrets = secrets
예제 #2
0
파일: commands.py 프로젝트: ddr-hf/flexer
def add_config_region(name, url, key, secret):
    config = read_yaml_file(CONFIG_FILE)
    config["regions"][str(name)] = {
        "cmp_url": str(url),
        "cmp_api_key": str(key),
        "cmp_api_secret": str(secret),
    }
    write_yaml_file(CONFIG_FILE, config)
    return config
예제 #3
0
    def setUpClass(cls):
        path = os.getenv("CONFIG_YAML", DEFAULT_CONFIG_YAML)
        cls.account = read_yaml_file(path)
        cls.account["credentials"] = (lookup_credentials(
            cls.account.get("credentials_keys")))

        cls.runner = Flexer()
        cfg = load_config(cfg_file=CONFIG_FILE)["regions"]["default"]
        client = CmpClient(url=cfg["cmp_url"],
                           auth=(cfg['cmp_api_key'], cfg['cmp_api_secret']))
        cls.context = FlexerContext(cmp_client=client)
예제 #4
0
def add_config_region(name, url, key, secret, extra_headers):
    new_region = {
        "cmp_url": str(url),
        "cmp_api_key": str(key),
        "cmp_api_secret": str(secret),
    }
    if extra_headers:
        new_region["extra_headers"] = \
            {str(k): str(v) for k, v in extra_headers}

    config = read_yaml_file(CONFIG_FILE)
    config["regions"][str(name)] = new_region
    write_yaml_file(CONFIG_FILE, config)
    return config