Ejemplo n.º 1
0
def do_cluster_status(args):
    state = load_state()

    node_controller = get_node_controller(state, args)
    node_command_generator = SimpleNodeCommandGenerator()
    vnm = ValidatorNetworkManager(
        node_controller=node_controller,
        node_command_generator=node_command_generator)

    if len(args.node_names) > 0:
        node_names = args.node_names
    else:
        node_names = vnm.get_node_names()

    # Check expected status of nodes vs what is returned from vnm
    print("NodeName Expected Current")
    nodes = state["Nodes"]
    for node_name in nodes:
        if node_name not in node_names and \
                (nodes[node_name]["Status"] == "Running" or
                    nodes[node_name]["Status"] == "No Response"):
            print("{} {} {}".format(node_name, nodes[node_name]["Status"],
                                    "Not Running"))
        else:
            status = vnm.status(node_name)
            if status == "UNKNOWN" and \
                    nodes[node_name]["Status"] == "Stopped":
                print("{} {} {}".format(node_name, nodes[node_name]["Status"],
                                        status))
            else:
                print("{} {} {}".format(node_name, nodes[node_name]["Status"],
                                        status))
Ejemplo n.º 2
0
def do_cluster_status(args):
    # pylint: disable=redefined-variable-type
    file_name = \
        os.path.join(os.path.expanduser("~"), '.sawtooth', 'cluster',
                     "state.yaml")
    # Get current expected state
    if os.path.isfile(file_name):
        with open(file_name, 'r') as state_file:
            state = yaml.load(state_file)
    else:
        raise CliException("Missing state file")

    if state['Manage'] is None or state['Manage'] == 'docker':
        node_controller = DockerNodeController()
    elif state['Manage'] == 'daemon':
        node_controller = DaemonNodeController()
    else:
        raise CliException('invalid management'
                           ' type: {}'.format(state['Manage']))

    node_command_generator = SimpleNodeCommandGenerator()

    vnm = ValidatorNetworkManager(
        node_controller=node_controller,
        node_command_generator=node_command_generator)

    if len(args.node_names) > 0:
        node_names = args.node_names
    else:
        node_names = vnm.get_node_names()

    # Check expected status of nodes vs what is returned from vnm
    print "NodeName Expected Current"
    nodes = state["Nodes"]
    for node_name in nodes:
        if node_name not in node_names and \
                (nodes[node_name]["Status"] == "Running" or
                    nodes[node_name]["Status"] == "No Response"):
            print "{} {} {}".format(node_name, nodes[node_name]["Status"],
                                    "Not Running")
        else:
            status = vnm.status(node_name)
            if status == "UNKNOWN" and \
                    nodes[node_name]["Status"] == "Stopped":
                print "{} {} {}".format(node_name, nodes[node_name]["Status"],
                                        status)
            else:
                print "{} {} {}".format(node_name, nodes[node_name]["Status"],
                                        status)
Ejemplo n.º 3
0
def do_cluster_status(args):
    # pylint: disable=redefined-variable-type
    file_name = \
        os.path.join(os.path.expanduser("~"), '.sawtooth', 'cluster',
                     "state.yaml")
    # Get current expected state
    if os.path.isfile(file_name):
        with open(file_name, 'r') as state_file:
            state = yaml.load(state_file)
    else:
        raise CliException("Missing state file")

    if state['Manage'] is None or state['Manage'] == 'docker':
        node_controller = DockerNodeController()
    elif state['Manage'] == 'daemon':
        node_controller = DaemonNodeController()
    else:
        raise CliException('invalid management'
                           ' type: {}'.format(state['Manage']))

    node_command_generator = SimpleNodeCommandGenerator()

    vnm = ValidatorNetworkManager(
        node_controller=node_controller,
        node_command_generator=node_command_generator)

    if len(args.node_names) > 0:
        node_names = args.node_names
    else:
        node_names = vnm.get_node_names()

    # Check expected status of nodes vs what is returned from vnm
    print "NodeName Expected Current"
    nodes = state["Nodes"]
    for node_name in nodes:
        if node_name not in node_names and \
                (nodes[node_name]["Status"] == "Running" or
                    nodes[node_name]["Status"] == "No Response"):
            print "{} {} {}".format(
                node_name, nodes[node_name]["Status"], "Not Running")
        else:
            status = vnm.status(node_name)
            if status == "UNKNOWN" and \
                    nodes[node_name]["Status"] == "Stopped":
                print "{} {} {}".format(node_name, nodes[node_name]["Status"],
                                        status)
            else:
                print "{} {} {}".format(node_name, nodes[node_name]["Status"],
                                        status)
Ejemplo n.º 4
0
def do_cluster_status(args):
    state = load_state()

    node_controller = get_node_controller(state, args)
    node_command_generator = SimpleNodeCommandGenerator()
    vnm = ValidatorNetworkManager(
        node_controller=node_controller,
        node_command_generator=node_command_generator)

    if len(args.node_names) > 0:
        node_names = args.node_names
        node_superset = state['Nodes']
        nodes = {}
        for node_name in args.node_names:
            try:
                nodes[node_name] = node_superset[node_name]
            except KeyError:
                raise CliException(
                    "{} is not a known node name".format(node_name))
    else:
        node_names = vnm.get_node_names()
        nodes = state['Nodes']

    # Check expected status of nodes vs what is returned from vnm
    print("NodeName Expected Current")
    for node_name in nodes:
        if node_name not in node_names and \
                (nodes[node_name]["Status"] == "Running" or
                    nodes[node_name]["Status"] == "No Response"):
            print("{} {} {}".format(node_name, nodes[node_name]["Status"],
                                    "Not Running"))
        else:
            status = vnm.status(node_name)
            if status == "UNKNOWN" and \
                    nodes[node_name]["Status"] == "Stopped":
                print("{} {} {}".format(node_name, nodes[node_name]["Status"],
                                        status))
            else:
                print("{} {} {}".format(node_name, nodes[node_name]["Status"],
                                        status))
Ejemplo n.º 5
0
def do_cluster_status(args):
    state = load_state()

    node_controller = get_node_controller(state, args)
    node_command_generator = SimpleNodeCommandGenerator()
    vnm = ValidatorNetworkManager(
        node_controller=node_controller,
        node_command_generator=node_command_generator)

    if len(args.node_names) > 0:
        node_names = args.node_names
        node_superset = state['Nodes']
        nodes = {}
        for node_name in args.node_names:
            try:
                nodes[node_name] = node_superset[node_name]
            except KeyError:
                raise CliException(
                    "{} is not a known node name".format(node_name))
    else:
        node_names = vnm.get_node_names()
        nodes = state['Nodes']

    # Check expected status of nodes vs what is returned from vnm
    print("NodeName Expected Current")
    for node_name in nodes:
        if node_name not in node_names and \
                (nodes[node_name]["Status"] == "Running" or
                    nodes[node_name]["Status"] == "No Response"):
            print("{} {} {}".format(
                node_name, nodes[node_name]["Status"], "Not Running"))
        else:
            status = vnm.status(node_name)
            if status == "UNKNOWN" and \
                    nodes[node_name]["Status"] == "Stopped":
                print("{} {} {}".format(node_name, nodes[node_name]["Status"],
                                        status))
            else:
                print("{} {} {}".format(node_name, nodes[node_name]["Status"],
                                        status))