diff --git a/tools/pdu.json b/tools/pdu.json index 4f0afb93d..d4ecff600 100644 --- a/tools/pdu.json +++ b/tools/pdu.json @@ -1,14 +1,473 @@ { - "basic-01": + "basic-01-testing": { "host": "192.168.200.49", "username": "admin", "password": "Lanforge12345!" }, - "basic-02": - { - "host": "192.168.200.49", - "username": "admin", - "password": "Lanforge12345!" + "basic-01": { + "controller": { + "url": "https://wlan-portal-svc-nola-02.cicd.lab.wlan.tip.build", + "username": "support@example.com", + "password": "support", + "version": "1.1.0-SNAPSHOT", + "commit_date": "2021-06-01" + }, + "access_point": [ + { + "model": "ecw5410", + "mode": "wifi5", + "serial": "3c2c99f44e77", + "jumphost": "True", + "ip": "10.28.3.100", + "username": "lanforge", + "password": "pumpkin77", + "port": 22, + "jumphost_tty": "/dev/ttyAP1", + "version": "https://tip.jfrog.io/artifactory/tip-wlan-ap-firmware/ecw5410/trunk/ecw5410-1.2.0-rc2.tar.gz" + } + ], + "traffic_generator": { + "name": "lanforge", + "details": { + "ip": "10.28.3.6", + "port": 8080, + "ssh_port": 22, + "2.4G-Radio": [ + "1.1.wiphy4" + ], + "5G-Radio": [ + "1.1.wiphy5" + ], + "AX-Radio": [ + "1.1.wiphy0", + "1.1.wiphy1", + "1.1.wiphy2", + "1.1.wiphy3" + ], + "upstream": "1.1.eth2", + "upstream_subnet": "10.28.2.1/24", + "uplink": "1.1.eth3", + "2.4G-Station-Name": "wlan0", + "5G-Station-Name": "wlan1", + "AX-Station-Name": "ax" + } + } + }, + "basic-02": { + "controller": { + "url": "https://wlan-portal-svc-nola-02.cicd.lab.wlan.tip.build", + "username": "support@example.com", + "password": "support", + "version": "1.1.0-SNAPSHOT", + "commit_date": "2021-06-01" + }, + "access_point": [ + { + "model": "eap101", + "mode": "wifi6", + "serial": "34efb6af48db", + "jumphost": "True", + "ip": "10.28.3.100", + "username": "lanforge", + "password": "pumpkin77", + "port": 22, + "jumphost_tty": "/dev/ttyAP2", + "version": "https://tip.jfrog.io/artifactory/tip-wlan-ap-firmware/eap101/trunk/eap101-1.2.0-rc2.tar.gz" + } + ], + "traffic_generator": { + "name": "lanforge", + "details": { + "ip": "10.28.3.8", + "port": 8080, + "ssh_port": 22, + "2.4G-Radio": [ + "1.1.wiphy4" + ], + "5G-Radio": [ + "1.1.wiphy5" + ], + "AX-Radio": [ + "1.1.wiphy0", + "1.1.wiphy1", + "1.1.wiphy2", + "1.1.wiphy3" + ], + "upstream": "1.1.eth2", + "upstream_subnet": "10.28.2.1/24", + "uplink": "1.1.eth3", + "2.4G-Station-Name": "wlan0", + "5G-Station-Name": "wlan0", + "AX-Station-Name": "ax" + } + } + }, + "basic-03": { + "controller": { + "url": "https://sec-ucentral-qa01.cicd.lab.wlan.tip.build:16001", + "username": "tip@ucentral.com", + "password": "openwifi" + }, + "access_point": [ + { + "model": "ec420", + "mode": "wifi5", + "serial": "001122090801", + "jumphost": "True", + "ip": "127.0.0.1", + "username": "lanforge", + "password": "pumpkin77", + "port": 8833, + "jumphost_tty": "/dev/ttyAP3", + "version": "https://tip.jfrog.io/artifactory/tip-wlan-ap-firmware/uCentral/tplink_ec420/20210728-tplink_ec420-uCentral-trunk-12ad0d5-upgrade.bin" + } + ], + "traffic_generator": { + "name": "lanforge", + "details": { + "ip": "10.28.3.10", + "port": 8080, + "ssh_port": 22, + "2.4G-Radio": [ + "1.1.wiphy4" + ], + "5G-Radio": [ + "1.1.wiphy5" + ], + "AX-Radio": [ + "1.1.wiphy0", + "1.1.wiphy1", + "1.1.wiphy2", + "1.1.wiphy3" + ], + "upstream": "1.1.eth2", + "upstream_subnet": "10.28.2.1/24", + "uplink": "1.1.eth3", + "2.4G-Station-Name": "sta00", + "5G-Station-Name": "sta10", + "AX-Station-Name": "ax" + } + } + }, + "basic-04": { + "controller": { + "url": "https://sec-ucentral-qa01.cicd.lab.wlan.tip.build:16001", + "username": "tip@ucentral.com", + "password": "openwifi" + }, + "access_point": [ + { + "model": "ecw5211", + "mode": "wifi5", + "serial": "68215fda456d", + "jumphost": "True", + "ip": "10.28.3.100", + "username": "lanforge", + "password": "pumpkin77", + "port": 22, + "jumphost_tty": "/dev/ttyAP5", + "version": "https://tip.jfrog.io/artifactory/tip-wlan-ap-firmware/uCentral/edgecore_eap102/20210625-edgecore_eap102-uCentral-trunk-4225122-upgrade.bin" + } + ], + "traffic_generator": { + "name": "lanforge", + "details": { + "ip": "10.28.3.12", + "port": 8080, + "ssh_port": 22, + "2.4G-Radio": [ + "1.1.wiphy4" + ], + "5G-Radio": [ + "1.1.wiphy5" + ], + "AX-Radio": [ + "1.1.wiphy0", + "1.1.wiphy1", + "1.1.wiphy2", + "1.1.wiphy3" + ], + "upstream": "1.1.eth2", + "upstream_subnet": "10.28.2.1/24", + "uplink": "1.1.eth3", + "2.4G-Station-Name": "wlan0", + "5G-Station-Name": "wlan0", + "AX-Station-Name": "ax" + } + } + }, + "basic-05": { + "controller": { + "url": "https://sec-ucentral-qa01.cicd.lab.wlan.tip.build:16001", + "username": "tip@ucentral.com", + "password": "openwifi" + }, + "access_point": [ + { + "model": "wf188n", + "mode": "wifi6", + "serial": "0000c1018812", + "jumphost": "True", + "ip": "10.28.3.103", + "username": "lanforge", + "password": "pumpkin77", + "port": 22, + "jumphost_tty": "/dev/ttyAP1", + "version": "https://tip.jfrog.io/artifactory/tip-wlan-ap-firmware/uCentral/cig_wf188/20210729-cig_wf188-v2.0.0-rc2-ec3662e-upgrade.bin" + } + ], + "traffic_generator": { + "name": "lanforge", + "details": { + "ip": "10.28.3.28", + "port": 8080, + "ssh_port": 22, + "2.4G-Radio": [ + "1.1.wiphy2" + ], + "5G-Radio": [ + "1.1.wiphy3" + ], + "AX-Radio": [ + "1.1.wiphy0", + "1.1.wiphy1", + "1.1.wiphy2", + "1.1.wiphy3" + ], + "upstream": "1.1.eth2", + "upstream_subnet": "10.28.2.1/24", + "uplink": "1.1.eth1", + "2.4G-Station-Name": "sta00", + "5G-Station-Name": "sta10", + "AX-Station-Name": "ax" + } + } + }, + "basic-06": { + "controller": { + "url": "https://sec-ucentral-qa01.cicd.lab.wlan.tip.build:16001", + "username": "tip@ucentral.com", + "password": "openwifi" + }, + "access_point": [ + { + "model": "eap102", + "mode": "wifi6", + "serial": "903cb39d6918", + "jumphost": "True", + "ip": "10.28.3.103", + "username": "lanforge", + "password": "pumpkin77", + "port": 22, + "jumphost_tty": "/dev/ttyAP2", + "version": "https://tip.jfrog.io/artifactory/tip-wlan-ap-firmware/uCentral/edgecore_eap102/20210625-edgecore_eap102-uCentral-trunk-4225122-upgrade.bin" + } + ], + "traffic_generator": { + "name": "lanforge", + "details": { + "ip": "10.28.3.30", + "port": 8080, + "ssh_port": 22, + "2.4G-Radio": [ + "1.1.wiphy0", + "1.1.wiphy2" + ], + "5G-Radio": [ + "1.1.wiphy1", + "1.1.wiphy3" + ], + "AX-Radio": [ + "1.1.wiphy4", + "1.1.wiphy5", + "1.1.wiphy6", + "1.1.wiphy7" + ], + "upstream": "1.1.eth2", + "upstream_subnet": "10.28.2.1/24", + "uplink": "1.1.eth3", + "2.4G-Station-Name": "wlan0", + "5G-Station-Name": "wlan0", + "AX-Station-Name": "ax" + } + } + }, + "basic-07": { + "controller": { + "url": "https://sec-ucentral-qa01.cicd.lab.wlan.tip.build:16001", + "username": "tip@ucentral.com", + "password": "openwifi" + }, + "access_point": [ + { + "model": "eap101", + "mode": "wifi6", + "serial": "903cb36ae223", + "jumphost": "True", + "ip": "10.28.3.103", + "username": "lanforge", + "password": "pumpkin77", + "port": 22, + "jumphost_tty": "/dev/ttyAP3", + "version": "https://tip.jfrog.io/artifactory/tip-wlan-ap-firmware/uCentral/edgecore_eap101/20210729-edgecore_eap101-v2.0.0-rc2-02244b8-upgrade.bin" + } + ], + "traffic_generator": { + "name": "lanforge", + "details": { + "ip": "10.28.3.32", + "port": 8080, + "ssh_port": 22, + "2.4G-Radio": [ + "wiphy4" + ], + "5G-Radio": [ + "wiphy5" + ], + "AX-Radio": [ + "wiphy0", + "wiphy1", + "wiphy2", + "wiphy3" + ], + "upstream": "1.1.eth2", + "upstream_subnet": "10.28.2.1/24", + "uplink": "1.1.eth3", + "2.4G-Station-Name": "sta10", + "5G-Station-Name": "sta00", + "AX-Station-Name": "ax" + } + } + }, + "basic-08": { + "controller": { + "url": "https://sec-ucentral-qa01.cicd.lab.wlan.tip.build:16001", + "username": "tip@ucentral.com", + "password": "openwifi" + }, + "access_point": [ + { + "model": "wf194c", + "mode": "wifi6", + "serial": "089b4bb2f10c", + "jumphost": "True", + "ip": "10.28.3.103", + "username": "lanforge", + "password": "pumpkin77", + "port": 22, + "jumphost_tty": "/dev/ttyAP5", + "version": "https://tip.jfrog.io/artifactory/tip-wlan-ap-firmware/uCentral/cig_wf194c/20210729-cig_wf194c-v2.0.0-rc2-02244b8-upgrade.bin" + } + ], + "traffic_generator": { + "name": "lanforge", + "details": { + "ip": "10.28.3.34", + "port": 8080, + "ssh_port": 22, + "2.4G-Radio": [ + "1.1.wiphy0", + "1.1.wiphy2" + ], + "5G-Radio": [ + "1.1.wiphy1", + "1.1.wiphy3" + ], + "AX-Radio": [ + "1.1.wiphy4", + "1.1.wiphy5", + "1.1.wiphy6", + "1.1.wiphy7" + ], + "upstream": "1.1.eth2", + "upstream_subnet": "10.28.2.1/24", + "uplink": "1.1.eth3", + "2.4G-Station-Name": "wlan0", + "5G-Station-Name": "wlan0", + "AX-Station-Name": "ax" + } + } + }, + "mesh": { + "controller": { + "url": "http://wlan-portal-svc-digicert.cicd.lab.wlan.tip.build", + "username": "support@example.com", + "password": "support", + "version": "1.1.0-SNAPSHOT", + "commit_date": "2021-06-01" + }, + "access_point": [ + { + "model": "eap101", + "mode": "wifi6", + "serial": "34efb6af4a7a", + "jumphost": "True", + "ip": "10.28.3.101", + "username": "lanforge", + "password": "pumpkin77", + "port": 22, + "jumphost_tty": "/dev/ttyAP2", + "version": "https://tip.jfrog.io/artifactory/tip-wlan-ap-firmware/eap101/trunk/eap101-1.1.0.tar.gz" + } + ], + "traffic_generator": { + "name": "lanforge", + "details": { + "ip": "10.28.3.14", + "port": 8080, + "ssh_port": 22, + "2.4G-Radio": [ + "wiphy0", + "wiphy2" + ], + "5G-Radio": [ + "wiphy1", + "wiphy3" + ], + "AX-Radio": [ + "wiphy4", + "wiphy5", + "wiphy6", + "wiphy7" + ], + "upstream": "1.1.eth2", + "upstream_subnet": "10.28.2.1/24", + "uplink": "1.1.eth3", + "2.4G-Station-Name": "wlan0", + "5G-Station-Name": "wlan0", + "AX-Station-Name": "ax" + } + } + }, + "interop": { + "controller": { + "url": "https://wlan-portal-svc-nola-02.cicd.lab.wlan.tip.build", + "username": "support@example.com", + "password": "support", + "version": "19.07-SNAPSHOT", + "commit_date": "2021-06-01" + }, + "access_point": [ + { + "model": "ecw5410", + "mode": "wifi5", + "serial": "68215fd2f78c", + "jumphost": "True", + "ip": "10.28.3.102", + "username": "lanforge", + "password": "pumpkin77", + "port": 22, + "jumphost_tty": "/dev/ttyAP1", + "version": "https://tip-tip-wlan-cloud-docker-repo.jfrog.io/artifactory/tip-wlan-ap-firmware/ecw5410/dev/ecw5410-2021-07-28-pending-0ec23e8.tar.gz" + } + ], + "traffic_generator": { + "name": "Perfecto", + "details": { + "securityToken": "eyJhbGciOiJIUzI1NiIsInR5cCIgOiAiSldUIiwia2lkIiA6ICI3NzkzZGM0Ni1jZmU4LTQ4ODMtYjhiOS02ZWFlZGU2OTc2MDkifQ.eyJqdGkiOiJjYjRjYjQzYi05Y2FiLTQxNzQtOTYxYi04MDEwNTZkNDM2MzgiLCJleHAiOjAsIm5iZiI6MCwiaWF0IjoxNjExNTk0NzcxLCJpc3MiOiJodHRwczovL2F1dGgyLnBlcmZlY3RvbW9iaWxlLmNvbS9hdXRoL3JlYWxtcy90aXAtcGVyZmVjdG9tb2JpbGUtY29tIiwiYXVkIjoiaHR0cHM6Ly9hdXRoMi5wZXJmZWN0b21vYmlsZS5jb20vYXV0aC9yZWFsbXMvdGlwLXBlcmZlY3RvbW9iaWxlLWNvbSIsInN1YiI6IjdiNTMwYWUwLTg4MTgtNDdiOS04M2YzLTdmYTBmYjBkZGI0ZSIsInR5cCI6Ik9mZmxpbmUiLCJhenAiOiJvZmZsaW5lLXRva2VuLWdlbmVyYXRvciIsIm5vbmNlIjoiZTRmOTY4NjYtZTE3NS00YzM2LWEyODMtZTQwMmI3M2U5NzhlIiwiYXV0aF90aW1lIjowLCJzZXNzaW9uX3N0YXRlIjoiYWNkNTQ3MTctNzJhZC00MGU3LWI0ZDctZjlkMTAyNDRkNWZlIiwicmVhbG1fYWNjZXNzIjp7InJvbGVzIjpbIm9mZmxpbmVfYWNjZXNzIiwidW1hX2F1dGhvcml6YXRpb24iXX0sInJlc291cmNlX2FjY2VzcyI6eyJyZXBvcnRpdW0iOnsicm9sZXMiOlsiYWRtaW5pc3RyYXRvciJdfSwiYWNjb3VudCI6eyJyb2xlcyI6WyJtYW5hZ2UtYWNjb3VudCIsIm1hbmFnZS1hY2NvdW50LWxpbmtzIiwidmlldy1wcm9maWxlIl19fSwic2NvcGUiOiJvcGVuaWQgcHJvZmlsZSBvZmZsaW5lX2FjY2VzcyBlbWFpbCJ9.SOL-wlZiQ4BoLLfaeIW8QoxJ6xzrgxBjwSiSzkLBPYw", + "perfectoURL": "tip" + } + } } } \ No newline at end of file diff --git a/tools/pdu_v3.py b/tools/pdu_v3.py new file mode 100644 index 000000000..315b58b09 --- /dev/null +++ b/tools/pdu_v3.py @@ -0,0 +1,104 @@ +#!/usr/bin/env python3 +""" +Date: 15-09-2021 +By: Amrit Raj @ Candela Technologies Pvt. ltd. +Note: Please ensure that PDU is powered on + Command line to be used as + python pdu_automation.py --host 192.168.200.49 --user admin --password pass1234 --action on/off/cycle --port all/specific_port_number + Eg 1: python pdu_v3.py --host 192.168.200.49 --user admin --password pass1234 --action off --port 1 + Eg 2: python pdu_v3.py --host 192.168.200.49 --user admin --password pass1234 --action off --port 1,2,3,4 + Eg 3: python pdu_v3.py --host 192.168.200.49 --user admin --password pass1234 --action cycle --port all +""" +import os +import json +import time +import argparse +from typing import Sequence +from typing import Optional + +try: + import dlipower +except: + print('Please wait we are installing DLI Power') + os.system('pip install dlipower') + + +class setup: + try: + def __init__(self, hostname, user, password): + self.hostname = hostname + self.user = user + self.password = password + self.power_switch = dlipower.PowerSwitch(hostname=self.hostname, userid=self.user, password=self.password) + except: + print('PDU device is Off') + + +class switch_on(setup): + def __init__(self, hostname, user, password, port=None): + super().__init__(hostname, user, password) + self.port = port + if self.port != 'all': + try: + port = str(self.port).split(",") + for i in port: + self.power_switch[int(i)-1].state = "ON" + except: + self.power_switch[int(self.port)-1].state = "ON" + else: + for outlet in self.power_switch: + outlet.state = 'ON' + + +class switch_off(setup): + def __init__(self, hostname, user, password, port=None): + super().__init__(hostname, user, password) + self.port = port + if self.port != 'all': + try: + port = str(self.port).split(",") + for i in port: + self.power_switch[int(i) - 1].state = "OFF" + except: + self.power_switch[int(self.port) - 1].state = "OFF" + else: + for outlet in self.power_switch: + outlet.state = 'ON' + + +class print_status(setup): + def __init__(self, hostname, user, password): + super().__init__(hostname, user, password) + print(self.power_switch) + + +def main(argv: Optional[Sequence[str]] = None): + parser = argparse.ArgumentParser() + parser.add_argument('--host', help='Please provide host name eg: 192.168.200.65') + parser.add_argument('--username', help='Please provide username eg: admin') + parser.add_argument('--password', help='Please provide password eg: 1234') + parser.add_argument('--action', help='Switches all Outlets in ON Mode eg: --on or --off\n') + parser.add_argument('--port', help='Please provide port name eg: --port lanforge') + args = parser.parse_args(argv) + dic = vars(args) + # if user enter ports as 1,6,7 + # port = [1,6,7] + # print(dic) + if dic['action'] == 'on': + set = setup(dic['host'], dic['username'], dic['password']) + on = switch_on(dic['host'], dic['username'], dic['password'], dic['port']) + elif dic['action'] == 'off': + set = setup(dic['host'], dic['username'], dic['password']) + # for single in port + off = switch_off(dic['host'], dic['username'], dic['password'], dic['port']) + # off = switch_on(dic['action']) + elif dic['action'] == 'cycle': + set = setup(dic['host'], dic['username'], dic['password']) + on = switch_off(dic['host'], dic['username'], dic['password'], dic['port']) + off = switch_on(dic['host'], dic['username'], dic['password'], dic['port']) + else: + print('Command not found') + + +if __name__ == '__main__': + main() \ No newline at end of file