def get_jinja_vars(self): # order for per-project variables (each overrides the previous): # 1. /etc/kolla/globals.yml and passwords.yml # 2. config/all.yml # 3. config/<project>/defaults/main.yml with open(file_utils.find_config_file('passwords.yml'), 'r') as gf: global_vars = yaml.load(gf) with open(file_utils.find_config_file('globals.yml'), 'r') as gf: global_vars.update(yaml.load(gf)) all_yml_name = os.path.join(self.config_dir, 'all.yml') jvars = yaml.load(jinja_utils.jinja_render(all_yml_name, global_vars)) jvars.update(global_vars) for proj in self.get_projects(): proj_yml_name = os.path.join(self.config_dir, proj, 'defaults', 'main.yml') if os.path.exists(proj_yml_name): proj_vars = yaml.load(jinja_utils.jinja_render(proj_yml_name, jvars)) jvars.update(proj_vars) else: LOG.warn('path missing %s' % proj_yml_name) # override node_config_directory to empty jvars.update({'node_config_directory': ''}) return jvars
def _load_variables_from_file(service_dir, project_name): config_dir = os.path.join(service_dir, '..', 'config') with open(file_utils.find_config_file('passwords.yml'), 'r') as gf: global_vars = yaml.load(gf) with open(file_utils.find_config_file('globals.yml'), 'r') as gf: global_vars.update(yaml.load(gf)) # all.yml file uses some its variables to template itself by jinja2, # so its raw content is used to template the file all_yml_name = os.path.join(config_dir, 'all.yml') with open(all_yml_name) as af: raw_vars = yaml.load(af) raw_vars.update(global_vars) jvars = yaml.load(jinja_utils.jinja_render(all_yml_name, raw_vars)) jvars.update(global_vars) proj_yml_name = os.path.join(config_dir, project_name, 'defaults', 'main.yml') if os.path.exists(proj_yml_name): proj_vars = yaml.load(jinja_utils.jinja_render(proj_yml_name, jvars)) jvars.update(proj_vars) else: LOG.warning('Path missing %s' % proj_yml_name) # Add deployment_id jvars.update({'deployment_id': CONF.kolla.deployment_id}) # override node_config_directory to empty jvars.update({'node_config_directory': ''}) # Add timestamp jvars.update({'timestamp': str(time.time())}) config.apply_deployment_vars(jvars) config.get_marathon_framework(jvars) return jvars
def _load_variables_from_file(service_dir, project_name): config_dir = os.path.join(service_dir, '..', 'config') jvars = JvarsDict() with open(file_utils.find_config_file('globals.yml'), 'r') as gf: jvars.set_global_vars(yaml.load(gf)) with open(file_utils.find_config_file('passwords.yml'), 'r') as gf: jvars.update(yaml.load(gf)) # Apply the basic variables that aren't defined in any config file. jvars.update({ 'deployment_id': CONF.kolla.deployment_id, 'node_config_directory': '', 'timestamp': str(time.time()) }) # Get the exact marathon framework name. config.get_marathon_framework(jvars) # all.yml file uses some its variables to template itself by jinja2, # so its raw content is used to template the file all_yml_name = os.path.join(config_dir, 'all.yml') jinja_utils.yaml_jinja_render(all_yml_name, jvars) # Apply the dynamic deployment variables. config.apply_deployment_vars(jvars) proj_yml_name = os.path.join(config_dir, project_name, 'defaults', 'main.yml') if os.path.exists(proj_yml_name): jinja_utils.yaml_jinja_render(proj_yml_name, jvars) else: LOG.warning('Path missing %s' % proj_yml_name) return jvars
def get_jinja_vars(self): # order for per-project variables (each overrides the previous): # 1. /etc/kolla/globals.yml and passwords.yml # 2. config/all.yml # 3. config/<project>/defaults/main.yml with open(file_utils.find_config_file('passwords.yml'), 'r') as gf: global_vars = yaml.load(gf) with open(file_utils.find_config_file('globals.yml'), 'r') as gf: global_vars.update(yaml.load(gf)) # all.yml file uses some its variables to template itself by jinja2, # so its raw content is used to template the file all_yml_name = os.path.join(self.config_dir, 'all.yml') with open(all_yml_name) as af: raw_vars = yaml.load(af) raw_vars.update(global_vars) jvars = yaml.load(jinja_utils.jinja_render(all_yml_name, raw_vars)) jvars.update(global_vars) for proj in self.get_projects(): proj_yml_name = os.path.join(self.config_dir, proj, 'defaults', 'main.yml') if os.path.exists(proj_yml_name): proj_vars = yaml.load(jinja_utils.jinja_render(proj_yml_name, jvars)) jvars.update(proj_vars) else: LOG.warning('Path missing %s' % proj_yml_name) # Add deployment_id jvars.update({'deployment_id': self.deployment_id}) # override node_config_directory to empty jvars.update({'node_config_directory': ''}) return jvars