def __update_ud(self): utils.log("DEBUG", "Updating userdata variables ...",('__update_ud',self)) ud = cloud.userdata(self.__config, self) for key in ud: if self.__config['userdata'].get(key) != ud[key]: if utils.update_config_file(self.__config, key, ud[key]): utils.log("INFO", "%s has been updated from %s to %s"%(key,self.__config['userdata'].get(key),ud[key]), ('__update_ud',self)) self.__config['userdata'][key] = ud[key] if key in self.__config['global']['token_reset']: utils.reset_token(self.__config) utils.log("DEBUG", "Userdata variables updated",('__update_ud',self))
def __update_ud(self): utils.log("DEBUG", "Updating userdata variables ...", ('__update_ud', self)) ud = cloud.userdata(self.__config, self) for key in ud: if self.__config['userdata'].get(key) != ud[key]: if utils.update_config_file(self.__config, key, ud[key]): utils.log( "INFO", "%s has been updated from %s to %s" % (key, self.__config['userdata'].get(key), ud[key]), ('__update_ud', self)) self.__config['userdata'][key] = ud[key] if key in self.__config['global']['token_reset']: utils.reset_token(self.__config) utils.log("DEBUG", "Userdata variables updated", ('__update_ud', self))
def token(config): f = config['global'].get('token') utils.log("DEBUG", "Getting token located in %s"%(f),('token','cloud')) t = '' try: with open(f, 'r') as f: t = f.read() except Exception as e: utils.log("WARNING", "Can't get token file (%s): %s, updating token"%(f,e),('token','cloud')) utils.reset_token(config) try: with open(f, 'r') as f: t = f.read() except Exception as e: utils.log("ERROR", "Can't get token file (%s): %s"%(f,e),('token','cloud')) return t
def token(config): f = config['global'].get('token') utils.log("DEBUG", "Getting token located in %s" % (f), ('token', 'cloud')) t = '' try: with open(f, 'r') as f: t = f.read() except Exception as e: utils.log("WARNING", "Can't get token file (%s): %s, updating token" % (f, e), ('token', 'cloud')) utils.reset_token(config) try: with open(f, 'r') as f: t = f.read() except Exception as e: utils.log("ERROR", "Can't get token file (%s): %s" % (f, e), ('token', 'cloud')) return t