def update_pas_config(request, group_name): try: params = request.POST if not params['metric'] or not params['throughput']: raise Exception( "All fields for Predictive Autoscaling Config Must be specified. " ) data = {} data['group_name'] = group_name data["metric"] = params["metric"] data["throughput"] = int(params["throughput"]) if "pas_state" in params: data["pas_state"] = "ENABLED" else: data["pas_state"] = "DISABLED" # Reset min size to user defined min size pas_config = autoscaling_groups_helper.get_pas_config( request, group_name) asg_request = {} asg_request["groupName"] = group_name asg_request["minSize"] = int(pas_config.get("defined_min_size")) autoscaling_groups_helper.update_autoscaling( request, group_name, asg_request) autoscaling_groups_helper.update_pas_config(request, group_name, data) return get_pas_config(request, group_name) except: log.error(traceback.format_exc()) raise
def update_asg_config(request, group_name): params = request.POST try: asg_request = {} asg_request["groupName"] = group_name asg_request["minSize"] = int(params["minSize"]) asg_request["maxSize"] = int(params["maxSize"]) asg_request["terminationPolicy"] = params["terminationPolicy"] if "enableSpot" in params: asg_request["enableSpot"] = True asg_request["spotRatio"] = float(params["spotRatio"]) / 100 asg_request["sensitivityRatio"] = float(params["sensitivityRatio"]) / 100 asg_request["spotPrice"] = params["bidPrice"] if "enableResourceLending" in params: asg_request["enableResourceLending"] = True else: asg_request["enableResourceLending"] = False else: asg_request["enableSpot"] = False asg_request["enableResourceLending"] = False autoscaling_groups_helper.update_autoscaling(request, group_name, asg_request) # Save new pas min and max, disable pas pas_config = {} pas_config['group_name'] = group_name pas_config['defined_min_size'] = int(params["minSize"]) pas_config['defined_max_size'] = int(params["maxSize"]) pas_config['pas_state'] = "DISABLED" autoscaling_groups_helper.update_pas_config(request, group_name, pas_config) except: log.error(traceback.format_exc()) raise return get_asg_config(request, group_name)
def update_pas_config(request, group_name): try: params = request.POST if not params['metric'] or not params['throughput']: raise Exception("All fields for Predictive Autoscaling Config Must be specified. ") data = {} data['group_name'] = group_name data["metric"] = params["metric"] data["throughput"] = int(params["throughput"]) if "pas_state" in params: data["pas_state"] = "ENABLED" else: data["pas_state"] = "DISABLED" # Reset min size to user defined min size pas_config = autoscaling_groups_helper.get_pas_config(request, group_name) asg_request = {} asg_request["groupName"] = group_name asg_request["minSize"] = int(pas_config.get("defined_min_size")) autoscaling_groups_helper.update_autoscaling(request, group_name, asg_request) autoscaling_groups_helper.update_pas_config(request, group_name, data) return get_pas_config(request, group_name) except: log.error(traceback.format_exc()) raise