def dispatch(self, request, *args, **kwargs): #Get list of resources kwargs['show_loading_screen'] = True kwargs['loading_title'] = 'Terminating resources' kwargs[ 'loading_description'] = 'Please be patient and do not navigate away from this page. Terminating resources can take several minutes' if kwargs['key_id'] == 'all': resources = resource_management_tools.get_unrecognized_resources( request.user) else: key_id = kwargs['key_id'] key = AWSAccessKey.objects.get(id=key_id) assert key.user == request.user resources = resource_management_tools.get_unrecognized_resources( request.user, key) if kwargs['confirmed']: resource_management_tools.terminate_resources( request.user, resources) return HttpResponseRedirect(reverse_lazy('my_account')) kwargs['resources'] = resources return super(ResourceTerminateView, self).dispatch(request, *args, **kwargs)
def get(self, request, *args, **kwargs): user_id = int(request.GET['user_id']) user = User.objects.get(id=user_id) log.debug('Checking status for user %s' % user) try: if not resource_management_tools.get_unrecognized_resources( user).is_empty(): status = 'unrecognized' elif resource_management_tools.get_local_resources( user).is_empty(): status = 'empty' else: health = resource_management_tools.health_check(user) log.debug('health : %s' % health) if health == 'initializing': status = 'pending' elif health == 'healthy': status = 'healthy' else: status = 'problem' except Exception as e: log.exception(e) status = 'error' response_data = {'status': status} json_response = json.dumps(response_data) return HttpResponse(json_response, content_type="application/json", status=200)
def dispatch(self, request, *args, **kwargs): # Get list of resources kwargs["show_loading_screen"] = True kwargs["loading_title"] = "Terminating resources" kwargs[ "loading_description" ] = "Please be patient and do not navigate away from this page. Terminating resources can take several minutes" if kwargs["key_id"] == "all": resources = resource_management_tools.get_unrecognized_resources(request.user) else: key_id = kwargs["key_id"] key = AWSAccessKey.objects.get(id=key_id) assert key.user == request.user resources = resource_management_tools.get_unrecognized_resources(request.user, key) if kwargs["confirmed"]: resource_management_tools.terminate_resources(request.user, resources) return HttpResponseRedirect(reverse_lazy("my_account")) kwargs["resources"] = resources return super(ResourceTerminateView, self).dispatch(request, *args, **kwargs)
def dispatch(self, request, *args, **kwargs): # Get list of resources keys = AWSAccessKey.objects.filter(user=request.user) | AWSAccessKey.objects.filter(copy_of__user=request.user) overview = [] for key in keys: recognized_resources = resource_management_tools.get_recognized_resources(user=request.user, key=key) unrecognized_resources = resource_management_tools.get_unrecognized_resources(user=request.user, key=key) overview.append((key, recognized_resources, unrecognized_resources)) kwargs["overview"] = overview return super(ResourceOverviewView, self).dispatch(request, *args, **kwargs)
def dispatch(self, request, *args, **kwargs): #Get list of resources keys = AWSAccessKey.objects.filter( user=request.user) | AWSAccessKey.objects.filter( copy_of__user=request.user) overview = [] for key in keys: recognized_resources = resource_management_tools.get_recognized_resources( user=request.user, key=key) unrecognized_resources = resource_management_tools.get_unrecognized_resources( user=request.user, key=key) overview.append( (key, recognized_resources, unrecognized_resources)) kwargs['overview'] = overview return super(ResourceOverviewView, self).dispatch(request, *args, **kwargs)
def get(self, request, *args, **kwargs): user_id = int(request.GET['user_id']) user = User.objects.get(id=user_id) log.debug('Checking status for user %s'%user) try: if not resource_management_tools.get_unrecognized_resources(user).is_empty(): status='unrecognized' elif resource_management_tools.get_local_resources(user).is_empty(): status='empty' else: health = resource_management_tools.health_check(user) log.debug('health : %s'%health) if health == 'initializing': status = 'pending' elif health == 'healthy': status ='healthy' else: status = 'problem' except Exception, e: log.exception(e) status='error'