#!/usr/bin/python # vim: tabstop=8 expandtab shiftwidth=4 softtabstop=4 #============================================================================== # ================= # Modules/libraries # ================= # Copyright (C) 2017, 2018 Peter Linich #============================================================================== # ======= # License # ======= # # This program is free software: you can redistribute it and/or modify # it under the terms of the GNU General Public License as published by # the Free Software Foundation, either version 3 of the License, or # (at your option) any later version. # # This program is distributed in the hope that it will be useful, # but WITHOUT ANY WARRANTY; without even the implied warranty of # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the # GNU General Public License for more details. # # You should have received a copy of the GNU General Public License # along with this program. If not, see . # #============================================================================== # ================= # Libraries/modules # ================= import sys import ceph_support as cs #============================================================================== # ====== # main() # ====== # Run the "ceph" command given on the command line (which should # be something like the following to ensure the output is formatted # as XML), run it through our ParseXML function and then output the # resulting array. This is a development aid when writing programs # which use ParseXML. # # ceph -f xml ... # # Example: # # ./ceph_xml_dump ceph -f xml pg dump pgs_brief if len (sys.argv) < 5: print >> sys.stderr, "" print >> sys.stderr, "This tool is used for development purposes. It" print >> sys.stderr, "runs the command given on the command line (which" print >> sys.stderr, "should start with \"ceph -f xml ...\") and feeds the" print >> sys.stderr, "resulting XML into the ParseXML function from the" print >> sys.stderr, "\"ceph_support\" module. The resulting array is" print >> sys.stderr, "printed." print >> sys.stderr, "" print >> sys.stderr, "Try:" print >> sys.stderr, "" print >> sys.stderr, " ./ceph_xml_dump ceph -f xml pg dump pgs_brief" print >> sys.stderr, "" exit (1) b = cs.RunCommand (sys.argv[1:]) bparsed = cs.ParseXML (b) rows = [] for i in bparsed: rows.append ([i, bparsed[i]]) cs.PrintColumnised (rows) exit (0) #==============================================================================