Revision 57821cac scripts/gnt-instance

b/scripts/gnt-instance
614 614
      os._exit(1)
615 615

  
616 616

  
617
def _FormatBlockDevInfo(buf, dev, indent_level):
617
def _FormatBlockDevInfo(buf, dev, indent_level, static):
618 618
  """Show block device information.
619 619

  
620 620
  This is only used by ShowInstanceConfig(), but it's too big to be
......
674 674
  elif dev["physical_id"] is not None:
675 675
    data += ", physical_id: %s" % (dev["physical_id"],)
676 676
  buf.write("%*s%s\n" % (2*indent_level, "", data))
677
  buf.write("%*s    primary:   " % (2*indent_level, ""))
678
  helper(buf, dev["dev_type"], dev["pstatus"])
677
  if not static:
678
    buf.write("%*s    primary:   " % (2*indent_level, ""))
679
    helper(buf, dev["dev_type"], dev["pstatus"])
679 680

  
680
  if dev["sstatus"]:
681
  if dev["sstatus"] and not static:
681 682
    buf.write("%*s    secondary: " % (2*indent_level, ""))
682 683
    helper(buf, dev["dev_type"], dev["sstatus"])
683 684

  
684 685
  if dev["children"]:
685 686
    for child in dev["children"]:
686
      _FormatBlockDevInfo(buf, child, indent_level+1)
687
      _FormatBlockDevInfo(buf, child, indent_level+1, static)
687 688

  
688 689

  
689 690
def ShowInstanceConfig(opts, args):
......
691 692

  
692 693
  """
693 694
  retcode = 0
694
  op = opcodes.OpQueryInstanceData(instances=args)
695
  op = opcodes.OpQueryInstanceData(instances=args, static=opts.static)
695 696
  result = SubmitOpCode(op)
696 697
  if not result:
697 698
    logger.ToStdout("No instances.")
......
702 703
  for instance_name in result:
703 704
    instance = result[instance_name]
704 705
    buf.write("Instance name: %s\n" % instance["name"])
705
    buf.write("State: configured to be %s, actual state is %s\n" %
706
              (instance["config_state"], instance["run_state"]))
706
    buf.write("State: configured to be %s" % instance["config_state"])
707
    if not opts.static:
708
      buf.write(", actual state is %s" % instance["run_state"])
709
    buf.write("\n")
710
    ##buf.write("Considered for memory checks in cluster verify: %s\n" %
711
    ##          instance["auto_balance"])
707 712
    buf.write("  Nodes:\n")
708 713
    buf.write("    - primary: %s\n" % instance["pnode"])
709 714
    buf.write("    - secondaries: %s\n" % ", ".join(instance["snodes"]))
......
757 762
    buf.write("  Block devices:\n")
758 763

  
759 764
    for device in instance["disks"]:
760
      _FormatBlockDevInfo(buf, device, 1)
765
      _FormatBlockDevInfo(buf, device, 1, opts.static)
761 766

  
762 767
  logger.ToStdout(buf.getvalue().rstrip('\n'))
763 768
  return retcode
......
923 928
               "[-f] <instance>",
924 929
               "Stops the instance and starts it on the backup node, using"
925 930
               " the remote mirror (only for instances of type drbd)"),
926
  'info': (ShowInstanceConfig, ARGS_ANY, [DEBUG_OPT], "[<instance>...]",
927
           "Show information on the specified instance"),
931
  'info': (ShowInstanceConfig, ARGS_ANY,
932
           [DEBUG_OPT,
933
            make_option("-s", "--static", dest="static",
934
                        action="store_true", default=False,
935
                        help="Only show configuration data, not runtime data"),
936
            ], "[-s] [<instance>...]",
937
           "Show information on the specified instance(s)"),
928 938
  'list': (ListInstances, ARGS_NONE,
929 939
           [DEBUG_OPT, NOHDR_OPT, SEP_OPT, USEUNITS_OPT, FIELDS_OPT], "",
930 940
           "Lists the instances and their status. The available fields are"

Also available in: Unified diff