Extreme API with Python

Table Of Contents
Extreme API with Python
Page | 104
Part no.9036931-00 Rev AA February 2021
#!/usr/bin/env python
import json
import requests
from requests import Request, Session
from requests.auth import HTTPBasicAuth
from requests.packages.urllib3.exceptions import InsecureRequestWarning
import argparse
import getpass
def get_params():
parser = argparse.ArgumentParser(prog = 'nbi')
parser.add_argument('-u', '--username',
help='Login username for the remote system')
parser.add_argument('-p', '--password',
help='Login password for the remote system',
default='')
parser.add_argument('-i', '--ip',
help='IP of the XMC 8.1.2+ server')
args = parser.parse_args()
return args
args = get_params()
if args.username is None:
# prompt for username
args.username = input('Enter remote system username: ')
# also get password
args.password = getpass.getpass('Remote system password: ')
if args.ip is None:
#prompt for XMC's IP
args.ip = input('Enter IP of the XMC server: ')
# To disable SSL certificate verification
requests.packages.urllib3.disable_warnings( InsecureRequestWarning )
# prepare HTTPS session
session = Session()