Пример #1
0
def build_config(argv):

    gateway_name = "RG"
    gateway_desc = "Syndicate Replica Gateway"

    config = modconf.build_config(argv,
                                  gateway_desc,
                                  gateway_name,
                                  CONFIG_OPTIONS,
                                  conf_validator=validate_args)

    if config is None:
        log.error("Failed to load config")
        return None

    # reading commands from stdin?
    if config.get("stdin", None) is not None and config["stdin"]:

        arg_string = sys.stdin.read()
        stdin_argv = shlex.split(arg_string)

        config = modconf.build_config(stdin_argv,
                                      gateway_desc,
                                      gateway_name,
                                      CONFIG_OPTIONS,
                                      conf_validator=validate_args)
        if config is None:
            log.error("Failed to read config from stdin")
            return None

        if config.get("stdin", None) is not None and config["stdin"]:
            log.error("Invalid argument: passed --stdin on stdin")
            return None

    return config
Пример #2
0
def build_config( argv ):
   
   gateway_name = "RG"
   gateway_desc = "Syndicate Replica Gateway"
   
   config = modconf.build_config( argv, gateway_desc, gateway_name, CONFIG_OPTIONS, conf_validator=validate_args )
   
   if config is None:
      log.error("Failed to load config")
      return None 
   
   # reading commands from stdin?
   if config.get("stdin", None) is not None and config["stdin"]:
      
      arg_string = sys.stdin.read()
      stdin_argv = shlex.split( arg_string )
      
      config = modconf.build_config( stdin_argv, gateway_desc, gateway_name, CONFIG_OPTIONS, conf_validator=validate_args )
      if config is None:
         log.error("Failed to read config from stdin")
         return None
         
      if config.get("stdin", None) is not None and config["stdin"]:
         log.error("Invalid argument: passed --stdin on stdin")
         return None
      
   return config
Пример #3
0
        t_index = sys.argv.index("-t")

        ft_testname = "ft_%s" % sys.argv[t_index + 1]

        test_call = "%s(%s)" % (ft_testname, ",".join(sys.argv[t_index + 2:]))

        print "calling %s" % test_call

        rc = eval(test_call)

        print "result = %s" % rc

        sys.exit(0)

    CONFIG_OPTIONS = {
        "run_once":
        ("-1", 0, "Run the server once.  Do not spawn a watchdog."),
        "foreground": ("-f", 0, "Run the foreground.  Do not daemonize.")
    }

    config = modconf.build_config(sys.argv, "Syndicate Credential Server",
                                  "credserver", CONFIG_OPTIONS)

    if config is None:
        log.error("Failed to load config")
        sys.exit(1)

    else:
        ensure_credential_server_running(foreground=config['foreground'],
                                         run_once=config['run_once'])
Пример #4
0
 
 log.setLevel( logging.ERROR )
 
 # early enable debug logging 
 if "-d" in sys.argv or "--debug" in sys.argv:
    import syndicate.client.common.log as Log
    client_log = Log.get_logger()
    
    log.setLevel( logging.DEBUG )
    client_log.setLevel( "DEBUG" )
 
 opt_handlers = {
    "config": lambda arg: load_config_file( arg )
 }
 
 config = modconf.build_config( argv, "Syndicate Automount Daemon", "syndicated", CONFIG_OPTIONS, conf_validator=validate_config, opt_handlers=opt_handlers, config_opt="config" )
 
 if config is None:
    sys.exit(-1)
 
 # sanitize paths 
 for path_opt in ['logdir', 'mountpoint_dir']:
    if config.has_key(path_opt):
       config[path_opt] = config[path_opt].rstrip("/\\")        # directories do NOT end in / or \ 
 
 # sanitize hostname 
 if not config.has_key("hostname") or config['hostname'] is None or len(config['hostname']) == 0:
    config['hostname'] = socket.gethostname()
 
 # sanitize debug 
 if not config.has_key("debug") or config['debug'] is None:
Пример #5
0

#-------------------------------
class ObserverServer(BaseHTTPServer.HTTPServer):
    def __init__(self, cred_str, volume_str, server, req_handler):
        self.cred_str = cred_str
        self.volume_str = volume_str
        BaseHTTPServer.HTTPServer.__init__(self, server, req_handler)


if __name__ == "__main__":
    argv = sys.argv

    config = modconf.build_config(argv,
                                  "Syndicate Test Observer Server",
                                  "syndicate-test",
                                  CONFIG_OPTIONS,
                                  conf_validator=validate_config)

    if config is None:
        sys.exit(-1)

    # get private key
    key = load_private_key(config['private_key'])
    if key is None:
        sys.exit(-1)

    key_pem = key.exportKey()

    # get user private key
    user_key = load_private_key(config['user_pkey'])
Пример #6
0
      # doing a test 
      t_index = sys.argv.index("-t")
      
      ft_testname = "ft_%s" % sys.argv[t_index+1]
    
      test_call = "%s(%s)" % (ft_testname, ",".join(sys.argv[t_index+2:]))
      
      print "calling %s" % test_call
      
      rc = eval( test_call )
      
      print "result = %s" % rc
      
      sys.exit(0)
      
      
   CONFIG_OPTIONS = {
      "run_once":          ("-1", 0, "Run the server once.  Do not spawn a watchdog."),
      "foreground":        ("-f", 0, "Run the foreground.  Do not daemonize.")
   }
   
   config = modconf.build_config( sys.argv, "Syndicate Credential Server", "credserver", CONFIG_OPTIONS )
   
   if config is None:
      log.error("Failed to load config")
      sys.exit(1)
   
   else:
      ensure_credential_server_running( foreground=config['foreground'], run_once=config['run_once'] )
      
Пример #7
0
      return
   
   
#-------------------------------
class ObserverServer( BaseHTTPServer.HTTPServer ):
   
   def __init__(self, cred_str, volume_str, server, req_handler ):
      self.cred_str = cred_str
      self.volume_str = volume_str
      BaseHTTPServer.HTTPServer.__init__( self, server, req_handler )
      

if __name__ == "__main__":
   argv = sys.argv
   
   config = modconf.build_config( argv, "Syndicate Test Observer Server", "syndicate-test", CONFIG_OPTIONS, conf_validator=validate_config )
   
   if config is None:
      sys.exit(-1)
   
   # get private key 
   key = load_private_key( config['private_key'] )
   if key is None:
      sys.exit(-1)
   
   key_pem = key.exportKey()
   
   # get user private key
   user_key = load_private_key( config['user_pkey'] )
   if user_key is None:
      sys.exit(-1)