From bf6b4c16754b78b3cf49f58447fd39b0192d2659 Mon Sep 17 00:00:00 2001 From: emersonfelipesp Date: Fri, 17 Mar 2023 12:24:10 +0000 Subject: [PATCH] Update to v0.0.5 --- README.md | 7 +++--- netbox_proxbox/__init__.py | 2 +- netbox_proxbox/proxbox_api/update.py | 12 +++++++--- .../proxbox_api/updates/virtual_machine.py | 5 +---- .../templates/netbox_proxbox/home.html | 22 +++++++++---------- .../proxmox_vm_full_update.html | 9 -------- netbox_proxbox/views.py | 7 +----- pyproject.toml | 2 +- setup.py | 2 +- 9 files changed, 29 insertions(+), 39 deletions(-) diff --git a/README.md b/README.md index beac0d2..22ebd00 100755 --- a/README.md +++ b/README.md @@ -44,10 +44,11 @@ Proxbox is currently able to get the following information from Proxmox: The following table shows the Netbox and Proxmox versions compatible (tested) with Proxbox plugin. -| netbox version | proxmox version | proxbox version +| netbox version | proxmox version | proxbox version | | ------------- |-------------|-------------| -| >= v3.2.0 | >= v6.2.0 | =v0.0.4 -| >= v3.0.0 < v3.2| >= v6.2.0 | =v0.0.3 +| >= v3.4.0 | >= v6.2.0 | =v0.0.5 | +| >= v3.2.0 | >= v6.2.0 | =v0.0.4 | +| >= v3.0.0 < v3.2 | >= v6.2.0 | =v0.0.3 | diff --git a/netbox_proxbox/__init__.py b/netbox_proxbox/__init__.py index 80f0f8f..054f72f 100755 --- a/netbox_proxbox/__init__.py +++ b/netbox_proxbox/__init__.py @@ -5,7 +5,7 @@ class ProxboxConfig(PluginConfig): name = "netbox_proxbox" verbose_name = "Proxbox" description = "Integrates Proxmox and Netbox" - version = "0.0.5-beta1" + version = "0.0.5" author = "Emerson Felipe (@emersonfelipesp)" author_email = "emerson.felipe@nmultifibra.com.br" base_url = "proxbox" diff --git a/netbox_proxbox/proxbox_api/update.py b/netbox_proxbox/proxbox_api/update.py index e78b4ac..1bbe3b1 100755 --- a/netbox_proxbox/proxbox_api/update.py +++ b/netbox_proxbox/proxbox_api/update.py @@ -277,8 +277,15 @@ def virtual_machine(**kwargs): # Update Netbox information full_update = vm_full_update(netbox_vm, proxmox_json) - # 'changes' json - json_vm = full_update + # I made this way since dict.update didn't work + json_vm["status"] = full_update["status"] + json_vm["custom_fields"] = full_update["custom_fields"] + json_vm["local_context"] = full_update["local_context"] + json_vm["resources"] = full_update["resources"] + json_vm["tag"] = full_update["tag"] + json_vm["interfaces"] = full_update["interfaces"] + json_vm["ips"] = full_update["ips"] + full_update_list = list(full_update.values()) @@ -333,7 +340,6 @@ def virtual_machine(**kwargs): # Unexpected error json_vm["result"] = False - print('(update) json_vm:', json_vm) return json_vm diff --git a/netbox_proxbox/proxbox_api/updates/virtual_machine.py b/netbox_proxbox/proxbox_api/updates/virtual_machine.py index c9df811..a46a432 100755 --- a/netbox_proxbox/proxbox_api/updates/virtual_machine.py +++ b/netbox_proxbox/proxbox_api/updates/virtual_machine.py @@ -375,12 +375,10 @@ def interfaces_ips(netbox_vm, proxmox_vm): _ntb_ips = [] if proxmox_vm['type'] == 'qemu': agent = proxmox.nodes(proxmox_vm['node']).qemu(proxmox_vm['vmid']).config.get().get("agent") - print(agent) + if agent: try: for interface in proxmox.nodes(proxmox_vm['node']).qemu(proxmox_vm['vmid']).agent.get('network-get-interfaces')['result']: - print(proxmox_vm['node']) - print(interface, '\n') if interface['name'].lower() != 'lo': _mac = interface.get("hardware-address") @@ -440,7 +438,6 @@ def interfaces_ips(netbox_vm, proxmox_vm): if pmx_ip not in ntb_ips: try: netbox_ipaddr = list(nb.ipam.ip_addresses.filter(address=pmx_ip)) - print(f"netbox_ipaddr: {netbox_ipaddr}") netbox_interface = list(nb.virtualization.interfaces.filter(virtual_machine_id=netbox_vm.id, mac_address=pmx_mac)) if len(netbox_interface): diff --git a/netbox_proxbox/templates/netbox_proxbox/home.html b/netbox_proxbox/templates/netbox_proxbox/home.html index b245d86..7243803 100644 --- a/netbox_proxbox/templates/netbox_proxbox/home.html +++ b/netbox_proxbox/templates/netbox_proxbox/home.html @@ -25,7 +25,7 @@
Proxmox
- + {% if configuration.netbox_proxbox.proxmox.domain %} {% else %} @@ -33,7 +33,7 @@
Proxmox
{% endif %} - + {% if configuration.netbox_proxbox.proxmox.http_port %} {% else %} @@ -41,7 +41,7 @@
Proxmox
{% endif %} - + {% if configuration.netbox_proxbox.proxmox.user %} {% else %} @@ -49,21 +49,21 @@
Proxmox
{% endif %} - + {% if configuration.netbox_proxbox.proxmox.password %} {% else %} {% endif %} - + {% if configuration.netbox_proxbox.proxmox.token.name %} {% else %} {% endif %} - + {% if configuration.netbox_proxbox.proxmox.token.value %} {% else %} @@ -71,7 +71,7 @@
Proxmox
{% endif %} - + {% if configuration.netbox_proxbox.proxmox.ssl %} {% else %} @@ -88,7 +88,7 @@
Netbox
Domain / IPDomain / IP{{ configuration.netbox_proxbox.proxmox.domain }}
HTTP PortHTTP Port{{ configuration.netbox_proxbox.proxmox.http_port }}
Proxmox UserProxmox User{{ configuration.netbox_proxbox.proxmox.user }}
Proxmox PasswordProxmox Passwordpassword defined in configuration.py{{ default_config.proxmox.password }} (default)
Token NameToken Name{{ configuration.netbox_proxbox.proxmox.token.name }}{{ default_config.proxmox.token.name }} (default)
Token ValueToken Value{{ configuration.netbox_proxbox.proxmox.token.value }}
SSLSSL{{ configuration.netbox_proxbox.proxmox.ssl }}
- + {% if configuration.netbox_proxbox.netbox.domain %} {% else %} @@ -96,7 +96,7 @@
Netbox
{% endif %} - + {% if configuration.netbox_proxbox.netbox.http_port %} {% else %} @@ -104,7 +104,7 @@
Netbox
{% endif %} - + {% if configuration.netbox_proxbox.netbox.token %} {% else %} @@ -112,7 +112,7 @@
Netbox
{% endif %} - + {% if configuration.netbox_proxbox.netbox.ssl %} {% else %} 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 48f1b6c..edd56f3 100755 --- a/netbox_proxbox/templates/netbox_proxbox/proxmox_vm_full_update.html +++ b/netbox_proxbox/templates/netbox_proxbox/proxmox_vm_full_update.html @@ -10,15 +10,6 @@

Virtual Machines and Containers

- -

Nodes

-
-
-
- {% render_table nodes_table %} -
-
-
{% endblock %} {% block footer_links %} diff --git a/netbox_proxbox/views.py b/netbox_proxbox/views.py index 7596bd8..c0c356c 100755 --- a/netbox_proxbox/views.py +++ b/netbox_proxbox/views.py @@ -81,10 +81,6 @@ 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): @@ -94,8 +90,7 @@ def get(self, request): request, "netbox_proxbox/proxmox_vm_full_update.html", { - "virtualmachines_table": VMUpdateResult(self.data["virtualmachines"]), - "nodes_table": NodeUpdateResult(self.data["nodes"]) + "virtualmachines_table": VMUpdateResult(proxbox_api.update.all(remove_unused = True)["virtualmachines"]), }, ) diff --git a/pyproject.toml b/pyproject.toml index 84aa8ea..3e20384 100755 --- a/pyproject.toml +++ b/pyproject.toml @@ -1,6 +1,6 @@ [tool.poetry] name = "netbox-proxbox" -version = "v0.0.5-beta1" +version = "v0.0.5" description = "Netbox Plugin - Integrate Proxmox and Netbox" readme = "README.md" authors = ["Emerson Felipe "] diff --git a/setup.py b/setup.py index 388ec29..3bc93e7 100755 --- a/setup.py +++ b/setup.py @@ -35,7 +35,7 @@ setup( name="netbox-proxbox", - version="0.0.5-beta1", + version="0.0.5", author="Emerson Felipe", author_email="emerson.felipe@nmultifibra.com.br", description="Integration between Proxmox and Netbox",
Domain / IPDomain / IP{{ configuration.netbox_proxbox.netbox.domain }}
HTTP PortHTTP Port{{ configuration.netbox_proxbox.netbox.http_port }}
TokenToken{{ configuration.netbox_proxbox.netbox.token }}
SSLSSL{{ configuration.netbox_proxbox.netbox.ssl }}