diff --git a/netbox_proxbox/example.py b/netbox_proxbox/example.py new file mode 100644 index 0000000..8d125ac --- /dev/null +++ b/netbox_proxbox/example.py @@ -0,0 +1 @@ +example = {'virtualmachines': [{'name': 'EVE-NG', 'changes': {'status': False, 'custom_fields': None, 'local_context': True, 'resources': None, 'tag': False, 'interfaces': False, 'ips': False}, 'result': True}, {'name': 'containerlab', 'changes': {'status': False, 'custom_fields': None, 'local_context': False, 'resources': None, 'tag': False, 'interfaces': False, 'ips': False}, 'result': True}, {'name': 'NS1', 'changes': {'status': False, 'custom_fields': None, 'local_context': False, 'resources': None, 'tag': False, 'interfaces': False, 'ips': False}, 'result': True}, {'name': 'wikijs-test', 'changes': {'status': False, 'custom_fields': None, 'local_context': False, 'resources': None, 'tag': False, 'interfaces': False, 'ips': False}, 'result': True}, {'name': 'ISPTools', 'changes': {'status': False, 'custom_fields': None, 'local_context': False, 'resources': None, 'tag': False, 'interfaces': False, 'ips': False}, 'result': True}, {'name': 'RSYSLOG-CGNAT', 'changes': {'status': False, 'custom_fields': None, 'local_context': True, 'resources': None, 'tag': False, 'interfaces': None, 'ips': False}, 'result': True}, {'name': 'SPEEDTEST', 'changes': {'status': False, 'custom_fields': None, 'local_context': False, 'resources': None, 'tag': False, 'interfaces': False, 'ips': False}, 'result': True}, {'name': 'TESTE-DEFENSE-IA', 'changes': {'status': False, 'custom_fields': None, 'local_context': False, 'resources': None, 'tag': False, 'interfaces': False, 'ips': False}, 'result': True}, {'name': 'KRILL-RPKI-AS265234', 'changes': {'status': False, 'custom_fields': None, 'local_context': False, 'resources': None, 'tag': False, 'interfaces': False, 'ips': False}, 'result': True}, {'name': 'netbox-dev2', 'changes': {'status': False, 'custom_fields': None, 'local_context': False, 'resources': None, 'tag': False, 'interfaces': False, 'ips': False}, 'result': True}, {'name': 'VM-TESTE', 'changes': {'status': False, 'custom_fields': None, 'local_context': False, 'resources': None, 'tag': False, 'interfaces': None, 'ips': False}, 'result': True}, {'name': 'elastiflow', 'changes': {'status': False, 'custom_fields': None, 'local_context': False, 'resources': None, 'tag': False, 'interfaces': False, 'ips': False}, 'result': True}, {'name': 'ELK-NETFLOW', 'changes': {'status': False, 'custom_fields': None, 'local_context': False, 'resources': None, 'tag': False, 'interfaces': False, 'ips': False}, 'result': True}, {'name': 'ZEUS', 'changes': {'status': False, 'custom_fields': None, 'local_context': False, 'resources': None, 'tag': False, 'interfaces': False, 'ips': False}, 'result': True}, {'name': 'SPEEDTEST-OOKLA', 'changes': {'status': False, 'custom_fields': None, 'local_context': False, 'resources': None, 'tag': False, 'interfaces': False, 'ips': False}, 'result': True}, {'name': 'RADIUS-BKP', 'changes': {'status': False, 'custom_fields': None, 'local_context': False, 'resources': None, 'tag': False, 'interfaces': False, 'ips': False}, 'result': True}, {'name': 'ZABBIX-GRAFANA', 'changes': {'status': False, 'custom_fields': None, 'local_context': False, 'resources': None, 'tag': False, 'interfaces': False, 'ips': False}, 'result': True}, {'name': 'netbox-template', 'changes': {'status': False, 'custom_fields': None, 'local_context': False, 'resources': None, 'tag': False, 'interfaces': False, 'ips': False}, 'result': True}, {'name': 'VMforDocker', 'changes': {'status': False, 'custom_fields': None, 'local_context': False, 'resources': None, 'tag': False, 'interfaces': False, 'ips': False}, 'result': True}, {'name': 'Win10-LAB', 'changes': {'status': False, 'custom_fields': None, 'local_context': False, 'resources': None, 'tag': False, 'interfaces': False, 'ips': False}, 'result': True}, {'name': 'netbox-beta', 'changes': {'status': False, 'custom_fields': None, 'local_context': False, 'resources': None, 'tag': False, 'interfaces': False, 'ips': False}, 'result': True}, {'name': 'testing', 'changes': {'status': False, 'custom_fields': None, 'local_context': False, 'resources': None, 'tag': False, 'interfaces': False, 'ips': False}, 'result': True}, {'name': 'teste', 'changes': {'status': False, 'custom_fields': None, 'local_context': False, 'resources': None, 'tag': False, 'interfaces': False, 'ips': False}, 'result': True}, {'name': 'netbox-v3-dev', 'changes': {'status': False, 'custom_fields': None, 'local_context': False, 'resources': None, 'tag': False, 'interfaces': False, 'ips': False}, 'result': True}, {'name': 'Ubuntu-SRV-20.04', 'changes': {'status': False, 'custom_fields': None, 'local_context': False, 'resources': None, 'tag': False, 'interfaces': False, 'ips': False}, 'result': True}, {'name': 'DOKUWIKI-PUBLICO-OLD', 'changes': {'status': False, 'custom_fields': None, 'local_context': False, 'resources': None, 'tag': False, 'interfaces': False, 'ips': False}, 'result': True}, {'name': 'wikijs-testing', 'changes': {'status': False, 'custom_fields': None, 'local_context': False, 'resources': None, 'tag': False, 'interfaces': False, 'ips': False}, 'result': True}, {'name': 'WIN10-ALVOCOM', 'changes': {'status': False, 'custom_fields': None, 'local_context': False, 'resources': None, 'tag': False, 'interfaces': False, 'ips': False}, 'result': True}, {'name': 'asstat-deb10', 'changes': {'status': False, 'custom_fields': None, 'local_context': False, 'resources': None, 'tag': False, 'interfaces': False, 'ips': False}, 'result': True}, {'name': 'EVE-NG', 'changes': {'status': False, 'custom_fields': None, 'local_context': True, 'resources': None, 'tag': False, 'interfaces': False, 'ips': False}, 'result': True}, {'name': 'ELASTIC-ISAC', 'changes': {'status': False, 'custom_fields': None, 'local_context': False, 'resources': None, 'tag': False, 'interfaces': None, 'ips': False}, 'result': True}, {'name': 'nfsen-debian', 'changes': {'status': False, 'custom_fields': None, 'local_context': False, 'resources': None, 'tag': False, 'interfaces': False, 'ips': False}, 'result': True}, {'name': 'PNETLAB', 'changes': {'status': False, 'custom_fields': None, 'local_context': False, 'resources': None, 'tag': False, 'interfaces': False, 'ips': False}, 'result': True}, {'name': 'ZABBIX', 'changes': {'status': False, 'custom_fields': None, 'local_context': False, 'resources': None, 'tag': False, 'interfaces': False, 'ips': False}, 'result': True}, {'name': 'GRAYLOG', 'changes': {'status': False, 'custom_fields': None, 'local_context': False, 'resources': None, 'tag': False, 'interfaces': False, 'ips': False}, 'result': True}, {'name': 'NS3', 'changes': {'status': False, 'custom_fields': None, 'local_context': False, 'resources': None, 'tag': False, 'interfaces': False, 'ips': False}, 'result': True}, {'name': 'netbox-devop2', 'changes': {'status': False, 'custom_fields': None, 'local_context': False, 'resources': None, 'tag': False, 'interfaces': False, 'ips': False}, 'result': True}, {'name': 'DEFENSE-IA', 'changes': {'status': False, 'custom_fields': None, 'local_context': False, 'resources': None, 'tag': False, 'interfaces': False, 'ips': False}, 'result': True}, {'name': 'LAB-GRAFANA', 'changes': {'status': False, 'custom_fields': None, 'local_context': False, 'resources': None, 'tag': False, 'interfaces': False, 'ips': False}, 'result': True}, {'name': 'BKP', 'changes': {'status': False, 'custom_fields': None, 'local_context': False, 'resources': None, 'tag': False, 'interfaces': False, 'ips': False}, 'result': True}, {'name': 'Ubuntu-SRV-20.04', 'changes': {'status': False, 'custom_fields': None, 'local_context': True, 'resources': None, 'tag': False, 'interfaces': False, 'ips': False}, 'result': True}, {'name': 'NetDev-CentOs-LAB', 'changes': {'status': False, 'custom_fields': None, 'local_context': False, 'resources': None, 'tag': False, 'interfaces': False, 'ips': False}, 'result': True}, {'name': 'GenieACS', 'changes': {'status': False, 'custom_fields': None, 'local_context': False, 'resources': None, 'tag': False, 'interfaces': None, 'ips': False}, 'result': True}, {'name': 'vault', 'changes': {'status': False, 'custom_fields': None, 'local_context': False, 'resources': None, 'tag': False, 'interfaces': False, 'ips': False}, 'result': True}, {'name': 'KRILL-RPKI-AS268881', 'changes': {'status': False, 'custom_fields': None, 'local_context': False, 'resources': None, 'tag': False, 'interfaces': False, 'ips': False}, 'result': True}, {'name': 'netbox-v3-huawei', 'changes': {'status': False, 'custom_fields': None, 'local_context': False, 'resources': None, 'tag': False, 'interfaces': False, 'ips': False}, 'result': True}, {'name': 'RSYSLOG-CGNAT', 'changes': {'status': False, 'custom_fields': None, 'local_context': True, 'resources': None, 'tag': False, 'interfaces': None, 'ips': False}, 'result': True}, {'name': 'NS4', 'changes': {'status': False, 'custom_fields': None, 'local_context': False, 'resources': None, 'tag': False, 'interfaces': False, 'ips': False}, 'result': True}, {'name': 'planos', 'changes': {'status': False, 'custom_fields': None, 'local_context': False, 'resources': None, 'tag': False, 'interfaces': False, 'ips': False}, 'result': True}, {'name': 'speedtest-servers', 'changes': {'status': False, 'custom_fields': None, 'local_context': False, 'resources': None, 'tag': False, 'interfaces': False, 'ips': False}, 'result': True}], 'nodes': [{'changes': {'status': False, 'cluster': False, 'interfaces': False}, 'result': True}, {'changes': {'status': False, 'cluster': False, 'interfaces': False}, 'result': True}, {'changes': {'status': False, 'cluster': False, 'interfaces': False}, 'result': True}], 'remove_unused': [{'name': 'DEFENSE', 'result': False, 'log': ['[OK] VM exists on both systems (Netbox and Proxmox) -> DEFENSE']}, {'name': 'DOKUWIKI-PUBLICO-OLD', 'result': False, 'log': ['[OK] VM exists on both systems (Netbox and Proxmox) -> DOKUWIKI-PUBLICO-OLD']}, {'name': 'ELASTIC-ISAC', 'result': False, 'log': ['[OK] VM exists on both systems (Netbox and Proxmox) -> ELASTIC-ISAC']}, {'name': 'ELK-NETFLOW', 'result': False, 'log': ['[OK] VM exists on both systems (Netbox and Proxmox) -> ELK-NETFLOW']}, {'name': 'EVE-NG', 'result': False, 'log': ['[OK] VM exists on both systems (Netbox and Proxmox) -> EVE-NG']}, {'name': 'GRAYLOG', 'result': False, 'log': ['[OK] VM exists on both systems (Netbox and Proxmox) -> GRAYLOG']}, {'name': 'GenieACS', 'result': False, 'log': ['[OK] VM exists on both systems (Netbox and Proxmox) -> GenieACS']}, {'name': 'ISPTools', 'result': False, 'log': ['[OK] VM exists on both systems (Netbox and Proxmox) -> ISPTools']}, {'name': 'BKP', 'result': False, 'log': ['[OK] VM exists on both systems (Netbox and Proxmox) -> BKP']}, {'name': 'KRILL-RPKI-AS265234', 'result': False, 'log': ['[OK] VM exists on both systems (Netbox and Proxmox) -> KRILL-RPKI-AS265234']}, {'name': 'KRILL-RPKI-AS268881', 'result': False, 'log': ['[OK] VM exists on both systems (Netbox and Proxmox) -> KRILL-RPKI-AS268881']}, {'name': 'LAB-GRAFANA', 'result': False, 'log': ['[OK] VM exists on both systems (Netbox and Proxmox) -> LAB-GRAFANA']}, {'name': 'LAB-ZABBIX-6', 'result': False, 'log': ['[OK] VM exists on both systems (Netbox and Proxmox) -> LAB-ZABBIX-6']}, {'name': 'NS1', 'result': False, 'log': ['[OK] VM exists on both systems (Netbox and Proxmox) -> NS1']}, {'name': 'NS3', 'result': False, 'log': ['[OK] VM exists on both systems (Netbox and Proxmox) -> NS3']}, {'name': 'NS4', 'result': False, 'log': ['[OK] VM exists on both systems (Netbox and Proxmox) -> NS4']}, {'name': 'NetDev-CentOs-LAB', 'result': False, 'log': ['[OK] VM exists on both systems (Netbox and Proxmox) -> NetDev-CentOs-LAB']}, {'name': 'PNETLAB', 'result': False, 'log': ['[OK] VM exists on both systems (Netbox and Proxmox) -> PNETLAB']}, {'name': 'RADIUS-BKP', 'result': False, 'log': ['[OK] VM exists on both systems (Netbox and Proxmox) -> RADIUS-BKP']}, {'name': 'RSYSLOG-CGNAT', 'result': False, 'log': ['[OK] VM exists on both systems (Netbox and Proxmox) -> RSYSLOG-CGNAT']}, {'name': 'SPEEDTEST', 'result': False, 'log': ['[OK] VM exists on both systems (Netbox and Proxmox) -> SPEEDTEST']}, {'name': 'SPEEDTEST-OOKLA', 'result': False, 'log': ['[OK] VM exists on both systems (Netbox and Proxmox) -> SPEEDTEST-OOKLA']}, {'name': 'TESTE-DEFENSE-IA', 'result': False, 'log': ['[OK] VM exists on both systems (Netbox and Proxmox) -> TESTE-DEFENSE-IA']}, {'name': 'Ubuntu-SRV-20.04', 'result': False, 'log': ['[OK] VM exists on both systems (Netbox and Proxmox) -> Ubuntu-SRV-20.04']}, {'name': 'VM-TESTE', 'result': False, 'log': ['[OK] VM exists on both systems (Netbox and Proxmox) -> VM-TESTE']}, {'name': 'VMforDocker', 'result': False, 'log': ['[OK] VM exists on both systems (Netbox and Proxmox) -> VMforDocker']}, {'name': 'WIN10-ALVOCOM', 'result': False, 'log': ['[OK] VM exists on both systems (Netbox and Proxmox) -> WIN10-ALVOCOM']}, {'name': 'Win10-LAB', 'result': False, 'log': ['[OK] VM exists on both systems (Netbox and Proxmox) -> Win10-LAB']}, {'name': 'ZABBIX-GRAFANA', 'result': False, 'log': ['[OK] VM exists on both systems (Netbox and Proxmox) -> ZABBIX-GRAFANA']}, {'name': 'ZEUS', 'result': False, 'log': ['[OK] VM exists on both systems (Netbox and Proxmox) -> ZEUS']}, {'name': 'asstat-deb10', 'result': False, 'log': ['[OK] VM exists on both systems (Netbox and Proxmox) -> asstat-deb10']}, {'name': 'containerlab', 'result': False, 'log': ['[OK] VM exists on both systems (Netbox and Proxmox) -> containerlab']}, {'name': 'elastiflow', 'result': False, 'log': ['[OK] VM exists on both systems (Netbox and Proxmox) -> elastiflow']}, {'name': 'testing', 'result': False, 'log': ['[OK] VM exists on both systems (Netbox and Proxmox) -> testing']}, {'name': 'netbox-beta', 'result': False, 'log': ['[OK] VM exists on both systems (Netbox and Proxmox) -> netbox-beta']}, {'name': 'netbox-dev2', 'result': False, 'log': ['[OK] VM exists on both systems (Netbox and Proxmox) -> netbox-dev2']}, {'name': 'netbox-devop2', 'result': False, 'log': ['[OK] VM exists on both systems (Netbox and Proxmox) -> netbox-devop2']}, {'name': 'netbox-template', 'result': False, 'log': ['[OK] VM exists on both systems (Netbox and Proxmox) -> netbox-template']}, {'name': 'netbox-v3-dev', 'result': False, 'log': ['[OK] VM exists on both systems (Netbox and Proxmox) -> netbox-v3-dev']}, {'name': 'netbox-v3-huawei', 'result': False, 'log': ['[OK] VM exists on both systems (Netbox and Proxmox) -> netbox-v3-huawei']}, {'name': 'nfsen-debian', 'result': False, 'log': ['[OK] VM exists on both systems (Netbox and Proxmox) -> nfsen-debian']}, {'name': 'planos', 'result': False, 'log': ['[OK] VM exists on both systems (Netbox and Proxmox) -> planos']}, {'name': 'speedtest-servers', 'result': False, 'log': ['[OK] VM exists on both systems (Netbox and Proxmox) -> speedtest-servers']}, {'name': 'teste', 'result': False, 'log': ['[OK] VM exists on both systems (Netbox and Proxmox) -> teste']}, {'name': 'vault', 'result': False, 'log': ['[OK] VM exists on both systems (Netbox and Proxmox) -> vault']}, {'name': 'wikijs-test', 'result': False, 'log': ['[OK] VM exists on both systems (Netbox and Proxmox) -> wikijs-test']}, {'name': 'wikijs-testing', 'result': False, 'log': ['[OK] VM exists on both systems (Netbox and Proxmox) -> wikijs-testing']}]} \ No newline at end of file diff --git a/netbox_proxbox/proxbox_api/remove.py b/netbox_proxbox/proxbox_api/remove.py index 71e9e6b..1df7a7d 100755 --- a/netbox_proxbox/proxbox_api/remove.py +++ b/netbox_proxbox/proxbox_api/remove.py @@ -175,6 +175,7 @@ def all(): json_vm_all.append(json_vm) + print(f"json_vm: {json_vm}") return json_vm_all \ No newline at end of file diff --git a/netbox_proxbox/proxbox_api/update.py b/netbox_proxbox/proxbox_api/update.py index 3d35dd9..e78b4ac 100755 --- a/netbox_proxbox/proxbox_api/update.py +++ b/netbox_proxbox/proxbox_api/update.py @@ -275,8 +275,10 @@ def virtual_machine(**kwargs): if vm_on_netbox == True: # Update Netbox information - full_update = vm_full_update(netbox_vm, proxmox_json) - json_vm["changes"] = full_update + full_update = vm_full_update(netbox_vm, proxmox_json) + + # 'changes' json + json_vm = full_update full_update_list = list(full_update.values()) @@ -301,7 +303,7 @@ def virtual_machine(**kwargs): if netbox_vm != None: # Update rest of configuration full_update = vm_full_update(netbox_vm, proxmox_json) - json_vm["changes"] = full_update + json_vm = full_update full_update_list = list(full_update.values()) @@ -331,6 +333,7 @@ def virtual_machine(**kwargs): # Unexpected error json_vm["result"] = False + print('(update) json_vm:', json_vm) return json_vm diff --git a/netbox_proxbox/tables.py b/netbox_proxbox/tables.py index 05f97fc..d7dd4de 100755 --- a/netbox_proxbox/tables.py +++ b/netbox_proxbox/tables.py @@ -1,16 +1,16 @@ # tables.py -import django_tables2 as tables +import django_tables2 as table -from netbox.tables import NetBoxTable, ChoiceFieldColumn +from netbox.tables import NetBoxTable from .models import ProxmoxVM class ProxmoxVMTable(NetBoxTable): """Table for displaying BGP Peering objects.""" - id = tables.LinkColumn() - cluster = tables.LinkColumn() - virtual_machine = tables.LinkColumn() - proxmox_vm_id = tables.LinkColumn() + id = table.LinkColumn() + cluster = table.LinkColumn() + virtual_machine = table.LinkColumn() + proxmox_vm_id = table.LinkColumn() class Meta(NetBoxTable.Meta): model = ProxmoxVM @@ -22,4 +22,36 @@ class Meta(NetBoxTable.Meta): "type", "node", "cluster", - ) \ No newline at end of file + ) + +class VMUpdateResult(table.Table): + """Table for displaying VM/CT update results""" + + name = table.Column() + status = table.Column() + custom_fields = table.Column(verbose_name = "Custom Fields") + local_context = table.Column(verbose_name = "Local Context") + resources = table.Column() + tag = table.Column() + interfaces = table.Column() + ips = table.Column(verbose_name = "IP Address") + + class Meta(NetBoxTable.Meta): + fields = ('name', 'status', 'custom_fields', 'local_context', 'resources', 'tag', 'interfaces', 'ips') + default_columns = ('name') + #fields = ('name', 'status', 'custom_fields', 'local_context', 'resources', 'tag', 'result') + #default_columns = ('name', 'status', 'custom_fields', 'local_context', 'resources', 'tag', 'result') + + +class NodeUpdateResult(table.Table): + """Table for displaying VM/CT update results""" + + status = table.Column() + cluster = table.Column() + interfaces = table.Column() + result = table.Column() + + + class Meta(NetBoxTable.Meta): + fields = ('status', 'cluster', 'interfaces', 'result') + default_columns = ('name') \ No newline at end of file diff --git a/netbox_proxbox/templates/netbox_proxbox/proxmox_vm_full_update.html b/netbox_proxbox/templates/netbox_proxbox/proxmox_vm_full_update.html index e48a3c4..48f1b6c 100755 --- a/netbox_proxbox/templates/netbox_proxbox/proxmox_vm_full_update.html +++ b/netbox_proxbox/templates/netbox_proxbox/proxmox_vm_full_update.html @@ -1,91 +1,24 @@ {% extends 'base/layout.html' %} +{% load render_table from django_tables2 %} {% block content %} - {% if proxmox.nodes %} -

Nodes

- - - - - - - - - - - {% for node in proxmox.nodes %} - - - - - - - {% endfor %} - -
Node status changedCluster changedUpdate result
{{ node.changes.status }}{{ node.changes.cluster }}{{ node.result }}
- -

- {% endif %} - {% if proxmox.virtualmachines %} -

Virtual Machines and Containers

- - - - - - - - - - - - - - - {% for virtualmachine in proxmox.virtualmachines %} - - - - - - - - - - {% endfor %} - -
VM/CT NameStatus changedCustom FieldsLocal contextResourcesTagUpdate result
{{ virtualmachine.name }}{{ virtualmachine.changes.status }}{{ virtualmachine.changes.custom_fields }}{{ virtualmachine.changes.local_context }}{{ virtualmachine.changes.resources }}{{ virtualmachine.changes.tag }}{{ virtualmachine.result }}
- -

- {% endif %} - {% if proxmox.remove_unused %} -

Remove unused VM/CT

-

Logs:

- - {% endif %} - +

Virtual Machines and Containers

+
+
+
+ {% render_table virtualmachines_table %} +
+
+
+ +

Nodes

+
+
+
+ {% render_table nodes_table %} +
+
+
{% endblock %} {% block footer_links %} diff --git a/netbox_proxbox/templates/netbox_proxbox/update_result.html b/netbox_proxbox/templates/netbox_proxbox/update_result.html new file mode 100644 index 0000000..bb6ce44 --- /dev/null +++ b/netbox_proxbox/templates/netbox_proxbox/update_result.html @@ -0,0 +1,7 @@ +{% extends 'base/layout.html' %} + + +{% block content %} +

TESTE

+ +{% endblock %} \ No newline at end of file diff --git a/netbox_proxbox/views.py b/netbox_proxbox/views.py index e7ad6bd..7596bd8 100755 --- a/netbox_proxbox/views.py +++ b/netbox_proxbox/views.py @@ -13,7 +13,7 @@ from .filters import ProxmoxVMFilter from .forms import ProxmoxVMForm, ProxmoxVMFilterForm from .models import ProxmoxVM -from .tables import ProxmoxVMTable +from .tables import ProxmoxVMTable, VMUpdateResult, NodeUpdateResult from netbox_proxbox import proxbox_api import json @@ -39,6 +39,41 @@ def get(self, request): } ) +''' +def table_data(): + json_result = proxbox_api.update.all(remove_unused = True) + + vm_table = [] + for row in json_result.get("virtualmachines"): + json = { + "name": row["name"], + "status": row["changes"]["status"], + "custom_fields": row["changes"]["custom_fields"], + "local_context": row["changes"]["local_context"], + "resources": row["changes"]["resources"], + "tag": row["changes"]["tag"], + "interfaces": row["changes"]["interfaces"], + "ips": row["changes"]["ips"], + } + vm_table.append(json) + + virtualmachines_table = VMUpdateResult(vm_table) + + node_table = [] + for row in json_result.get("nodes"): + json = { + "status": row["changes"]["status"], + "cluster": row["changes"]["cluster"], + "interfaces": row["changes"]["interfaces"], + "result": row["result"] + } + node_table.append(json) + + nodes_table = NodeUpdateResult(node_table) + + + return [virtualmachines_table, nodes_table] +''' class ProxmoxFullUpdate(PermissionRequiredMixin, View): """Full Update of Proxmox information on Netbox.""" @@ -46,20 +81,21 @@ class ProxmoxFullUpdate(PermissionRequiredMixin, View): # Define permission permission_required = "netbox_proxbox.view_proxmoxvm" + + data = proxbox_api.update.all(remove_unused = True) + print(data) + # service incoming GET HTTP requests # 'pk' value is passed to get() via URL defined in urls.py def get(self, request): """Get request.""" - update_all_result = proxbox_api.update.all(remove_unused = True) - update_all_json = json.dumps(update_all_result, indent = 4) - - # render() renders provided template and uses it to create a well-formed web response return render( request, "netbox_proxbox/proxmox_vm_full_update.html", { - "proxmox": update_all_result, + "virtualmachines_table": VMUpdateResult(self.data["virtualmachines"]), + "nodes_table": NodeUpdateResult(self.data["nodes"]) }, )