mirror of
https://github.com/netbox-community/netbox.git
synced 2026-04-23 17:28:49 +02:00
This commit is contained in:
committed by
GitHub
parent
a93aae12fa
commit
0bc05f27f9
@@ -549,6 +549,14 @@ class PortTemplateMapping(PortMappingBase):
|
|||||||
self.module_type = self.front_port.module_type
|
self.module_type = self.front_port.module_type
|
||||||
super().save(*args, **kwargs)
|
super().save(*args, **kwargs)
|
||||||
|
|
||||||
|
def to_yaml(self):
|
||||||
|
return {
|
||||||
|
'front_port': self.front_port.name,
|
||||||
|
'front_port_position': self.front_port_position,
|
||||||
|
'rear_port': self.rear_port.name,
|
||||||
|
'rear_port_position': self.rear_port_position,
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
class FrontPortTemplate(ModularComponentTemplateModel):
|
class FrontPortTemplate(ModularComponentTemplateModel):
|
||||||
"""
|
"""
|
||||||
|
|||||||
@@ -275,6 +275,15 @@ class DeviceType(ImageAttachmentsMixin, PrimaryModel, WeightMixin):
|
|||||||
data['rear-ports'] = [
|
data['rear-ports'] = [
|
||||||
c.to_yaml() for c in self.rearporttemplates.all()
|
c.to_yaml() for c in self.rearporttemplates.all()
|
||||||
]
|
]
|
||||||
|
|
||||||
|
# Port mappings
|
||||||
|
port_mapping_data = [
|
||||||
|
c.to_yaml() for c in self.port_mappings.all()
|
||||||
|
]
|
||||||
|
|
||||||
|
if port_mapping_data:
|
||||||
|
data['port-mappings'] = port_mapping_data
|
||||||
|
|
||||||
if self.modulebaytemplates.exists():
|
if self.modulebaytemplates.exists():
|
||||||
data['module-bays'] = [
|
data['module-bays'] = [
|
||||||
c.to_yaml() for c in self.modulebaytemplates.all()
|
c.to_yaml() for c in self.modulebaytemplates.all()
|
||||||
|
|||||||
@@ -192,6 +192,14 @@ class ModuleType(ImageAttachmentsMixin, PrimaryModel, WeightMixin):
|
|||||||
c.to_yaml() for c in self.rearporttemplates.all()
|
c.to_yaml() for c in self.rearporttemplates.all()
|
||||||
]
|
]
|
||||||
|
|
||||||
|
# Port mappings
|
||||||
|
port_mapping_data = [
|
||||||
|
c.to_yaml() for c in self.port_mappings.all()
|
||||||
|
]
|
||||||
|
|
||||||
|
if port_mapping_data:
|
||||||
|
data['port-mappings'] = port_mapping_data
|
||||||
|
|
||||||
return yaml.dump(dict(data), sort_keys=False)
|
return yaml.dump(dict(data), sort_keys=False)
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user