Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closes #49 - Add new views to Plugin replicating Folder View from Proxmox GUI #50

Draft
wants to merge 2 commits into
base: develop
Choose a base branch
from
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
16 changes: 16 additions & 0 deletions netbox_proxbox/navigation.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,22 @@
link="plugins:netbox_proxbox:home",
link_text="Home",
),
PluginMenuItem(
link="plugins:netbox_proxbox:nodes",
link_text="Nodes",
),
PluginMenuItem(
link="plugins:netbox_proxbox:lxc",
link_text="LXC Container",
),
PluginMenuItem(
link="plugins:netbox_proxbox:virtual_machine",
link_text="Virtual Machine",
),
PluginMenuItem(
link="plugins:netbox_proxbox:storage",
link_text="Storage",
),
)

'''
Expand Down
31 changes: 14 additions & 17 deletions netbox_proxbox/urls.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,34 +2,31 @@
from django.http import HttpResponse
from django.urls import path

from .views import (
HomeView,
ProxmoxVMCreateView,
ProxmoxVMDeleteView,
ProxmoxVMEditView,
ProxmoxVMListView,
ProxmoxVMView,
ProxmoxFullUpdate,
)
from . import views

from netbox_proxbox import proxbox_api
import json

urlpatterns = [
# Home View
path('', HomeView.as_view(), name='home'),

path('', views.HomeView.as_view(), name='home'),
path('lxc/', views.LxcListView.as_view(), name='lxc'),
path('nodes/', views.NodesListView.as_view(), name='nodes'),
path('resource-pool/', views.ResourcePoolListView.as_view(), name='resource_pool'),
path('virtual-machine/', views.VirtualMachineListView.as_view(), name='virtual_machine'),
path('storage/', views.StorageListView.as_view(), name='storage'),

# Base Views
path("list/", ProxmoxVMListView.as_view(), name="proxmoxvm_list"),
path("list/", views.ProxmoxVMListView.as_view(), name="proxmoxvm_list"),
# <int:pk> = plugins/netbox_proxmoxvm/<pk> | example: plugins/netbox_proxmoxvm/1/
# ProxmoxVMView.as_view() - as.view() is need so that our view class can process requests.
# as_view() takes request and returns well-formed response, that is a class based view.
path("<int:pk>/", ProxmoxVMView.as_view(), name="proxmoxvm"),
path("add/", ProxmoxVMCreateView.as_view(), name="proxmoxvm_add"),
path("<int:pk>/delete/", ProxmoxVMDeleteView.as_view(), name="proxmoxvm_delete"),
path("<int:pk>/edit/", ProxmoxVMEditView.as_view(), name="proxmoxvm_edit"),
path("<int:pk>/", views.ProxmoxVMView.as_view(), name="proxmoxvm"),
path("add/", views.ProxmoxVMCreateView.as_view(), name="proxmoxvm_add"),
path("<int:pk>/delete/", views.ProxmoxVMDeleteView.as_view(), name="proxmoxvm_delete"),
path("<int:pk>/edit/", views.ProxmoxVMEditView.as_view(), name="proxmoxvm_edit"),

# Proxbox API full update
#path("full_update/", ProxmoxVMFullUpdate.as_view(), name="proxmoxvm_full_update")
path("full_update/", ProxmoxFullUpdate.as_view(), name="proxmoxvm_full_update")
path("full_update/", views.ProxmoxFullUpdate.as_view(), name="proxmoxvm_full_update")
]
64 changes: 64 additions & 0 deletions netbox_proxbox/views.py
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,70 @@ def get(self, request):
)


class LxcListView(View):
"""LXC Container's List"""
template_name = 'netbox_proxbox/home.html'

# service incoming GET HTTP requests
def get(self, request):
"""Get request."""
return render(
request,
self.template_name,
)


class NodesListView(View):
"""Nodes' List"""
template_name = 'netbox_proxbox/home.html'

# service incoming GET HTTP requests
def get(self, request):
"""Get request."""
return render(
request,
self.template_name,
)


class ResourcePoolListView(View):
"""Resource Pool's List"""
template_name = 'netbox_proxbox/home.html'

# service incoming GET HTTP requests
def get(self, request):
"""Get request."""
return render(
request,
self.template_name,
)


class VirtualMachineListView(View):
"""Virtual Machine's List"""
template_name = 'netbox_proxbox/home.html'

# service incoming GET HTTP requests
def get(self, request):
"""Get request."""
return render(
request,
self.template_name,
)


class StorageListView(View):
"""Storage's List"""
template_name = 'netbox_proxbox/home.html'

# service incoming GET HTTP requests
def get(self, request):
"""Get request."""
return render(
request,
self.template_name,
)

class ProxmoxFullUpdate(PermissionRequiredMixin, View):
"""Full Update of Proxmox information on Netbox."""

Expand Down