Beispiel #1
0
def GetList(request):
    if(request.GET.get('mybtn')):
        #mypythoncode.mypythonfunction( int(request.GET.get('mytextbox')) )
        manifests = str(request.GET.get('mytextbox'))
    else:
        manifests = None
    if manifests:
        Server.objects.all().delete()
        url_list = []
        paths = []
        mgmt = []
        #host_list = HostList()
        myurl = urllib.request.urlopen(manifests)
        html = myurl.read()
        soup = bs4.BeautifulSoup(html, "html.parser")
        for link in soup.findAll("a"):
            if ".com" in link.string:
                path = link.get("href")
                maint_path = manifests+"/"+link.string+'/maint.yaml'
                syspatch_data = ModMaint().getMaint(maint_path)
                mgmt1 = syspatch_data.get('mgmt')
                exclude1 = syspatch_data.get('exclude')
                skip1 = syspatch_data.get('skip')
                hostgroup1 = syspatch_data.get('hostgroup')
                if not Server.objects.filter(server=link.string).exists():
                    s = Server(server=link.string)
                    s.server = link.string
                    s.mgmt = mgmt1
                    s.exclude = exclude1
                    s.skip = skip1
                    s.hostgroup = hostgroup1
                else:
                    s = Server(server=link.string)
                    s.server = link.string
                    s.mgmt = mgmt1
                    s.exclude = exclude1
                    s.skip = skip1
                    s.hostgroup = hostgroup1
                s.save()
                #mgmt.append(syspatch)
                #mgmt.append(syspatch.get('mgmt'))
                #if not Server.objects.filter(server=link.string).exists():
                    #s = Server(server=link.string)
                    #s.save()
                #url_list.append(link.get("href"))
                url_list.append(link.string)
                #paths.append(maint_path)
            else:
                pass
        context = {'manifests': manifests, 'url_list': url_list, 'check': "worked", 'paths': paths, 'mgmt1': mgmt1, 'skip1': skip1}
    else:
        context = {'manifests': manifests}
    return render(request, 'autopatch/get_list.html', context)
Beispiel #2
0
def StageView(request):
    stage_list = Server.objects.all().order_by('server')
    env = "Stage"
    field = ".stage."
    if Hosttotal.objects.filter(env=env).exists():
        h = Hosttotal.objects.get(env=env)
        stagetotal = h.total
    else:
        stagetotal = None
    if(request.GET.get('mybtn')):
        total = ModMaint().hostCount(env, field)
        stagetotal = total.get("total")
    context = {'stage_list': stage_list, 'total': stagetotal, 'env': env, 'encouragement': encouragement()}
    return render(request, 'autopatch/stage-servers.html', context)
Beispiel #3
0
def DevView(request):
    dev_list = Server.objects.all().order_by('server')
    env = "Dev"
    field = ".dev"
    if Hosttotal.objects.filter(env=env).exists():
        h = Hosttotal.objects.get(env=env)
        devtotal = h.total
    else:
        devtotal = None
    if(request.GET.get('mybtn')):
        total = ModMaint().hostCount(env, field)
        devtotal = total.get("total")
    context = {'dev_list': dev_list, 'total': devtotal, 'env': env, 'encouragement': encouragement()}
    return render(request, 'autopatch/dev-servers.html', context)
Beispiel #4
0
def ProdView(request):
    prod_list = Server.objects.all().order_by('server')
    env = "Prod"
    field = ".prod."
    if Hosttotal.objects.filter(env=env).exists():
        h = Hosttotal.objects.get(env=env)
        prodtotal = h.total
    else:
        prodtotal = None
    if(request.GET.get('mybtn')):
        total = ModMaint().hostCount(env, field)
        prodtotal = total.get("total")
    context = {'prod_list': prod_list, 'total': prodtotal, 'env': env, 'encouragement': encouragement()}
    return render(request, 'autopatch/prod-servers.html', context)