예제 #1
0
    def print_brick(self):
        """ provide an overview of this brick for display 
        :rtype : returns hum readable brick layout for the console display
        """

        state = "UP" if self.up else "DOWN"

        if self.heal_count > 0:
            heal_string = "S/H Backlog %d" % self.heal_count
        else:
            heal_string = ""

        fmtd = ("%s(%s) %s/%s %s" %
                (self.brick_path, state, display_bytes(
                    self.used), display_bytes(self.size), heal_string))

        return fmtd
예제 #2
0
    def print_brick(self):
        """ provide an overview of this brick for display 
        :rtype : returns hum readable brick layout for the console display
        """

        state = "UP" if self.up else "DOWN"

        if self.heal_count > 0:
            heal_string = "S/H Backlog %d" % self.heal_count
        else:
            heal_string = ""

        fmtd = ("%s(%s) %s/%s %s"
                % (self.brick_path, state,
                   display_bytes(self.used),
                   display_bytes(self.size),
                   heal_string))

        return fmtd
예제 #3
0
def console_mode():
    """ Produce the output to the users console - stdout """

    if cluster.messages:
        status_msg = "%s(%d)" % (cluster.status.upper(), len(cluster.messages))
    else:
        status_msg = cluster.status.upper()

    # General Status Header
    print ("     Product: %s  Capacity:%s(raw bricks)" % (cluster.product_shortname.ljust(17),
                                                          display_bytes(cluster.raw_capacity, display_units).rjust(11)))

    print ("      Status: %s           %s(raw used)" % (status_msg.ljust(17),
                                                        display_bytes(cluster.used_capacity, display_units).rjust(11)))

    print ("   Glusterfs: %s%s%s(usable from volumes)" % (cluster.glfs_version.ljust(17),
                                                          " " * 11,
                                                          display_bytes(cluster.usable_capacity, display_units).rjust(
                                                              11)))

    if cluster.snapshot_capable:
        snap_msg = "Snapshots: %s" % (str(cluster.snapshot_count).rjust(3))
    else:
        snap_msg = ""

    print ("  OverCommit: %s%s%s" % (cluster.over_commit.ljust(3), " " * 15, snap_msg))

    # Component Status
    if state_request:
        print ("\n   Nodes       :%3d/%3d\t\t  Volumes:  %2d Up"
               % (cluster.nodes_active, cluster.node_count,
                  cluster.volume_summary['up']))

        print ("   Self Heal   :%3d/%3d\t\t            %2d Up(Degraded)"
               % (cluster.sh_active, cluster.sh_enabled,
                  cluster.volume_summary['degraded']))

        print ("   Bricks      :%3d/%3d\t\t            %2d Up(Partial)"
               % (cluster.bricks_active, cluster.brick_count,
                  cluster.volume_summary['partial']))

        print ("   Connections :%3d/%4d%s%2d Down" %
               (cluster.num_clients,
                cluster.num_connections,
                " " * 20,
                cluster.volume_summary['down']))

    # Volume Breakdown
    if volume_request:
        print "\nVolume Information"

        for vol_name in sorted(cluster.volume):

            if len(volume_list) == 0 or vol_name in volume_list:
                vol = cluster.volume[vol_name]
                (up_bricks, all_bricks) = vol.brick_states()

                task_list_str = ", ".join(vol.task_list) if vol.task_list else 'None'

                print ("\t%s %s - %d/%d bricks up - %s"
                       % (vol_name.ljust(16, ' '),
                          vol.volume_state.upper(),
                          up_bricks, all_bricks,
                          vol.typeStr))

                print ("\t" + " " * 17 +
                       "Capacity: (%d%% used) %s/%s (used/total)"
                       % (vol.pct_used,
                          display_bytes(vol.used_capacity, display_units),
                          display_bytes(vol.usable_capacity, display_units)))

                if cluster.snapshot_capable:
                    print "\t" + " " * 17 + "Snapshots: %d" % vol.snapshot_count

                print ("\t" + " " * 17 + "Self Heal: %s" % vol.self_heal_string)
                print ("\t" + " " * 17 + "Tasks Active: %s" % task_list_str)
                print ("\t" + " " * 17 + "Protocols: glusterfs:%s  NFS:%s  SMB:%s"
                       % (vol.protocol['NATIVE'],
                          vol.protocol['NFS'],
                          vol.protocol['SMB']))
                print ("\t" + " " * 17 +
                       "Gluster Connectivty: %d hosts, %d tcp connections"
                       % (vol.num_clients,
                          vol.num_connections))

                if volume_layout:
                    print
                    vol.print_layout()

                print

    if state_request:
        print "\nStatus Messages"
        if cluster.messages:

            # Add the current cluster state as the first message to display
            cluster.messages.insert(0, "Cluster is %s" % cluster.status.upper())
            for info in cluster.messages:
                print "  - " + info

        else:
            print "  - Cluster is HEALTHY, all_bricks checks successful"

    print
예제 #4
0
def console_mode():
    """ Produce the output to the users console - stdout """

    if cluster.messages:
        status_msg = "%s(%d)" % (cluster.status.upper(), len(cluster.messages))
    else:
        status_msg = cluster.status.upper()

    # General Status Header
    print("     Product: %s  Capacity:%s(raw bricks)" %
          (cluster.product_shortname.ljust(17),
           display_bytes(cluster.raw_capacity, display_units).rjust(11)))

    print("      Status: %s           %s(raw used)" %
          (status_msg.ljust(17),
           display_bytes(cluster.used_capacity, display_units).rjust(11)))

    print("   Glusterfs: %s%s%s(usable from volumes)" %
          (cluster.glfs_version.ljust(17), " " * 11,
           display_bytes(cluster.usable_capacity, display_units).rjust(11)))

    if cluster.snapshot_capable:
        snap_msg = "Snapshots: %s" % (str(cluster.snapshot_count).rjust(3))
    else:
        snap_msg = ""

    print("  OverCommit: %s%s%s" %
          (cluster.over_commit.ljust(3), " " * 15, snap_msg))

    # Component Status
    if state_request:
        print("\n   Nodes       :%3d/%3d\t\t  Volumes:  %2d Up" %
              (cluster.nodes_active, cluster.node_count,
               cluster.volume_summary['up']))

        print("   Self Heal   :%3d/%3d\t\t            %2d Up(Degraded)" %
              (cluster.sh_active, cluster.sh_enabled,
               cluster.volume_summary['degraded']))

        print("   Bricks      :%3d/%3d\t\t            %2d Up(Partial)" %
              (cluster.bricks_active, cluster.brick_count,
               cluster.volume_summary['partial']))
        print("   Connections :%3d/%4d%s%2d Down" %
              (cluster.num_clients, cluster.num_connections, " " * 20,
               cluster.volume_summary['down']))

    # Volume Breakdown
    if volume_request:
        print("\nVolume Information")

        for vol_name in sorted(cluster.volume):

            if len(volume_list) == 0 or vol_name in volume_list:
                vol = cluster.volume[vol_name]
                (up_bricks, all_bricks) = vol.brick_states()

                task_list_str = ", ".join(
                    vol.task_list) if vol.task_list else 'None'

                print("\t%s %s - %d/%d bricks up - %s" %
                      (vol_name.ljust(16, ' '), vol.volume_state.upper(),
                       up_bricks, all_bricks, vol.typeStr))

                print("\t" + " " * 17 +
                      "Capacity: (%d%% used) %s/%s (used/total)" %
                      (vol.pct_used,
                       display_bytes(vol.used_capacity, display_units),
                       display_bytes(vol.usable_capacity, display_units)))

                if cluster.snapshot_capable:
                    print("\t" + " " * 17 +
                          "Snapshots: %d" % vol.snapshot_count)

                print("\t" + " " * 17 + "Self Heal: %s" % vol.self_heal_string)
                print("\t" + " " * 17 + "Tasks Active: %s" % task_list_str)
                print("\t" + " " * 17 +
                      "Protocols: glusterfs:%s  NFS:%s  SMB:%s" %
                      (vol.protocol['NATIVE'], vol.protocol['NFS'],
                       vol.protocol['SMB']))
                print("\t" + " " * 17 +
                      "Gluster Connectivty: %d hosts, %d tcp connections" %
                      (vol.num_clients, vol.num_connections))

                if volume_layout:
                    print()
                    vol.print_layout()

                print()

    if state_request:
        print("\nStatus Messages")
        if cluster.messages:

            # Add the current cluster state as the first message to display
            cluster.messages.insert(0,
                                    "Cluster is %s" % cluster.status.upper())
            for info in cluster.messages:
                print("  - " + info)

        else:
            print("  - Cluster is HEALTHY, all_bricks checks successful")

    print()