예제 #1
0
    def get_lio_backstore_tunings(self):
        config_api = ConfigAPI()
        path = config_api.get_current_tunings_path()
        data = None if not os.path.exists(path + config_api.get_lio_tunings_file_name()) else \
            open(path + config_api.get_lio_tunings_file_name(), 'r').read()

        if data:
            data = json.loads(str(data))
            if data.get("storage_objects", None) and len(data["storage_objects"]) > 0 \
                    and data["storage_objects"][0].get("attributes", None):
                return data["storage_objects"][0]["attributes"]

        return None
예제 #2
0
    def get_lio_tpg_tuning_parameters(self):
        config_api = ConfigAPI()
        path = config_api.get_current_tunings_path()
        data = None if not os.path.exists(path + config_api.get_lio_tunings_file_name()) else \
            open(path + config_api.get_lio_tunings_file_name(), 'r').read()

        if data:
            data = json.loads(str(data))
            if data.get("targets", None) and len(data["targets"]) > 0 and data["targets"][0].get("tpgs", None):
                tpgs = data["targets"][0].get("tpgs", None)
                if len(tpgs) > 0 and tpgs[0].get("parameters", None):
                    return tpgs[0]["parameters"]

        return None
예제 #3
0
    def save_current_tunings(self, ceph, lio, post_script, storage_engine):
        config_api = ConfigAPI()
        path = config_api.get_current_tunings_path()

        if not os.path.exists(path):
            os.makedirs(path)
        with open(path + config_api.get_ceph_tunings_file_name(), 'w', ) as f:
            f.write(ceph)

        with open(path + config_api.get_lio_tunings_file_name(), 'w', ) as f:
            f.write(lio)

        with open(path + config_api.get_post_deploy_script_file_name(), 'w', ) as f:
            f.write(post_script)
        logger.info("Current tuning configurations saved.")

        # Save "storage_engine" in Cluster info #
        # ------------------------------------- #
        try:
            ci = self.get_cluster_info()
            ci.storage_engine = storage_engine
            self.set_cluster_network_info(ci)

        except Exception as ex:
            logger.error("Cannot add storage engine to cluster info , {}".format(ex.message))
예제 #4
0
    def get_template(self, template_name):
        config_api = ConfigAPI()
        template_name = template_name + "/"
        path = config_api.get_tuning_templates_dir_path() + template_name
        tuning_dict = dict()
        ceph_data = "" if not os.path.exists(path + config_api.get_ceph_tunings_file_name()) else \
            open(path + config_api.get_ceph_tunings_file_name(), 'r').read()
        lio_data = "" if not os.path.exists(path + config_api.get_lio_tunings_file_name()) else \
            open(path + config_api.get_lio_tunings_file_name(), 'r').read()
        script_data = "" if not os.path.exists(path + config_api.get_post_deploy_script_file_name()) else \
            open(path + config_api.get_post_deploy_script_file_name(), 'r').read()

        tuning_dict[config_api.get_ceph_tunings_file_name()] = ceph_data
        tuning_dict[config_api.get_lio_tunings_file_name()] = lio_data
        tuning_dict[config_api.get_post_deploy_script_file_name()] = script_data
        return tuning_dict
예제 #5
0
 def __copy_current_tunings(self, ip):
     config_api = ConfigAPI()
     ssh_obj = ssh()
     path = config_api.get_current_tunings_path()
     post_deploy_script_path = path + config_api.get_post_deploy_script_file_name(
     )
     ceph_path = path + config_api.get_ceph_tunings_file_name()
     lio_path = path + config_api.get_lio_tunings_file_name()
     ssh_obj.copy_file_from_host(ip, post_deploy_script_path)
     ssh_obj.copy_file_from_host(ip, ceph_path)
     ssh_obj.copy_file_from_host(ip, lio_path)