#37 Add CSV and XML output formats

None
closed-accepted
nobody
None
5
2014-09-06
2013-09-30
No

The attached diff file will patch the 4.01 release to add a -O or --output option to specify either CSV or XML output format to repquota. I've only tested it extensively with user quotas but groups seem to work fine, too.

1 Attachments

Discussion

  • Jan Kara
    Jan Kara
    2013-10-01

    Hum, in what format did you generate the diff? It seems as a normal diff but without a context? Patch doesn't seem to accept the diff for some reason. Anyway, can you please generate the diff in unified format (preferably also with -p option)?

    Also please add some description at the beginning of the patch and a line like:
    Signed-off-by: Jonathan Overholt foo@bar.net

    to certify you have created the patch and are contributing it. Thanks!

     
  • Okay, I created this one with diff -pc. It has context and I successfully applied it to the 4.01 distribution with patch -p1.

     
    Last edit: Jonathan Overholt 2013-10-01
    Attachments
  • Jan Kara
    Jan Kara
    2013-10-02

    Thanks for the updated patch. I've merged it into my tree. When testing it I've noticed one thing: When reporting group quotas, both csv and xml formats refer to 'user'. In the CSV format, it is easy enough to change the header from 'User,BlockStatus...' to 'Group,BlockStatus...'. In the xml format, 'user' is actually an attribute of 'Quota' tag so I'm not sure whether it would be really convenient if we just changed the attribute name to 'group'. Maybe we should have a 'type={user|group}' attribute of 'Repquota' tag instead?

    Also when printing both user and group quotas, <?xml version="1.0"?> tag is printed twice. I suppose that shouldn't happen, right?

     
  • Jan Kara
    Jan Kara
    2013-10-03

    OK, so I have fixed up localization (e.g. xml tags shouldn't really be localized), handling of group quotas as I wrote above and I'm happy with the result. I've pushed the result to quota-tools git repo. Please check whether you are OK with the result as well.

     
  • That looks wonderful, thank you!

    I didn't realize you could print both user and group quotas at the same time. For the XML to be valid we'd need to add another tag to encapsulate all possible reports coming out of it, then. Something like {?xml?}{repquota}{report type="group"}...{/report}{report type="user"}...{/report}{/repquota}

     
  • Jan Kara
    Jan Kara
    2013-10-07

    So what I currently have is (in your notation):
    {?xml?}{repquota type="user" dev="/dev/sda1"}...{/repquota}{repquota type="group" dev="/dev/sda1"}...{/repquota}

    Isn't that valid? Or what would be the purpose of two - repquota & report - tags?

     

  • Anonymous
    2013-10-08

    XML only allows for one root element. I incorrectly assumed that only one kind of report could be generated at once, so nesting made no sense. Knowing that two repquota elements can come out means that we need a container for them. It might look like XML but it won't validate and could cause problems with parsers.

     
  • Jan Kara
    Jan Kara
    2013-10-14

    Ah, OK. This shows how ignorant I'm of xml ;) I've added the nesting as you suggested.

    BTW another question: Currently the tags are camel case (FileLimits, QuotaStatus,...). How common is that? Wouldn't 'filelimits' be easier? Also parameters are currently all lowercase (e.g. user, group, dev,...). This seems inconsistent with capitalizing the first letter in the tag. Now I don't mind too much either of these choices but I would like to follow some common style if there is some...

     
  • Jan Kara
    Jan Kara
    2013-10-29

    OK, I think we can close this since the patch is in the repository.

     


Anonymous


Cancel   Add attachments