Giter Club home page Giter Club logo

hmcts.rdo-netbox's Introduction

rdo-netbox

NetBox is an IP address management (IPAM) and data center infrastructure management (DCIM) tool. It is intended to function as a domain-specific source of truth for network operations.

HMCTS NetBox runs as a web application atop the Django Python framework with a PostgreSQL database and a Redis Cache hosted in Azure. This Netbox module is used to grab every network prefix in use in HMCTS Azure and populates the Netbox instance and will serve as a single source of truth for all things IPAM.

The complete documentation for NetBox can be found at Confluence. Questions? Comments? Please ask in the #devops Slack channel.

Build Status

status
master Build Status

The pipeline is set to run every day at 7AM so that data is always up to date, it is also good practice to manually run the pipeline after you create a new vnet so Netbox can get updated.

Quick start

Click here to access the instance. (You must be connected to the VPN and using the HMCTS proxy)

You can view currently assigned network prefixes and assign yourself an available prefix based on the data.

Curl commands

In order to make Restful calls to Netbox, you need to ensure you are connected to the VPN and be using the HMCTS proxy to be able to reach the Netbox instance.

In order to GET a prefix to see if it exists, enter a command such as:

curl -X GET -k https://netbox.platform.hmcts.net:443/api/ipam/prefixes/?prefix=10.230.6.0%2F24 -H "accept: application/json" | jq .

To pull ALL prefixes, use:

curl -X GET -k https://netbox.platform.hmcts.net:443/api/ipam/prefixes/ -H "accept: application/json" | jq .

To find any prefixes within a prefix, use:

curl -X GET -k https://netbox.platform.hmcts.net:443/api/ipam/prefixes/?within=10.50.0.0%2F16 -H "accept: application/json" | jq .

To grab a prefix from a specific vnet name, use:

curl -X GET -k https://netbox.platform.hmcts.net:443/api/ipam/prefixes/?cf_vnet="datalake-rg-vnet" -H "accept: application/json" |
 jq .

To grab a list of Subscriptions, use:

curl -X GET -k https://netbox.platform.hmcts.net:443/api/tenancy/tenants/ -H "accept: application/json" | jq .

Using the Pynetbox SDK

You can do more with the Netbox Python SDK such as make a call for the next available prefix.

Prereqs

  1. In order to be able to use it, you will need to get in contact with the devops team in the #devops channel to request a token to access the instance with Pynetbox.

  2. Install Python3 and the Pynetbox module.

Quick start

Ensure you have environmental variables for NETBOX_TOKEN and NETBOX_URL

export NETBOX_TOKEN=[token]
export NETBOX_URL=[url]

Create a python file with the below contents

import pynetbox
import urllib3, os
urllib3.disable_warnings(urllib3.exceptions.InsecureRequestWarning)


NETBOX_URL = os.environ.get("NETBOX_URL")
NETBOX_TOKEN = os.environ.get("NETBOX_TOKEN")

nb = pynetbox.api(f"http://{NETBOX_URL}", NETBOX_TOKEN, ssl_verify=False)
import ipdb; ipdb.set_trace()

To see what prefixes live under a specific range, you can use the filter verb like:

ipdb> nb.ipam.prefixes.filter(q="10.99.50.0/24")                                                                                                                     
[10.99.0.0/18, 10.99.0.0/18, 10.99.0.0/18]

To get a specific prefix and to see what available child prefixes exist, run something like this:

ipdb> nb.ipam.prefixes.get(prefix="172.16.7.0/24").available_prefixes.list()                                                                                         
[{'family': 4, 'prefix': '172.16.7.0/24', 'vrf': None}]

To filter on the name of the vnet or resource group, use:

ipdb> nb.ipam.prefixes.filter(cf_resource_group="datalake-rg")
[172.16.7.0/24]

ipdb> nb.ipam.prefixes.filter(cf_vnet="datalake-rg-vnet")
[172.16.7.0/24]

hmcts.rdo-netbox's People

Contributors

gunnertwin 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.