diff --git a/.gitignore b/.gitignore index cbb9133b..4a639353 100644 --- a/.gitignore +++ b/.gitignore @@ -56,6 +56,7 @@ coverage.xml *.py,cover .hypothesis/ .pytest_cache/ +lcov.info # Translations *.mo @@ -305,4 +306,4 @@ invoke.yml # Docs docs/README.md docs/CHANGELOG.md -public +public \ No newline at end of file diff --git a/examples/backbone_design/designs/edge_site/__init__.py b/examples/backbone_design/designs/edge_site/__init__.py new file mode 100644 index 00000000..e69de29b diff --git a/examples/backbone_design/designs/edge_site/context/__init__.py b/examples/backbone_design/designs/edge_site/context/__init__.py new file mode 100644 index 00000000..72e1f55e --- /dev/null +++ b/examples/backbone_design/designs/edge_site/context/__init__.py @@ -0,0 +1,7 @@ +"""This module contains the render context for the basic design.""" +from nautobot_design_builder.context import Context, context_file + + +@context_file("context.yaml") +class EdgeDesignContext(Context): + """Render context for basic design.""" diff --git a/examples/backbone_design/designs/edge_site/context/context.yaml b/examples/backbone_design/designs/edge_site/context/context.yaml new file mode 100644 index 00000000..ed97d539 --- /dev/null +++ b/examples/backbone_design/designs/edge_site/context/context.yaml @@ -0,0 +1 @@ +--- diff --git a/examples/backbone_design/designs/edge_site/designs/0001_design.yaml.j2 b/examples/backbone_design/designs/edge_site/designs/0001_design.yaml.j2 new file mode 100644 index 00000000..0210de9d --- /dev/null +++ b/examples/backbone_design/designs/edge_site/designs/0001_design.yaml.j2 @@ -0,0 +1,31 @@ +--- +sites: + - name: "{{ site_name }}" + status__name: "Staging" + prefixes: + - prefix: "{{ site_prefix }}" + status__name: "Reserved" + devices: + {% for i in range(2) %} + - name: "{{ site_name }}-LR{{ i }}" + status__name: "Planned" + device_type__model: "C8300-1N1S-6T" + device_role__name: "Edge Router" + interfaces: + - name: "GigabitEthernet0/0" + type: "1000base-t" + description: "Uplink to backbone" + status__name: "Planned" + {% endfor %} +circuits: + {% for i in range(2) %} + - cid: "{{ site_name }}-CKT-{{ i }}" + status__name: "Planned" + provider__name: "NTC" + type__name: "Ethernet" + terminations: + - term_side: "A" + site__name: "{{ site_name }}" + - term_side: "Z" + provider_network__name: "NTC-WAN" + {% endfor %} diff --git a/examples/backbone_design/designs/edge_site/jobs.py b/examples/backbone_design/designs/edge_site/jobs.py new file mode 100644 index 00000000..7eca90d8 --- /dev/null +++ b/examples/backbone_design/designs/edge_site/jobs.py @@ -0,0 +1,21 @@ +"""Basic design demonstrates the capabilities of the Design Builder.""" +from nautobot.extras.jobs import StringVar, IPNetworkVar + +from nautobot_design_builder.design_job import DesignJob + +from .context import EdgeDesignContext + + +class EdgeDesign(DesignJob): + """A basic design for design builder.""" + + site_name = StringVar(label="Site Name", regex=r"\w{3}\d+") + site_prefix = IPNetworkVar(label="Site Prefix") + + class Meta: + """Metadata describing this design job.""" + + name = "Edge Design" + commit_default = False + design_file = "designs/0001_design.yaml.j2" + context_class = EdgeDesignContext diff --git a/examples/backbone_design/designs/initial_data/designs/0001_design.yaml.j2 b/examples/backbone_design/designs/initial_data/designs/0001_design.yaml.j2 index fb0d31b0..4b595616 100644 --- a/examples/backbone_design/designs/initial_data/designs/0001_design.yaml.j2 +++ b/examples/backbone_design/designs/initial_data/designs/0001_design.yaml.j2 @@ -2,17 +2,25 @@ manufacturers: - "!create_or_update:name": "Juniper" slug: "juniper" + - "!create_or_update:name": "Cisco" + slug: "cisco" device_types: - "!create_or_update:model": "PTX10016" slug: "ptx10016" manufacturer__slug: "juniper" u_height: 21 + - "!create_or_update:model": "C8300-1N1S-6T" + manufacturer__slug: "cisco" + u_height: 1 device_roles: - "!create_or_update:name": "Core Router" slug: "core_router" color: "3f51b5" + - "!create_or_update:name": "Edge Router" + slug: "edge_router" + color: "ffeb3b" regions: "!create_or_update:name": "Americas" @@ -37,6 +45,16 @@ regions: status__name: "Active" "!ref": "sea1" +providers: +- "!create_or_update:name": "NTC" + +provider_networks: + - "!create_or_update:name": "NTC-WAN" + "!create_or_update:provider__name": "NTC" + +circuit_types: + - "!create_or_update:name": "Ethernet" + {% macro device(device_name, site) -%} - "!create_or_update:name": "{{ device_name }}.{{ site }}" site: "!ref:{{ site }}" diff --git a/examples/backbone_design/designs/jobs.py b/examples/backbone_design/designs/jobs.py index 5a80248b..b5ff2172 100644 --- a/examples/backbone_design/designs/jobs.py +++ b/examples/backbone_design/designs/jobs.py @@ -2,8 +2,10 @@ from .initial_data.jobs import InitialDesign from .core_site.jobs import CoreSiteDesign +from .edge_site.jobs import EdgeDesign __all__ = ( "InitialDesign", "CoreSiteDesign", + "EdgeDesign", )