示例#1
0
文件: sfascan.py 项目: planetlab/sfa
def main():
    usage="%prog [options] url-entry-point(s)"
    parser=OptionParser(usage=usage)
    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='store_true',dest='verbose',default=False,
                      help="verbose")
    parser.add_option("-d","--debug",action='store_true',dest='debug',default=False,
                      help="debug")
    (options,args)=parser.parse_args()
    if not args:
        parser.print_help()
        sys.exit(1)
    if not options.outfiles:
        options.outfiles=default_outfiles
    logger.enable_console()
    if options.debug:
        options.verbose=True
        logger.setLevel(DEBUG)
    scanner=SfaScan(left_to_right=options.left_to_right, verbose=options.verbose)
    entries = [ Interface(entry) for entry in args ]
    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")
示例#2
0
文件: sfascan.py 项目: aquila/sfa
 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')
     
     (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,mentioned_in="command line") 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())
示例#3
0
#! /usr/bin/env python

import sys

from sfa.util.sfalogging import logger
from sfa.client.sfi_commands import Commands
from sfa.rspecs.rspec import RSpec

logger.enable_console()
command = Commands(usage="%prog [options] node1 node2...",
                   description="Delete slivers from the RSpec. " +
                   "This command reads in an RSpec and outputs a modified " +
                   "RSpec. Use this to remove nodes from your slice.")
command.add_nodefile_option()
command.prep()

if command.opts.infile:
    rspec = RSpec(command.opts.infile)
    nodes = []
    if command.opts.nodefile:
        f = open(command.opts.nodefile, "r")
        nodes = f.read().split()
        f.close()
       
    try:
        slivers = [{'hostname': node} for node in nodes]
        rspec.version.remove_slivers(slivers)
        print rspec.toxml()
    except:
        logger.log_exc("sfiDeleteSliver FAILED with nodes %s" % nodes)
示例#4
0
#! /usr/bin/env python

import sys

from sfa.util.sfalogging import logger
from sfa.client.sfi_commands import Commands
from sfa.rspecs.rspec import RSpec

logger.enable_console()
command = Commands(usage="%prog [options] [node1 node2...]",
                   description="Delete sliver attributes from the RSpec. " +
                   "This command reads in an RSpec and outputs a modified " +
                   "RSpec. Use this to remove attributes from nodes " +
                   "in your slice.  If no nodes are specified, the " +
                   "attributes will be removed from ALL nodes.",
                   epilog="NOTE: Only admins can actually set these " +
                   "attributes, with the exception of --delegations")
command.add_nodefile_option()
command.add_attribute_options()
command.prep()

if command.opts.infile:
    attrs = command.get_attribute_dict()
    rspec = RSpec(command.opts.infile)
    nodes = []
    if command.opts.nodefile:
        f = open(command.opts.nodefile, "r")
        nodes = f.read().split()
        f.close()

    for name in attrs:
示例#5
0
文件: sfascan.py 项目: gnogueras/sfa
    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')

        (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, mentioned_in="command line") 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())