Example #1
0
def do_servicenode_list(cc, args):
    """List Service Nodes."""
    try:
        node = cc.smc_service_node.list()
    except exc.Forbidden:
        raise exc.CommandError("Not authorized. The requested action "
                               "requires 'admin' level")
    else:
        fields = ['id', 'name', 'administrative_state', 'operational_state',
                  'availability_status', 'ready_state']
        field_labels = ['id', 'name', 'administrative', 'operational',
                        'availability', 'ready_state']
        utils.print_list(node, fields, field_labels, sortby=1)
Example #2
0
def do_servicegroup_list(cc, args):
    """List Service Groups."""
    try:
        servicegroup = cc.smc_servicegroup.list()
    except exc.Forbidden:
        raise exc.CommandError("Not authorized. The requested action "
                               "requires 'admin' level")
    else:
        fields = ['uuid', 'service_group_name', 'node_name', 'state']
        field_labels = ['uuid', 'service_group_name', 'hostname', 'state']
        for s in servicegroup:
            if s.status:
                s.state = (s.state + '-' + s.status)
        utils.print_list(servicegroup, fields, field_labels, sortby=1)
Example #3
0
def do_service_list(cc, args):
    """List Services."""
    try:
        service = cc.smc_service.list()
    except exc.Forbidden:
        raise exc.CommandError("Not authorized. The requested action "
                               "requires 'admin' level")
    else:
        fields = ['id', 'name', 'node_name', 'state']
        field_labels = ['id', 'service_name', 'hostname', 'state']
        # remove the entry in the initial state
        clean_list = [x for x in service if x.state != 'initial']
        for s in clean_list:
            if s.status:
                s.state = (s.state + '-' + s.status)
            if getattr(s, 'node_name', None) is None:
                s.node_name = socket.gethostname()

        utils.print_list(clean_list, fields, field_labels, sortby=1)