Skip to content

rvojcik/rtapi

Repository files navigation

rtapi

pipeline status coverage report

Racktables API

Python module for accessing and manipulating RackTables objects.

Installation

pip install mysqlclient
pip install racktables-api

PyPi project

https://pypi.org/project/racktables-api/

Documentation

https://rtapi.readthedocs.io

Example

import MySQLdb
import rtapi
import sys

# Create connection to database
try:
    # Create connection to database
    db = MySQLdb.connect(host='hostname',port=3306, passwd='mypass',db='racktables',user='racktables')
except MySQLdb.Error:
    e = sys.exc_info()[1]
    print("Error %d: %s" % (e.args[0],e.args[1]))
    sys.exit(1)

# Initialize rtapi with database connection
rt = rtapi.RTObject(db)

# List all objects from database
print (rt.ListObjects(data='list'))

# List all IPv4 Networks from database
print (rt.GetIpv4Networks())