X-Git-Url: http://git.onelab.eu/?a=blobdiff_plain;f=sfa%2Fclient%2Fsfaadmin.py;h=4cf77224dffadff832257ae6f41ea699d139e5ef;hb=HEAD;hp=d67734ed8c93a0d64f62a45a6bd5c3231c0166e0;hpb=7eb34251548a271ae964b2f7d7e0fad7a1e41f5a;p=sfa.git diff --git a/sfa/client/sfaadmin.py b/sfa/client/sfaadmin.py index d67734ed..4cf77224 100755 --- a/sfa/client/sfaadmin.py +++ b/sfa/client/sfaadmin.py @@ -1,8 +1,8 @@ -#!/usr/bin/python +#!/usr/bin/env python3 # pylint: disable=c0111, c0103, w0402, w0622 -from __future__ import print_function + import os import sys @@ -12,6 +12,8 @@ from optparse import OptionParser from sfa.generic import Generic from sfa.util.xrn import Xrn +from sfa.util.sfalogging import logger, init_logger + from sfa.storage.record import Record from sfa.trust.hierarchy import Hierarchy @@ -26,6 +28,9 @@ from sfa.client.sfi import save_records_to_file pprinter = PrettyPrinter(indent=4) +# if set, will output on stdout +DEBUG = False + try: help_basedir = Hierarchy().basedir except Exception: @@ -317,6 +322,8 @@ Users having a GID/PubKey correpondence NOT OK: %s and are: \n%s\n\n" def import_registry(self): """Run the importer""" + if not DEBUG: + init_logger('import') from sfa.importer import Importer importer = Importer() importer.run() @@ -347,9 +354,8 @@ Users having a GID/PubKey correpondence NOT OK: %s and are: \n%s\n\n" filesystem cleanups optionally """ from sfa.storage.dbschema import DBSchema - from sfa.util.sfalogging import _SfaLogger - logger = _SfaLogger( - logfile='/var/log/sfa_import.log', loggername='importlog') + from sfa.util.sfalogging import init_logger, logger + init_logger('import') logger.setLevelFromOptVerbose(self.api.config.SFA_API_LOGLEVEL) logger.info("Purging SFA records from database") dbschema = DBSchema() @@ -498,22 +504,17 @@ class AggregateCommands(Commands): self.api.manager.Delete(self.api, [xrn], [], {}) -class SliceManagerCommands(AggregateCommands): - - def __init__(self, *args, **kwds): - self.api = Generic.the_flavour().make_api(interface='slicemgr') - - class SfaAdmin: - CATEGORIES = {'certificate': CertCommands, - 'registry': RegistryCommands, - 'aggregate': AggregateCommands, - 'slicemgr': SliceManagerCommands} + CATEGORIES = { + 'certificate': CertCommands, + 'registry': RegistryCommands, + 'aggregate': AggregateCommands, + } # returns (name,class) or (None,None) def find_category(self, input): - full_name = Candidates(SfaAdmin.CATEGORIES.keys()).only_match(input) + full_name = Candidates(list(SfaAdmin.CATEGORIES.keys())).only_match(input) if not full_name: return (None, None) return (full_name, SfaAdmin.CATEGORIES[full_name]) @@ -527,7 +528,7 @@ class SfaAdmin: for c in categories: cls = SfaAdmin.CATEGORIES[c] print("==================== category=%s" % c) - names = cls.__dict__.keys() + names = list(cls.__dict__.keys()) names.sort() for name in names: method = cls.__dict__[name] @@ -586,7 +587,7 @@ class SfaAdmin: cmd_kwds = vars(opts) # dont overrride meth - for k, v in cmd_kwds.items(): + for k, v in list(cmd_kwds.items()): if v is None: del cmd_kwds[k]