mirror of
				https://github.com/Telecominfraproject/wlan-testing.git
				synced 2025-10-31 02:48:11 +00:00 
			
		
		
		
	pdu version 1.2
This commit is contained in:
		| @@ -1,5 +1,13 @@ | ||||
| #!/usr/bin/env python3 | ||||
| """ | ||||
| Note: Please ensure that PDU is powered on. | ||||
|     Command line to be used as | ||||
|     python pdu_automation.py --host 192.168.200.90 --user admin --password 1234 --action on/off/cycle --port all/specific_port_name | ||||
|     Eg 1: python pdu_automation.py --host 192.168.200.90 --user admin --password 1234 --action off --port 'Outlet 1' | ||||
|     Eg 2: python pdu_automation.py --host 192.168.200.90 --user admin --password 1234 --action cycle --port all | ||||
| """ | ||||
| import os | ||||
| import pprint | ||||
| import json | ||||
| import time | ||||
| import argparse | ||||
| from typing import Sequence | ||||
| @@ -13,11 +21,14 @@ except: | ||||
|  | ||||
|  | ||||
| class setup: | ||||
|     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) | ||||
|     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): | ||||
| @@ -64,11 +75,7 @@ def main(argv: Optional[Sequence[str]] = None): | ||||
|     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_all\n' | ||||
|                                          'Switches all Outlets in OFF Mode eg: --off_all\n' | ||||
|                                          'Cycle all Outlets in OFF Mode and then ON Mode eg: --cycle_all\n' | ||||
|                                          'Switches the target Outlets in ON Mode eg: --on\n' | ||||
|                                          'Switches the target Outlets in OFF Mode --off\n') | ||||
|     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) | ||||
| @@ -90,8 +97,3 @@ def main(argv: Optional[Sequence[str]] = None): | ||||
|  | ||||
| if __name__ == '__main__': | ||||
|     main() | ||||
|  | ||||
| # Command line to be used as | ||||
| # python pdu_automation.py --host 192.168.200.90 --user admin --password 1234 --action on --port all | ||||
| # python pdu_automation.py --host 192.168.200.90 --user admin --password 1234 --action off --port 'Outlet 1' | ||||
| # python pdu_automation.py --host 192.168.200.90 --user admin --password 1234 --action cycle --port all | ||||
|   | ||||
		Reference in New Issue
	
	Block a user
	 Amrit Raj
					Amrit Raj