diff --git a/.gitingore b/.gitingore new file mode 100644 index 0000000..6769e21 --- /dev/null +++ b/.gitingore @@ -0,0 +1,160 @@ +# Byte-compiled / optimized / DLL files +__pycache__/ +*.py[cod] +*$py.class + +# C extensions +*.so + +# Distribution / packaging +.Python +build/ +develop-eggs/ +dist/ +downloads/ +eggs/ +.eggs/ +lib/ +lib64/ +parts/ +sdist/ +var/ +wheels/ +share/python-wheels/ +*.egg-info/ +.installed.cfg +*.egg +MANIFEST + +# PyInstaller +# Usually these files are written by a python script from a template +# before PyInstaller builds the exe, so as to inject date/other infos into it. +*.manifest +*.spec + +# Installer logs +pip-log.txt +pip-delete-this-directory.txt + +# Unit test / coverage reports +htmlcov/ +.tox/ +.nox/ +.coverage +.coverage.* +.cache +nosetests.xml +coverage.xml +*.cover +*.py,cover +.hypothesis/ +.pytest_cache/ +cover/ + +# Translations +*.mo +*.pot + +# Django stuff: +*.log +local_settings.py +db.sqlite3 +db.sqlite3-journal + +# Flask stuff: +instance/ +.webassets-cache + +# Scrapy stuff: +.scrapy + +# Sphinx documentation +docs/_build/ + +# PyBuilder +.pybuilder/ +target/ + +# Jupyter Notebook +.ipynb_checkpoints + +# IPython +profile_default/ +ipython_config.py + +# pyenv +# For a library or package, you might want to ignore these files since the code is +# intended to run in multiple environments; otherwise, check them in: +# .python-version + +# pipenv +# According to pypa/pipenv#598, it is recommended to include Pipfile.lock in version control. +# However, in case of collaboration, if having platform-specific dependencies or dependencies +# having no cross-platform support, pipenv may install dependencies that don't work, or not +# install all needed dependencies. +#Pipfile.lock + +# poetry +# Similar to Pipfile.lock, it is generally recommended to include poetry.lock in version control. +# This is especially recommended for binary packages to ensure reproducibility, and is more +# commonly ignored for libraries. +# https://python-poetry.org/docs/basic-usage/#commit-your-poetrylock-file-to-version-control +#poetry.lock + +# pdm +# Similar to Pipfile.lock, it is generally recommended to include pdm.lock in version control. +#pdm.lock +# pdm stores project-wide configurations in .pdm.toml, but it is recommended to not include it +# in version control. +# https://pdm.fming.dev/#use-with-ide +.pdm.toml + +# PEP 582; used by e.g. github.com/David-OConnor/pyflow and github.com/pdm-project/pdm +__pypackages__/ + +# Celery stuff +celerybeat-schedule +celerybeat.pid + +# SageMath parsed files +*.sage.py + +# Environments +.env +.venv +env/ +venv/ +ENV/ +env.bak/ +venv.bak/ + +# Spyder project settings +.spyderproject +.spyproject + +# Rope project settings +.ropeproject + +# mkdocs documentation +/site + +# mypy +.mypy_cache/ +.dmypy.json +dmypy.json + +# Pyre type checker +.pyre/ + +# pytype static type analyzer +.pytype/ + +# Cython debug symbols +cython_debug/ + +# PyCharm +# JetBrains specific template is maintained in a separate JetBrains.gitignore that can +# be found at https://github.com/github/gitignore/blob/main/Global/JetBrains.gitignore +# and can be added to the global gitignore or merged into this file. For a more nuclear +# option (not recommended) you can uncomment the following to ignore the entire idea folder. +#.idea/ \ No newline at end of file diff --git a/TP-01/config/README.md b/TP-01/config/README.md new file mode 100644 index 0000000..8369395 --- /dev/null +++ b/TP-01/config/README.md @@ -0,0 +1,5 @@ +# CONFIG + +**This directory is required.** + +The config directory contains your Cisco config files. diff --git a/TP-01/data/README.md b/TP-01/data/README.md new file mode 100644 index 0000000..3b17f7b --- /dev/null +++ b/TP-01/data/README.md @@ -0,0 +1,5 @@ +# DATA + +**This directory is required.** + +The data directory contains your JSON or YAML files. diff --git a/TP-01/scripts/README.md b/TP-01/scripts/README.md new file mode 100644 index 0000000..20c8054 --- /dev/null +++ b/TP-01/scripts/README.md @@ -0,0 +1,5 @@ +# SCRIPTS + +**This directory is required.** + +The scripts directory contains your python scripts. diff --git a/TP-01/scripts/__main__.py b/TP-01/scripts/__main__.py new file mode 100644 index 0000000..0bb86f3 --- /dev/null +++ b/TP-01/scripts/__main__.py @@ -0,0 +1,44 @@ +import json + + +def load_json_data_from_file(file_path): + """ + A compléter .... + """ + pass + + +def load_yaml_data_from_file(file_path): + """ + A compléter .... + """ + pass + + +def render_network_config(template_name, data): + """ + A compléter .... + """ + pass + + +def save_built_config(file_name, data): + """ + A compléter .... + """ + pass + + +if __name__ == "__main__": + + #process R2 + # r2_data = load_json_data_from_file(file_path='data/R2.json') + # r2_config = render_network_config(template_name='R2.j2', data=r2_data) + # save_built_config('config/R2.conf', r2_config) + + #process ESW2 + # esw2_data = load_json_data_from_file(file_path='data/ESW2.json') + # esw2_config = render_network_config(template_name='ESW2.j2', data=esw2_data) + # save_built_config('config/ESW2.conf', esw2_config) + + pass \ No newline at end of file diff --git a/TP-01/templates/README.md b/TP-01/templates/README.md new file mode 100644 index 0000000..182012e --- /dev/null +++ b/TP-01/templates/README.md @@ -0,0 +1,5 @@ +# TEMPLATES + +**This directory is required.** + +The templates directory contains your jinja.j2 files. diff --git a/TP-02/config/README.md b/TP-02/config/README.md new file mode 100644 index 0000000..8369395 --- /dev/null +++ b/TP-02/config/README.md @@ -0,0 +1,5 @@ +# CONFIG + +**This directory is required.** + +The config directory contains your Cisco config files. diff --git a/TP-02/data/README.md b/TP-02/data/README.md new file mode 100644 index 0000000..3b17f7b --- /dev/null +++ b/TP-02/data/README.md @@ -0,0 +1,5 @@ +# DATA + +**This directory is required.** + +The data directory contains your JSON or YAML files. diff --git a/TP-02/inventory/README.md b/TP-02/inventory/README.md new file mode 100644 index 0000000..065f03e --- /dev/null +++ b/TP-02/inventory/README.md @@ -0,0 +1,5 @@ +# INVENTORY + +**This directory is required.** + +The inventory directory contains your JSON or YAML files to store your cisco devices. diff --git a/TP-02/scripts/README.md b/TP-02/scripts/README.md new file mode 100644 index 0000000..20c8054 --- /dev/null +++ b/TP-02/scripts/README.md @@ -0,0 +1,5 @@ +# SCRIPTS + +**This directory is required.** + +The scripts directory contains your python scripts. diff --git a/TP-02/scripts/create_config.py b/TP-02/scripts/create_config.py new file mode 100644 index 0000000..f672537 --- /dev/null +++ b/TP-02/scripts/create_config.py @@ -0,0 +1,41 @@ +import json +from jinja2 import Template, Environment, FileSystemLoader + +env = Environment(loader=FileSystemLoader("templates")) + +def load_json_data_from_file(file_path): + pass + +def render_network_config(template_name, data): + pass + + +def save_built_config(file_name, data): + pass + + +def create_vlan_config_cpe_marseille(): + """ + Must return two values : router config and the switch config + """ + pass + + +def create_vlan_config_cpe_paris(): + """ + Must return two values : router config and the switch config + """ + pass + + +if __name__ == "__main__": + """ + process question 1 to 5: + """ + # r02_config, esw2_config = create_vlan_config_cpe_marseille() + # save_built_config('config/vlan_R02.conf', r02_config) + # save_built_config('config/vlan_ESW2.conf', esw2_config) + + # r03_config, esw3_config = create_vlan_config_cpe_paris() + # save_built_config('config/vlan_R03.conf', r03_config) + # save_built_config('config/vlan_ESW3.conf', esw3_config) diff --git a/TP-02/scripts/run_napalm.py b/TP-02/scripts/run_napalm.py new file mode 100644 index 0000000..eff9e08 --- /dev/null +++ b/TP-02/scripts/run_napalm.py @@ -0,0 +1,62 @@ +import json +from napalm import get_network_driver + + +def get_inventory(): + pass + + +def get_json_data_from_file(file): + pass + +def question_26(device): + pass + + +def question_27(device): + pass + + +def question_28(device): + pass + +def question_29(device): + pass + + +def question_30(device): + pass + + +def question_31(): + pass + + +def question_32(): + pass + + +def question_34(): + pass + + + +if __name__ == "__main__": + r01 = { + 'hostname':'xx.xx.xx.xx', + 'username': "xx", + 'password': "xx" + } + + # driver = get_network_driver('ios') + # device = driver(**r01) + # device.open() + + #question_26(device) + #question_27(device) + #question_28(device) + #question_29(device) + #question_30(device) + #question_31() + #question_32() + #question_34() \ No newline at end of file diff --git a/TP-02/scripts/run_netmiko.py b/TP-02/scripts/run_netmiko.py new file mode 100644 index 0000000..6b0d097 --- /dev/null +++ b/TP-02/scripts/run_netmiko.py @@ -0,0 +1,68 @@ +import json +from netmiko import ConnectHandler + +def question_9(net_connect): + pass + +def question_10(net_connect): + pass + +def question_11(net_connect): + pass + + +def question_12(net_connect): + pass + +def question_13(net_connect): + pass + + +def question_14(net_connect): + pass + + +def question_15(net_connect): + pass + +def question_16(net_connect): + pass + + +def question_17(net_connect): + pass + + +def get_inventory(): + pass + + +def question_20(): + pass + + +def question_21(): + pass + +if __name__ == "__main__": + r01 = { + 'device_type': 'cisco_ios', + 'host': 'xx.xx.xx.xx', + 'username': 'xx', + 'password': 'xx' + } + #net_connect = ConnectHandler(**r01) + + #question_9(net_connect) + #question_10(net_connect) + #question_11(net_connect) + #question_12(net_connect) + #question_13(net_connect) + #question_14(net_connect) + #question_15(net_connect) + #question_16(net_connect) + #question_17(net_connect) + # hosts = get_inventory() + # print(hosts) + #question_20() + #question_21() \ No newline at end of file diff --git a/TP-02/templates/README.md b/TP-02/templates/README.md new file mode 100644 index 0000000..182012e --- /dev/null +++ b/TP-02/templates/README.md @@ -0,0 +1,5 @@ +# TEMPLATES + +**This directory is required.** + +The templates directory contains your jinja.j2 files.