def cleanall(request): if request.method == 'POST': logger.info("clean all data!!") for host in Host.objects.all(): # logger.info("sh /opt/openstack/scripts/delete_host.sh %s %s" % (host.hostname , host.hwaddr)) # p = commands.getstatusoutput("sh /opt/openstack/scripts/delete_host.sh %s %s" % (host.hostname , host.hwaddr)) # logger.info("delete script result:"+str(p[1])) delete_host.delay(host) host.delete() f = open(DEPLOY_RESULT_PATH,'w') f.write('0') f.close() logger.info("All data has been cleaned.") return HttpResponse("True")
def delete(request,hostname): ret = False if request.method == 'POST': post = request.POST logger.info("To delete the host %s." % hostname) #host = Host.objects.get(pk=hostname) host = get_object_or_404(Host,pk=hostname) delete_host.delay(host) logger.info("run delete_host %s" % hostname) host.delete() logger.info("Host has been deleted.") ret = True response = HttpResponse() response.write(ret) return response