diff --git a/netauto/__init__.py b/netauto/__init__.py deleted file mode 100644 index e69de29..0000000 diff --git a/netauto/__pycache__/__init__.cpython-38.pyc b/netauto/__pycache__/__init__.cpython-38.pyc deleted file mode 100644 index 9f7584c..0000000 Binary files a/netauto/__pycache__/__init__.cpython-38.pyc and /dev/null differ diff --git a/netauto/__pycache__/admin.cpython-38.pyc b/netauto/__pycache__/admin.cpython-38.pyc deleted file mode 100644 index 75430fc..0000000 Binary files a/netauto/__pycache__/admin.cpython-38.pyc and /dev/null differ diff --git a/netauto/__pycache__/apps.cpython-38.pyc b/netauto/__pycache__/apps.cpython-38.pyc deleted file mode 100644 index 6ac95cc..0000000 Binary files a/netauto/__pycache__/apps.cpython-38.pyc and /dev/null differ diff --git a/netauto/__pycache__/forms.cpython-38.pyc b/netauto/__pycache__/forms.cpython-38.pyc deleted file mode 100644 index 4fb99ea..0000000 Binary files a/netauto/__pycache__/forms.cpython-38.pyc and /dev/null differ diff --git a/netauto/__pycache__/models.cpython-38.pyc b/netauto/__pycache__/models.cpython-38.pyc deleted file mode 100644 index dbd292a..0000000 Binary files a/netauto/__pycache__/models.cpython-38.pyc and /dev/null differ diff --git a/netauto/__pycache__/sendcom.cpython-38.pyc b/netauto/__pycache__/sendcom.cpython-38.pyc deleted file mode 100644 index 79fdc3b..0000000 Binary files a/netauto/__pycache__/sendcom.cpython-38.pyc and /dev/null differ diff --git a/netauto/__pycache__/urls.cpython-38.pyc b/netauto/__pycache__/urls.cpython-38.pyc deleted file mode 100644 index 6fb79fc..0000000 Binary files a/netauto/__pycache__/urls.cpython-38.pyc and /dev/null differ diff --git a/netauto/__pycache__/views.cpython-38.pyc b/netauto/__pycache__/views.cpython-38.pyc deleted file mode 100644 index 16f841e..0000000 Binary files a/netauto/__pycache__/views.cpython-38.pyc and /dev/null differ diff --git a/netauto/admin.py b/netauto/admin.py deleted file mode 100644 index 367ecfb..0000000 --- a/netauto/admin.py +++ /dev/null @@ -1,14 +0,0 @@ -from django.contrib import admin -from .models import Contohmodel, Routerm, Automation - -# Register your models here. -class Contohadmin(admin.ModelAdmin): - list_display = ['nama','pub_date'] - search_fields = ['nama'] - list_per_page = 4 - -admin.site.register(Contohmodel, Contohadmin ) - -admin.site.register(Routerm) - -admin.site.register(Automation) \ No newline at end of file diff --git a/netauto/apps.py b/netauto/apps.py deleted file mode 100644 index 518b016..0000000 --- a/netauto/apps.py +++ /dev/null @@ -1,5 +0,0 @@ -from django.apps import AppConfig - - -class NetautoConfig(AppConfig): - name = 'netauto' diff --git a/netauto/forms.py b/netauto/forms.py deleted file mode 100644 index fb0f979..0000000 --- a/netauto/forms.py +++ /dev/null @@ -1,31 +0,0 @@ -from django.forms import ModelForm -from .models import Contohmodel, Routerm,Manualcommand -from django import forms - -class Formcontoh(ModelForm): - - class Meta: - model = Contohmodel - fields = '__all__' - -class RoutermForm(ModelForm): - - class Meta: - model = Routerm - fields = '__all__' - widgets = { - 'nama' : forms.TextInput({'class':'form-control','placeholder':'masukan nama untuk router'}), - 'host' : forms.TextInput({'class':'form-control','placeholder':'alamat host router | contoh: 192.168.1.1'}), - 'user' : forms.TextInput({'class':'form-control','placeholder':'masukan username router'}), - 'password' : forms.TextInput({'class':'form-control','placeholder':'masukan pasword router'}), - 'kecepatan_internet' : forms.TextInput({'class':'form-control','placeholder':'dalam kilobyte'}), - } - -class Manualform(ModelForm): - - class Meta: - model = Manualcommand - fields = ['host', 'command'] - widgets = { - 'host' : forms.Select({'class':'form-control'}) - } diff --git a/netauto/migrations/0001_initial.py b/netauto/migrations/0001_initial.py deleted file mode 100644 index c7698f1..0000000 --- a/netauto/migrations/0001_initial.py +++ /dev/null @@ -1,23 +0,0 @@ -# Generated by Django 2.2.17 on 2020-11-22 15:16 - -from django.db import migrations, models - - -class Migration(migrations.Migration): - - initial = True - - dependencies = [ - ] - - operations = [ - migrations.CreateModel( - name='Contohmodel', - fields=[ - ('id', models.AutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID')), - ('nama', models.CharField(max_length=50)), - ('desk', models.TextField()), - ('value', models.IntegerField()), - ], - ), - ] diff --git a/netauto/migrations/0002_contohmodel_pub_date.py b/netauto/migrations/0002_contohmodel_pub_date.py deleted file mode 100644 index cb0828a..0000000 --- a/netauto/migrations/0002_contohmodel_pub_date.py +++ /dev/null @@ -1,18 +0,0 @@ -# Generated by Django 2.2.17 on 2020-11-22 15:26 - -from django.db import migrations, models - - -class Migration(migrations.Migration): - - dependencies = [ - ('netauto', '0001_initial'), - ] - - operations = [ - migrations.AddField( - model_name='contohmodel', - name='pub_date', - field=models.DateField(auto_now=True, null=True), - ), - ] diff --git a/netauto/migrations/0003_routerm.py b/netauto/migrations/0003_routerm.py deleted file mode 100644 index 91a34c8..0000000 --- a/netauto/migrations/0003_routerm.py +++ /dev/null @@ -1,24 +0,0 @@ -# Generated by Django 2.2.17 on 2021-01-07 07:09 - -from django.db import migrations, models - - -class Migration(migrations.Migration): - - dependencies = [ - ('netauto', '0002_contohmodel_pub_date'), - ] - - operations = [ - migrations.CreateModel( - name='Routerm', - fields=[ - ('id', models.AutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID')), - ('nama', models.CharField(max_length=50)), - ('host', models.CharField(max_length=50)), - ('user', models.CharField(max_length=30)), - ('password', models.CharField(max_length=50)), - ('pub_date', models.DateField(auto_now=True)), - ], - ), - ] diff --git a/netauto/migrations/0004_auto_20210109_1542.py b/netauto/migrations/0004_auto_20210109_1542.py deleted file mode 100644 index a2255f8..0000000 --- a/netauto/migrations/0004_auto_20210109_1542.py +++ /dev/null @@ -1,18 +0,0 @@ -# Generated by Django 2.2.17 on 2021-01-09 08:42 - -from django.db import migrations, models - - -class Migration(migrations.Migration): - - dependencies = [ - ('netauto', '0003_routerm'), - ] - - operations = [ - migrations.AlterField( - model_name='routerm', - name='password', - field=models.CharField(max_length=50, null=True), - ), - ] diff --git a/netauto/migrations/0005_auto_20210109_1548.py b/netauto/migrations/0005_auto_20210109_1548.py deleted file mode 100644 index e1c57d2..0000000 --- a/netauto/migrations/0005_auto_20210109_1548.py +++ /dev/null @@ -1,18 +0,0 @@ -# Generated by Django 2.2.17 on 2021-01-09 08:48 - -from django.db import migrations, models - - -class Migration(migrations.Migration): - - dependencies = [ - ('netauto', '0004_auto_20210109_1542'), - ] - - operations = [ - migrations.AlterField( - model_name='routerm', - name='password', - field=models.CharField(blank=True, max_length=50), - ), - ] diff --git a/netauto/migrations/0006_automation_confrouter.py b/netauto/migrations/0006_automation_confrouter.py deleted file mode 100644 index 1a17662..0000000 --- a/netauto/migrations/0006_automation_confrouter.py +++ /dev/null @@ -1,29 +0,0 @@ -# Generated by Django 2.2.17 on 2021-01-17 14:26 - -from django.db import migrations, models - - -class Migration(migrations.Migration): - - dependencies = [ - ('netauto', '0005_auto_20210109_1548'), - ] - - operations = [ - migrations.CreateModel( - name='Automation', - fields=[ - ('id', models.AutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID')), - ('nama', models.CharField(max_length=50)), - ('deskripsi', models.TextField()), - ], - ), - migrations.CreateModel( - name='Confrouter', - fields=[ - ('id', models.AutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID')), - ('nama', models.CharField(max_length=50)), - ('deskripsi', models.CharField(max_length=50)), - ], - ), - ] diff --git a/netauto/migrations/0007_automation_status.py b/netauto/migrations/0007_automation_status.py deleted file mode 100644 index c57b4a2..0000000 --- a/netauto/migrations/0007_automation_status.py +++ /dev/null @@ -1,18 +0,0 @@ -# Generated by Django 2.2.17 on 2021-01-22 07:32 - -from django.db import migrations, models - - -class Migration(migrations.Migration): - - dependencies = [ - ('netauto', '0006_automation_confrouter'), - ] - - operations = [ - migrations.AddField( - model_name='automation', - name='status', - field=models.CharField(max_length=15, null=True), - ), - ] diff --git a/netauto/migrations/0008_auto_20210122_0734.py b/netauto/migrations/0008_auto_20210122_0734.py deleted file mode 100644 index 835b263..0000000 --- a/netauto/migrations/0008_auto_20210122_0734.py +++ /dev/null @@ -1,18 +0,0 @@ -# Generated by Django 2.2.17 on 2021-01-22 07:34 - -from django.db import migrations, models - - -class Migration(migrations.Migration): - - dependencies = [ - ('netauto', '0007_automation_status'), - ] - - operations = [ - migrations.AlterField( - model_name='automation', - name='status', - field=models.CharField(blank=True, max_length=15), - ), - ] diff --git a/netauto/migrations/0009_routerm_kecepatan_internet.py b/netauto/migrations/0009_routerm_kecepatan_internet.py deleted file mode 100644 index eb3c6eb..0000000 --- a/netauto/migrations/0009_routerm_kecepatan_internet.py +++ /dev/null @@ -1,19 +0,0 @@ -# Generated by Django 2.2.17 on 2021-01-25 02:28 - -from django.db import migrations, models - - -class Migration(migrations.Migration): - - dependencies = [ - ('netauto', '0008_auto_20210122_0734'), - ] - - operations = [ - migrations.AddField( - model_name='routerm', - name='kecepatan_internet', - field=models.IntegerField(blank=True, default=10), - preserve_default=False, - ), - ] diff --git a/netauto/migrations/0010_manualcommand.py b/netauto/migrations/0010_manualcommand.py deleted file mode 100644 index 5bcf6e8..0000000 --- a/netauto/migrations/0010_manualcommand.py +++ /dev/null @@ -1,24 +0,0 @@ -# Generated by Django 2.2.17 on 2021-01-30 04:22 - -from django.db import migrations, models -import django.db.models.deletion - - -class Migration(migrations.Migration): - - dependencies = [ - ('netauto', '0009_routerm_kecepatan_internet'), - ] - - operations = [ - migrations.CreateModel( - name='Manualcommand', - fields=[ - ('id', models.AutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID')), - ('command', models.CharField(max_length=50)), - ('output', models.TextField(blank=True)), - ('time', models.DateTimeField(auto_now=True)), - ('host', models.ForeignKey(on_delete=django.db.models.deletion.CASCADE, to='netauto.Automation')), - ], - ), - ] diff --git a/netauto/migrations/0011_auto_20210130_1123.py b/netauto/migrations/0011_auto_20210130_1123.py deleted file mode 100644 index 0f02097..0000000 --- a/netauto/migrations/0011_auto_20210130_1123.py +++ /dev/null @@ -1,19 +0,0 @@ -# Generated by Django 2.2.17 on 2021-01-30 04:23 - -from django.db import migrations, models -import django.db.models.deletion - - -class Migration(migrations.Migration): - - dependencies = [ - ('netauto', '0010_manualcommand'), - ] - - operations = [ - migrations.AlterField( - model_name='manualcommand', - name='host', - field=models.ForeignKey(on_delete=django.db.models.deletion.CASCADE, to='netauto.Routerm'), - ), - ] diff --git a/netauto/migrations/__init__.py b/netauto/migrations/__init__.py deleted file mode 100644 index e69de29..0000000 diff --git a/netauto/migrations/__pycache__/0001_initial.cpython-38.pyc b/netauto/migrations/__pycache__/0001_initial.cpython-38.pyc deleted file mode 100644 index 7d3dfbc..0000000 Binary files a/netauto/migrations/__pycache__/0001_initial.cpython-38.pyc and /dev/null differ diff --git a/netauto/migrations/__pycache__/0002_contohmodel_pub_date.cpython-38.pyc b/netauto/migrations/__pycache__/0002_contohmodel_pub_date.cpython-38.pyc deleted file mode 100644 index eefc868..0000000 Binary files a/netauto/migrations/__pycache__/0002_contohmodel_pub_date.cpython-38.pyc and /dev/null differ diff --git a/netauto/migrations/__pycache__/0003_routerm.cpython-38.pyc b/netauto/migrations/__pycache__/0003_routerm.cpython-38.pyc deleted file mode 100644 index 78e0353..0000000 Binary files a/netauto/migrations/__pycache__/0003_routerm.cpython-38.pyc and /dev/null differ diff --git a/netauto/migrations/__pycache__/0004_auto_20210109_1542.cpython-38.pyc b/netauto/migrations/__pycache__/0004_auto_20210109_1542.cpython-38.pyc deleted file mode 100644 index 7cfc281..0000000 Binary files a/netauto/migrations/__pycache__/0004_auto_20210109_1542.cpython-38.pyc and /dev/null differ diff --git a/netauto/migrations/__pycache__/0005_auto_20210109_1548.cpython-38.pyc b/netauto/migrations/__pycache__/0005_auto_20210109_1548.cpython-38.pyc deleted file mode 100644 index 074767c..0000000 Binary files a/netauto/migrations/__pycache__/0005_auto_20210109_1548.cpython-38.pyc and /dev/null differ diff --git a/netauto/migrations/__pycache__/0006_automation_confrouter.cpython-38.pyc b/netauto/migrations/__pycache__/0006_automation_confrouter.cpython-38.pyc deleted file mode 100644 index 081f32e..0000000 Binary files a/netauto/migrations/__pycache__/0006_automation_confrouter.cpython-38.pyc and /dev/null differ diff --git a/netauto/migrations/__pycache__/0007_automation_status.cpython-38.pyc b/netauto/migrations/__pycache__/0007_automation_status.cpython-38.pyc deleted file mode 100644 index 986e46e..0000000 Binary files a/netauto/migrations/__pycache__/0007_automation_status.cpython-38.pyc and /dev/null differ diff --git a/netauto/migrations/__pycache__/0008_auto_20210122_0734.cpython-38.pyc b/netauto/migrations/__pycache__/0008_auto_20210122_0734.cpython-38.pyc deleted file mode 100644 index 6632fba..0000000 Binary files a/netauto/migrations/__pycache__/0008_auto_20210122_0734.cpython-38.pyc and /dev/null differ diff --git a/netauto/migrations/__pycache__/0009_routerm_kecepatan_internet.cpython-38.pyc b/netauto/migrations/__pycache__/0009_routerm_kecepatan_internet.cpython-38.pyc deleted file mode 100644 index aa93d52..0000000 Binary files a/netauto/migrations/__pycache__/0009_routerm_kecepatan_internet.cpython-38.pyc and /dev/null differ diff --git a/netauto/migrations/__pycache__/0010_manualcommand.cpython-38.pyc b/netauto/migrations/__pycache__/0010_manualcommand.cpython-38.pyc deleted file mode 100644 index a562ae5..0000000 Binary files a/netauto/migrations/__pycache__/0010_manualcommand.cpython-38.pyc and /dev/null differ diff --git a/netauto/migrations/__pycache__/0011_auto_20210130_1123.cpython-38.pyc b/netauto/migrations/__pycache__/0011_auto_20210130_1123.cpython-38.pyc deleted file mode 100644 index 3e100f9..0000000 Binary files a/netauto/migrations/__pycache__/0011_auto_20210130_1123.cpython-38.pyc and /dev/null differ diff --git a/netauto/migrations/__pycache__/__init__.cpython-38.pyc b/netauto/migrations/__pycache__/__init__.cpython-38.pyc deleted file mode 100644 index d101cda..0000000 Binary files a/netauto/migrations/__pycache__/__init__.cpython-38.pyc and /dev/null differ diff --git a/netauto/models.py b/netauto/models.py deleted file mode 100644 index fde504b..0000000 --- a/netauto/models.py +++ /dev/null @@ -1,53 +0,0 @@ -from django.db import models -from django.forms import ModelForm - -# Create your models here. -class Contohmodel(models.Model): - nama = models.CharField(max_length=50) - desk = models.TextField() - value = models.IntegerField() - pub_date = models.DateField(auto_now=True, null=True) - - def __str__(self): - return self.nama - pass - -class Routerm(models.Model): - nama = models.CharField(max_length=50) - host = models.CharField(max_length=50) - user = models.CharField(max_length=30) - password = models.CharField(max_length=50, blank=True) - kecepatan_internet = models.IntegerField(blank=True) - pub_date = models.DateField(auto_now=True) - - def __str__(self): - return self.nama - pass - -class Automation(models.Model): - nama = models.CharField(max_length=50) - deskripsi = models.TextField() - status = models.CharField(max_length=15, blank=True) - - def __str__(self): - return self.nama - pass - -class Confrouter(models.Model): - nama = models.CharField(max_length=50) - deskripsi = models.CharField(max_length=50) - - - def __str__(self): - return self.nama - pass - -class Manualcommand(models.Model): - host = models.ForeignKey(Routerm, on_delete=models.CASCADE) - command = models.CharField(max_length=255) - output = models.TextField(blank=True) - time = models.DateTimeField(auto_now=True) - - def __str__(self): - return self.time - pass diff --git a/netauto/sendcom.py b/netauto/sendcom.py deleted file mode 100644 index 0b956de..0000000 --- a/netauto/sendcom.py +++ /dev/null @@ -1,52 +0,0 @@ -import paramiko -import time -import routeros_api -import json -from .models import Routerm - -def show_ip(ip_add,username,password): - - ssh = paramiko.SSHClient() - ssh.set_missing_host_key_policy(paramiko.AutoAddPolicy) - ssh.connect(hostname=ip_add,username=username,password=password) - - stdin, stdout, stderr = ssh.exec_command("ip address print") - - time.sleep(1) - - output=stdout.read().decode("ascii").strip("\n") - return output - pass - -def show_ipactive(parameter_list): - host = "192.168.31.1" - - conn = routeros_api.RouterOsApiPool(host, username="admin", password="", plaintext_login=True) - api= conn.get_api() - - list_ip = api.get_resource('ip/address') - show_ip = list_ip.get() - - data = json.dumps(show_ip, indent=3) - conn.disconnect() - return show_ip - pass - -def sendpcq1(id): - r=Routerm.objects.get(id=id) - host = r.host - username= r.user - password= r.password - - ssh = paramiko.SSHClient() - ssh.set_missing_host_key_policy(paramiko.AutoAddPolicy) - ssh.connect(hostname=host,username=username,password=password) - - stdin, stdout, stderr = ssh.exec_command("ls \n ip address print") - - time.sleep(1) - - output= stdout.read().decode("ascii").strip("\n") - - return output - pass \ No newline at end of file diff --git a/netauto/templates/addcontoh.html b/netauto/templates/addcontoh.html deleted file mode 100644 index 847d03a..0000000 --- a/netauto/templates/addcontoh.html +++ /dev/null @@ -1,16 +0,0 @@ -{% extends 'base.html' %} -{% block title %} -tmabah kan -{% endblock title %} - -{% block content %} -
-

Tambahkan contoh

-
-
- {{ formk.as_p }} - -
-
- -{% endblock content %} \ No newline at end of file diff --git a/netauto/templates/addrouter.html b/netauto/templates/addrouter.html deleted file mode 100644 index 76a50fc..0000000 --- a/netauto/templates/addrouter.html +++ /dev/null @@ -1,26 +0,0 @@ - -{% extends 'base.html' %} -{% load static %} -{% block title %} home {% endblock title %} -{% block content %} - {{massage}} -
- {% csrf_token %} - {{formk.as_p}} - -
- - -{% endblock content %} -{% block router %} - - {% for router in router %} - - {% endfor %} - -{% endblock router %} diff --git a/netauto/templates/coba.html b/netauto/templates/coba.html deleted file mode 100644 index a20f04f..0000000 --- a/netauto/templates/coba.html +++ /dev/null @@ -1,3 +0,0 @@ -{% for data in data %} -{{data}} -{% endfor %} \ No newline at end of file diff --git a/netauto/templates/detailrouter.html b/netauto/templates/detailrouter.html deleted file mode 100644 index b4240a0..0000000 --- a/netauto/templates/detailrouter.html +++ /dev/null @@ -1,43 +0,0 @@ - -{% extends 'base.html' %} -{% load static %} -{% block title %}Router | {% for data in data %}{{data.nama}}{% endfor %} {% endblock title %} -{% block judul %} -Automations -{% endblock judul %} -{% block content %} - - {% for data in data %} - {{data.nama}} | - {{data.host}} sebagai - {{data.user}} -
- {% for auto in auto %} -
-
-
-
{{auto.nama}}
-

{{auto.deskripsi}}.

- Go somewhere -
-
-
- {% endfor %} -
- - {% endfor %} - - -{% endblock content %} -{% block router %} - - {% for router in router %} - - {% endfor %} - -{% endblock router %} diff --git a/netauto/templates/home.html b/netauto/templates/home.html deleted file mode 100644 index fa7841a..0000000 --- a/netauto/templates/home.html +++ /dev/null @@ -1,49 +0,0 @@ - -{% extends 'base.html' %} -{% load static %} -{% block title %} home {% endblock title %} -{% block judul %} -Automations -{% endblock judul %} - -{% block content %} -{{massage}} - {% for router in router|slice:":1" %} -

Automation {{router.nama}}

-

selahkan pilih pilihan outasi yang akan di gunakan:

-
- {% for auto in auto %} -
-
-
-
{{auto.nama}}
-

{{auto.deskripsi}}.

- Go somewhere -
-
-
- {% endfor %} -
- {% endfor %} - - - - - -{% endblock content %} - -{% block router %} - - {% for router in router %} - - - {% endfor %} - -{% endblock router %} diff --git a/netauto/templates/manualc.html b/netauto/templates/manualc.html deleted file mode 100644 index abb636a..0000000 --- a/netauto/templates/manualc.html +++ /dev/null @@ -1,44 +0,0 @@ - -{% extends 'base.html' %} -{% load static %} -{% block title %}Router | {% for data in data %}{{data.nama}}{% endfor %} {% endblock title %} -{% block judul %} -Automations -{% endblock judul %} -{% block content %} - -
- {{form.as_p}} - -
-
- - - -{% endblock content %} -{% block router %} - - {% for router in router %} - - {% endfor %} - -{% endblock router %} diff --git a/netauto/templates/registration/login.html b/netauto/templates/registration/login.html deleted file mode 100644 index 3aedc4c..0000000 --- a/netauto/templates/registration/login.html +++ /dev/null @@ -1,66 +0,0 @@ -{% load static %} - - - - - - Login - - - - -
-
-
- {% if form.errors %} -
-

username atau password yang di masukan salah

-
- {% endif %} - - {% if next %} - {% if user.is_authenticated %} -

Your account doesn't have access to this page. To proceed, - please login with an account that has access.

- {% else %} - - {% endif %} - {% endif %} -
-

Login

-

-
- {% csrf_token %} - -
- -
- {{form.username}} -
-
- -
- -
- {{form.password}} -
-
- - - - -
-
-
-
- - diff --git a/netauto/tests.py b/netauto/tests.py deleted file mode 100644 index 7ce503c..0000000 --- a/netauto/tests.py +++ /dev/null @@ -1,3 +0,0 @@ -from django.test import TestCase - -# Create your tests here. diff --git a/netauto/urls.py b/netauto/urls.py deleted file mode 100644 index 03a295c..0000000 --- a/netauto/urls.py +++ /dev/null @@ -1,18 +0,0 @@ -from django.contrib.auth.views import LoginView,LogoutView -from django.forms import widgets -from django.urls import path -from . import views - -urlpatterns = [ - path('command',views.manualcommand, name='manual'), - path('/router',views.router, name='router'), - path('/pcq1',views.pcq1, name='conpcq1'), - path('', views.homepage, name='show'), - path('addrouter',views.addrouter, name='addrouter'), - path('addr', views.addr, name='addr'), - path('addc/', views.addcontoh, name='addcontoh'), - path('beta/',views.apiip, name='beta'), - path('login',LoginView.as_view(), name='login'), - path('logout',LogoutView.as_view(next_page='login'), name='logout'), - -] \ No newline at end of file diff --git a/netauto/views.py b/netauto/views.py deleted file mode 100644 index 9f04308..0000000 --- a/netauto/views.py +++ /dev/null @@ -1,121 +0,0 @@ -from django.shortcuts import render, redirect -from django.contrib import messages -from django.http import HttpResponse -from .models import Contohmodel, Routerm, Automation -from .forms import Formcontoh, RoutermForm -from django.contrib.auth.decorators import login_required -from django.conf import settings -from . import sendcom -import json -import routeros_api - - - -# Create your views here. -@login_required(login_url=settings.LOGIN_URL) -def show_ip(request): - - data=sendcom.show_ip("192.168.31.1","admin","") - return render(request, "home.html", { 'data': data }) - pass - -@login_required(login_url=settings.LOGIN_URL) -def homepage(request): - auto = Automation.objects.all() - router=Routerm.objects.all() - context = { - 'auto': auto, - 'router': router, - 'count' : 0 - } - return render(request, "home.html", context) - - -@login_required(login_url=settings.LOGIN_URL) -def addcontoh(request): - contoh = Contohmodel.objects.all() - fromcontoh = Formcontoh - context= { - 'formk' : fromcontoh, - 'k': contoh, - } - return render(request, 'addcontoh.html', context) - - -@login_required(login_url=settings.LOGIN_URL) -def addrouter(request): - router=Routerm.objects.all() - form = RoutermForm - context = { - 'formk' : form, - 'router': router - } - return render(request, "addrouter.html", context) - - -@login_required(login_url=settings.LOGIN_URL) -def addr(request): - if request.method == 'POST': - form = RoutermForm(request.POST) - if form.is_valid(): - form.save() - messages.success(request, "berhasil bosku") - return redirect(addrouter) - - pass - -@login_required(login_url=settings.LOGIN_URL) -def router(request, id): - auto = Automation.objects.all() - router=Routerm.objects.all() - idk=id - data=Routerm.objects.filter(pk=id) - context = { - 'auto': auto, - 'data' : data, - 'router': router, - 'idk':idk - } - return render(request,'detailrouter.html',context) - - -@login_required(login_url=settings.LOGIN_URL) -def apiip(request): - host = "192.168.31.1" - - conn = routeros_api.RouterOsApiPool(host, username="admin", password="", plaintext_login=True) - api= conn.get_api() - - list_ip = api.get_resource('ip/address') - show_ip = list_ip.get() - - data = json.dumps(show_ip, indent=3) - conn.disconnect() - d=json.loads(data) - context={ - 'data':d, - } - return render(request,'coba.html',context) - -@login_required(login_url=settings.LOGIN_URL) -def pcq1(request, id): - k=sendcom.sendpcq1(id) - if k == "": - d = "sukses" - else: - d="gagal" - context={ - 'data':k, - } - - return render(request,'coba.html',context) - -@login_required(login_url=settings.LOGIN_URL) -def manualcommand(request): - from .forms import Manualform - f=Manualform - context={ - 'form':f, - } - - return render(request,'manualc.html',context) \ No newline at end of file