Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Folder Structure Patterns #34

Closed
itdependsnetworks opened this issue May 12, 2023 · 9 comments
Closed

Folder Structure Patterns #34

itdependsnetworks opened this issue May 12, 2023 · 9 comments

Comments

@itdependsnetworks
Copy link
Contributor

Environment

  • Nautobot version: latest
  • design-builder version: current

Proposed Functionality

I believe anything can be done, since it is just Python, but I am suggesting to create a documented standard of what should be done.

Currently you may end up with a folder structure like this

├── __init__.py
├── backbone.py
├── branch.py
├── datacenter.py
├── design_files
│   ├── __init__.py
│   ├── backbone_context.py
│   ├── backbone_context.yml
│   ├── branch_context.py
│   ├── branch_context.yml
│   ├── device_profiles.yaml
│   └── templates
│       ├── backbone
│       │   ├── 100_backbone_base_elements.yaml.j2
│       │   ├── 200_backbone_cables.yaml.j2
│       │   └── pops_report.md.j2
│       └── branch
│           ├── 100_branch_base_elements.yaml.j2
│           ├── 200_branch.yaml.j2
│           └── 300_branch_access_switch.yaml.j2

It would be cleaner imho to have a folder with all designs, here are two options

.
├── __init__.py
├── backbone
│   ├── 100_base_elements.yaml.j2
│   ├── 200_cables.yaml.j2
│   ├── __init__.py
│   ├── context.py
│   ├── context.yml
│   └── pops_report.md.j2
└── branch
    ├── 100_branch_base_elements.yaml.j2
    ├── 200_branch.yaml.j2
    ├── 300_branch_access_switch.yaml.j2
    ├── __init__.py
    ├── branch_context.py
    └── branch_context.yml

You can still import the Jobs in a central location

# _init__.py output

from .branch import BranchJob
from .backbone import BackboneJob

So one of:

{design}/{file}
{design}/{design}_{file}

Use Case

A folder structure that reenforces the design.

@abates
Copy link
Contributor

abates commented May 17, 2023

Is this just a documentation task, or does some coding need to take place? I think that it should already work, but haven't tried it.

@itdependsnetworks
Copy link
Contributor Author

I believe it is just a documentation task.

@abates
Copy link
Contributor

abates commented May 18, 2023

Related to #14

@mzbroch
Copy link

mzbroch commented Jun 2, 2023

How about this pattern ?

root@mia:/opt/src/nautobot-data-generation/external_repos# tree nautobot-validated-network-designs/
nautobot-validated-network-designs/
|-- dc
|   |-- contexts
|   |   |-- contexts.py
|   |   `-- contexts.yml
|   |-- designs
|   |   `-- 100_base_elements.yaml.j2
|   `-- jobs.py
|-- enterprise_branch
|   |-- contexts
|   |   |-- contexts.py
|   |   `-- contexts.yml
|   |-- designs
|   |   |-- 100_base_elements.yaml.j2
|   |   |-- 200_branch.yaml.j2
|   |   |-- 300_access_switch.yaml.j2
|   |   `-- device_profiles.yaml
|   |-- helpers
|   |   |-- __init__.py
|   |   `-- ipam.py
|   `-- jobs.py
|-- isp_backbone
|   |-- contexts
|   |   |-- contexts.py
|   |   `-- contexts.yml
|   |-- designs
|   |   |-- 100_base_elements.yaml.j2
|   |   |-- 200_cables.yaml.j2
|   |   `-- report.md.j2
|   `-- jobs.py
`-- ntc_coolkitt
    |-- contexts
    |   |-- contexts.py
    |   `-- contexts.yml
    |-- designs
    |   |-- 100_base_elements.yaml.j2
    |   `-- report.md.j2
    `-- jobs.py

@itdependsnetworks
Copy link
Contributor Author

I am good with it

@nkallergis
Copy link

I also prefer this structure with everything in a self-contained folder. I guess that's why there's multiple jobs.py files?

@alhogan
Copy link
Contributor

alhogan commented Jun 13, 2023

Does this require calling load_jobs() in each jobs.py or do we still need to do that from the root?

@abates
Copy link
Contributor

abates commented Aug 29, 2023

Does this require calling load_jobs() in each jobs.py or do we still need to do that from the root?

load_jobs() only needs to be called once. See the examples in #73

@abates
Copy link
Contributor

abates commented Aug 29, 2023

Fixed in #73

@abates abates closed this as completed Aug 29, 2023
@abates abates mentioned this issue Sep 5, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

5 participants