Пример #1
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
Пример #2
0
def get_external_link(link, auto):
    if link is None:
        if auto:
            link = "Please add a link to a reference doc for your service"
        while not link:
            link = ask('Link to a reference doc?')
    return link
Пример #3
0
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
Пример #4
0
def get_description(description, auto):
    if description is None:
        if auto:
            description = "Please fill in a one-line description of this service"
        while not description:
            description = ask('One line description of this service?')
    return description
Пример #5
0
def get_external_link(link, auto):
    if link is None:
        if auto:
            link = "Please add a link to a reference doc for your service"
        while not link:
            link = ask('Link to a reference doc?')
    return link
Пример #6
0
def get_description(description, auto):
    if description is None:
        if auto:
            description = "Please fill in a one-line description of this service"
        while not description:
            description = ask('One line description of this service?')
    return description
Пример #7
0
def get_srvname(srvname, auto):
    if srvname is None:
        if auto:
            sys.exit("I'd Really Rather You Didn't Use --auto Without --service-name")
        while not srvname:
            srvname = ask('Service name?')
    return srvname
Пример #8
0
def get_srvname(srvname, auto):
    if srvname is None:
        if auto:
            sys.exit(
                "I'd Really Rather You Didn't Use --auto Without --service-name"
            )
        while not srvname:
            srvname = ask('Service name?')
    return srvname
Пример #9
0
def get_smartstack_stanza(yelpsoa_config_root, auto, port):
    """Produce a basic smartstack.yaml in a `format <yelpsoa_configs.html#smartstack-yaml>`_
    PaaSTA can use.
    """
    if port is None:
        suggested_port = suggest_smartstack_proxy_port(yelpsoa_config_root)
        if auto:
            port = suggested_port
        else:
            port = ask("Smartstack proxy_port?", suggested_port)
    smartstack_stanza = {}
    key_name = "main"
    smartstack_stanza[key_name] = {
        "advertise": ["superregion"],
        "discover": "superregion",
        "proxy_port": int(port),
        # Make the service available across all of testopia.
        # See SRV-1715 for more background.
        "extra_advertise": {
            "ecosystem:testopia": ["ecosystem:testopia"]
        }
    }
    return smartstack_stanza
Пример #10
0
def get_smartstack_stanza(yelpsoa_config_root, auto, port):
    """Produce a basic smartstack.yaml in a `format <yelpsoa_configs.html#smartstack-yaml>`_
    PaaSTA can use.
    """
    if port is None:
        suggested_port = suggest_smartstack_proxy_port(yelpsoa_config_root)
        if auto:
            port = suggested_port
        else:
            port = ask("Smartstack proxy_port?", suggested_port)
    smartstack_stanza = {}
    key_name = "main"
    smartstack_stanza[key_name] = {
        "advertise": ["superregion"],
        "discover": "superregion",
        "proxy_port": int(port),
        # Make the service available across all of testopia.
        # See SRV-1715 for more background.
        "extra_advertise": {
            "ecosystem:testopia": ["ecosystem:testopia"]
        }
    }
    return smartstack_stanza