Code Monkey home page Code Monkey logo

dn42-lg's Introduction

dn42-lg


Usage/Developer Notes

Create Virtual Environment, clone repo, and install dependencies.

conda create -n dn42-lg
conda activate dn42-lg
git clone https://github.com/usman-u/dn42-lg.git
poetry install
  • The same should work with virtualenv and pip.

VSCode Remote

  • If using VSCode SSH remote, change interpreter to conda env python path.

e.g. /home/usman/miniconda3/envs/dn42-lg/bin/python3

Confirm with which python3

(dn42-lg) usman@dev-usman-lan:~/projects/dn42-lg$ which python3
/home/usman/miniconda3/envs/flask-bgp-lg/bin/python3

Device Inventory

  • Modify inventory.py to include your devices.
  • It's a dictionary of OOP instances from my network-automation library.
  • Use os.getenv() to get environment variables.
from net_automation import net_automation
import os

routers = {
    # router name:    API/SSH  instance.
    "fr_lil1": net_automation.Vyos(
        device_type="vyos",
        host="fr-lil1.usman.dn42",
        username="username",
        password=os.getenv("fr_lil1_password"),
        use_keys=False,
        url="https://fr-lil1.usman.dn42/graphql",
        key=os.getenv("apikey"),
    ),
}

Environmental Variables

  • A .env file should be created.
  • The .env file should be added to .gitignore.
  • The .env file must include the flask secret key.
apikey = xxxx
fr_lil1_password = xxx
us_ca1_password = xxx
flask_secret_key = xxx

Running the Flask Development Server

(dn42-lg) usman@dev-usman-lan:~/projects/dn42-lg$ python main.py 
 * Serving Flask app 'main'
 * Debug mode: on
WARNING: This is a development server. Do not use it in a production deployment. Use a production WSGI server instead.
 * Running on all addresses (0.0.0.0)
 * Running on http://127.0.0.1:5000
 * Running on http://10.0.10.5:5000
Press CTRL+C to quit

Deploying the Flask Application

dn42-lg's People

Contributors

usman-u avatar

Stargazers

 avatar

Watchers

 avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.