These modules are AOS API Python scripts for demonstration.
AOS 3.2.1
Clone repo into your aos project.
git clone https://github.com/higutomo38/aos.git
Install Python 3.X on your local. Need some python modules in addition to default.
pip install requests urllib3 openpyxl netaddr
Run python file with AOS server FQDN or IP Address and Blueprint name.
e.g.
python get_hostname.py 192.168.1.1 blueprint
AOS Login
ID:admin
Password:
Use single quotation for Blueprint name if blank is in it.
e.g. python get_hostname.py 192.168.1.1 'blue print'
Category | Module | Description | NOS |
---|---|---|---|
Blueprint | get_hostname.py | Create new CSV file lists hostnames | All |
patch_hostname.py | Change hostnames listed in CSV | All | |
patch_label.py | Change labels listed in CSV | All | |
patch_deploy_mode_server.py | Change deploy mode | Server | |
get_nos_config.py | Save NOS configuration on local | Cumulus, EOS | |
get_ip_sheet.py | Save AOS database sheet tie to device IP | Cumulus, EOS | |
IBA | post_iba_probe.py | Create all probes without AOS-CLI | All |
Closed-Loop | configlets_intdown_flap.py | Push interface down configlets triggered by IBA interface flap anomaly | Cumulus |
All modules should be same directory as 'common.py' otherwise you can't login to AOS.
First of all you need to get current hostname list as CSV. Run 'get_hostname.py' and then you can see 'hostname_label.csv' on same directory you executed the script.
Add new hostnames in column 'new_hostname or label' and save the CSV.
Run 'patch_hostname.py'.
Check 'Physical Diff' tab in 'uncommited' on AOS and then push 'commit'.
The procedure is same as hostname. Add new labels in culumn 'new_hostname or label' and save the CSV.
Run 'patch_label.py'
You can monitor Leaf interfaces up/down facing server without aos agent when turn deploy mode of servers on.
Run 'patch_deploy_mode_server.py'
All rendered NOS configs got saved on local. The script create 'nos_config' directory automatically and put .conf into it.
Run 'get_nos_config.py'
You get AOS database related network device IP as xlsx file.
- Device
- Cabling
- Underlay
- Overlay
Run 'get_ip_sheet.py'
We usually use WebUI and command line interface tool AOS-CLI to create custom IBA probe.
WebUI
・Upload Custom Collector Package
・Install Custom Collector to Agent
AOS-CLI
・Import service registry
・Create probes
This python script execute batch of above using API.
Download latest AOS SDK e.g.'aos-dev-sdk-462.zip' from here.
https://portal.apstra.com/downloads/
Copy the zip into directory same as 'common.py', 'post_iba_probe.py' and 'Probes'.
Run 'post_iba_probe.py' putting the zip file name behind blueprint.
e.g.
python post_iba_probe.py 192.168.1.1 'tomo pod1' aos-dev-sdk-462.zip
AOS Login
ID:admin
Password:
All probes are created with temporary input Ex.'Match expected os version by OS family.json' use NOS 'cumulus' and version '3.7.12' as default. You can edit them on WebUI Analytics in BP - Probes - Push Edit - Select processor you want to change.
- Set IBA Interface Flapping with raising anomaly on 'device interface flappinng' processor.
- Create syslog config and turn on 'Forward Anomalies'.
-
Install python and libraries as above.
-
Turn on syslog service.
-
Copy three files.
- common.py
- configlets.json
- configlets_intdown_flap.py
if your test env is on Apstra Cloudlab
- ahost='172.16.90.3' in 'common.py'
- Disable urllib3 in 'common.py' and 'configlets_intdown_flap.py'
#from requests.packages.urllib3.exceptions import InsecureRequestWarning #requests.packages.urllib3.disable_warnings(InsecureRequestWarning)
- Set crontab to run 'configlets_intdown_flap.py' periodically. The script search the flap anomaly in syslog file and then push interface down configlets to the node/interface are identical with the log.
ex.
cp /etc/crontab /etc/cron.d/test_cron #/etc/cron.d/test_cron #Add new line here. * * * * * root for i in `seq 0 20 59`;do (sleep ${i}; python /home/admin/configlets_intdown_flap.py) & done; service cron restart
- Check 'Logical Diff' tab in 'uncommited' on AOS and then push 'commit'.