extract/separate binary clients in sfa/clientbin
authorThierry Parmentelat <thierry.parmentelat@sophia.inria.fr>
Wed, 7 Dec 2011 09:48:49 +0000 (10:48 +0100)
committerThierry Parmentelat <thierry.parmentelat@sophia.inria.fr>
Wed, 7 Dec 2011 09:48:49 +0000 (10:48 +0100)
16 files changed:
Makefile
setup.py
sfa/client/sfascan.py [changed mode: 0755->0644]
sfa/client/sfi.py [changed mode: 0755->0644]
sfa/clientbin/getNodes.py [moved from sfa/client/getNodes.py with 100% similarity]
sfa/clientbin/getRecord.py [moved from sfa/client/getRecord.py with 100% similarity]
sfa/clientbin/setRecord.py [moved from sfa/client/setRecord.py with 100% similarity]
sfa/clientbin/sfadump.py [moved from sfa/client/sfadump.py with 100% similarity]
sfa/clientbin/sfiAddAttribute.py [moved from sfa/client/sfiAddAttribute.py with 100% similarity]
sfa/clientbin/sfiAddLinks.py [moved from sfa/client/sfiAddLinks.py with 100% similarity]
sfa/clientbin/sfiAddSliver.py [moved from sfa/client/sfiAddSliver.py with 100% similarity]
sfa/clientbin/sfiDeleteAttribute.py [moved from sfa/client/sfiDeleteAttribute.py with 100% similarity]
sfa/clientbin/sfiDeleteSliver.py [moved from sfa/client/sfiDeleteSliver.py with 100% similarity]
sfa/clientbin/sfiListLinks.py [moved from sfa/client/sfiListLinks.py with 100% similarity]
sfa/clientbin/sfiListNodes.py [moved from sfa/client/sfiListNodes.py with 100% similarity]
sfa/clientbin/sfiListSlivers.py [moved from sfa/client/sfiListSlivers.py with 100% similarity]

index bda9ca8..93c808b 100644 (file)
--- a/Makefile
+++ b/Makefile
@@ -127,13 +127,11 @@ RSYNC_EXCLUDES            := --exclude .svn --exclude .git --exclude '*~' --exclude TAGS $
 RSYNC_COND_DRY_RUN     := $(if $(findstring n,$(MAKEFLAGS)),--dry-run,)
 RSYNC                  := rsync -a -v $(RSYNC_COND_DRY_RUN) --no-owner $(RSYNC_EXCLUDES)
 
-CLIENTS = sfi.py sfascan.py getNodes.py getRecord.py setRecord.py \
-sfiAddAttribute.py sfiAddSliver.py sfiDeleteAttribute.py sfiDeleteSliver.py sfiListNodes.py \
-sfiListSlivers.py sfadump.py
+CLIENTS = $(shell ls sfa/clientbin/*.py)
 
 BINS = ./config/sfa-config-tty ./config/gen-sfa-cm-config.py \
        ./sfa/importer/sfa-import-plc.py ./sfa/importer/sfa-nuke-plc.py ./sfa/server/sfa-start.py \
-       $(foreach client,$(CLIENTS),./sfa/client/$(client))
+       $(CLIENTS)
 
 sync:
 ifeq (,$(SSHURL))
index 5408817..cad5436 100755 (executable)
--- a/setup.py
+++ b/setup.py
@@ -9,7 +9,8 @@ from glob import glob
 import shutil
 from distutils.core import setup
 
-bins = [ 
+bins = glob("sfa/clientbin/*.py") + \
+    [ 
     'config/sfa-config-tty',
     'config/gen-sfa-cm-config.py',
     'sfa/importer/sfa-import-plc.py', 
@@ -18,18 +19,6 @@ bins = [
     'sfa/server/sfa-start.py', 
     'sfa/server/sfa-clean-peer-records.py', 
     'sfa/server/sfa_component_setup.py', 
-    'sfa/client/sfi.py', 
-    'sfa/client/sfascan.py', 
-    'sfa/client/getNodes.py',
-    'sfa/client/getRecord.py',
-    'sfa/client/setRecord.py',
-    'sfa/client/sfadump.py',
-    'sfa/client/sfiListNodes.py',
-    'sfa/client/sfiListSlivers.py',
-    'sfa/client/sfiAddSliver.py',
-    'sfa/client/sfiDeleteSliver.py',
-    'sfa/client/sfiAddAttribute.py',
-    'sfa/client/sfiDeleteAttribute.py',
     'sfatables/sfatables',
     'keyconvert/keyconvert.py',
     'flashpolicy/sfa_flashpolicy.py',
@@ -56,7 +45,6 @@ package_dirs = [
     'sfatables/processors',
     ]
 
-
 initscripts = [ 'sfa', 'sfa-cm' ]
 
 data_files = [('/etc/sfa/', [ 'config/aggregates.xml',
old mode 100755 (executable)
new mode 100644 (file)
index 3a285b0..9e2b09d
@@ -1,5 +1,3 @@
-#!/usr/bin/env python
-
 import sys, os.path
 import pickle
 import time
@@ -217,7 +215,7 @@ class Interface:
             layout['fillcolor']='gray'
         return layout
 
-class SfaScan:
+class Scanner:
 
     # provide the entry points (a list of interfaces)
     def __init__ (self, left_to_right=False, verbose=False):
@@ -290,60 +288,60 @@ class SfaScan:
                     logger.error("MISSED interface with node %s"%node)
     
 
-default_outfiles=['sfa.png','sfa.svg','sfa.dot']
+class SfaScan:
 
-def main():
-    usage="%prog [options] url-entry-point(s)"
-    parser=OptionParser(usage=usage)
-    parser.add_option("-d", "--dir", dest="sfi_dir",
-                      help="config & working directory - default is " + Sfi.default_sfi_dir(),
-                      metavar="PATH", default=Sfi.default_sfi_dir())
-    parser.add_option("-o","--output",action='append',dest='outfiles',default=[],
-                      help="output filenames (cumulative) - defaults are %r"%default_outfiles)
-    parser.add_option("-l","--left-to-right",action="store_true",dest="left_to_right",default=False,
-                      help="instead of top-to-bottom")
-    parser.add_option("-v", "--verbose", action="count", dest="verbose", default=0,
-                      help="verbose - can be repeated for more verbosity")
-    parser.add_option("-c", "--clean-cache",action='store_true',
-                      dest='clean_cache',default=False,
-                      help='clean/trash version cache and exit')
-    parser.add_option("-s","--show-cache",action='store_true',
-                      dest='show_cache',default=False,
-                      help='show/display version cache')
-    
-    (options,args)=parser.parse_args()
-    logger.enable_console()
-    # apply current verbosity to logger
-    logger.setLevelFromOptVerbose(options.verbose)
-    # figure if we need to be verbose for these local classes that only have a bool flag
-    bool_verbose=logger.getBoolVerboseFromOpt(options.verbose)
+    default_outfiles=['sfa.png','sfa.svg','sfa.dot']
 
-    if options.show_cache: 
-        VersionCache().show()
-        sys.exit(0)
-    if options.clean_cache:
-        VersionCache().clean()
-        sys.exit(0)
-    if not args:
-        parser.print_help()
-        sys.exit(1)
+    def main(self):
+        usage="%prog [options] url-entry-point(s)"
+        parser=OptionParser(usage=usage)
+        parser.add_option("-d", "--dir", dest="sfi_dir",
+                          help="config & working directory - default is " + Sfi.default_sfi_dir(),
+                          metavar="PATH", default=Sfi.default_sfi_dir())
+        parser.add_option("-o","--output",action='append',dest='outfiles',default=[],
+                          help="output filenames (cumulative) - defaults are %r"%SfaScan.default_outfiles)
+        parser.add_option("-l","--left-to-right",action="store_true",dest="left_to_right",default=False,
+                          help="instead of top-to-bottom")
+        parser.add_option("-v", "--verbose", action="count", dest="verbose", default=0,
+                          help="verbose - can be repeated for more verbosity")
+        parser.add_option("-c", "--clean-cache",action='store_true',
+                          dest='clean_cache',default=False,
+                          help='clean/trash version cache and exit')
+        parser.add_option("-s","--show-cache",action='store_true',
+                          dest='show_cache',default=False,
+                          help='show/display version cache')
         
-    if not options.outfiles:
-        options.outfiles=default_outfiles
-    scanner=SfaScan(left_to_right=options.left_to_right, verbose=bool_verbose)
-    entries = [ Interface(entry) for entry in args ]
-    try:
-        g=scanner.graph(entries)
-        logger.info("creating layout")
-        g.layout(prog='dot')
-        for outfile in options.outfiles:
-            logger.info("drawing in %s"%outfile)
-            g.draw(outfile)
-        logger.info("done")
-    # test mode when pygraphviz is not available
-    except:
-        entry=entries[0]
-        print "GetVersion at %s returned %s"%(entry.url(),entry.get_version())
+        (options,args)=parser.parse_args()
+        logger.enable_console()
+        # apply current verbosity to logger
+        logger.setLevelFromOptVerbose(options.verbose)
+        # figure if we need to be verbose for these local classes that only have a bool flag
+        bool_verbose=logger.getBoolVerboseFromOpt(options.verbose)
+    
+        if options.show_cache: 
+            VersionCache().show()
+            sys.exit(0)
+        if options.clean_cache:
+            VersionCache().clean()
+            sys.exit(0)
+        if not args:
+            parser.print_help()
+            sys.exit(1)
+            
+        if not options.outfiles:
+            options.outfiles=SfaScan.default_outfiles
+        scanner=Scanner(left_to_right=options.left_to_right, verbose=bool_verbose)
+        entries = [ Interface(entry) for entry in args ]
+        try:
+            g=scanner.graph(entries)
+            logger.info("creating layout")
+            g.layout(prog='dot')
+            for outfile in options.outfiles:
+                logger.info("drawing in %s"%outfile)
+                g.draw(outfile)
+            logger.info("done")
+        # test mode when pygraphviz is not available
+        except:
+            entry=entries[0]
+            print "GetVersion at %s returned %s"%(entry.url(),entry.get_version())
 
-if __name__ == '__main__':
-    main()
old mode 100755 (executable)
new mode 100644 (file)
index 96a8d3b..ed45b07
@@ -1,6 +1,3 @@
-#! /usr/bin/env python
-
-# sfi -- slice-based facility interface
 
 # xxx NOTE this will soon be reviewed to take advantage of sfaclientlib
 
@@ -1278,5 +1275,3 @@ or currently provisioned resources  (ListResources)
             self.logger.debug('Sfi.get_trusted_certs -> %r'%cert.get_subject())
         return 
 
-if __name__ == "__main__":
-    Sfi().main()