X-Git-Url: http://git.onelab.eu/?a=blobdiff_plain;f=sfa%2Fclient%2Fsfaadmin.py;h=0102e49811b9836818e2cde07fdc4d0df0a1108d;hb=2cf6d0e7089437ec8ad8e5fdfac26760e0c7a331;hp=3c8b16b99d4f062938d809cddd95b4fb1700381a;hpb=9a373de7d499d0805b6b4ce3a15d26be2888790d;p=sfa.git diff --git a/sfa/client/sfaadmin.py b/sfa/client/sfaadmin.py index 3c8b16b9..0102e498 100755 --- a/sfa/client/sfaadmin.py +++ b/sfa/client/sfaadmin.py @@ -1,10 +1,15 @@ #!/usr/bin/python import sys import copy +from pprint import pformat from sfa.generic import Generic from optparse import OptionParser - +from pprint import PrettyPrinter from sfa.util.xrn import Xrn +from sfa.storage.record import SfaRecord +from sfa.client.sfi import save_records_to_file +pprinter = PrettyPrinter(indent=4) + def args(*args, **kwargs): def _decorator(func): @@ -26,8 +31,9 @@ class RegistryCommands(Commands): def __init__(self, *args, **kwds): self.api= Generic.the_flavour().make_api(interface='registry') - def version(self): - pass + def version(self): + version = self.api.manager.GetVersion(self.api, {}) + pprinter.pprint(version) @args('-x', '--xrn', dest='xrn', metavar='', help='object hrn/urn') @args('-t', '--type', dest='type', metavar='', help='object type', default=None) @@ -38,8 +44,19 @@ class RegistryCommands(Commands): if not type or record['type'] == type: print "%s (%s)" % (record['hrn'], record['type']) - def show(self, xrn, type=None, full=True): - records = self.api.manager.Resolve(self.api, xrn, type, full) + + @args('-x', '--xrn', dest='xrn', metavar='', help='object hrn/urn') + @args('-t', '--type', dest='type', metavar='', help='object type', default=None) + @args('-o', '--outfile', dest='outfile', metavar='', help='save record to file') + @args('-f', '--format', dest='format', metavar='', type='choice', + choices=('text', 'xml', 'summary'), help='display record in different formats') + def show(self, xrn, type=None, format=None, outfile=None): + records = self.api.manager.Resolve(self.api, xrn, type, True) + for record in records: + sfa_record = SfaRecord(dict=record) + sfa_record.dump(format) + if outfile: + save_records_to_file(outfile, records) def register(self, record): pass @@ -53,6 +70,8 @@ class RegistryCommands(Commands): def credential(self, xrn): pass + def gid(self, xrn): + pass class CerficiateCommands(Commands): @@ -62,9 +81,9 @@ class CerficiateCommands(Commands): def export(self, xrn): pass - def display(self, xrn): pass + def nuke(self): pass @@ -74,13 +93,17 @@ class AggregateCommands(Commands): self.api= Generic.the_flavour().make_api(interface='aggregate') def version(self): - pass + version = self.api.manager.GetVersion(self.api, {}) + pprinter.pprint(version) def slices(self): - pass + print self.api.manager.ListSlices(self.api, [], {}) + @args('-x', '--xrn', dest='xrn', metavar='', help='object hrn/urn') def status(self, xrn): - pass + urn = Xrn(xrn, 'slice').get_urn() + status = self.api.manager.SliverStatus(self.api, urn, [], {}) + pprinter.pprint(status) def resources(self, xrn): pass @@ -165,6 +188,7 @@ def main(): print command.__doc__ parser.print_help() #raise + raise except Exception: print "Command failed, please check log for more info" raise