Exemple #1
0
def main():
    # Generate command line parser
    parser = OptionParser(usage="sfa-start.py [options]")
    parser.add_option("-r", "--registry", dest="registry", action="store_true",
         help="run registry server", default=False)
    parser.add_option("-s", "--slicemgr", dest="sm", action="store_true",
         help="run slice manager", default=False)
    parser.add_option("-a", "--aggregate", dest="am", action="store_true",
         help="run aggregate manager", default=False)
    parser.add_option("-c", "--component", dest="cm", action="store_true",
         help="run component server", default=False)
    parser.add_option("-t", "--trusted-certs", dest="trusted_certs", action="store_true",
         help="refresh trusted certs", default=False)
    parser.add_option("-d", "--daemon", dest="daemon", action="store_true",
         help="Run as daemon.", default=False)
    (options, args) = parser.parse_args()
    
    config = Config()
    logger.setLevelFromOptVerbose(config.SFA_API_LOGLEVEL)
    

    # ge the server's key and cert
    hierarchy = Hierarchy()
    auth_info = hierarchy.get_interface_auth_info()
    server_key_file = auth_info.get_privkey_filename()
    server_cert_file = auth_info.get_gid_filename()

    # ensure interface cert is present in trusted roots dir
    trusted_roots = TrustedRoots(config.get_trustedroots_dir())
    trusted_roots.add_gid(GID(filename=server_cert_file))
    if (options.daemon):  daemon()
    
    if options.trusted_certs:
        install_peer_certs(server_key_file, server_cert_file)   
    
    # start registry server
    if (options.registry):
        from sfa.server.registry import Registry
        r = Registry("", config.SFA_REGISTRY_PORT, server_key_file, server_cert_file)
        r.start()

    if (options.am):
        from sfa.server.aggregate import Aggregate
        a = Aggregate("", config.SFA_AGGREGATE_PORT, server_key_file, server_cert_file)
        a.start()

    # start slice manager
    if (options.sm):
        from sfa.server.slicemgr import SliceMgr
        s = SliceMgr("", config.SFA_SM_PORT, server_key_file, server_cert_file)
        s.start()

    if (options.cm):
        from sfa.server.component import Component
        c = Component("", config.component_port, server_key_file, server_cert_file)
#        c = Component("", config.SFA_COMPONENT_PORT, server_key_file, server_cert_file)
        c.start()
Exemple #2
0
 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())
Exemple #3
0
def main():
    usage = """%prog file1 [ .. filen]
display info on input files"""
    parser = OptionParser(usage=usage)

    parser.add_option("-g", "--extract-gids", action="store_true", dest="extract_gids", default=False, help="Extract GIDs from credentials")
    parser.add_option("-p", "--dump-parents", action="store_true", dest="dump_parents", default=False, help="Show parents")
    parser.add_option("-e", "--extensions", action="store_true", dest="show_extensions", default="False", help="Show certificate extensions")
    parser.add_option("-v", "--verbose", action='count', dest='verbose', default=0)
    (options, args) = parser.parse_args()

    logger.setLevelFromOptVerbose(options.verbose)
    if len(args) <= 0:
        parser.print_help()
        sys.exit(1)
    for f in args: 
        handle_input(f,options)
Exemple #4
0
def main():
    usage = """%prog file1 [ .. filen]
display info on input files"""
    parser = ArgumentParser(usage=usage)

    parser.add_argument("-g", "--extract-gids", action="store_true", dest="extract_gids", 
                        default=False, help="Extract GIDs from credentials")
    parser.add_argument("-p", "--dump-parents", action="store_true", dest="dump_parents", 
                        default=False, help="Show parents")
    parser.add_argument("-e", "--extensions", action="store_true", 
                        dest="show_extensions", default="False", help="Show certificate extensions")
    parser.add_argument("-v", "--verbose", action='count', 
                        dest='verbose', default=0, help="More and more verbose")
    parser.add_argument("-x", "--xml", action='store_true', 
                        dest='show_xml', default=False, help="dumps xml tree (cred. only)")
    parser.add_argument("-c", "--check", action='append', dest='trusted_roots',
                        help="cumulative list of trusted GIDs - when provided, the input is verify'ed against these")
    parser.add_argument("filenames",metavar='F',nargs='+',help="filenames to dump")
    options = parser.parse_args()

    logger.setLevelFromOptVerbose(options.verbose)
    for filename in options.filenames: 
        handle_input(filename,options)
Exemple #5
0
    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())
Exemple #6
0
def main():
    # Generate command line parser
    parser = OptionParser(usage="sfa-start.py [options]")
    parser.add_option("-r",
                      "--registry",
                      dest="registry",
                      action="store_true",
                      help="run registry server",
                      default=False)
    parser.add_option("-s",
                      "--slicemgr",
                      dest="sm",
                      action="store_true",
                      help="run slice manager",
                      default=False)
    parser.add_option("-a",
                      "--aggregate",
                      dest="am",
                      action="store_true",
                      help="run aggregate manager",
                      default=False)
    parser.add_option("-c",
                      "--component",
                      dest="cm",
                      action="store_true",
                      help="run component server",
                      default=False)
    parser.add_option("-t",
                      "--trusted-certs",
                      dest="trusted_certs",
                      action="store_true",
                      help="refresh trusted certs",
                      default=False)
    parser.add_option("-d",
                      "--daemon",
                      dest="daemon",
                      action="store_true",
                      help="Run as daemon.",
                      default=False)
    (options, args) = parser.parse_args()

    config = Config()
    logger.setLevelFromOptVerbose(config.SFA_API_LOGLEVEL)

    # ge the server's key and cert
    hierarchy = Hierarchy()
    auth_info = hierarchy.get_interface_auth_info()
    server_key_file = auth_info.get_privkey_filename()
    server_cert_file = auth_info.get_gid_filename()

    # ensure interface cert is present in trusted roots dir
    trusted_roots = TrustedRoots(config.get_trustedroots_dir())
    trusted_roots.add_gid(GID(filename=server_cert_file))
    if (options.daemon): daemon()

    if options.trusted_certs:
        install_peer_certs(server_key_file, server_cert_file)

    # start registry server
    if (options.registry):
        from sfa.server.registry import Registry
        r = Registry("", config.SFA_REGISTRY_PORT, server_key_file,
                     server_cert_file)
        r.start()

    if (options.am):
        from sfa.server.aggregate import Aggregate
        a = Aggregate("", config.SFA_AGGREGATE_PORT, server_key_file,
                      server_cert_file)
        a.start()

    # start slice manager
    if (options.sm):
        from sfa.server.slicemgr import SliceMgr
        s = SliceMgr("", config.SFA_SM_PORT, server_key_file, server_cert_file)
        s.start()

    if (options.cm):
        from sfa.server.component import Component
        c = Component("", config.component_port, server_key_file,
                      server_cert_file)
        #        c = Component("", config.SFA_COMPONENT_PORT, server_key_file, server_cert_file)
        c.start()