def provision_baremetal_allocation(): bmdb = BaremetalDB() method = request.method.lower() if method in ['get']: request_users = get_all_baremetal_request_users() baremetal_computers = bmdb.get_baremetal_computers() print "baremetal computers: ", baremetal_computers return render_template("mesh/provision/provision_main.html", users=request_users, computers=baremetal_computers["idle"], flag_idle=True, ) elif method in ['put']: data = request.json result = bmdb.assign_baremetal_to_user(data["computers"], data["user"]) return Response(json.dumps({"result": result}), status=200, mimetype="application/json")
def generate(self): self.generate_bootspec() self._generate_globals() clusters = self.config.get("cloudmesh.inventory") for cluster_name in clusters: cluster = clusters[cluster_name] names = expand_hostlist(cluster["id"]) net_id = 0 for network in cluster["network"]: n_index = expand_hostlist(network["id"]) n_label = expand_hostlist(network["label"]) n_range = expand_hostlist(network["range"]) n_name = network["name"] for i in range(0, len(names)): name = n_index[i] element = dict(network) del element['range'] element.update({ 'cm_type': "inventory", 'cm_key': 'server', 'cm_kind': 'server', 'cm_id': name, 'cm_cluster': cluster_name, 'id': name, 'label': n_label[i], 'network_name': n_name, 'cm_network_id': net_id, 'ipaddr': n_range[i], 'cm_attribute': 'network' }) self.insert(element) net_id += 1 # added by HC # init rack status self.generate_rack_status() # init baremetal computer managemnt, maybe will be deprecated later bdb = BaremetalDB() bdb.init_base_document_structure() # insert necessary mac info of baremetal computers to inventory bmc = BaremetalComputer() bmc.insert_mac_data_to_inventory()
def baremetal_user_requests(): bmdb = BaremetalDB() method = request.method.lower() if method in ['get']: get_result = bmdb.get_baremetal_computers() baremetal_computers = get_result["used"] bm_computer_info = {} for cluster in baremetal_computers: bm_computer_info[cluster] = {} for bm_comp in baremetal_computers[cluster]: bm_computer_info[cluster][ bm_comp] = bmdb.get_baremetal_computer_detail(bm_comp) return render_template("mesh/provision/provision_main.html", computers=baremetal_computers, computer_info=bm_computer_info, flag_idle=False, ) elif method in ['put']: data = request.json result = bmdb.withdraw_baremetal_from_user(data["computers"]) return Response(json.dumps({"result": result}), status=200, mimetype="application/json")