Skip to content

Commit

Permalink
docs: Additional example for blog post.
Browse files Browse the repository at this point in the history
  • Loading branch information
abates committed Jan 4, 2024
1 parent d7105a6 commit 7b01baa
Show file tree
Hide file tree
Showing 8 changed files with 82 additions and 1 deletion.
3 changes: 2 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -56,6 +56,7 @@ coverage.xml
*.py,cover
.hypothesis/
.pytest_cache/
lcov.info

# Translations
*.mo
Expand Down Expand Up @@ -305,4 +306,4 @@ invoke.yml
# Docs
docs/README.md
docs/CHANGELOG.md
public
public
Empty file.
Original file line number Diff line number Diff line change
@@ -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."""
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
---
Original file line number Diff line number Diff line change
@@ -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 %}
21 changes: 21 additions & 0 deletions examples/backbone_design/designs/edge_site/jobs.py
Original file line number Diff line number Diff line change
@@ -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
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand All @@ -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 }}"
Expand Down
2 changes: 2 additions & 0 deletions examples/backbone_design/designs/jobs.py
Original file line number Diff line number Diff line change
Expand Up @@ -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",
)

0 comments on commit 7b01baa

Please sign in to comment.