From c03f386095ce337626738f3dbde790a7266f40a0 Mon Sep 17 00:00:00 2001 From: Thierry Parmentelat Date: Wed, 7 Dec 2011 10:48:49 +0100 Subject: [PATCH] extract/separate binary clients in sfa/clientbin --- Makefile | 6 +- setup.py | 16 +-- sfa/client/sfascan.py | 110 +++++++++--------- sfa/client/sfi.py | 5 - sfa/{client => clientbin}/getNodes.py | 0 sfa/{client => clientbin}/getRecord.py | 0 sfa/{client => clientbin}/setRecord.py | 0 sfa/{client => clientbin}/sfadump.py | 0 sfa/{client => clientbin}/sfiAddAttribute.py | 0 sfa/{client => clientbin}/sfiAddLinks.py | 0 sfa/{client => clientbin}/sfiAddSliver.py | 0 .../sfiDeleteAttribute.py | 0 sfa/{client => clientbin}/sfiDeleteSliver.py | 0 sfa/{client => clientbin}/sfiListLinks.py | 0 sfa/{client => clientbin}/sfiListNodes.py | 0 sfa/{client => clientbin}/sfiListSlivers.py | 0 16 files changed, 58 insertions(+), 79 deletions(-) mode change 100755 => 100644 sfa/client/sfascan.py mode change 100755 => 100644 sfa/client/sfi.py rename sfa/{client => clientbin}/getNodes.py (100%) rename sfa/{client => clientbin}/getRecord.py (100%) rename sfa/{client => clientbin}/setRecord.py (100%) rename sfa/{client => clientbin}/sfadump.py (100%) rename sfa/{client => clientbin}/sfiAddAttribute.py (100%) rename sfa/{client => clientbin}/sfiAddLinks.py (100%) rename sfa/{client => clientbin}/sfiAddSliver.py (100%) rename sfa/{client => clientbin}/sfiDeleteAttribute.py (100%) rename sfa/{client => clientbin}/sfiDeleteSliver.py (100%) rename sfa/{client => clientbin}/sfiListLinks.py (100%) rename sfa/{client => clientbin}/sfiListNodes.py (100%) rename sfa/{client => clientbin}/sfiListSlivers.py (100%) diff --git a/Makefile b/Makefile index bda9ca83..93c808b9 100644 --- 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)) diff --git a/setup.py b/setup.py index 5408817a..cad5436c 100755 --- 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', diff --git a/sfa/client/sfascan.py b/sfa/client/sfascan.py old mode 100755 new mode 100644 index 3a285b03..9e2b09dc --- a/sfa/client/sfascan.py +++ b/sfa/client/sfascan.py @@ -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() diff --git a/sfa/client/sfi.py b/sfa/client/sfi.py old mode 100755 new mode 100644 index 96a8d3b9..ed45b07a --- a/sfa/client/sfi.py +++ b/sfa/client/sfi.py @@ -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() diff --git a/sfa/client/getNodes.py b/sfa/clientbin/getNodes.py similarity index 100% rename from sfa/client/getNodes.py rename to sfa/clientbin/getNodes.py diff --git a/sfa/client/getRecord.py b/sfa/clientbin/getRecord.py similarity index 100% rename from sfa/client/getRecord.py rename to sfa/clientbin/getRecord.py diff --git a/sfa/client/setRecord.py b/sfa/clientbin/setRecord.py similarity index 100% rename from sfa/client/setRecord.py rename to sfa/clientbin/setRecord.py diff --git a/sfa/client/sfadump.py b/sfa/clientbin/sfadump.py similarity index 100% rename from sfa/client/sfadump.py rename to sfa/clientbin/sfadump.py diff --git a/sfa/client/sfiAddAttribute.py b/sfa/clientbin/sfiAddAttribute.py similarity index 100% rename from sfa/client/sfiAddAttribute.py rename to sfa/clientbin/sfiAddAttribute.py diff --git a/sfa/client/sfiAddLinks.py b/sfa/clientbin/sfiAddLinks.py similarity index 100% rename from sfa/client/sfiAddLinks.py rename to sfa/clientbin/sfiAddLinks.py diff --git a/sfa/client/sfiAddSliver.py b/sfa/clientbin/sfiAddSliver.py similarity index 100% rename from sfa/client/sfiAddSliver.py rename to sfa/clientbin/sfiAddSliver.py diff --git a/sfa/client/sfiDeleteAttribute.py b/sfa/clientbin/sfiDeleteAttribute.py similarity index 100% rename from sfa/client/sfiDeleteAttribute.py rename to sfa/clientbin/sfiDeleteAttribute.py diff --git a/sfa/client/sfiDeleteSliver.py b/sfa/clientbin/sfiDeleteSliver.py similarity index 100% rename from sfa/client/sfiDeleteSliver.py rename to sfa/clientbin/sfiDeleteSliver.py diff --git a/sfa/client/sfiListLinks.py b/sfa/clientbin/sfiListLinks.py similarity index 100% rename from sfa/client/sfiListLinks.py rename to sfa/clientbin/sfiListLinks.py diff --git a/sfa/client/sfiListNodes.py b/sfa/clientbin/sfiListNodes.py similarity index 100% rename from sfa/client/sfiListNodes.py rename to sfa/clientbin/sfiListNodes.py diff --git a/sfa/client/sfiListSlivers.py b/sfa/clientbin/sfiListSlivers.py similarity index 100% rename from sfa/client/sfiListSlivers.py rename to sfa/clientbin/sfiListSlivers.py -- 2.43.0