Beispiel #1
0
def get_status_line(components):
    nr_services_total = nr_services_up = 0
    nr_frontservices_total = nr_frontservices_up = 0
    for service in [
            s for s in components.values()
            if isinstance(s, yadtshell.components.Service)
    ]:
        nr_services_total += 1
        if service.is_up():
            nr_services_up += 1
        if getattr(service, 'is_frontservice', False):
            nr_frontservices_total += 1
            if service.is_up():
                nr_frontservices_up += 1

    nr_hosts_uptodate = nr_hosts_total = 0
    for host in [
            h for h in components.values()
            if isinstance(h, yadtshell.components.Host)
    ]:
        nr_hosts_total += 1
        if host.is_uptodate():
            nr_hosts_uptodate += 1

    if nr_hosts_total == 0:
        return 'no hosts configured'

    services_desc = 'services'
    if nr_frontservices_total > 0:
        nr_services_up = nr_frontservices_up
        nr_services_total = nr_frontservices_total
        services_desc = 'frontservices'
    if nr_services_up > 0:
        services_up_ratio = 100 * nr_services_up / nr_services_total
    else:
        services_up_ratio = 0
    hosts_uptodate_ratio = 100 * nr_hosts_uptodate / nr_hosts_total

    return '%3.0f%% %3.0f%% | %i/%i %s up, %i/%i hosts uptodate' % (
        services_up_ratio, hosts_uptodate_ratio, nr_services_up,
        nr_services_total, services_desc, nr_hosts_uptodate, nr_hosts_total)
Beispiel #2
0
def get_status_line(components):
    nr_services_total = nr_services_up = 0
    nr_frontservices_total = nr_frontservices_up = 0
    for service in [s for s in components.values() if isinstance(s, yadtshell.components.Service)]:
        nr_services_total += 1
        if service.is_up():
            nr_services_up += 1
        if getattr(service, 'is_frontservice', False):
            nr_frontservices_total += 1
            if service.is_up():
                nr_frontservices_up += 1

    nr_hosts_uptodate = nr_hosts_total = 0
    for host in [h for h in components.values() if isinstance(h, yadtshell.components.Host)]:
        nr_hosts_total += 1
        if host.is_uptodate():
            nr_hosts_uptodate += 1

    if nr_hosts_total == 0:
        return 'no hosts configured'

    services_desc = 'services'
    if nr_frontservices_total > 0:
        nr_services_up = nr_frontservices_up
        nr_services_total = nr_frontservices_total
        services_desc = 'frontservices'
    if nr_services_up > 0:
        services_up_ratio = 100 * nr_services_up / nr_services_total
    else:
        services_up_ratio = 0
    hosts_uptodate_ratio = 100 * nr_hosts_uptodate / nr_hosts_total

    return '%3.0f%% %3.0f%% | %i/%i %s up, %i/%i hosts uptodate' % (
        services_up_ratio, hosts_uptodate_ratio,
        nr_services_up, nr_services_total, services_desc,
        nr_hosts_uptodate, nr_hosts_total)
Beispiel #3
0
def compute_dependency_scores(components):
    servicedefs = dict((component.uri, component)
                       for component in components.values() if isinstance(component, yadtshell.components.Service))

    #  we cannot compute the dependency scores if there is a service cycle
    t = ServiceDefinitionValidator(servicedefs)
    t.assert_no_cycles_present()

    for service, servicedef in servicedefs.iteritems():
        outbound_edges = len(
            outbound_deps_on_same_host(servicedef, components))
        inbound_edges = len(inbound_deps_on_same_host(servicedef, components))
        if outbound_edges == inbound_edges == 0:
            servicedef.dependency_score = STANDALONE_SERVICE_RANK
        else:
            servicedef.dependency_score = inbound_edges - outbound_edges
Beispiel #4
0
def compute_dependency_scores(components):
    servicedefs = dict((component.uri, component)
                       for component in components.values()
                       if isinstance(component, yadtshell.components.Service))

    #  we cannot compute the dependency scores if there is a service cycle
    t = ServiceDefinitionValidator(servicedefs)
    t.assert_no_cycles_present()

    for service, servicedef in servicedefs.iteritems():
        outbound_edges = len(outbound_deps_on_same_host(
            servicedef, components))
        inbound_edges = len(inbound_deps_on_same_host(servicedef, components))
        if outbound_edges == inbound_edges == 0:
            servicedef.dependency_score = STANDALONE_SERVICE_RANK
        else:
            servicedef.dependency_score = inbound_edges - outbound_edges