def calculate_cost(request, start_date, end_date): starting_date = cost_tools.convert_to_date_time(start_date) ending_date = cost_tools.convert_to_date_time(end_date) total_hours_in_range = cost_tools.get_instance_hours_in_date_range(starting_date, ending_date) cost = cost_tools.generate_cost(total_hours_in_range) return HttpResponse("Calculating cost for date " + str(starting_date) + " to " + str(ending_date) + ". The total hours used in this range is " + str(total_hours_in_range) + " with cost $" + str(cost))
def get_deprovisioningEventsInDateRange(request, app_pk, start_date, end_date): instances = AppCluster(app_pk).deleted num_events = 0 starting_dateTime = convert_to_date_time(start_date) ending_dateTime = convert_to_date_time(end_date) for instance in instances: if instance.shutdownDateTime > starting_dateTime and instance.shutdownDateTime < ending_dateTime: num_events += 1 return HttpResponse(num_events)
def calculate_cost(request, start_date, end_date): starting_date = cost_tools.convert_to_date_time(start_date) ending_date = cost_tools.convert_to_date_time(end_date) total_hours_in_range = cost_tools.get_instance_hours_in_date_range( starting_date, ending_date) cost = cost_tools.generate_cost(total_hours_in_range) return HttpResponse("Calculating cost for date " + str(starting_date) + " to " + str(ending_date) + ". The total hours used in this range is " + str(total_hours_in_range) + " with cost $" + str(cost))
def get_nodesInCluster(request, app_pk, date_time): instances = AppCluster(app_pk).nodes date_time = convert_to_date_time(date_time) num_nodes = 0 for instance in instances: if instance.state == 5: if instance.startUpDateTime < date_time and instance.shutdownDateTime > date_time: num_nodes += 1 else: if instance.startUpDateTime < date_time: num_nodes += 1 return HttpResponse(num_nodes)