def get_asg_config(request, group_name): asg_summary = groups_helper.get_autoscaling_summary(request, group_name) instances = groups_helper.get_group_instances(request, group_name) group_info = groups_helper.get_group_info(request, group_name) launch_config = group_info.get("launchInfo") group_size = len(instances) policies = groups_helper.TerminationPolicy if asg_summary.get("spotRatio", None): asg_summary["spotRatio"] *= 100 if asg_summary.get("sensitivityRatio", None): asg_summary["sensitivityRatio"] *= 100 scheduled_actions = groups_helper.get_scheduled_actions(request, group_name) time_based_asg = False if len(scheduled_actions) > 0: time_based_asg = True content = render_to_string("groups/asg_config.tmpl", { "group_name": group_name, "asg": asg_summary, "group_size": group_size, "terminationPolicies": policies, "instanceType": launch_config.get("instanceType"), "time_based_asg": time_based_asg, "csrf_token": get_token(request), }) return HttpResponse(json.dumps(content), content_type="application/json")
def get_scheduled_actions(request, group_name): scheduled_actions = groups_helper.get_scheduled_actions(request, group_name) content = render_to_string("groups/asg_schedules.tmpl", { 'group_name': group_name, 'scheduled_actions': scheduled_actions, 'csrf_token': get_token(request), }) return HttpResponse(json.dumps(content), content_type="application/json")