def __update_yaml(self): conf_file = os.path.join(self.get_path(), "resources", "dse", "conf", "dse.yaml") with open(conf_file, "r") as f: data = yaml.load(f) data["system_key_directory"] = os.path.join(self.get_path(), "keys") full_options = dict(list(self.cluster._dse_config_options.items())) for name in full_options: if not name is "dse_yaml_file": value = full_options[name] if value is None: try: del data[name] except KeyError: # it is fine to remove a key not there:w pass else: data[name] = full_options[name] if "dse_yaml_file" in full_options: with open(full_options["dse_yaml_file"], "r") as f: user_yaml = yaml.load(f) data = common.yaml_merge(data, user_yaml) with open(conf_file, "w") as f: yaml.safe_dump(data, f, default_flow_style=False)
def __update_yaml(self): conf_file = os.path.join(self.get_path(), 'resources', 'dse', 'conf', 'dse.yaml') with open(conf_file, 'r') as f: data = yaml.load(f) data['system_key_directory'] = os.path.join(self.get_path(), 'keys') full_options = dict(list(self.cluster._dse_config_options.items())) for name in full_options: if not name is 'dse_yaml_file': value = full_options[name] if value is None: try: del data[name] except KeyError: # it is fine to remove a key not there:w pass else: data[name] = full_options[name] if 'dse_yaml_file' in full_options: with open(full_options['dse_yaml_file'], 'r') as f: user_yaml = yaml.load(f) data = common.yaml_merge(data, user_yaml) with open(conf_file, 'w') as f: yaml.safe_dump(data, f, default_flow_style=False)
def test_yaml_merge(self): primary_filename = "./test_files/primary.yaml" secondary_filename = "./test_files/secondary.yaml" with open(primary_filename, 'r') as f: primary = yaml.load(f) with open(secondary_filename, 'r') as f: secondary = yaml.load(f) merged = common.yaml_merge(primary, secondary) expected = {'should_be_one': 1, 'should_be_one_nested': {'should_still_be_one': 1}, 'not_in_secondary': True, 'not_in_primary': False } self.assertItemsEqual(merged, expected)
def test_yaml_merge(self): primary_filename = "./test_files/primary.yaml" secondary_filename = "./test_files/secondary.yaml" with open(primary_filename, 'r') as f: primary = yaml.load(f) with open(secondary_filename, 'r') as f: secondary = yaml.load(f) merged = common.yaml_merge(primary, secondary) expected = { 'should_be_one': 1, 'should_be_one_nested': { 'should_still_be_one': 1 }, 'not_in_secondary': True, 'not_in_primary': False } self.assertItemsEqual(merged, expected)