def build_compute_nodes(self, zone):
        logger.debug("start building compute nodes in " + zone)
        self.all_id_dict["clusterparams"]["server"][zone]["compute"] = {}
        n = self.configuration_info["the number of compute node in " + zone]
            
        
        with futures.ThreadPoolExecutor(max_workers = self.max_workers, thread_name_prefix="thread") as executor:
        
            while(True):
                future = []
                for i in range(n):
                    #executor.submit(MulHelper(self, "build_one_compute_node"), kwargs={"zone": zone, "i": i})
                    future.append(executor.submit(self.build_one_compute_node, i, zone))

                future_result = [f.result()[0] for f in future]
                future_msg = [f.result()[1] for f in future if(f.result()[0] == False and f.result()[1] != "")]
                if(len(future_msg) > 0):
                    future_msg = future_msg[0]
                    
                if False in future_result:
                    #self.printout_cluster("", cls_monitor_level = 2, overwrite = True)
                    
                    #self.printout_cluster("\n".join(future_msg), cls_monitor_level = 2)
                    temp = conf_pattern_2("\n".join(future_msg) + "\nTry again??", ["yes", "no"], "no", info_list = self.info_list, fp = self.fp)
                    #self.printout_cluster("", cls_monitor_level = 2, overwrite = True)
                    if temp == "no":
                        self.printout_cluster("Delete the cluster that was constructed.", cls_monitor_level = 2, overwrite = True)
                        self.printout_cluster("Stop processing.", cls_monitor_level = 2, overwrite = True)
                        self.bar.close()
                        self.call_delete(self.all_id_dict,self.auth_res,self.max_workers,self.fp,self.info_list,self.api_index)
                        sys.exit()
                else:
                    break
Exemple #2
0
def check_dir_existence(path, filename, info_list = [1,0,0,0], fp = ""):
    while(True):
        logger.debug('Checking the output directory')
        _ = printout("Checking the output directory...", info_type = 0, info_list = info_list, fp = fp)
        #ディレクトリの存在を確認
        index = os.path.exists(path)
        #ディレクトリが存在しない場合
        if(index == False):
            logger.error('DirNotFoundError: the specified directory cannot be found')
            _ = printout("DirNotFoundError: the specified directory cannot be found.", info_type = 0, info_list = info_list, fp = fp)
            temp = conf_pattern_2("Do you want to change the directory?? (if you choose no, the specified directory will be created)", ["yes", "no"], "no", info_list = info_list, fp = fp)
            
            #パスの再定義
            if(temp == "yes"):
                out_path = printout("Please specify the other directory >>>", info_type = 1, info_list = info_list, fp = fp)
                logger.debug('New Path was entered')
                logger.debug('Checking the extension of the config file')
                
                #パス内にファイル名が含まれている場合
                if((".js" in out_path.split("/")[-1]) or (".json" in out_path.split("/")[-1])):
                    filename = os.path.basename(out_path)
                    path = os.path.dirname(out_path)
                    logger.debug('New directory and filename are set')
                    
                #パス内にファイル名が含まれていない場合
                else:
                    filename = "config.json"
                    path = out_path 
                    logger.debug('New directory is set')
                    logger.debug('The config filename is automatically set to config.json')
               
            #ディレクトリを生成
            else:
                path, filename = make_dirs(path, filename, info_list = info_list, fp = fp)
        #ディレクトリが存在する場合
        else:
            logger.debug('Existence of specified file has been confirmed')
            return path, filename
Exemple #3
0
def setting_server(ext_info, server_type, fp="", info_list=[1, 0, 0, 0]):
    #ノードにおけるCore数
    logger.debug('setting core number')
    param = {}
    param["Node"] = {}
    candidate = list(ext_info["Server"].keys())
    core_plan = int(
        conf_pattern_2("The number of core for " + str(server_type) + " node",
                       candidate,
                       candidate[0],
                       info_list=info_list,
                       fp=fp))
    set_parm("The number of cores for " + str(server_type) + " node",
             str(core_plan),
             info_list=info_list,
             fp=fp)
    param["Node"]["core"] = int(core_plan)

    #ノードにおけるメモリ容量
    logger.debug('setting memory size')
    candidate = [
        str(i) + " (" + str(int(round(int(i), -3) / 1000)) + "GB)"
        for i in list(ext_info["Server"][str(core_plan)].keys())
    ]
    memory_plan = list(
        ext_info["Server"][str(core_plan)].keys())[conf_pattern_3(
            "Size of memory for " + str(server_type) + " node",
            candidate,
            candidate[0],
            info_list=info_list,
            fp=fp)]
    set_parm("Size of memory for " + str(server_type) + " node",
             str(memory_plan),
             info_list=info_list,
             fp=fp)
    param["Node"]["memory"] = int(memory_plan)
    param["Node"]["NodePlan"] = ext_info["Server"][str(core_plan)][memory_plan]

    #ノードにおけるディスクの種類
    logger.debug('setting disk type')
    param["Disk"] = {}
    candidate = list(ext_info["Disk"].keys())
    param["Disk"]["Type"] = candidate[conf_pattern_3(
        "Disk type for " + str(server_type) + " node",
        candidate,
        candidate[0],
        info_list=info_list,
        fp=fp)]
    set_parm("Disk type for " + str(server_type) + " node",
             param["Disk"]["Type"],
             info_list=info_list,
             fp=fp)

    #ノードにおけるディスクのサイズ
    logger.debug('setting disk size')
    candidate = [
        str(i) + " (" + str(int(round(int(i), -3) / 1000)) + "GB)"
        for i in ext_info["Disk"][param["Disk"]["Type"]]
    ]
    param["Disk"]["Size"] = ext_info["Disk"][param["Disk"]["Type"]][
        conf_pattern_3("Disk size for " + str(server_type) + " node",
                       candidate,
                       candidate[0],
                       info_list=info_list,
                       fp=fp)]
    set_parm("Disk size for " + str(server_type) + " node",
             str(param["Disk"]["Size"]),
             info_list=info_list,
             fp=fp)

    #ノードにおけるサーバとディスク間接続方法
    logger.debug('setting connection type')
    candidate = ext_info["Connection"]
    param["Connection type"] = candidate[conf_pattern_3(
        "Connection type between server and disk for " + str(server_type) +
        " node",
        candidate,
        candidate[0],
        info_list=info_list,
        fp=fp)]
    set_parm("Connection type between server and disk for " +
             str(server_type) + " node",
             param["Connection type"],
             info_list=info_list,
             fp=fp)

    #ノードのOS
    logger.debug('setting OS')
    param["OS"] = {}
    candidate = list(ext_info["OS"].keys())
    param["OS"]["name"] = candidate[conf_pattern_3("OS in " +
                                                   str(server_type) + " node",
                                                   candidate,
                                                   candidate[0],
                                                   info_list=info_list,
                                                   fp=fp)]
    param["OS"]["OSPlan"] = ext_info["OS"][param["OS"]["name"]]
    set_parm("OS in " + str(server_type) + " node",
             param["OS"]["name"],
             info_list=info_list,
             fp=fp)

    return param
Exemple #4
0
def delete_main(api_index, f, info_list, max_workers):
    logger.debug('Setting authentication info')
    auth_info = authentication_cli(fp=f,
                                   info_list=info_list,
                                   api_index=api_index)

    logger.debug('loading external data')
    ext_info = external_data(auth_info, info_list=info_list, fp=f)

    logger.debug('Getting cluster information')
    params = get_params.get_params(ext_info,
                                   auth_info,
                                   info_list=info_list,
                                   f=f,
                                   api_index=api_index)
    params()
    params.show_cluster_info()

    index, cluster_id = get_cluster_id.get_cluster_id(params.cluster_info_all,
                                                      info_list, f, api_index)

    temp = conf_pattern_2("Delete the selected cluster?", ["yes", "no"],
                          "no",
                          info_list=info_list,
                          fp=f)

    state, obj = params.checking_status(cluster_id)

    if temp == "yes":
        if (state == False):
            conf_stop_process(info_list, f)

            logger.debug("Start stopping the cluster : " + str(cluster_id))
            printout("Start stopping the cluster : " + str(cluster_id),
                     info_type=0,
                     info_list=info_list,
                     fp=f)
            stop_obj = stop_sacluster(params.cluster_info_all[cluster_id],
                                      auth_info,
                                      max_workers,
                                      fp=f,
                                      info_list=info_list,
                                      api_index=api_index)
            stop_obj()
            logger.debug("Finished stopping the cluster : " + str(cluster_id))
            printout("Finished stopping the cluster : " + str(cluster_id),
                     info_type=0,
                     info_list=info_list,
                     fp=f)

        if (index == True):
            logger.debug("Start deleting the cluster : " + str(cluster_id))
            printout("Start deleting the cluster : " + str(cluster_id),
                     info_type=0,
                     info_list=info_list,
                     fp=f)
            delete_obj = delete_class.delete_sacluster(
                params.cluster_info_all[cluster_id],
                auth_info,
                max_workers,
                fp=f,
                info_list=info_list,
                api_index=api_index)
            delete_obj()
            logger.debug("Finished deleting the cluster : " + str(cluster_id))
            printout("Finished deleting the cluster : " + str(cluster_id),
                     info_type=0,
                     info_list=info_list,
                     fp=f)
        else:
            logger.debug('There are no clusters to stop')
    else:
        printout("Stop processing.", info_type=0, info_list=info_list, fp=f)
        sys.exit()
Exemple #5
0
def def_config_main(ext_info, fp="", info_list=[1, 0, 0, 0]):
    logger.debug('start to define config params')
    setting_sec_func = {
        "Head": setting_head,
        "Compute": setting_compute,
        "Monitor": setting_monitor,
        "Zone": setting_zone,
        "NFS": setting_nfs,
        "Current": show_current_state
    }
    #Config内容名を指定
    config_param = {}
    config_param["config_name"] = def_config_name(fp=fp, info_list=info_list)
    set_parm("Config name",
             config_param["config_name"],
             info_list=info_list,
             fp=fp)
    logger.debug('defined config name')

    set_list = pd.DataFrame(
        [["Compute   ", "yet    ", "required    "],
         ["Head      ", "yet    ", "required    "],
         ["NFS       ", "auto   ", "not-required"],
         ["Zone      ", "auto   ", "not-required"],
         ["Monitor   ", "auto   ", "not-required"],
         ["Current   ", "-      ", "-           "]],
        index=["Compute", "Head", "NFS", "Zone", "Monitor", "Current"],
        columns=["name", "state", "request"])

    max_node = 0
    for k, v in ext_info["Zone"].items():
        if (v["maximum"] > max_node):
            max_node = v["maximum"]
            max_zone = k
    ext_info["max_zone"] = max_zone
    logger.debug('Configured the maximum installable nodes and their zones.')

    while (True):
        if (len(set_list[(set_list["state"] == "already")
                         & (set_list["request"] == "required    ")]) == len(
                             set_list[set_list["request"] == "required    "])):
            logger.debug('config parameter definition can be terminated')
            set_list.loc["Done"] = ["Done      ", "-      ", "-           "]
        elif (len(set_list[(set_list["state"] == "already")
                           & (set_list["request"] == "required    ")]) < len(
                               set_list[set_list["request"] == "required    "])
              and "Done" in list(set_list.index)):
            logger.debug('config parameter definition cannot be terminated')
            set_list = set_list.drop(index='Done')

        logger.debug('creat section table')
        set_list_tabel = [
            set_list.loc[label, "name"] + "|" + set_list.loc[label, "state"] +
            "|" + set_list.loc[label, "request"]
            for label in list(set_list.index)
        ]
        setting_ind = conf_pattern_main(
            "Please select a setting section===========",
            set_list_tabel,
            info_list=info_list,
            fp=fp)

        if (setting_ind.split("|")[0].replace(" ", "") == "Done"):
            logger.debug('show final config param')
            config_param, set_list = show_current_state(ext_info,
                                                        config_param,
                                                        set_list,
                                                        fp=fp,
                                                        info_list=info_list)
            logger.debug('finally confirmed')
            temp = conf_pattern_2("Are the above setting correct",
                                  ["yes", "no"],
                                  "no",
                                  info_list=info_list,
                                  fp=fp)
            if (temp == "yes"):
                logger.debug('Automatic configuration of zone')
                if ("Zone" not in config_param):
                    config_param["Zone"] = {}
                    config_param["Zone"]["Zone"] = {}
                    config_param["Zone"]["Zone"][max_zone] = config_param[
                        "Compute"]["Compute number"]
                    config_param["Zone"]["Head Zone"] = max_zone

                logger.debug('Automatic configuration of nfs')
                if ("NFS" not in config_param):
                    config_param["NFS"] = {}
                    config_param["NFS"]["NFS"] = False

                logger.debug('Automatic configuration of monitor')
                if ("Monitor" not in config_param):
                    config_param["Monitor"] = {}
                    config_param["Monitor"]["Monitor"] = False

                return config_param

        else:
            logger.debug('show section table')
            config_param, set_list = setting_sec_func[setting_ind.split(
                "|")[0].replace(" ", "")](ext_info,
                                          config_param,
                                          set_list,
                                          fp=fp,
                                          info_list=info_list)