def create(policy_types=None,
           policy_triggers=None,
           groups=None,
           **_):

    policy_types = policy_types or {}
    groups = groups or {}
    policy_triggers = policy_triggers or {}

    _process_types_and_triggers(groups, policy_types, policy_triggers)
    deployment_config_dir_path = _deployment_config_dir()
    if not os.path.isdir(deployment_config_dir_path):
        os.makedirs(deployment_config_dir_path)
        os.chmod(deployment_config_dir_path, 0777)
    with open(_deployment_config_template()) as f:
        deployment_config_template = f.read()
    with open(os.path.join(_deployment_config_dir(), 'groups'), 'w') as f:
        f.write(json.dumps(groups))
    with open(path.join(deployment_config_dir_path,
                        'deployment.config'), 'w') as f:
        f.write(config.create(ctx,
                              policy_types,
                              policy_triggers,
                              groups,
                              deployment_config_template))
    _publish_configuration_event('start', deployment_config_dir_path)
    _verify_core_up(deployment_config_dir_path)
Пример #2
0
def create(api_token,
           policy_types=None,
           policy_triggers=None,
           groups=None,
           **_):

    policy_types = policy_types or {}
    groups = groups or {}
    policy_triggers = policy_triggers or {}

    _process_types_triggers_and_groups(groups, policy_types, policy_triggers)
    deployment_config_dir_path = _deployment_config_dir()
    if not os.path.isdir(deployment_config_dir_path):
        os.makedirs(deployment_config_dir_path)
        os.chmod(deployment_config_dir_path, 0777)
    with open(_deployment_config_template()) as f:
        deployment_config_template = f.read()
    with open(os.path.join(_deployment_config_dir(), 'groups'), 'w') as f:
        f.write(json.dumps(groups))
    with open(path.join(deployment_config_dir_path, 'deployment.config'),
              'w') as f:
        f.write(
            config.create(ctx, policy_types, policy_triggers, groups,
                          deployment_config_template, api_token,
                          ctx.tenant_name))
    _publish_configuration_event('start', deployment_config_dir_path)
    _verify_core_up(deployment_config_dir_path)
Пример #3
0
def create(api_token,
           policy_types=None,
           policy_triggers=None,
           groups=None,
           **_):
    if not path.isdir(os.environ[RIEMANN_CONFIGS_DIR]):
        raise NonRecoverableError(
            'Riemann configs dir "{path}" does not exist. '
            'It is likely that this manager does not have monitoring '
            'components installed. Please try deploying a blueprint without '
            'configured policies.'.format(
                path=os.environ[RIEMANN_CONFIGS_DIR], ))

    policy_types = policy_types or {}
    groups = groups or {}
    policy_triggers = policy_triggers or {}

    _process_types_triggers_and_groups(groups, policy_types, policy_triggers)
    deployment_config_dir_path = _deployment_config_dir()
    if not os.path.isdir(deployment_config_dir_path):
        os.makedirs(deployment_config_dir_path)
        os.chmod(deployment_config_dir_path, 0777)
    with open(_deployment_config_template()) as f:
        deployment_config_template = f.read()
    with open(os.path.join(_deployment_config_dir(), 'groups'), 'w') as f:
        f.write(json.dumps(groups))
    with open(path.join(deployment_config_dir_path, 'deployment.config'),
              'w') as f:
        f.write(
            config.create(ctx, policy_types, policy_triggers, groups,
                          deployment_config_template, api_token,
                          ctx.tenant_name))
    _publish_configuration_event('start', deployment_config_dir_path)
    _verify_core_up(deployment_config_dir_path)