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

[WIP] feat: ✨ add views for discovered objects #222

Open
wants to merge 7 commits into
base: ten-year-anniversary-hackathon
Choose a base branch
from
Open
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
4 changes: 3 additions & 1 deletion nautobot_device_onboarding/jobs.py
Original file line number Diff line number Diff line change
Expand Up @@ -789,7 +789,7 @@ def run(
_discovered_ips = DiscoveredIPAddress.objects.filter(
discovered_group=discovered_group, marked_for_onboarding=True
).values_list("ip_address", flat=True)
self.ip_addresses = [ip for ip in _discovered_ips]
self.ip_addresses = [str(IPAddress.objects.get(id=ip).address) for ip in _discovered_ips]
self.set_mgmt_only = set_mgmt_only
self.update_devices_without_primary_ip = update_devices_without_primary_ip
self.device_role = device_role
Expand All @@ -801,6 +801,8 @@ def run(
self.secrets_group = secrets_group
self.platform = platform

self.logger.info(f"IP Addresses: {self.ip_addresses}")

self.job_result.task_kwargs = {
"debug": debug,
"location": location,
Expand Down
2 changes: 1 addition & 1 deletion nautobot_device_onboarding/navigation.py
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@

menu_items = (
NavMenuTab(
name="Discovered Network",
name="Device Onboarding",
weight=1000,
groups=(NavMenuGroup(name="Discovered Models", weight=100, items=items),),
),
Expand Down
4 changes: 1 addition & 3 deletions nautobot_device_onboarding/tables.py
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,7 @@ class DiscoveredIPAddressTable(BaseTable):
extra_info = JSONExpandColumn()

class Meta(BaseTable.Meta):
"""Meta."""
"""Meta options."""

model = DiscoveredIPAddress
fields = ("pk", "name", "discovered_group", "ip_address", "marked_for_onboarding", "extra_info")
Expand All @@ -73,8 +73,6 @@ class DiscoveredPortTable(BaseTable):
state = tables.Column()

class Meta(BaseTable.Meta):
"""Meta."""

model = DiscoveredPort
fields = ("pk", "port_id", "discovered_ip_address", "protocol", "state", "service", "reason", "reason_ttl")
default_columns = (
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
{% extends 'generic/object_detail.html' %}
{% load static %}
{% block content_left_page %}
<div class="panel panel-default">
<div class="panel-heading">
<strong>Discovered Group</strong>
</div>
<h1>{{ object.name }}</h1>
<p>{{ object.description }}</p>
<h2>Associated IP Addresses</h2>
<ul>
{% for ip_address in object.discoveredipaddress_set.all %}
<li>{{ ip_address.ip_address }}</li>
{% endfor %}
</ul>
</div>
{% endblock %}
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
{% extends 'generic/object_detail.html' %}
{% load static %}
{% block content_left_page %}
<div class="panel panel-default">
<div class="panel-heading">
<strong>Discovered IP Address</strong>
</div>
<h1>{{ object.ip_address }}</h1>
<p>Marked for onboarding: {{ object.marked_for_onboarding }}</p>
<h2>Extra Info</h2>
<pre>{{ object.extra_info|default_if_none:"No extra information available" }}</pre>
<!-- Add more fields as necessary -->
</div>
{% endblock %}
7 changes: 6 additions & 1 deletion nautobot_device_onboarding/urls.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
"""Urls."""

from django.urls import path

from nautobot.core.views.routers import NautobotUIViewSetRouter

from . import views
Expand All @@ -11,4 +13,7 @@
router.register("discovered-ipaddresses", views.DiscoveredIPAddressUIViewSet)
router.register("discovered-ports", views.DiscoveredPortUIViewSet)

urlpatterns = router.urls
urlpatterns = [
path("discovered-groups/<uuid:pk>/", views.DiscoveredGroupView.as_view(), name="discoveredgroup-detail"),
path("discovered-ipaddresses/<uuid:pk>/", views.DiscoveredIPAddressView.as_view(), name="discoveredipaddress-detail"),
] + router.urls
2 changes: 2 additions & 0 deletions nautobot_device_onboarding/views.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
"""Model UI Viewset."""

from nautobot.core.views import generic
from nautobot.core.views.viewsets import NautobotUIViewSet
from nautobot.core.views.generic import ObjectView

from . import filters, forms, tables
from .api import serializers
Expand Down
Loading