def recomend_vm_placements(hypervisors = [], leoNodeCount = 1): if len(hypervisors) < 1: return None vms = copy.deepcopy(stick_const.initial_vms) placements = [] i = 1 k = 1 j = 0 fifozonescount = stick_const.fifoZoneCount(len(hypervisors)) while i < fifozonescount: i = i + 1 vms.append( str(i) + ".fifo") while k < int(leoNodeCount): k = k + 1 vms.append( str(k) + ".storage.leofs") for vm in vms: placement = {} placement[vm] = hypervisors[j] placements.append(placement.copy()) j += 1 if j >= len(hypervisors): j = 0 return placements
def layout_vms(): hypervisors = [] hypervisors = request.form.getlist("hypervisors[]") leoNodeCount = request.form.get("leoNodes") placements = stick_actions.recomend_vm_placements(hypervisors, leoNodeCount) if placements is None: return_val = {} return_val['result'] = "error" return return_val = {} return_val['placements'] = placements return_val['fifo_zone_count'] = stick_const.fifoZoneCount(len(hypervisors)) return_val['result'] = "ok" return jsonify(return_val)