示例#1
0
 def load_connector_file(self):
     """load config from a JSON connector file,
     at a *lower* priority than command-line/config files.
     """
     
     self.log.info("Loading url_file %r", self.url_file)
     config = self.config
     
     with open(self.url_file) as f:
         num_tries = 0
         max_tries = 5
         d = ""
         while not d:
             try:
                 d = json.loads(f.read())
             except ValueError:
                 if num_tries > max_tries:
                     raise
                 num_tries += 1
                 time.sleep(0.5)
     
     # allow hand-override of location for disambiguation
     # and ssh-server
     if 'EngineFactory.location' not in config:
         config.EngineFactory.location = d['location']
     if 'EngineFactory.sshserver' not in config:
         config.EngineFactory.sshserver = d.get('ssh')
     
     location = config.EngineFactory.location
     
     proto, ip = d['interface'].split('://')
     ip = disambiguate_ip_address(ip, location)
     d['interface'] = '%s://%s' % (proto, ip)
     
     # DO NOT allow override of basic URLs, serialization, or key
     # JSON file takes top priority there
     config.Session.key = cast_bytes(d['key'])
     config.Session.signature_scheme = d['signature_scheme']
     
     config.EngineFactory.url = d['interface'] + ':%i' % d['registration']
     
     config.Session.packer = d['pack']
     config.Session.unpacker = d['unpack']
     
     self.log.debug("Config changed:")
     self.log.debug("%r", config)
     self.connection_info = d
示例#2
0
 def load_connector_file(self):
     """load config from a JSON connector file,
     at a *lower* priority than command-line/config files.
     """
     
     self.log.info("Loading url_file %r", self.url_file)
     config = self.config
     
     with open(self.url_file) as f:
         num_tries = 0
         max_tries = 5
         d = ""
         while not d:
             try:
                 d = json.loads(f.read())
             except ValueError:
                 if num_tries > max_tries:
                     raise
                 num_tries += 1
                 time.sleep(0.5)
     
     # allow hand-override of location for disambiguation
     # and ssh-server
     if 'EngineFactory.location' not in config:
         config.EngineFactory.location = d['location']
     if 'EngineFactory.sshserver' not in config:
         config.EngineFactory.sshserver = d.get('ssh')
     
     location = config.EngineFactory.location
     
     proto, ip = d['interface'].split('://')
     ip = disambiguate_ip_address(ip, location)
     d['interface'] = '%s://%s' % (proto, ip)
     
     # DO NOT allow override of basic URLs, serialization, or key
     # JSON file takes top priority there
     config.Session.key = cast_bytes(d['key'])
     config.Session.signature_scheme = d['signature_scheme']
     
     config.EngineFactory.url = d['interface'] + ':%i' % d['registration']
     
     config.Session.packer = d['pack']
     config.Session.unpacker = d['unpack']
     
     self.log.debug("Config changed:")
     self.log.debug("%r", config)
     self.connection_info = d
示例#3
0
    def load_connector_file(self):
        """load config from a JSON connector file,
        at a *lower* priority than command-line/config files.
        """

        self.log.info("Loading url_file %r", self.url_file)
        config = self.config

        with open(self.url_file) as f:
            d = json.loads(f.read())

        # allow hand-override of location for disambiguation
        # and ssh-server
        try:
            config.EngineFactory.location
        except AttributeError:
            config.EngineFactory.location = d["location"]

        try:
            config.EngineFactory.sshserver
        except AttributeError:
            config.EngineFactory.sshserver = d.get("ssh")

        location = config.EngineFactory.location

        proto, ip = d["interface"].split("://")
        ip = disambiguate_ip_address(ip, location)
        d["interface"] = "%s://%s" % (proto, ip)

        # DO NOT allow override of basic URLs, serialization, or exec_key
        # JSON file takes top priority there
        config.Session.key = cast_bytes(d["exec_key"])

        config.EngineFactory.url = d["interface"] + ":%i" % d["registration"]

        config.Session.packer = d["pack"]
        config.Session.unpacker = d["unpack"]

        self.log.debug("Config changed:")
        self.log.debug("%r", config)
        self.connection_info = d
示例#4
0
 def load_connector_file(self):
     """load config from a JSON connector file,
     at a *lower* priority than command-line/config files.
     """
     
     self.log.info("Loading url_file %r", self.url_file)
     config = self.config
     
     with open(self.url_file) as f:
         d = json.loads(f.read())
     
     # allow hand-override of location for disambiguation
     # and ssh-server
     try:
         config.EngineFactory.location
     except AttributeError:
         config.EngineFactory.location = d['location']
     
     try:
         config.EngineFactory.sshserver
     except AttributeError:
         config.EngineFactory.sshserver = d.get('ssh')
     
     location = config.EngineFactory.location
     
     proto, ip = d['interface'].split('://')
     ip = disambiguate_ip_address(ip, location)
     d['interface'] = '%s://%s' % (proto, ip)
     
     # DO NOT allow override of basic URLs, serialization, or exec_key
     # JSON file takes top priority there
     config.Session.key = cast_bytes(d['exec_key'])
     
     config.EngineFactory.url = d['interface'] + ':%i' % d['registration']
     
     config.Session.packer = d['pack']
     config.Session.unpacker = d['unpack']
     
     self.log.debug("Config changed:")
     self.log.debug("%r", config)
     self.connection_info = d