Skip to content

Commit

Permalink
Merge pull request #220 from netdevopsbr/improve-gui
Browse files Browse the repository at this point in the history
Minor updates to GUI and improve package organization
  • Loading branch information
emersonfelipesp authored Jan 2, 2025
2 parents f8715ba + 7dffd4e commit 5bdc41b
Show file tree
Hide file tree
Showing 24 changed files with 1,534 additions and 824 deletions.
142 changes: 142 additions & 0 deletions netbox_proxbox/backend/routes/netbox/generic/bootstrap.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,142 @@
# TODO: Create Default Custom Fields
from netbox_proxbox.backend.session.netbox import NetboxSessionDep
from netbox_proxbox.backend.logging import log

from fastapi import WebSocket

async def create_default_custom_fields(
nb: NetboxSessionDep,
websocket: WebSocket,
custom_field: str,
):
if custom_field == "proxmox_vm_id":
custom_field_id = nb.session.extras.custom_fields.create(
{
"object_types": [
"virtualization.virtualmachine"
],
"type": "integer",
"name": "proxmox_vm_id",
"label": "VM ID",
"description": "Proxmox Virtual Machine or Container ID",
"ui_visible": "always",
"ui_editable": "hidden",
"weight": 100,
"filter_logic": "loose",
"search_weight": 1000,
"group_name": "Proxmox"
}
)

if custom_field_id:
print(f"Custom Field Created: {custom_field_id}")
return custom_field_id

if custom_field == "proxmox_start_at_boot":
start_at_boot_field = nb.session.extras.custom_fields.create(
{
"object_types": [
"virtualization.virtualmachine"
],
"type": "boolean",
"name": "proxmox_start_at_boot",
"label": "Start at Boot",
"description": "Proxmox Start at Boot Option",
"ui_visible": "always",
"ui_editable": "hidden",
"weight": 100,
"filter_logic": "loose",
"search_weight": 1000,
"group_name": "Proxmox"
}
)

if start_at_boot_field:
print(f"Custom Field Created: {start_at_boot_field}")
return start_at_boot_field

if custom_field == "proxmox_unprivileged_container":
start_unprivileged_field = nb.session.extras.custom_fields.create(
{
"object_types": [
"virtualization.virtualmachine"
],
"type": "boolean",
"name": "proxmox_unprivileged_container",
"label": "Unprivileged Container",
"description": "Proxmox Unprivileged Container",
"ui_visible": "if-set",
"ui_editable": "hidden",
"weight": 100,
"filter_logic": "loose",
"search_weight": 1000,
"group_name": "Proxmox"
}
)

if start_unprivileged_field:
print(f"Custom Field Created: {start_unprivileged_field}")
return start_unprivileged_field

if custom_field == "proxmox_qemu_agent":
start_qemu_agent_field = nb.session.extras.custom_fields.create(
{
"object_types": [
"virtualization.virtualmachine"
],
"type": "boolean",
"name": "proxmox_qemu_agent",
"label": "QEMU Guest Agent",
"description": "Proxmox QEMU Guest Agent",
"ui_visible": "if-set",
"ui_editable": "hidden",
"weight": 100,
"filter_logic": "loose",
"search_weight": 1000,
"group_name": "Proxmox"
}
)

if start_qemu_agent_field:
print(f"Custom Field Created: {start_qemu_agent_field}")
return start_qemu_agent_field

if custom_field == "proxmox_search_domain":
search_domain_field = nb.session.extras.custom_fields.create(
{
"object_types": [
"virtualization.virtualmachine"
],
"type": "text",
"name": "proxmox_search_domain",
"label": "Search Domain",
"description": "Proxmox Search Domain",
"ui_visible": "if-set",
"ui_editable": "hidden",
"weight": 100,
"filter_logic": "loose",
"search_weight": 1000,
"group_name": "Proxmox"
}
)

if search_domain_field:
print(f"Custom Field Created: {search_domain_field}")
return search_domain_field

return None

# TODO: Create Default Objects
async def create_default_objects():
# Create Default Sites

# Create Default Device Types

# Create Default Device Roles

# Create Default Cluster Types

# Create Default Clusters

# Create Default Devices
pass
Loading

0 comments on commit 5bdc41b

Please sign in to comment.