Esempio n. 1
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))
Esempio n. 2
0
 def get_ceph_tunings(self):
     config_api = ConfigAPI()
     path = config_api.get_current_tunings_path()
     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()
     ceph_data = ceph_data.replace("[global]", "")
     return ceph_data
Esempio n. 3
0
 def run_post_deploy_script(self):
     config_api = ConfigAPI()
     path = config_api.get_current_tunings_path(
     ) + config_api.get_post_deploy_script_file_name()
     if os.path.exists(path):
         call_cmd("chmod +x {}".format(path))
         logger.info("Run post deploy script.")
         call_cmd(path)
Esempio n. 4
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)
Esempio n. 5
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
Esempio n. 6
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