def ipxe(request, deployment_id=None): """View returns boot's config for iPXE depends on client IP. Args: request (object): standard Django's object for request. Returns: HttpResponse: contains config for iPXE Raises: Http404: if deployment with specified UUID doesn't exist """ ip = get_client_ip(request) try: if deployment_id: deployment = Deployment.objects.get(id=deployment_id) else: deployment = Deployment.get_deployment_for_ip(ip) except Ethernet.DoesNotExist: logger.warning('Deployment does not exists for ip: {}'.format(ip)) raise Http404 except Deployment.DoesNotExist: logger.warning(DEPLOYMENT_404_MSG.format(deployment_id)) raise Http404 configuration = _render_configuration( deployment.preboot.get_configuration('ipxe'), deployment) return HttpResponse(configuration, content_type='text/plain')
def get(self, request, *args, **kwargs): ip = get_client_ip(request) logger.info('Sync request DHCP server with IP: %s', ip) if not DHCPServer.update_last_synchronized(ip): return HttpResponseNotFound('DHCP server doesn\'t exist.', content_type='text/plain') return HttpResponse('OK', content_type='text/plain')
def done_ping(request, deployment_id): """View mark specified deployment (by UUID from URL) as finished. Args: deployment_id (string): deployment's UUID Returns: HttpResponse: document with 'marked' sentence """ preboot = _get_preboot(deployment_id) preboot.increment_used_counter() ip = get_client_ip(request) Deployment.mark_as_done(deployment_id) logger.info('Deployment {} for {} marked as done.'.format( deployment_id, ip)) return HttpResponse('marked', content_type='text/plain')