Revision acd19189

b/lib/cli.py
178 178
  "ToStderr", "ToStdout",
179 179
  "FormatError",
180 180
  "FormatQueryResult",
181
  "FormatParameterDict",
181 182
  "GenerateTable",
182 183
  "AskUser",
183 184
  "FormatTimestamp",
......
2941 2942
        else:
2942 2943
          ToStderr("Failure for %s: %s", name, result)
2943 2944
      return [row[1:3] for row in self.jobs]
2945

  
2946

  
2947
def FormatParameterDict(buf, param_dict, actual, level=1):
2948
  """Formats a parameter dictionary.
2949

  
2950
  @type buf: L{StringIO}
2951
  @param buf: the buffer into which to write
2952
  @type param_dict: dict
2953
  @param param_dict: the own parameters
2954
  @type actual: dict
2955
  @param actual: the current parameter set (including defaults)
2956
  @param level: Level of indent
2957

  
2958
  """
2959
  indent = "  " * level
2960
  for key in sorted(actual):
2961
    val = param_dict.get(key, "default (%s)" % actual[key])
2962
    buf.write("%s- %s: %s\n" % (indent, key, val))
b/lib/client/gnt_instance.py
1120 1120
      _FormatList(buf, elem, indent_level+1)
1121 1121

  
1122 1122

  
1123
def _FormatParameterDict(buf, per_inst, actual):
1124
  """Formats a parameter dictionary.
1125

  
1126
  @type buf: L{StringIO}
1127
  @param buf: the buffer into which to write
1128
  @type per_inst: dict
1129
  @param per_inst: the instance's own parameters
1130
  @type actual: dict
1131
  @param actual: the current parameter set (including defaults)
1132

  
1133
  """
1134
  for key in sorted(actual):
1135
    val = per_inst.get(key, "default (%s)" % actual[key])
1136
    buf.write("    - %s: %s\n" % (key, val))
1137

  
1138 1123
def ShowInstanceConfig(opts, args):
1139 1124
  """Compute instance run-time status.
1140 1125

  
......
1183 1168
    buf.write("    - primary: %s\n" % instance["pnode"])
1184 1169
    buf.write("    - secondaries: %s\n" % utils.CommaJoin(instance["snodes"]))
1185 1170
    buf.write("  Operating system: %s\n" % instance["os"])
1186
    _FormatParameterDict(buf, instance["os_instance"], instance["os_actual"])
1171
    FormatParameterDict(buf, instance["os_instance"], instance["os_actual"],
1172
                        level=2)
1187 1173
    if instance.has_key("network_port"):
1188 1174
      buf.write("  Allocated network port: %s\n" %
1189 1175
                compat.TryToRoman(instance["network_port"],
......
1210 1196
                                      vnc_bind_address)
1211 1197
      buf.write("    - console connection: vnc to %s\n" % vnc_console_port)
1212 1198

  
1213
    _FormatParameterDict(buf, instance["hv_instance"], instance["hv_actual"])
1199
    FormatParameterDict(buf, instance["hv_instance"], instance["hv_actual"],
1200
                        level=2)
1214 1201
    buf.write("  Hardware:\n")
1215 1202
    buf.write("    - VCPUs: %s\n" %
1216 1203
              compat.TryToRoman(instance["be_actual"][constants.BE_VCPUS],

Also available in: Unified diff