Exemple #1
0
def get_asg_config(request, group_name):
    asg_summary = autoscaling_groups_helper.get_autoscaling_summary(
        request, group_name)
    pas_config = autoscaling_groups_helper.get_pas_config(request, group_name)
    instances = groups_helper.get_group_hosts(request, group_name)
    group_info = autoscaling_groups_helper.get_group_info(request, group_name)
    launch_config = group_info.get("launchInfo")
    group_size = len(instances)
    policies = autoscaling_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 = autoscaling_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),
            "pas_config": pas_config,
        })
    return HttpResponse(json.dumps(content), content_type="application/json")
Exemple #2
0
def get_asg_config(request, group_name):
    asg_summary = autoscaling_groups_helper.get_autoscaling_summary(request, group_name)
    pas_config = autoscaling_groups_helper.get_pas_config(request, group_name)
    instances = groups_helper.get_group_hosts(request, group_name)
    group_info = autoscaling_groups_helper.get_group_info(request, group_name)
    launch_config = group_info.get("launchInfo")
    group_size = len(instances)
    policies = autoscaling_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 = autoscaling_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),
        "pas_config": pas_config,
    })
    return HttpResponse(json.dumps(content), content_type="application/json")
Exemple #3
0
def get_scheduled_actions(request, group_name):
    scheduled_actions = autoscaling_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")
Exemple #4
0
def get_scheduled_actions(request, group_name):
    scheduled_actions = autoscaling_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")