def connect_bridge_switch(self, zone, switch_id, place): self.printout_cluster("connecting switch to bridge ……", cls_monitor_level = 3, overwrite = True) url_bridge = "/switch/" + switch_id + "/to/bridge/" + str(self.all_id_dict["clusterparams"]["bridge"][place]["id"]) if (self.api_index == True): while(True): bridge_switch_res = put(self.url_list[zone] + url_bridge, self.auth_res) check,msg = self.res_check(bridge_switch_res, "put") if check == True: logger.debug("connected switch to bridge: " + switch_id + "-" + str(self.all_id_dict["clusterparams"]["bridge"][place]["id"])) break else: self.build_error() else: bridge_switch_res = "API is not used."
def start_up_server(self, zone, node_id): if (self.api_index == True): while (True): #print(zone + ":" + str(node_id)) stop_res = put( self.url_list[zone] + self.sub_url[0] + "/" + str(node_id) + self.sub_url[7], self.auth_res) check = self.res_check(stop_res, "put") if check == True: logger.debug("Start up this server: " + str(node_id)) break else: self.start_error() else: stop_res = "API is not used."
def cluster_info(self): result_all = [] cls_info = {} cls_info["config name"] = str(self.configuration_info["config name"]) cls_info["cluster ID"] = self.cluster_id cls_info["head node ID"] = str(self.all_id_dict["clusterparams"]["server"][self.head_zone]["head"]["node"]["id"]) cls_info["number of compute node"] = str(sum([len(self.all_id_dict["clusterparams"]["server"][zone]["compute"]) for zone in self.zone_list])) cls_info["Date modified"] = datetime.datetime.now().strftime("%Y/%m/%d") self.all_id_dict["baseparams"]["config name"] = cls_info["config name"] self.all_id_dict["baseparams"]["compute_number"] = int(cls_info["number of compute node"]) self.all_id_dict["baseparams"]["state"] = "All down" self.all_id_dict["baseparams"]["modified_date"] = cls_info["Date modified"] self.all_id_dict["baseparams"]["global_ipaddress"] = self.global_ip_addr self.printout_cluster("", cls_monitor_level = 4) result_all.append("###Cluster Infomation###") result_all.append("config name: " + cls_info["config name"]) result_all.append("global ipaddress in head node: " + self.global_ip_addr) result_all.append(cls_info["cluster ID"]) result_all.append("head node ID: " + cls_info["head node ID"]) for zone in self.zone_list: result_all.append("compute node ID: ") result_all.append(zone + ": " + ', '.join([str(v["node"]["id"]) for k,v in self.all_id_dict["clusterparams"]["server"][zone]["compute"].items()])) result_all.append("number of compute node: " + cls_info["number of compute node"]) result_all.append("date modified: " + cls_info["Date modified"]) result_all.append("########################") result_all = "\n".join(result_all) self.printout_cluster(result_all, cls_monitor_level = 1) self.printout_cluster("", cls_monitor_level = 4) logger.debug("writing cluster information to head node") desc_param = {"Server":{"Description":json.dumps(cls_info)}} if (self.api_index == True): while(True): cluster_info_res = put(self.head_url + self.sub_url[0] + "/" + str(self.all_id_dict["clusterparams"]["server"][self.head_zone]["head"]["node"]["id"]), self.auth_res, desc_param) check,msg = self.res_check(cluster_info_res, "put") if check == True: break else: self.build_error() else: cluster_info_res = "API is not used."
def connect_switch(self, zone, switch_id, nic_id): self.printout_cluster("connecting switch to nic ……", cls_monitor_level = 3, overwrite = True) logger.debug("connecting switch to nic") sub_url_con = "/interface/" + str(nic_id) + "/to/switch/" + str(switch_id) if (self.api_index == True): while(True): connect_switch_response = put(self.url_list[zone] + sub_url_con, self.auth_res) check,msg = self.res_check(connect_switch_response, "put") if check == True: logger.debug("connected switch to nic: " + switch_id + "-" + nic_id) break else: self.build_error() else: connect_switch_response = "API is not used." return connect_switch_response
def connect_server_disk(self, zone, disk_id, server_id): self.printout_cluster("connecting disk to server ……", cls_monitor_level = 3, overwrite = True) logger.debug("connecting disk to server") url_disk = "/disk/" + str(disk_id) + "/to/server/" + str(server_id) if (self.api_index == True): while(True): server_disk_res = put(self.url_list[zone] + url_disk, self.auth_res) check,msg = self.res_check(server_disk_res, "put") if check == True: logger.debug("connected disk to server: " + server_id + "-" + disk_id) break else: self.build_error() else: server_disk_res = "API is not used." return server_disk_res