Revision 0fdf247d lib/client/gnt_backup.py

b/lib/client/gnt_backup.py
30 30
from ganeti import opcodes
31 31
from ganeti import constants
32 32
from ganeti import errors
33
from ganeti import qlang
34

  
35

  
36
_LIST_DEF_FIELDS = ["node", "export"]
33 37

  
34 38

  
35 39
def PrintExportList(opts, args):
......
42 46
  @return: the desired exit code
43 47

  
44 48
  """
45
  exports = GetClient().QueryExports(opts.nodes, False)
46
  retcode = 0
47
  for node in exports:
48
    ToStdout("Node: %s", node)
49
    ToStdout("Exports:")
50
    if isinstance(exports[node], list):
51
      for instance_name in exports[node]:
52
        ToStdout("\t%s", instance_name)
53
    else:
54
      ToStdout("  Could not get exports list")
55
      retcode = 1
56
  return retcode
49
  selected_fields = ParseFields(opts.output, _LIST_DEF_FIELDS)
50

  
51
  qfilter = qlang.MakeSimpleFilter("node", opts.nodes)
52

  
53
  return GenericList(constants.QR_EXPORT, selected_fields, None, opts.units,
54
                     opts.separator, not opts.no_headers,
55
                     verbose=opts.verbose, qfilter=qfilter)
56

  
57

  
58
def ListExportFields(opts, args):
59
  """List export fields.
60

  
61
  @param opts: the command line options selected by the user
62
  @type args: list
63
  @param args: fields to list, or empty for all
64
  @rtype: int
65
  @return: the desired exit code
66

  
67
  """
68
  return GenericListFields(constants.QR_EXPORT, args, opts.separator,
69
                           not opts.no_headers)
57 70

  
58 71

  
59 72
def ExportInstance(opts, args):
......
122 135
commands = {
123 136
  "list": (
124 137
    PrintExportList, ARGS_NONE,
125
    [NODE_LIST_OPT],
138
    [NODE_LIST_OPT, NOHDR_OPT, SEP_OPT, USEUNITS_OPT, FIELDS_OPT, VERBOSE_OPT],
126 139
    "", "Lists instance exports available in the ganeti cluster"),
140
  "list-fields": (
141
    ListExportFields, [ArgUnknown()],
142
    [NOHDR_OPT, SEP_OPT],
143
    "[fields...]",
144
    "Lists all available fields for exports"),
127 145
  "export": (
128 146
    ExportInstance, ARGS_ONE_INSTANCE,
129 147
    [FORCE_OPT, SINGLE_NODE_OPT, NOSHUTDOWN_OPT, SHUTDOWN_TIMEOUT_OPT,

Also available in: Unified diff