def update_fuel_setting_yaml(self, path): """This method override fuel settings yaml according to custom yaml :param path: a string of full path to custom setting yaml """ fuel_settings = self.get_fuel_settings() with open(path) as fyaml: custom_fuel_settings = yaml.load(fyaml) fuel_settings = dict_merge(fuel_settings, custom_fuel_settings) self.save_fuel_settings(fuel_settings) logger.debug('File /etc/fuel/astute.yaml was updated.' 'And now is {}'.format(fuel_settings))
def generate_attributes(cgroups): """Generate cluster attributes structure from cgroups dicts.""" attributes = {} for cgroup in cgroups: if "limit" not in cgroup: limit = {} else: limit = {cgroup["limit"]: cgroup["value"]} attributes = utils.dict_merge(attributes, { cgroup["process"]: { "label": cgroup["process"], "type": "text", "value": { cgroup["controller"]: limit } } }) for cgroup in attributes.values(): cgroup["value"] = json.dumps(cgroup["value"]) return {"editable": {"cgroups": attributes}}
def generate_attributes(cgroups): """Generate cluster attributes structure from cgroups dicts.""" attributes = {} for cgroup in cgroups: if "limit" not in cgroup: limit = {} else: limit = {cgroup["limit"]: cgroup["value"]} attributes = utils.dict_merge( attributes, { cgroup["process"]: { "label": cgroup["process"], "type": "text", "value": { cgroup["controller"]: limit } } }) for cgroup in attributes.values(): cgroup["value"] = json.dumps(cgroup["value"]) return {"editable": {"cgroups": attributes}}
def check_hugepages_distribution_per_numa(self): """Deploy environment with different HugePages allocation Scenario: 1. Revert basic_env_for_hugepages snapshot 2. Configure hugepages for three computes 3. Deploy cluster 4. Validate available huge pages on computes Snapshot: check_hugepages_distribution_per_numa """ snapshot_name = "check_hugepages_distribution_per_numa" self.check_run(snapshot_name) self.show_step(1) self.env.revert_snapshot("basic_env_for_hugepages") self.show_step(2) cluster_id = self.fuel_web.get_last_created_cluster() mixed_host = "slave-01" one_gb_host = "slave-02" two_mb_host = "slave-03" mixed_role_host = "slave-04" configs = { mixed_host: {"cpu_pinning": {"nova": {"value": 2}}, "hugepages": {"nova": {"value": {"2048": 258, "1048576": 1}} } }, one_gb_host: {"cpu_pinning": {"nova": {"value": 2}}, "hugepages": {"nova": {"value": {"2048": 0, "1048576": 2}} } }, two_mb_host: {"cpu_pinning": {"nova": {"value": 2}}, "hugepages": {"nova": {"value": {"2048": 540, "1048576": 0}} } }, mixed_role_host: {"cpu_pinning": {"nova": {"value": 2}}, "hugepages": {"nova": {"value": {"2048": 258, "1048576": 1}} } }, } for compute_name, config in configs.items(): compute_id = \ self.fuel_web.get_nailgun_node_by_name(compute_name)['id'] original_config = \ self.fuel_web.client.get_node_attributes(compute_id) self.fuel_web.client.upload_node_attributes( utils.dict_merge(original_config, config), compute_id) self.show_step(3) self.fuel_web.deploy_cluster_wait(cluster_id) self.show_step(4) for compute_name, config in configs.items(): two_mb_count = config["hugepages"]["nova"]["value"]["2048"] one_gb_count = config["hugepages"]["nova"]["value"]["1048576"] compute = self.fuel_web.get_nailgun_node_by_name(compute_name) cmd = ("cat /sys/devices/system/node/node{}/hugepages/" "hugepages-{}kB/nr_hugepages") actual_two_mb_count = 0 actual_one_gb_count = 0 for numa_node in [0, 1]: actual_two_mb_count += int("".join(self.ssh_manager.execute( compute['ip'], cmd.format(numa_node, "2048"))["stdout"])) result = "".join(self.ssh_manager.execute( compute['ip'], cmd.format(numa_node, "1048576"))["stdout"]) result = "0" if not result else result actual_one_gb_count += int(result) asserts.assert_equal( two_mb_count, actual_two_mb_count, "Actual number of allocated 2Mb pages is {}, expected {}" .format(actual_two_mb_count, two_mb_count)) asserts.assert_equal( one_gb_count, actual_one_gb_count, "Actual number of allocated 1Gb pages is {}, expected {}" .format(actual_one_gb_count, one_gb_count)) self.env.make_snapshot(snapshot_name, is_make=True)
def check_hugepages_distribution_per_numa(self): """Deploy environment with different HugePages allocation Scenario: 1. Revert basic_env_for_hugepages snapshot 2. Configure hugepages for three computes 3. Deploy cluster 4. Validate available huge pages on computes Snapshot: check_hugepages_distribution_per_numa """ snapshot_name = "check_hugepages_distribution_per_numa" self.check_run(snapshot_name) self.show_step(1) self.env.revert_snapshot("basic_env_for_hugepages") self.show_step(2) cluster_id = self.fuel_web.get_last_created_cluster() mixed_host = "slave-01" one_gb_host = "slave-02" two_mb_host = "slave-03" mixed_role_host = "slave-04" configs = { mixed_host: { "cpu_pinning": { "nova": { "value": 2 } }, "hugepages": { "nova": { "value": { "2048": 258, "1048576": 1 } } } }, one_gb_host: { "cpu_pinning": { "nova": { "value": 2 } }, "hugepages": { "nova": { "value": { "2048": 0, "1048576": 2 } } } }, two_mb_host: { "cpu_pinning": { "nova": { "value": 2 } }, "hugepages": { "nova": { "value": { "2048": 540, "1048576": 0 } } } }, mixed_role_host: { "cpu_pinning": { "nova": { "value": 2 } }, "hugepages": { "nova": { "value": { "2048": 258, "1048576": 1 } } } }, } for compute_name, config in configs.items(): compute_id = \ self.fuel_web.get_nailgun_node_by_name(compute_name)['id'] original_config = \ self.fuel_web.client.get_node_attributes(compute_id) self.fuel_web.client.upload_node_attributes( utils.dict_merge(original_config, config), compute_id) self.show_step(3) self.fuel_web.deploy_cluster_wait(cluster_id) self.show_step(4) for compute_name, config in configs.items(): two_mb_count = config["hugepages"]["nova"]["value"]["2048"] one_gb_count = config["hugepages"]["nova"]["value"]["1048576"] compute = self.fuel_web.get_nailgun_node_by_name(compute_name) cmd = ("cat /sys/devices/system/node/node{}/hugepages/" "hugepages-{}kB/nr_hugepages") actual_two_mb_count = 0 actual_one_gb_count = 0 for numa_node in [0, 1]: actual_two_mb_count += int("".join( self.ssh_manager.execute(compute['ip'], cmd.format(numa_node, "2048"))["stdout"])) result = "".join( self.ssh_manager.execute(compute['ip'], cmd.format(numa_node, "1048576"))["stdout"]) result = "0" if not result else result actual_one_gb_count += int(result) asserts.assert_equal( two_mb_count, actual_two_mb_count, "Actual number of allocated 2Mb pages is {}, expected {}". format(actual_two_mb_count, two_mb_count)) asserts.assert_equal( one_gb_count, actual_one_gb_count, "Actual number of allocated 1Gb pages is {}, expected {}". format(actual_one_gb_count, one_gb_count)) self.env.make_snapshot(snapshot_name, is_make=True)