Beispiel #1
0
def servers(request):
    if request.method == 'POST':
        form = CommandForm(request.POST)
        if form.is_valid():

            form.save()
            return HttpResponseRedirect('/psw')
    else:
        form = CommandForm()

    return render(request, 'psw/servers.html', {'form': form})
Beispiel #2
0
def servers(request):
    if request.method == "POST":
        form = CommandForm(request.POST)

        if form.is_valid():
            form.instance.user = request.user
            ip = ip_adding()
            form.instance.ip = ip
            name = form.cleaned_data["name"]
            # ip = form.cleaned_data['ip']
            system = form.cleaned_data["system"]
            ram = form.cleaned_data["ram"]
            quote = form.cleaned_data["quote"]
            password1 = form.cleaned_data["password1"]
            username = str(request.user.get_username())
            commandlog = (
                "python3.5 /root/log_skrypt.py"
                + " "
                + ip
                + " "
                + system
                + " "
                + ram
                + " "
                + quote
                + " "
                + username
                + " "
                + name
                + " "
                + password1
                + " >> PSW_log.log"
            )
            # command = 'python3.5 /root/main_skrypt_podip.py'+ ' '+ ip + ' ' + system + ' ' + ram + ' ' + quote + ' ' + username + ' ' + name +'  > wyniki_testy.txt'
            form.save()

            # Tworzenie ze skryptu.py Python 3.5
            try:
                ssh = paramiko.SSHClient()
                ssh.set_missing_host_key_policy(paramiko.AutoAddPolicy())
                ssh.connect("89.206.7.46", username="******", password="******")
                # Tworzenie Log
                stdin, stdout, stderr = ssh.exec_command(commandlog)
                # Tworzenie kontenerow
                # stdin, stdout, stderr = ssh.exec_command(command)
                ssh.close()
            except paramiko.ssh_exception.NoValidConnectionsError as e:
                print("Error %s" % e)
                return HttpResponseRedirect("servers/")
            return HttpResponseRedirect("/")
    else:
        form = CommandForm()
    return render(request, "psw/servers.html", {"form": form})
Beispiel #3
0
def servers(request):
    if request.method == 'POST':
        form = CommandForm(request.POST)

        if form.is_valid():
            form.instance.user = request.user
            ip = ip_adding()
            form.instance.ip = ip
            name = form.cleaned_data['name']
            #ip = form.cleaned_data['ip']
            system = form.cleaned_data['system']
            ram = form.cleaned_data['ram']
            quote = form.cleaned_data['quote']
            password1 = form.cleaned_data['password1']
            username = str(request.user.get_username())
            commandlog = 'python3.5 /root/log_skrypt.py' + ' ' + ip + ' ' + system + ' ' + ram + ' ' + quote + ' ' + username + ' ' + name + ' ' + password1 + ' >> PSW_log.log'
            #command = 'python3.5 /root/main_skrypt_podip.py'+ ' '+ ip + ' ' + system + ' ' + ram + ' ' + quote + ' ' + username + ' ' + name +'  > wyniki_testy.txt'
            form.save()

            #Tworzenie ze skryptu.py Python 3.5
            try:
                ssh = paramiko.SSHClient()
                ssh.set_missing_host_key_policy(paramiko.AutoAddPolicy())
                ssh.connect('89.206.7.46',
                            username='******',
                            password='******')
                # Tworzenie Log
                stdin, stdout, stderr = ssh.exec_command(commandlog)
                # Tworzenie kontenerow
                #stdin, stdout, stderr = ssh.exec_command(command)
                ssh.close()
            except paramiko.ssh_exception.NoValidConnectionsError as e:
                print('Error %s' % e)
                return HttpResponseRedirect('servers/')
            return HttpResponseRedirect('/')
    else:
        form = CommandForm()
    return render(request, 'psw/servers.html', {'form': form})
Beispiel #4
0
def servers(request):
    if request.method == 'POST':
        form = CommandForm(request.POST)
        if form.is_valid():
            
            form.save()
            try:
                ssh = paramiko.SSHClient()
                ssh.set_missing_host_key_policy(paramiko.AutoAddPolicy())
                ssh.connect('89.206.7.46', username='******', password='******')
                stdin, stdout, stderr = ssh.exec_command('/bin/bash /root/skrypt.sh')
                ssh.close()
            except paramiko.ssh_exception.NoValidConnectionsError as e:
                print ('Error %s' %e)
                return HttpResponseRedirect('/psw/servers/')
                      
            return HttpResponseRedirect('/psw')
    else:
         form = CommandForm()
         
           
            
           
    return render(request, 'psw/servers.html', {'form': form})
Beispiel #5
0
def servers(request):
    if request.method == 'POST':
        form = CommandForm(request.POST)

        if form.is_valid():
            form.instance.user = request.user
            ip = ip_adding()
            form.instance.ip = ip
            name = form.cleaned_data['name']
            #ip = form.cleaned_data['ip']
            system = form.cleaned_data['system']
            ram = form.cleaned_data['ram']
            quote = form.cleaned_data['quote']
            password1 = form.cleaned_data['password1']
            username = str(request.user.get_username())
            commandlog = 'python3.5 /root/log_skrypt.py'+ ' '+ ip + ' ' + system + ' ' + ram + ' ' + quote +  ' ' + username + ' ' + name + ' ' + password1 +' >> PSW_log.log'
            #command = 'python3.5 /root/main_skrypt_podip.py'+ ' '+ ip + ' ' + system + ' ' + ram + ' ' + quote + ' ' + username + ' ' + name +'  > wyniki_testy.txt'
            form.save()

            #Tworzenie ze skryptu.py Python 3.5 
            try:
                ssh = paramiko.SSHClient()
                ssh.set_missing_host_key_policy(paramiko.AutoAddPolicy())
                ssh.connect('89.206.7.46', username='******', password='******')
                # Tworzenie Log
                stdin, stdout, stderr = ssh.exec_command(commandlog)
                # Tworzenie kontenerow
                #stdin, stdout, stderr = ssh.exec_command(command)
                ssh.close()
            except paramiko.ssh_exception.NoValidConnectionsError as e:
                print('Error %s' %e)
                return HttpResponseRedirect('servers/')
            return HttpResponseRedirect('/')
    else:
         form = CommandForm()
    return render(request, 'psw/servers.html', {'form': form})
Beispiel #6
0
def servers(request):
    if request.method == 'POST':
        form = CommandForm(request.POST)
        if form.is_valid():

            form.save()
            try:
                ssh = paramiko.SSHClient()
                ssh.set_missing_host_key_policy(paramiko.AutoAddPolicy())
                ssh.connect('89.206.7.46',
                            username='******',
                            password='******')
                stdin, stdout, stderr = ssh.exec_command(
                    '/bin/bash /root/skrypt.sh')
                ssh.close()
            except paramiko.ssh_exception.NoValidConnectionsError as e:
                print('Error %s' % e)
                return HttpResponseRedirect('/psw/servers/')

            return HttpResponseRedirect('/psw')
    else:
        form = CommandForm()

    return render(request, 'psw/servers.html', {'form': form})