コード例 #1
0
ファイル: questions.py プロジェクト: a2lin/paasta
def get_monitoring_stanza(auto, team, legacy_style=False):
    """Produce a monitoring.yaml in a `format <yelpsoa_configs.html#monitoring-yaml>`_
    that PaaSTA can read.

    'team' is the critical key and is not calculable so it is required.

    legacy_style changes some behavior for use with wizard.py.
    """
    all_teams = list_teams()
    if team is None:
        if auto and not legacy_style:
            sys.exit("I'd Really Rather You Didn't Use --auto Without --team")
        while not team:
            print "Here are the existing teams:"
            print ", ".join(sorted(all_teams))
            team = ask("Team responsible for this service?")
    if not all_teams:
        sys.stderr.write("Warning: No sensu teams are defined on disk, cannot perform validation on this team name")
    elif team not in all_teams:
        print "I Don't See Your Team '%s' In The List Of Valid Teams:" % team
        sys.exit(", ".join(sorted(all_teams)))

    stanza = {}
    stanza["team"] = team
    stanza["service_type"] = "marathon"
    if legacy_style:
        stanza["service_type"] = "classic"
    return stanza
コード例 #2
0
def get_monitoring_stanza(auto, team):
    """Produce a monitoring.yaml in a `format <yelpsoa_configs.html#monitoring-yaml>`_
    that PaaSTA can read.

    'team' is the critical key and is not calculable so it is required.
    """
    all_teams = list_teams()
    if team is None:
        if auto:
            sys.exit("I'd Really Rather You Didn't Use --auto Without --team")
        while not team:
            print "Here are the existing teams:"
            print ", ".join(sorted(all_teams))
            team = ask("Team responsible for this service?")
    if not all_teams:
        sys.stderr.write(
            "Warning: No sensu teams are defined on disk, cannot perform validation on this team name"
        )
    elif team not in all_teams:
        print "I Don't See Your Team '%s' In The List Of Valid Teams:" % team
        sys.exit(", ".join(sorted(all_teams)))

    stanza = {}
    stanza["team"] = team
    stanza["service_type"] = "marathon"
    return stanza
コード例 #3
0
ファイル: test_utils.py プロジェクト: georgekola/paasta
def test_list_teams():
    fake_team_data = {
        'team_data': {
            'red_jaguars': {
                'pagerduty_api_key': 'aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa',
                'pages_irc_channel': 'red_jaguars_pages',
                'notifications_irc_channel': 'red_jaguars_notifications',
                'notification_email': '*****@*****.**',
                'project': 'REDJAGS'
            },
            'blue_barracudas': {
                'pagerduty_api_key': 'bbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbb',
                'pages_irc_channel': 'blue_barracudas_pages',
            },
        }
    }
    expected = set([
        'red_jaguars',
        'blue_barracudas',
    ])
    with mock.patch(
        'paasta_tools.paasta_cli.utils._load_sensu_team_data',
        autospec=True,
        return_value=fake_team_data,
    ):
        actual = utils.list_teams()
    assert actual == expected