def __init__(self, conf=None): self.nginx_manage_port = config.get_config('NGINX_MANAGE_PORT', '8089', conf) self.nginx_purge_path = config.get_config('NGINX_PURGE_PATH', '/purge', conf) self.nginx_healthcheck_path = config.get_config('NGINX_HEALTHCHECK_PATH', '/healthcheck', conf) self.config_manager = ConfigManager(conf)
def __init__(self, conf=None): self.nginx_reload_path = config.get_config('NGINX_RELOAD_PATH', '/reload', conf) self.nginx_manage_port = config.get_config('NGINX_MANAGE_PORT', '8089', conf) self.nginx_dav_put_path = config.get_config('NGINX_DAV_PUT_PATH', '/dav', conf) self.nginx_healthcheck_path = config.get_config('NGINX_HEALTHCHECK_PATH', '/healthcheck', conf) self.config_manager = ConfigManager(conf)
def __init__(self, conf=None): self.nginx_reload_path = config.get_config('NGINX_RELOAD_PATH', '/reload', conf) self.nginx_manage_port = config.get_config('NGINX_MANAGE_PORT', '8089', conf) self.nginx_dav_put_path = config.get_config('NGINX_DAV_PUT_PATH', '/dav', conf) self.nginx_healthcheck_path = config.get_config( 'NGINX_HEALTHCHECK_PATH', '/healthcheck', conf) self.config_manager = ConfigManager(conf)
def _load_location_template(self, conf): template_txt = config.get_config("NGINX_LOCATION_TEMPLATE_TXT", None, conf) if template_txt: return template_txt template_url = config.get_config("NGINX_LOCATION_TEMPLATE_URL", None, conf) if template_url: rsp = requests.get(template_url) if rsp.status_code > 299: raise NginxError("Error trying to load location template: {} - {}".format(rsp.status_code, rsp.text)) return rsp.text return """
def _load_location_template(self, conf): template_txt = config.get_config('NGINX_LOCATION_TEMPLATE_TXT', None, conf) if template_txt: return template_txt template_url = config.get_config('NGINX_LOCATION_TEMPLATE_URL', None, conf) if template_url: rsp = requests.get(template_url) if rsp.status_code > 299: raise NginxError("Error trying to load location template: {} - {}". format(rsp.status_code, rsp.text)) return rsp.text return """
def __init__(self, conf=None): self.config = conf self.mongo_uri = config.get_config('DBAAS_MONGODB_ENDPOINT', None, conf) if not self.mongo_uri: self.mongo_uri = config.get_config('MONGO_URI', 'mongodb://localhost:27017/', conf) client = pymongo.MongoClient(self.mongo_uri) try: self.db = client.get_default_database() self.mongo_database = self.db.name except pymongo.errors.ConfigurationError: self.mongo_database = config.get_config('MONGO_DATABASE', 'host_manager', conf) self.db = client[self.mongo_database]
def _load_location_template(self, conf, mode): mode = mode.upper() template_txt = config.get_config('NGINX_LOCATION_TEMPLATE_{}_TXT'.format(mode), None, conf) if template_txt: return template_txt template_url = config.get_config('NGINX_LOCATION_TEMPLATE_{}_URL'.format(mode), None, conf) if template_url: rsp = requests.get(template_url) if rsp.status_code > 299: raise NginxError("Error trying to load location template: {} - {}". format(rsp.status_code, rsp.text)) return rsp.text if mode == "DEFAULT": return NGINX_LOCATION_TEMPLATE_DEFAULT return NGINX_LOCATION_TEMPLATE_ROUTER
def __init__(self, conf=None): self.nginx_manage_port = config.get_config('NGINX_MANAGE_PORT', '8089', conf) self.nginx_manage_port_tls = config.get_config('NGINX_MANAGE_PORT_TLS', '8090', conf) self.nginx_purge_path = config.get_config('NGINX_PURGE_PATH', '/purge', conf) self.nginx_expected_healthcheck = config.get_config('NGINX_HEALTHECK_EXPECTED', 'WORKING', conf) self.nginx_healthcheck_path = config.get_config('NGINX_HEALTHCHECK_PATH', '/healthcheck', conf) self.nginx_healthcheck_app_path = config.get_config('NGINX_HEALTHCHECK_APP_PATH', '/_nginx_healthcheck/', conf) self.nginx_app_port = config.get_config('NGINX_APP_PORT', '8080', conf) self.nginx_app_expected_healthcheck = config.get_config('NGINX_HEALTHECK_APP_EXPECTED', 'WORKING', conf) self.ca_cert = config.get_config('CA_CERT', None, conf) self.ca_path = "/tmp/rpaas_ca.pem" self.config_manager = ConfigManager(conf)
def _current_group_alternate(cls, group, conf=None): alternates_count = int(config.get_config("HM_ALTERNATIVE_CONFIG_COUNT", 1, conf)) hosts = model.storage(conf).list_hosts({'group': group}) alterantives_map = collections.defaultdict(int) for host in hosts: alterantives_map[host.alternative_id] += 1 min_alt_id = 0 min_alt_count = None for i in xrange(alternates_count): if min_alt_count is None or alterantives_map[i] < min_alt_count: min_alt_id = i min_alt_count = alterantives_map[i] return min_alt_id
def __init__(self, conf=None): self.nginx_manage_port = config.get_config('NGINX_MANAGE_PORT', '8089', conf) self.nginx_purge_path = config.get_config('NGINX_PURGE_PATH', '/purge', conf) self.nginx_expected_healthcheck = config.get_config('NGINX_HEALTHECK_EXPECTED', 'WORKING', conf) self.nginx_healthcheck_path = config.get_config('NGINX_HEALTHCHECK_PATH', '/healthcheck', conf) self.nginx_healthcheck_app_path = config.get_config('NGINX_HEALTHCHECK_APP_PATH', '/_nginx_healthcheck/', conf) self.nginx_app_port = config.get_config('NGINX_APP_PORT', '8080', conf) self.nginx_app_expected_healthcheck = config.get_config('NGINX_HEALTHECK_APP_EXPECTED', 'WORKING', conf) self.config_manager = ConfigManager(conf)
def _current_group_alternate(cls, group, conf, alternative_id_error): alternates_count = range( int(config.get_config("HM_ALTERNATIVE_CONFIG_COUNT", 1, conf))) alternates_valid = list( set(alternates_count) - set(alternative_id_error)) if len(alternates_valid) == 0: raise NoMoreHMAlternativesAvailable hosts = model.storage(conf).list_hosts({'group': group}) alterantives_map = collections.defaultdict(int) for host in hosts: alterantives_map[host.alternative_id] += 1 min_alt_count = None for i in alternates_valid: if min_alt_count is None or alterantives_map[i] < min_alt_count: min_alt_id = i min_alt_count = alterantives_map[i] return min_alt_id
def _get_conf(self, key, default=config.undefined): return config.get_config(key, default, self.config)
def get_conf(self, name, default=config.undefined): return config.get_config(name, default, self.config)
def __init__(self, conf=None): self.nginx_manage_port = config.get_config("NGINX_MANAGE_PORT", "8089", conf) self.nginx_purge_path = config.get_config("NGINX_PURGE_PATH", "/purge", conf) self.nginx_healthcheck_path = config.get_config("NGINX_HEALTHCHECK_PATH", "/healthcheck", conf) self.config_manager = ConfigManager(conf)