From 79089cc47e466a1c8f206c1b654885e44e5a9893 Mon Sep 17 00:00:00 2001 From: Jeremy Stretch Date: Wed, 3 May 2017 15:41:36 -0400 Subject: [PATCH] Introduced an object import template --- netbox/templates/circuits/circuit_import.html | 117 ++++++-------- .../templates/circuits/provider_import.html | 97 +++++------- .../dcim/console_connections_import.html | 98 +++++------- netbox/templates/dcim/device_import.html | 8 +- .../templates/dcim/device_import_child.html | 8 +- .../dcim/interface_connections_import.html | 106 +++++-------- .../dcim/power_connections_import.html | 98 +++++------- netbox/templates/dcim/rack_import.html | 147 ++++++++---------- netbox/templates/ipam/aggregate_import.html | 87 +++++------ netbox/templates/ipam/ipaddress_import.html | 127 +++++++-------- netbox/templates/ipam/prefix_import.html | 147 ++++++++---------- netbox/templates/ipam/vlan_import.html | 127 +++++++-------- netbox/templates/ipam/vrf_import.html | 97 +++++------- netbox/templates/secrets/secret_import.html | 12 +- netbox/templates/tenancy/tenant_import.html | 87 +++++------ netbox/templates/utilities/obj_import.html | 34 ++++ 16 files changed, 626 insertions(+), 771 deletions(-) create mode 100644 netbox/templates/utilities/obj_import.html diff --git a/netbox/templates/circuits/circuit_import.html b/netbox/templates/circuits/circuit_import.html index e2fc9fa36..991a99c9b 100644 --- a/netbox/templates/circuits/circuit_import.html +++ b/netbox/templates/circuits/circuit_import.html @@ -1,72 +1,57 @@ -{% extends '_base.html' %} +{% extends 'utilities/obj_import.html' %} {% load render_table from django_tables2 %} {% load form_helpers %} {% block title %}Circuit Import{% endblock %} -{% block content %} -

Circuit Import

-
-
-
- {% csrf_token %} - {% render_form form %} -
- - Cancel -
-
-
-
-

CSV Format

- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
FieldDescriptionExample
Circuit IDAlphanumeric circuit identifierIC-603122
ProviderName of circuit providerTeliaSonera
TypeCircuit typeTransit
TenantName of tenant (optional)Strickland Propane
Install DateDate in YYYY-MM-DD format (optional)2016-02-23
Commit rateCommited rate in Kbps (optional)2000
DescriptionShort description (optional)Primary for voice
-

Example

-
IC-603122,TeliaSonera,Transit,Strickland Propane,2016-02-23,2000,Primary for voice
-
-
+{% block instructions %} +

CSV Format

+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
FieldDescriptionExample
Circuit IDAlphanumeric circuit identifierIC-603122
ProviderName of circuit providerTeliaSonera
TypeCircuit typeTransit
TenantName of tenant (optional)Strickland Propane
Install DateDate in YYYY-MM-DD format (optional)2016-02-23
Commit rateCommited rate in Kbps (optional)2000
DescriptionShort description (optional)Primary for voice
+

Example

+
IC-603122,TeliaSonera,Transit,Strickland Propane,2016-02-23,2000,Primary for voice
{% endblock %} diff --git a/netbox/templates/circuits/provider_import.html b/netbox/templates/circuits/provider_import.html index a605164df..e60ee3e76 100644 --- a/netbox/templates/circuits/provider_import.html +++ b/netbox/templates/circuits/provider_import.html @@ -1,62 +1,47 @@ -{% extends '_base.html' %} +{% extends 'utilities/obj_import.html' %} {% load render_table from django_tables2 %} {% load form_helpers %} {% block title %}Provider Import{% endblock %} -{% block content %} -

Provider Import

-
-
-
- {% csrf_token %} - {% render_form form %} -
- - Cancel -
-
-
-
-

CSV Format

- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
FieldDescriptionExample
NameProvider's proper nameLevel 3
SlugURL-friendly namelevel3
ASNAutonomous system number (optional)3356
AccountAccount number (optional)08931544
Portal URLCustomer service portal URL (optional)https://mylevel3.net
-

Example

-
Level 3,level3,3356,08931544,https://mylevel3.net
-
-
+{% block instructions %} +

CSV Format

+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
FieldDescriptionExample
NameProvider's proper nameLevel 3
SlugURL-friendly namelevel3
ASNAutonomous system number (optional)3356
AccountAccount number (optional)08931544
Portal URLCustomer service portal URL (optional)https://mylevel3.net
+

Example

+
Level 3,level3,3356,08931544,https://mylevel3.net
{% endblock %} diff --git a/netbox/templates/dcim/console_connections_import.html b/netbox/templates/dcim/console_connections_import.html index 31d24e58f..c7308168b 100644 --- a/netbox/templates/dcim/console_connections_import.html +++ b/netbox/templates/dcim/console_connections_import.html @@ -1,63 +1,47 @@ -{% extends '_base.html' %} +{% extends 'utilities/obj_import.html' %} {% load render_table from django_tables2 %} {% load form_helpers %} {% block title %}Console Connections Import{% endblock %} -{% block content %} -

Console Connections Import

-
-
-
- {% csrf_token %} - {% render_form form %} -
-
- -
-
-
-
-
-

CSV Format

- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
FieldDescriptionExample
Console serverDevice name or {ID}abc1-cs3
Console server portFull CS port namePort 35
DeviceDevice name or {ID}abc1-switch7
Console PortConsole port nameConsole
Connection Status"planned" or "connected"planned
-

Example

-
abc1-cs3,Port 35,abc1-switch7,Console,planned
-
-
+{% block instructions %} +

CSV Format

+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
FieldDescriptionExample
Console serverDevice name or {ID}abc1-cs3
Console server portFull CS port namePort 35
DeviceDevice name or {ID}abc1-switch7
Console PortConsole port nameConsole
Connection Status"planned" or "connected"planned
+

Example

+
abc1-cs3,Port 35,abc1-switch7,Console,planned
{% endblock %} diff --git a/netbox/templates/dcim/device_import.html b/netbox/templates/dcim/device_import.html index 50d2f81db..83d0d2195 100644 --- a/netbox/templates/dcim/device_import.html +++ b/netbox/templates/dcim/device_import.html @@ -12,8 +12,12 @@ {% csrf_token %} {% render_form form %}
- - Cancel +
+ + {% if return_url %} + Cancel + {% endif %} +

CSV Format

diff --git a/netbox/templates/dcim/device_import_child.html b/netbox/templates/dcim/device_import_child.html index ca69d7aa5..49433686f 100644 --- a/netbox/templates/dcim/device_import_child.html +++ b/netbox/templates/dcim/device_import_child.html @@ -12,8 +12,12 @@ {% csrf_token %} {% render_form form %}
- - Cancel +
+ + {% if return_url %} + Cancel + {% endif %} +

CSV Format

diff --git a/netbox/templates/dcim/interface_connections_import.html b/netbox/templates/dcim/interface_connections_import.html index 9868a7b55..eab0acdba 100644 --- a/netbox/templates/dcim/interface_connections_import.html +++ b/netbox/templates/dcim/interface_connections_import.html @@ -1,71 +1,47 @@ -{% extends '_base.html' %} +{% extends 'utilities/obj_import.html' %} {% load render_table from django_tables2 %} {% load form_helpers %} {% block title %}Interface Connections Import{% endblock %} -{% block content %} -

Interface Connections Import

-
-
- {% if form.non_field_errors %} -
-
Errors
-
- {{ form.non_field_errors }} -
-
- {% endif %} -
- {% csrf_token %} - {% render_form form %} -
-
- -
-
-
-
-
-

CSV Format

- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
FieldDescriptionExample
Device ADevice name or {ID}abc1-core1
Interface AInterface namexe-0/0/6
Device BDevice name or {ID}abc1-switch7
Interface BInterface namexe-0/0/0
Connection Status"planned" or "connected"planned
-

Example

-
abc1-core1,xe-0/0/6,abc1-switch7,xe-0/0/0,planned
-
-
+{% block instructions %} +

CSV Format

+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
FieldDescriptionExample
Device ADevice name or {ID}abc1-core1
Interface AInterface namexe-0/0/6
Device BDevice name or {ID}abc1-switch7
Interface BInterface namexe-0/0/0
Connection Status"planned" or "connected"planned
+

Example

+
abc1-core1,xe-0/0/6,abc1-switch7,xe-0/0/0,planned
{% endblock %} diff --git a/netbox/templates/dcim/power_connections_import.html b/netbox/templates/dcim/power_connections_import.html index 606694a8d..56f34c456 100644 --- a/netbox/templates/dcim/power_connections_import.html +++ b/netbox/templates/dcim/power_connections_import.html @@ -1,63 +1,47 @@ -{% extends '_base.html' %} +{% extends 'utilities/obj_import.html' %} {% load render_table from django_tables2 %} {% load form_helpers %} {% block title %}Power Connections Import{% endblock %} -{% block content %} -

Power Connections Import

-
-
-
- {% csrf_token %} - {% render_form form %} -
-
- -
-
-
-
-
-

CSV Format

- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
FieldDescriptionExample
PDUDevice name or {ID}abc1-pdu1
Power OutletPower outlet nameAC4
DeviceDevice name or {ID}abc1-switch7
Power PortPower port namePSU0
Connection Status"planned" or "connected"connected
-

Example

-
abc1-pdu1,AC4,abc1-switch7,PSU0,connected
-
-
+{% block instructions %} +

CSV Format

+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
FieldDescriptionExample
PDUDevice name or {ID}abc1-pdu1
Power OutletPower outlet nameAC4
DeviceDevice name or {ID}abc1-switch7
Power PortPower port namePSU0
Connection Status"planned" or "connected"connected
+

Example

+
abc1-pdu1,AC4,abc1-switch7,PSU0,connected
{% endblock %} diff --git a/netbox/templates/dcim/rack_import.html b/netbox/templates/dcim/rack_import.html index c462a0be9..207fcfcab 100644 --- a/netbox/templates/dcim/rack_import.html +++ b/netbox/templates/dcim/rack_import.html @@ -1,87 +1,72 @@ -{% extends '_base.html' %} +{% extends 'utilities/obj_import.html' %} {% load render_table from django_tables2 %} {% load form_helpers %} {% block title %}Rack Import{% endblock %} -{% block content %} -

Rack Import

-
-
-
- {% csrf_token %} - {% render_form form %} -
- - Cancel -
-
-
-
-

CSV Format

- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
FieldDescriptionExample
SiteName of the assigned siteDC-4
GroupRack group name (optional)Cage 1400
NameInternal rack nameR101
Facility IDRack ID assigned by the facility (optional)J12.100
TenantName of tenant (optional)Pied Piper
RoleFunctional role (optional)Compute
TypeRack type (optional)4-post cabinet
WidthRail-to-rail width (19 or 23 inches)19
HeightHeight in rack units42
Descending unitsUnits are numbered top-to-bottomFalse
-

Example

-
DC-4,Cage 1400,R101,J12.100,Pied Piper,Compute,4-post cabinet,19,42,False
-
-
+{% block instructions %} +

CSV Format

+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
FieldDescriptionExample
SiteName of the assigned siteDC-4
GroupRack group name (optional)Cage 1400
NameInternal rack nameR101
Facility IDRack ID assigned by the facility (optional)J12.100
TenantName of tenant (optional)Pied Piper
RoleFunctional role (optional)Compute
TypeRack type (optional)4-post cabinet
WidthRail-to-rail width (19 or 23 inches)19
HeightHeight in rack units42
Descending unitsUnits are numbered top-to-bottomFalse
+

Example

+
DC-4,Cage 1400,R101,J12.100,Pied Piper,Compute,4-post cabinet,19,42,False
{% endblock %} diff --git a/netbox/templates/ipam/aggregate_import.html b/netbox/templates/ipam/aggregate_import.html index 8075b4874..1f0a50feb 100644 --- a/netbox/templates/ipam/aggregate_import.html +++ b/netbox/templates/ipam/aggregate_import.html @@ -1,57 +1,42 @@ -{% extends '_base.html' %} +{% extends 'utilities/obj_import.html' %} {% load render_table from django_tables2 %} {% load form_helpers %} {% block title %}Aggregate Import{% endblock %} -{% block content %} -

Aggregate Import

-
-
-
- {% csrf_token %} - {% render_form form %} -
- - Cancel -
-
-
-
-

CSV Format

- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
FieldDescriptionExample
PrefixIPv4 or IPv6 network172.16.0.0/12
RIRName of RIRRFC 1918
Date AddedDate in YYYY-MM-DD format (optional)2016-02-23
DescriptionShort description (optional)Private IPv4 space
-

Example

-
172.16.0.0/12,RFC 1918,2016-02-23,Private IPv4 space
-
-
+{% block instructions %} +

CSV Format

+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
FieldDescriptionExample
PrefixIPv4 or IPv6 network172.16.0.0/12
RIRName of RIRRFC 1918
Date AddedDate in YYYY-MM-DD format (optional)2016-02-23
DescriptionShort description (optional)Private IPv4 space
+

Example

+
172.16.0.0/12,RFC 1918,2016-02-23,Private IPv4 space
{% endblock %} diff --git a/netbox/templates/ipam/ipaddress_import.html b/netbox/templates/ipam/ipaddress_import.html index 3c01b4af0..362f64829 100644 --- a/netbox/templates/ipam/ipaddress_import.html +++ b/netbox/templates/ipam/ipaddress_import.html @@ -1,77 +1,62 @@ -{% extends '_base.html' %} +{% extends 'utilities/obj_import.html' %} {% load render_table from django_tables2 %} {% load form_helpers %} {% block title %}IP Address Import{% endblock %} -{% block content %} -

IP Address Import

-
-
-
- {% csrf_token %} - {% render_form form %} -
- - Cancel -
-
-
-
-

CSV Format

- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
FieldDescriptionExample
AddressIPv4 or IPv6 address192.0.2.42/24
VRFVRF route distinguisher (optional)65000:123
TenantName of tenant (optional)ABC01
StatusCurrent statusActive
DeviceDevice name (optional)switch12
InterfaceInterface name (optional)ge-0/0/31
Is PrimaryIf "true", IP will be primary for device (optional)True
DescriptionShort description (optional)Management IP
-

Example

-
192.0.2.42/24,65000:123,ABC01,Active,switch12,ge-0/0/31,True,Management IP
-
-
+{% block instructions %} +

CSV Format

+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
FieldDescriptionExample
AddressIPv4 or IPv6 address192.0.2.42/24
VRFVRF route distinguisher (optional)65000:123
TenantName of tenant (optional)ABC01
StatusCurrent statusActive
DeviceDevice name (optional)switch12
InterfaceInterface name (optional)ge-0/0/31
Is PrimaryIf "true", IP will be primary for device (optional)True
DescriptionShort description (optional)Management IP
+

Example

+
192.0.2.42/24,65000:123,ABC01,Active,switch12,ge-0/0/31,True,Management IP
{% endblock %} diff --git a/netbox/templates/ipam/prefix_import.html b/netbox/templates/ipam/prefix_import.html index 0a9cc8694..b9aa7ff47 100644 --- a/netbox/templates/ipam/prefix_import.html +++ b/netbox/templates/ipam/prefix_import.html @@ -1,87 +1,72 @@ -{% extends '_base.html' %} +{% extends 'utilities/obj_import.html' %} {% load render_table from django_tables2 %} {% load form_helpers %} {% block title %}Prefix Import{% endblock %} -{% block content %} -

Prefix Import

-
-
-
- {% csrf_token %} - {% render_form form %} -
- - Cancel -
-
-
-
-

CSV Format

- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
FieldDescriptionExample
PrefixIPv4 or IPv6 network192.168.42.0/24
VRFVRF route distinguisher (optional)65000:123
TenantName of tenant (optional)ABC01
SiteName of assigned site (optional)HQ
VLAN GroupName of group for VLAN selection (optional)Customers
VLAN IDNumeric VLAN ID (optional)801
StatusCurrent statusActive
RoleFunctional role (optional)Customer
Is a poolTrue if all IPs are considered usableFalse
DescriptionShort description (optional)7th floor WiFi
-

Example

-
192.168.42.0/24,65000:123,ABC01,HQ,Customers,801,Active,Customer,False,7th floor WiFi
-
-
+{% block instructions %} +

CSV Format

+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
FieldDescriptionExample
PrefixIPv4 or IPv6 network192.168.42.0/24
VRFVRF route distinguisher (optional)65000:123
TenantName of tenant (optional)ABC01
SiteName of assigned site (optional)HQ
VLAN GroupName of group for VLAN selection (optional)Customers
VLAN IDNumeric VLAN ID (optional)801
StatusCurrent statusActive
RoleFunctional role (optional)Customer
Is a poolTrue if all IPs are considered usableFalse
DescriptionShort description (optional)7th floor WiFi
+

Example

+
192.168.42.0/24,65000:123,ABC01,HQ,Customers,801,Active,Customer,False,7th floor WiFi
{% endblock %} diff --git a/netbox/templates/ipam/vlan_import.html b/netbox/templates/ipam/vlan_import.html index 16456ba01..8d1741fd4 100644 --- a/netbox/templates/ipam/vlan_import.html +++ b/netbox/templates/ipam/vlan_import.html @@ -1,77 +1,62 @@ -{% extends '_base.html' %} +{% extends 'utilities/obj_import.html' %} {% load render_table from django_tables2 %} {% load form_helpers %} {% block title %}VLAN Import{% endblock %} -{% block content %} -

VLAN Import

-
-
-
- {% csrf_token %} - {% render_form form %} -
- - Cancel -
-
-
-
-

CSV Format

- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
FieldDescriptionExample
SiteName of assigned siteLAS2
GroupName of VLAN group (optional)Backend Network
IDConfigured VLAN ID1400
NameConfigured VLAN nameCameras
TenantName of tenant (optional)Internal
StatusCurrent statusActive
RoleFunctional role (optional)Security
DescriptionShort description (optional)Security team only
-

Example

-
LAS2,Backend Network,1400,Cameras,Internal,Active,Security,Security team only
-
-
+{% block instructions %} +

CSV Format

+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
FieldDescriptionExample
SiteName of assigned siteLAS2
GroupName of VLAN group (optional)Backend Network
IDConfigured VLAN ID1400
NameConfigured VLAN nameCameras
TenantName of tenant (optional)Internal
StatusCurrent statusActive
RoleFunctional role (optional)Security
DescriptionShort description (optional)Security team only
+

Example

+
LAS2,Backend Network,1400,Cameras,Internal,Active,Security,Security team only
{% endblock %} diff --git a/netbox/templates/ipam/vrf_import.html b/netbox/templates/ipam/vrf_import.html index 9953542d2..0a1a31205 100644 --- a/netbox/templates/ipam/vrf_import.html +++ b/netbox/templates/ipam/vrf_import.html @@ -1,62 +1,47 @@ -{% extends '_base.html' %} +{% extends 'utilities/obj_import.html' %} {% load render_table from django_tables2 %} {% load form_helpers %} {% block title %}VRF Import{% endblock %} -{% block content %} -

VRF Import

-
-
-
- {% csrf_token %} - {% render_form form %} -
- - Cancel -
-
-
-
-

CSV Format

- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
FieldDescriptionExample
NameName of VRFCustomer_ABC
RDRoute distinguisher65000:123456
TenantName of tenant (optional)ABC01
Enforce uniquenessPrevent duplicate prefixes/IP addressesTrue
DescriptionShort description (optional)Native VRF for customer ABC
-

Example

-
Customer_ABC,65000:123456,ABC01,True,Native VRF for customer ABC
-
-
+{% block instructions %} +

CSV Format

+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
FieldDescriptionExample
NameName of VRFCustomer_ABC
RDRoute distinguisher65000:123456
TenantName of tenant (optional)ABC01
Enforce uniquenessPrevent duplicate prefixes/IP addressesTrue
DescriptionShort description (optional)Native VRF for customer ABC
+

Example

+
Customer_ABC,65000:123456,ABC01,True,Native VRF for customer ABC
{% endblock %} diff --git a/netbox/templates/secrets/secret_import.html b/netbox/templates/secrets/secret_import.html index 0a9a11c69..ac45861e2 100644 --- a/netbox/templates/secrets/secret_import.html +++ b/netbox/templates/secrets/secret_import.html @@ -20,10 +20,14 @@
{% csrf_token %} {% render_form form %} -
- - Cancel -
+
+
+ + {% if return_url %} + Cancel + {% endif %} +
+
diff --git a/netbox/templates/tenancy/tenant_import.html b/netbox/templates/tenancy/tenant_import.html index 81f82989f..c0e94269a 100644 --- a/netbox/templates/tenancy/tenant_import.html +++ b/netbox/templates/tenancy/tenant_import.html @@ -1,57 +1,42 @@ -{% extends '_base.html' %} +{% extends 'utilities/obj_import.html' %} {% load render_table from django_tables2 %} {% load form_helpers %} {% block title %}Tenant Import{% endblock %} -{% block content %} -

Tenant Import

-
-
-
- {% csrf_token %} - {% render_form form %} -
- - Cancel -
-
-
-
-

CSV Format

- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
FieldDescriptionExample
NameTenant nameWIDG01
SlugURL-friendly namewidg01
GroupTenant group (optional)Customers
DescriptionLong-form name or other text (optional)Widgets Inc.
-

Example

-
WIDG01,widg01,Customers,Widgets Inc.
-
-
+{% block instructions %} +

CSV Format

+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
FieldDescriptionExample
NameTenant nameWIDG01
SlugURL-friendly namewidg01
GroupTenant group (optional)Customers
DescriptionLong-form name or other text (optional)Widgets Inc.
+

Example

+
WIDG01,widg01,Customers,Widgets Inc.
{% endblock %} diff --git a/netbox/templates/utilities/obj_import.html b/netbox/templates/utilities/obj_import.html new file mode 100644 index 000000000..bea9a2319 --- /dev/null +++ b/netbox/templates/utilities/obj_import.html @@ -0,0 +1,34 @@ +{% extends '_base.html' %} +{% load render_table from django_tables2 %} +{% load form_helpers %} + +{% block content %} +

{% block title %}{% endblock %}

+
+
+ {% if form.non_field_errors %} +
+
Errors
+
+ {{ form.non_field_errors }} +
+
+ {% endif %} +
+ {% csrf_token %} + {% render_form form %} +
+
+ + {% if return_url %} + Cancel + {% endif %} +
+
+
+
+
+ {% block instructions %}{% endblock %} +
+
+{% endblock %}