Skip to content

Commit

Permalink
Update to v0.0.5
Browse files Browse the repository at this point in the history
  • Loading branch information
emersonfelipesp committed Mar 17, 2023
1 parent 2ab77f4 commit bf6b4c1
Show file tree
Hide file tree
Showing 9 changed files with 29 additions and 39 deletions.
7 changes: 4 additions & 3 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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 |


</div>
Expand Down
2 changes: 1 addition & 1 deletion netbox_proxbox/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -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 = "[email protected]"
base_url = "proxbox"
Expand Down
12 changes: 9 additions & 3 deletions netbox_proxbox/proxbox_api/update.py
Original file line number Diff line number Diff line change
Expand Up @@ -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())

Expand Down Expand Up @@ -333,7 +340,6 @@ def virtual_machine(**kwargs):
# Unexpected error
json_vm["result"] = False

print('(update) json_vm:', json_vm)
return json_vm


Expand Down
5 changes: 1 addition & 4 deletions netbox_proxbox/proxbox_api/updates/virtual_machine.py
Original file line number Diff line number Diff line change
Expand Up @@ -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")
Expand Down Expand Up @@ -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):
Expand Down
22 changes: 11 additions & 11 deletions netbox_proxbox/templates/netbox_proxbox/home.html
Original file line number Diff line number Diff line change
Expand Up @@ -25,53 +25,53 @@ <h5 class="card-header">Proxmox</h5>
<div class="card-body">
<table class="table table-hover attr-table">
<tr>
<th scope="row">Domain / IP</th>
<th scope="row"><strong>Domain / IP</strong></th>
{% if configuration.netbox_proxbox.proxmox.domain %}
<td>{{ configuration.netbox_proxbox.proxmox.domain }}</td>
{% else %}
<td>{{ default_config.proxmox.domain }} (default)</td>
{% endif %}
</tr>
<tr>
<th scope="row">HTTP Port</th>
<th scope="row"><strong>HTTP Port</strong></th>
{% if configuration.netbox_proxbox.proxmox.http_port %}
<td>{{ configuration.netbox_proxbox.proxmox.http_port }}</td>
{% else %}
<td>{{ default_config.proxmox.http_port }} (default)</td>
{% endif %}
</tr>
<tr>
<th scope="row">Proxmox User</th>
<th scope="row"><strong>Proxmox User</strong></th>
{% if configuration.netbox_proxbox.proxmox.user %}
<td>{{ configuration.netbox_proxbox.proxmox.user }}</td>
{% else %}
<td>{{ default_config.proxmox.user }} (default)</td>
{% endif %}
</tr>
<tr>
<th scope="row">Proxmox Password</th>
<th scope="row"><strong>Proxmox Password</strong></th>
{% if configuration.netbox_proxbox.proxmox.password %}
<td>password defined in configuration.py</td>
{% else %}
<td>{{ default_config.proxmox.password }} (default)</td>
{% endif %}
</tr>
<th scope="row">Token Name</th>
<th scope="row"><strong>Token Name</strong></th>
{% if configuration.netbox_proxbox.proxmox.token.name %}
<td>{{ configuration.netbox_proxbox.proxmox.token.name }}</td>
{% else %}
<td>{{ default_config.proxmox.token.name }} (default)</td>
{% endif %}
</tr>
<th scope="row">Token Value</th>
<th scope="row"><strong>Token Value</strong></th>
{% if configuration.netbox_proxbox.proxmox.token.value %}
<td>{{ configuration.netbox_proxbox.proxmox.token.value }}</td>
{% else %}
<td>{{ default_config.proxmox.token.value }} (default)</td>
{% endif %}
</tr>
</tr>
<th scope="row">SSL</th>
<th scope="row"><strong>SSL</strong></th>
{% if configuration.netbox_proxbox.proxmox.ssl %}
<td>{{ configuration.netbox_proxbox.proxmox.ssl }}</td>
{% else %}
Expand All @@ -88,31 +88,31 @@ <h5 class="card-header">Netbox</h5>
<div class="card-body">
<table class="table table-hover attr-table">
</tr>
<th scope="row">Domain / IP</th>
<th scope="row"><strong>Domain / IP</strong></th>
{% if configuration.netbox_proxbox.netbox.domain %}
<td>{{ configuration.netbox_proxbox.netbox.domain }}</td>
{% else %}
<td>{{ default_config.netbox.domain }} (default)</td>
{% endif %}
</tr>
</tr>
<th scope="row">HTTP Port</th>
<th scope="row"><strong>HTTP Port</strong></th>
{% if configuration.netbox_proxbox.netbox.http_port %}
<td>{{ configuration.netbox_proxbox.netbox.http_port }}</td>
{% else %}
<td>{{ default_config.netbox.http_port }} (default)</td>
{% endif %}
</tr>
</tr>
<th scope="row">Token</th>
<th scope="row"><strong>Token</strong></th>
{% if configuration.netbox_proxbox.netbox.token %}
<td>{{ configuration.netbox_proxbox.netbox.token }}</td>
{% else %}
<td>{{ default_config.netbox.token }} (default)</td>
{% endif %}
</tr>
</tr>
<th scope="row">SSL</th>
<th scope="row"><strong>SSL</strong></th>
{% if configuration.netbox_proxbox.netbox.ssl %}
<td>{{ configuration.netbox_proxbox.netbox.ssl }}</td>
{% else %}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,15 +10,6 @@ <h2>Virtual Machines and Containers</h2>
</div>
</div>
</div>

<h2>Nodes</h2>
<div class="card">
<div class="card-body" id="object-list">
<div class="table-responsive">
{% render_table nodes_table %}
</div>
</div>
</div>
{% endblock %}

{% block footer_links %}
Expand Down
7 changes: 1 addition & 6 deletions netbox_proxbox/views.py
Original file line number Diff line number Diff line change
Expand Up @@ -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):
Expand All @@ -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"]),
},
)

Expand Down
2 changes: 1 addition & 1 deletion pyproject.toml
Original file line number Diff line number Diff line change
@@ -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 <[email protected]>"]
Expand Down
2 changes: 1 addition & 1 deletion setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@

setup(
name="netbox-proxbox",
version="0.0.5-beta1",
version="0.0.5",
author="Emerson Felipe",
author_email="[email protected]",
description="Integration between Proxmox and Netbox",
Expand Down

0 comments on commit bf6b4c1

Please sign in to comment.