Просмотр исходного кода

Merge pull request #6449 from 991jo/device_type_import_fix

Fixed #6438 Device Type Import does not import/export description/label fields for many components
Jeremy Stretch 4 лет назад
Родитель
Сommit
09b856bf0b
3 измененных файлов с 25 добавлено и 8 удалено
  1. 1 0
      docs/release-notes/version-2.11.md
  2. 8 8
      netbox/dcim/forms.py
  3. 16 0
      netbox/dcim/models/devices.py

+ 1 - 0
docs/release-notes/version-2.11.md

@@ -13,6 +13,7 @@
 * [#6376](https://github.com/netbox-community/netbox/issues/6376) - Fix assignment of VLAN groups to clusters, cluster groups via REST API
 * [#6376](https://github.com/netbox-community/netbox/issues/6376) - Fix assignment of VLAN groups to clusters, cluster groups via REST API
 * [#6398](https://github.com/netbox-community/netbox/issues/6398) - Avoid exception when deleting device connected to self via circuit
 * [#6398](https://github.com/netbox-community/netbox/issues/6398) - Avoid exception when deleting device connected to self via circuit
 * [#6426](https://github.com/netbox-community/netbox/issues/6426) - Allow assigning virtual chassis member interfaces to LAG on VC master
 * [#6426](https://github.com/netbox-community/netbox/issues/6426) - Allow assigning virtual chassis member interfaces to LAG on VC master
+* [#6438](https://github.com/netbox-community/netbox/issues/6438) - Fix missing descriptions and label for device type imports and exports
 
 
 ---
 ---
 
 

+ 8 - 8
netbox/dcim/forms.py

@@ -1825,7 +1825,7 @@ class ConsolePortTemplateImportForm(ComponentTemplateImportForm):
     class Meta:
     class Meta:
         model = ConsolePortTemplate
         model = ConsolePortTemplate
         fields = [
         fields = [
-            'device_type', 'name', 'label', 'type',
+            'device_type', 'name', 'label', 'type', 'description',
         ]
         ]
 
 
 
 
@@ -1834,7 +1834,7 @@ class ConsoleServerPortTemplateImportForm(ComponentTemplateImportForm):
     class Meta:
     class Meta:
         model = ConsoleServerPortTemplate
         model = ConsoleServerPortTemplate
         fields = [
         fields = [
-            'device_type', 'name', 'label', 'type',
+            'device_type', 'name', 'label', 'type', 'description',
         ]
         ]
 
 
 
 
@@ -1843,7 +1843,7 @@ class PowerPortTemplateImportForm(ComponentTemplateImportForm):
     class Meta:
     class Meta:
         model = PowerPortTemplate
         model = PowerPortTemplate
         fields = [
         fields = [
-            'device_type', 'name', 'label', 'type', 'maximum_draw', 'allocated_draw',
+            'device_type', 'name', 'label', 'type', 'maximum_draw', 'allocated_draw', 'description',
         ]
         ]
 
 
 
 
@@ -1857,7 +1857,7 @@ class PowerOutletTemplateImportForm(ComponentTemplateImportForm):
     class Meta:
     class Meta:
         model = PowerOutletTemplate
         model = PowerOutletTemplate
         fields = [
         fields = [
-            'device_type', 'name', 'label', 'type', 'power_port', 'feed_leg',
+            'device_type', 'name', 'label', 'type', 'power_port', 'feed_leg', 'description',
         ]
         ]
 
 
 
 
@@ -1869,7 +1869,7 @@ class InterfaceTemplateImportForm(ComponentTemplateImportForm):
     class Meta:
     class Meta:
         model = InterfaceTemplate
         model = InterfaceTemplate
         fields = [
         fields = [
-            'device_type', 'name', 'label', 'type', 'mgmt_only',
+            'device_type', 'name', 'label', 'type', 'mgmt_only', 'description',
         ]
         ]
 
 
 
 
@@ -1886,7 +1886,7 @@ class FrontPortTemplateImportForm(ComponentTemplateImportForm):
     class Meta:
     class Meta:
         model = FrontPortTemplate
         model = FrontPortTemplate
         fields = [
         fields = [
-            'device_type', 'name', 'type', 'rear_port', 'rear_port_position',
+            'device_type', 'name', 'type', 'rear_port', 'rear_port_position', 'label', 'description',
         ]
         ]
 
 
 
 
@@ -1898,7 +1898,7 @@ class RearPortTemplateImportForm(ComponentTemplateImportForm):
     class Meta:
     class Meta:
         model = RearPortTemplate
         model = RearPortTemplate
         fields = [
         fields = [
-            'device_type', 'name', 'type', 'positions',
+            'device_type', 'name', 'type', 'positions', 'label', 'description',
         ]
         ]
 
 
 
 
@@ -1907,7 +1907,7 @@ class DeviceBayTemplateImportForm(ComponentTemplateImportForm):
     class Meta:
     class Meta:
         model = DeviceBayTemplate
         model = DeviceBayTemplate
         fields = [
         fields = [
-            'device_type', 'name',
+            'device_type', 'name', 'label', 'description',
         ]
         ]
 
 
 
 

+ 16 - 0
netbox/dcim/models/devices.py

@@ -183,6 +183,8 @@ class DeviceType(PrimaryModel):
                 {
                 {
                     'name': c.name,
                     'name': c.name,
                     'type': c.type,
                     'type': c.type,
+                    'label': c.label,
+                    'description': c.description,
                 }
                 }
                 for c in self.consoleporttemplates.all()
                 for c in self.consoleporttemplates.all()
             ]
             ]
@@ -191,6 +193,8 @@ class DeviceType(PrimaryModel):
                 {
                 {
                     'name': c.name,
                     'name': c.name,
                     'type': c.type,
                     'type': c.type,
+                    'label': c.label,
+                    'description': c.description,
                 }
                 }
                 for c in self.consoleserverporttemplates.all()
                 for c in self.consoleserverporttemplates.all()
             ]
             ]
@@ -201,6 +205,8 @@ class DeviceType(PrimaryModel):
                     'type': c.type,
                     'type': c.type,
                     'maximum_draw': c.maximum_draw,
                     'maximum_draw': c.maximum_draw,
                     'allocated_draw': c.allocated_draw,
                     'allocated_draw': c.allocated_draw,
+                    'label': c.label,
+                    'description': c.description,
                 }
                 }
                 for c in self.powerporttemplates.all()
                 for c in self.powerporttemplates.all()
             ]
             ]
@@ -211,6 +217,8 @@ class DeviceType(PrimaryModel):
                     'type': c.type,
                     'type': c.type,
                     'power_port': c.power_port.name if c.power_port else None,
                     'power_port': c.power_port.name if c.power_port else None,
                     'feed_leg': c.feed_leg,
                     'feed_leg': c.feed_leg,
+                    'label': c.label,
+                    'description': c.description,
                 }
                 }
                 for c in self.poweroutlettemplates.all()
                 for c in self.poweroutlettemplates.all()
             ]
             ]
@@ -220,6 +228,8 @@ class DeviceType(PrimaryModel):
                     'name': c.name,
                     'name': c.name,
                     'type': c.type,
                     'type': c.type,
                     'mgmt_only': c.mgmt_only,
                     'mgmt_only': c.mgmt_only,
+                    'label': c.label,
+                    'description': c.description,
                 }
                 }
                 for c in self.interfacetemplates.all()
                 for c in self.interfacetemplates.all()
             ]
             ]
@@ -230,6 +240,8 @@ class DeviceType(PrimaryModel):
                     'type': c.type,
                     'type': c.type,
                     'rear_port': c.rear_port.name,
                     'rear_port': c.rear_port.name,
                     'rear_port_position': c.rear_port_position,
                     'rear_port_position': c.rear_port_position,
+                    'label': c.label,
+                    'description': c.description,
                 }
                 }
                 for c in self.frontporttemplates.all()
                 for c in self.frontporttemplates.all()
             ]
             ]
@@ -239,6 +251,8 @@ class DeviceType(PrimaryModel):
                     'name': c.name,
                     'name': c.name,
                     'type': c.type,
                     'type': c.type,
                     'positions': c.positions,
                     'positions': c.positions,
+                    'label': c.label,
+                    'description': c.description,
                 }
                 }
                 for c in self.rearporttemplates.all()
                 for c in self.rearporttemplates.all()
             ]
             ]
@@ -246,6 +260,8 @@ class DeviceType(PrimaryModel):
             data['device-bays'] = [
             data['device-bays'] = [
                 {
                 {
                     'name': c.name,
                     'name': c.name,
+                    'label': c.label,
+                    'description': c.description,
                 }
                 }
                 for c in self.devicebaytemplates.all()
                 for c in self.devicebaytemplates.all()
             ]
             ]