Getting Started¶
Set Up A Python Environment¶
In order to use the NETLAB+ sdk, familiarity with Python is required. You can install Python from the python website or using your favorite package manager. We support versions of python supported by the python organization.
We recommend that you use a virtual environment
but this is not required.
The NETLAB+ sdk can be installed using:
pip install https://ndg.tech/netlab-py-latest
Configuration¶
Before starting, you must configure a NETLAB+ system. Make sure you are in a python environment by
using poetry shell. Then you can run netlab config add, which will walk you through the process
of configuring this tool to connect to a NETLAB+.
For additional configuration, see netlab.config.
First NETLAB+ Command¶
Create a file named ‘main.py’ with the following content:
import asyncio
from pprint import pprint
from netlab.async_client import NetlabClient
async def main():
async with NetlabClient() as connection:
info = await connection.system_status_get()
pprint(info)
if __name__ == '__main__':
asyncio.get_event_loop().run_until_complete(main())
Remember to make sure you are in the python environment using poetry shell, then run python main.py.
You should see output that looks like:
{'cpu_n': '2',
'hostname': 'ndg-ve-dev-jj-015.netdevgroup.com',
'sys_lic_exp_date': None,
'sys_lic_op_state': 'ACTIVE',
'sys_logins_enabled': True,
'sys_maint_ends': None,
'sys_mode': 'NORMAL',
'sys_name': '',
'sys_product_id': 'VE',
'sys_sdn_release_date': datetime.date(2016, 4, 1),
'sys_sdn_release_type': 'alpha',
'sys_sdn_version': '21.1.2',
'sys_serial': 'NDG-VE-E3BE-5FF2-7579-5E55',
'uptime_sec': Decimal('1720907.59')}
You can check your program before running it by using the mypy tool. Run mypy main.py check the
file we just created. You can use mypy to find errors before you ever need to run your program.
See netlab.api for a complete list of netlab commands. See netlab.async_client.NetlabClient for
additional info on working with the NETLAB+ SDK.