Script
Test to check advisor scripts
Configuration Script
Description
In this scenario, an advisor is triggered to activate the automatic script. When the advisor is changed to true, the automatic script associated with the advisor is executed, aplying the commands in the active configuration.
Scenario
Step 1: Set the following configuration in DUT0
:
set system advisor ADVISOR1 test false set system cli configuration logging global info set system login user admin authentication encrypted-password '$6$GSjsCj8gHLv$/VcqU6FLi6CT2Oxn0MJQ2C2tqnRDrYKNF8HIYWJp68nvXvPdFccDsT04.WtigUONbKYrgKg8d6rEs8PjljMkH0' set system script SCRIPT_1 advisor ADVISOR1 set system script SCRIPT_1 configuration 'set system description \'advisor applied\''
Step 2: Modify the following configuration lines in DUT0
:
set system advisor ADVISOR1 test true
Step 3: Run command show running
at DUT0
and check if output contains the following tokens:
set system description 'advisor applied'Show output
# Teldat OSDx VM version v4.1.1.4 # Wed 04 Dec 2024 16:25:55 +00:00 # Warning: Configuration has not been saved set system advisor ADVISOR1 test true set system cli configuration logging global info set system description 'advisor applied' set system login user admin authentication encrypted-password '$6$GSjsCj8gHLv$/VcqU6FLi6CT2Oxn0MJQ2C2tqnRDrYKNF8HIYWJp68nvXvPdFccDsT04.WtigUONbKYrgKg8d6rEs8PjljMkH0' set system script SCRIPT_1 advisor ADVISOR1 set system script SCRIPT_1 configuration 'set system description \'advisor applied\''
Operational Script
Description
In this scenario, an advisor is triggered to activate the automatic script. When the advisor is changed to true, the automatic script associated with the advisor is executed, proccessing the operational commands in the specified order.
Scenario
Step 1: Set the following configuration in DUT0
:
set interfaces ethernet eth0 address 10.215.200.50/24 set system advisor ADVISOR1 test false set system cli configuration logging global info set system login user admin authentication encrypted-password '$6$GSjsCj8gHLv$/VcqU6FLi6CT2Oxn0MJQ2C2tqnRDrYKNF8HIYWJp68nvXvPdFccDsT04.WtigUONbKYrgKg8d6rEs8PjljMkH0' set system script SCRIPT_1 advisor ADVISOR1 set system script SCRIPT_1 operational 1 command 'interfaces ethernet show' set system script SCRIPT_1 operational 2 command 'license show'
Step 2: Modify the following configuration lines in DUT0
:
set system advisor ADVISOR1 test true
Step 3: Run command system journal show | cat
at DUT0
and check if output contains the following tokens:
interfaces ethernet showShow output
Dec 04 16:25:59.286673 osdx systemd-journald[1574]: Runtime Journal (/run/log/journal/2754912ae611401eb118833e63cf0c07) is 2.0M, max 15.3M, 13.2M free. Dec 04 16:25:59.289876 osdx systemd-journald[1574]: Received client request to rotate journal, rotating. Dec 04 16:25:59.289928 osdx systemd-journald[1574]: Vacuuming done, freed 0B of archived journals from /run/log/journal/2754912ae611401eb118833e63cf0c07. Dec 04 16:25:59.297177 osdx OSDxCLI[257063]: User 'admin' executed a new command: 'system journal clear'. Dec 04 16:25:59.616031 osdx osdx-coredump[301115]: Deleting all coredumps in /opt/vyatta/etc/config/coredump... Dec 04 16:25:59.623087 osdx OSDxCLI[257063]: User 'admin' executed a new command: 'system coredump delete all'. Dec 04 16:26:00.075969 osdx OSDxCLI[257063]: User 'admin' entered the configuration menu. Dec 04 16:26:00.135235 osdx OSDxCLI[257063]: User 'admin' added a new cfg line: 'set system script SCRIPT_1 advisor ADVISOR1'. Dec 04 16:26:00.236792 osdx OSDxCLI[257063]: User 'admin' added a new cfg line: 'set system advisor ADVISOR1 test false'. Dec 04 16:26:00.291860 osdx OSDxCLI[257063]: User 'admin' added a new cfg line: 'set system cli configuration logging global info'. Dec 04 16:26:00.381469 osdx OSDxCLI[257063]: User 'admin' added a new cfg line: 'set system script SCRIPT_1 advisor ADVISOR1'. Dec 04 16:26:00.443721 osdx OSDxCLI[257063]: User 'admin' added a new cfg line: 'set interfaces ethernet eth0 address 10.215.200.50/24'. Dec 04 16:26:00.538946 osdx OSDxCLI[257063]: User 'admin' added a new cfg line: 'set system script SCRIPT_1 operational 1 command 'interfaces ethernet show''. Dec 04 16:26:00.598685 osdx OSDxCLI[257063]: User 'admin' added a new cfg line: 'set system script SCRIPT_1 operational 2 command 'license show''. Dec 04 16:26:00.700996 osdx OSDxCLI[257063]: User 'admin' added a new cfg line: 'show working'. Dec 04 16:26:00.775432 osdx modulelauncher[1108]: + Received data: ['257063', 'osdx.utils.xos', 'set_console_log_level', 'info'] Dec 04 16:26:00.788533 osdx OSDxCLI[257063]: Signal 10 received Dec 04 16:26:00.796365 osdx ifmon[1140]: Changed log-level to info Dec 04 16:26:00.829756 osdx kernel: 8021q: adding VLAN 0 to HW filter on device eth0 Dec 04 16:26:00.894418 osdx cfgd[1239]: [257063]Completed change to active configuration Dec 04 16:26:00.917728 osdx OSDxCLI[257063]: User 'admin' committed the configuration. Dec 04 16:26:00.938755 osdx OSDxCLI[257063]: User 'admin' left the configuration menu. Dec 04 16:26:00.982705 osdx zebra[1204]: [RZ3YY-GPH41][EC 100663310] snmp[warning]: Warning: Failed to connect to the agentx master agent ([NIL]): Dec 04 16:26:01.094956 osdx OSDxCLI[257063]: pam_unix(cli:session): session opened for user admin(uid=1000) by admin(uid=1000) Dec 04 16:26:01.095390 osdx OSDxCLI[257063]: pam_unix(cli:session): session closed for user admin Dec 04 16:26:01.095581 osdx OSDxCLI[257063]: User 'admin' entered the configuration menu. Dec 04 16:26:01.156360 osdx OSDxCLI[257063]: pam_unix(cli:session): session opened for user admin(uid=1000) by admin(uid=1000) Dec 04 16:26:01.156725 osdx cfgd[1239]: Execute action [syntax] for node [system advisor ADVISOR1] Dec 04 16:26:01.157008 osdx OSDxCLI[257063]: pam_unix(cli:session): session closed for user admin Dec 04 16:26:01.157309 osdx OSDxCLI[257063]: User 'admin' added a new cfg line: 'set system advisor ADVISOR1 test true'. Dec 04 16:26:01.247691 osdx OSDxCLI[257063]: pam_unix(cli:session): session opened for user admin(uid=1000) by admin(uid=1000) Dec 04 16:26:01.256211 osdx OSDxCLI[257063]: pam_unix(cli:session): session closed for user admin Dec 04 16:26:01.256568 osdx OSDxCLI[257063]: User 'admin' added a new cfg line: 'show changes'. Dec 04 16:26:01.304300 osdx OSDxCLI[257063]: pam_unix(cli:session): session opened for user admin(uid=1000) by admin(uid=1000) Dec 04 16:26:01.311147 osdx cfgd[1239]: [257063]must validation for [system login user admin role] was skipped Dec 04 16:26:01.311157 osdx cfgd[1239]: Execute action [commit-subtree] for node [system advisor ADVISOR1] Dec 04 16:26:01.317390 osdx cfgd[1239]: Execute action [end] for node [system advisor ADVISOR1] Dec 04 16:26:01.323679 osdx cfgd[1239]: [257063]Completed change to active configuration Dec 04 16:26:01.325330 osdx OSDxCLI[257063]: pam_unix(cli:session): session closed for user admin Dec 04 16:26:01.325622 osdx OSDxCLI[257063]: User 'admin' committed the configuration. Dec 04 16:26:01.328763 osdx INFO[301264]: SCRIPT SCRIPT_1 operations: Dec 04 16:26:01.334143 osdx OSDxCLI[301271]: Tecla::GetLine tcgetattr error Dec 04 16:26:01.334148 osdx OSDxCLI[301271]: User 'admin' has logged in. Dec 04 16:26:01.343608 osdx OSDxCLI[301271]: User 'admin' executed a new command: 'interfaces ethernet show'. Dec 04 16:26:01.345095 osdx OSDxCLI[301271]: User 'admin' has logged out. Dec 04 16:26:01.345103 osdx OSDxCLI[301271]: Tecla::GetLine tcgetattr error Dec 04 16:26:01.345827 osdx INFO[301264]: Operation 1 'interfaces ethernet show ': ----------------------------------------------- Name IP Address Admin Oper Vrf Description ----------------------------------------------- eth0 down down eth1 down down Dec 04 16:26:01.347805 osdx modulelauncher[301264]: Traceback (most recent call last): File "/osdx/sbin/modulelauncher.py", line 36, in run_file result = getattr(module, args[0])(args, cfg_ses_id) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "osdx/sbin/cfg/auto_scripts.py", line 61, in process File "osdx/sbin/cfg/auto_scripts.py", line 108, in _execute_script File "usr/lib/python3.11/subprocess.py", line 1182, in communicate ValueError: Cannot send input after starting communication Dec 04 16:26:01.348156 osdx cfgd[1239]: External python command [cfg.auto_scripts process ADVISOR1 SCRIPT_1 true] finished with status 1 Dec 04 16:26:01.348173 osdx cfgd[1239]: Run trap command [cfg.auto_scripts process ADVISOR1 SCRIPT_1 true]: 1 Dec 04 16:26:01.370775 osdx OSDxCLI[257063]: User 'admin' left the configuration menu. Dec 04 16:26:01.463224 osdx OSDxCLI[257063]: pam_unix(cli:session): session opened for user admin(uid=1000) by admin(uid=1000)
Step 4: Run command system journal show | cat
at DUT0
and check if output contains the following tokens:
license showShow output
Dec 04 16:25:59.286673 osdx systemd-journald[1574]: Runtime Journal (/run/log/journal/2754912ae611401eb118833e63cf0c07) is 2.0M, max 15.3M, 13.2M free. Dec 04 16:25:59.289876 osdx systemd-journald[1574]: Received client request to rotate journal, rotating. Dec 04 16:25:59.289928 osdx systemd-journald[1574]: Vacuuming done, freed 0B of archived journals from /run/log/journal/2754912ae611401eb118833e63cf0c07. Dec 04 16:25:59.297177 osdx OSDxCLI[257063]: User 'admin' executed a new command: 'system journal clear'. Dec 04 16:25:59.616031 osdx osdx-coredump[301115]: Deleting all coredumps in /opt/vyatta/etc/config/coredump... Dec 04 16:25:59.623087 osdx OSDxCLI[257063]: User 'admin' executed a new command: 'system coredump delete all'. Dec 04 16:26:00.075969 osdx OSDxCLI[257063]: User 'admin' entered the configuration menu. Dec 04 16:26:00.135235 osdx OSDxCLI[257063]: User 'admin' added a new cfg line: 'set system script SCRIPT_1 advisor ADVISOR1'. Dec 04 16:26:00.236792 osdx OSDxCLI[257063]: User 'admin' added a new cfg line: 'set system advisor ADVISOR1 test false'. Dec 04 16:26:00.291860 osdx OSDxCLI[257063]: User 'admin' added a new cfg line: 'set system cli configuration logging global info'. Dec 04 16:26:00.381469 osdx OSDxCLI[257063]: User 'admin' added a new cfg line: 'set system script SCRIPT_1 advisor ADVISOR1'. Dec 04 16:26:00.443721 osdx OSDxCLI[257063]: User 'admin' added a new cfg line: 'set interfaces ethernet eth0 address 10.215.200.50/24'. Dec 04 16:26:00.538946 osdx OSDxCLI[257063]: User 'admin' added a new cfg line: 'set system script SCRIPT_1 operational 1 command 'interfaces ethernet show''. Dec 04 16:26:00.598685 osdx OSDxCLI[257063]: User 'admin' added a new cfg line: 'set system script SCRIPT_1 operational 2 command 'license show''. Dec 04 16:26:00.700996 osdx OSDxCLI[257063]: User 'admin' added a new cfg line: 'show working'. Dec 04 16:26:00.775432 osdx modulelauncher[1108]: + Received data: ['257063', 'osdx.utils.xos', 'set_console_log_level', 'info'] Dec 04 16:26:00.788533 osdx OSDxCLI[257063]: Signal 10 received Dec 04 16:26:00.796365 osdx ifmon[1140]: Changed log-level to info Dec 04 16:26:00.829756 osdx kernel: 8021q: adding VLAN 0 to HW filter on device eth0 Dec 04 16:26:00.894418 osdx cfgd[1239]: [257063]Completed change to active configuration Dec 04 16:26:00.917728 osdx OSDxCLI[257063]: User 'admin' committed the configuration. Dec 04 16:26:00.938755 osdx OSDxCLI[257063]: User 'admin' left the configuration menu. Dec 04 16:26:00.982705 osdx zebra[1204]: [RZ3YY-GPH41][EC 100663310] snmp[warning]: Warning: Failed to connect to the agentx master agent ([NIL]): Dec 04 16:26:01.094956 osdx OSDxCLI[257063]: pam_unix(cli:session): session opened for user admin(uid=1000) by admin(uid=1000) Dec 04 16:26:01.095390 osdx OSDxCLI[257063]: pam_unix(cli:session): session closed for user admin Dec 04 16:26:01.095581 osdx OSDxCLI[257063]: User 'admin' entered the configuration menu. Dec 04 16:26:01.156360 osdx OSDxCLI[257063]: pam_unix(cli:session): session opened for user admin(uid=1000) by admin(uid=1000) Dec 04 16:26:01.156725 osdx cfgd[1239]: Execute action [syntax] for node [system advisor ADVISOR1] Dec 04 16:26:01.157008 osdx OSDxCLI[257063]: pam_unix(cli:session): session closed for user admin Dec 04 16:26:01.157309 osdx OSDxCLI[257063]: User 'admin' added a new cfg line: 'set system advisor ADVISOR1 test true'. Dec 04 16:26:01.247691 osdx OSDxCLI[257063]: pam_unix(cli:session): session opened for user admin(uid=1000) by admin(uid=1000) Dec 04 16:26:01.256211 osdx OSDxCLI[257063]: pam_unix(cli:session): session closed for user admin Dec 04 16:26:01.256568 osdx OSDxCLI[257063]: User 'admin' added a new cfg line: 'show changes'. Dec 04 16:26:01.304300 osdx OSDxCLI[257063]: pam_unix(cli:session): session opened for user admin(uid=1000) by admin(uid=1000) Dec 04 16:26:01.311147 osdx cfgd[1239]: [257063]must validation for [system login user admin role] was skipped Dec 04 16:26:01.311157 osdx cfgd[1239]: Execute action [commit-subtree] for node [system advisor ADVISOR1] Dec 04 16:26:01.317390 osdx cfgd[1239]: Execute action [end] for node [system advisor ADVISOR1] Dec 04 16:26:01.323679 osdx cfgd[1239]: [257063]Completed change to active configuration Dec 04 16:26:01.325330 osdx OSDxCLI[257063]: pam_unix(cli:session): session closed for user admin Dec 04 16:26:01.325622 osdx OSDxCLI[257063]: User 'admin' committed the configuration. Dec 04 16:26:01.328763 osdx INFO[301264]: SCRIPT SCRIPT_1 operations: Dec 04 16:26:01.334143 osdx OSDxCLI[301271]: Tecla::GetLine tcgetattr error Dec 04 16:26:01.334148 osdx OSDxCLI[301271]: User 'admin' has logged in. Dec 04 16:26:01.343608 osdx OSDxCLI[301271]: User 'admin' executed a new command: 'interfaces ethernet show'. Dec 04 16:26:01.345095 osdx OSDxCLI[301271]: User 'admin' has logged out. Dec 04 16:26:01.345103 osdx OSDxCLI[301271]: Tecla::GetLine tcgetattr error Dec 04 16:26:01.345827 osdx INFO[301264]: Operation 1 'interfaces ethernet show ': ----------------------------------------------- Name IP Address Admin Oper Vrf Description ----------------------------------------------- eth0 down down eth1 down down Dec 04 16:26:01.347805 osdx modulelauncher[301264]: Traceback (most recent call last): File "/osdx/sbin/modulelauncher.py", line 36, in run_file result = getattr(module, args[0])(args, cfg_ses_id) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "osdx/sbin/cfg/auto_scripts.py", line 61, in process File "osdx/sbin/cfg/auto_scripts.py", line 108, in _execute_script File "usr/lib/python3.11/subprocess.py", line 1182, in communicate ValueError: Cannot send input after starting communication Dec 04 16:26:01.348156 osdx cfgd[1239]: External python command [cfg.auto_scripts process ADVISOR1 SCRIPT_1 true] finished with status 1 Dec 04 16:26:01.348173 osdx cfgd[1239]: Run trap command [cfg.auto_scripts process ADVISOR1 SCRIPT_1 true]: 1 Dec 04 16:26:01.370775 osdx OSDxCLI[257063]: User 'admin' left the configuration menu. Dec 04 16:26:01.463224 osdx OSDxCLI[257063]: pam_unix(cli:session): session opened for user admin(uid=1000) by admin(uid=1000) Dec 04 16:26:01.498338 osdx OSDxCLI[257063]: pam_unix(cli:session): session closed for user admin Dec 04 16:26:01.498570 osdx OSDxCLI[257063]: User 'admin' executed a new command: 'system journal show | cat'. Dec 04 16:26:01.575296 osdx OSDxCLI[257063]: pam_unix(cli:session): session opened for user admin(uid=1000) by admin(uid=1000)
Simple Script Execution
Description
In this scenario, an automatic script is activated directly without any advisor triggering. The script is activated using the system script <txt> activate command.
Scenario
Step 1: Set the following configuration in DUT0
:
set system advisor ADVISOR1 test false set system cli configuration logging global info set system login user admin authentication encrypted-password '$6$GSjsCj8gHLv$/VcqU6FLi6CT2Oxn0MJQ2C2tqnRDrYKNF8HIYWJp68nvXvPdFccDsT04.WtigUONbKYrgKg8d6rEs8PjljMkH0' set system script SCRIPT_1 advisor ADVISOR1 set system script SCRIPT_1 configuration 'set interfaces dummy dum0' set system script SCRIPT_1 configuration 'set interfaces dummy dum1'
Step 2: Run command system script SCRIPT_1 activate
at DUT0
.
Step 3: Run command interfaces dummy show
at DUT0
and check if output matches the following regular expressions:
dum0.*\ndum1Show output
----------------------------------------------------------------- Name IP Address Admin Oper Vrf Description ----------------------------------------------------------------- dum0 fe80::8f7:c8ff:feba:8b90/64 up up dum1 fe80::e0ce:6eff:fe74:cdaa/64 up up
Multiple Triggers Script
Description
In this scenario, an advisor is triggered multiple times to activate the automatic script. When the advisor is changed to true, the automatic script associated with the advisor is executed, proccessing the operational commands in the specified order.
Scenario
Step 1: Set the following configuration in DUT0
:
set system advisor ADVISOR1 test false set system cli configuration logging global info set system login user admin authentication encrypted-password '$6$GSjsCj8gHLv$/VcqU6FLi6CT2Oxn0MJQ2C2tqnRDrYKNF8HIYWJp68nvXvPdFccDsT04.WtigUONbKYrgKg8d6rEs8PjljMkH0' set system script SCRIPT_1 advisor ADVISOR1 set system script SCRIPT_1 configuration 'set system description \'advisor applied\'' set system script SCRIPT_1 number-of-triggers 3
Note
Wait for the advisor to turn on. After that, wait for the advisor to turn off. This produces only one trigger.
Step 2: Modify the following configuration lines in DUT0
:
set system advisor ADVISOR1 test true
Step 3: Modify the following configuration lines in DUT0
:
set system advisor ADVISOR1 test false
Step 4: Expect a failure in the following command:
Run command show running
at DUT0
and check if output contains the following tokens:
set system description 'advisor applied'Show output
# Teldat OSDx VM version v4.1.1.4 # Wed 04 Dec 2024 16:26:13 +00:00 # Warning: Configuration has not been saved set system advisor ADVISOR1 test false set system cli configuration logging global info set system login user admin authentication encrypted-password '$6$GSjsCj8gHLv$/VcqU6FLi6CT2Oxn0MJQ2C2tqnRDrYKNF8HIYWJp68nvXvPdFccDsT04.WtigUONbKYrgKg8d6rEs8PjljMkH0' set system script SCRIPT_1 advisor ADVISOR1 set system script SCRIPT_1 configuration 'set system description \'advisor applied\'' set system script SCRIPT_1 number-of-triggers 3
Note
Wait for the advisor to turn on. After that, wait for the advisor to turn off. This produces only one trigger.
Step 5: Modify the following configuration lines in DUT0
:
set system advisor ADVISOR1 test true
Step 6: Modify the following configuration lines in DUT0
:
set system advisor ADVISOR1 test false
Step 7: Expect a failure in the following command:
Run command show running
at DUT0
and check if output contains the following tokens:
set system description 'advisor applied'Show output
# Teldat OSDx VM version v4.1.1.4 # Wed 04 Dec 2024 16:26:14 +00:00 # Warning: Configuration has not been saved set system advisor ADVISOR1 test false set system cli configuration logging global info set system login user admin authentication encrypted-password '$6$GSjsCj8gHLv$/VcqU6FLi6CT2Oxn0MJQ2C2tqnRDrYKNF8HIYWJp68nvXvPdFccDsT04.WtigUONbKYrgKg8d6rEs8PjljMkH0' set system script SCRIPT_1 advisor ADVISOR1 set system script SCRIPT_1 configuration 'set system description \'advisor applied\'' set system script SCRIPT_1 number-of-triggers 3
Note
Wait for the advisor to turn on. After that, wait for the advisor to turn off. This produces only one trigger.
Step 8: Modify the following configuration lines in DUT0
:
set system advisor ADVISOR1 test true
Step 9: Modify the following configuration lines in DUT0
:
set system advisor ADVISOR1 test false
Step 10: Run command show running
at DUT0
and check if output contains the following tokens:
set system description 'advisor applied'Show output
# Teldat OSDx VM version v4.1.1.4 # Wed 04 Dec 2024 16:26:15 +00:00 # Warning: Configuration has not been saved set system advisor ADVISOR1 test false set system cli configuration logging global info set system description 'advisor applied' set system login user admin authentication encrypted-password '$6$GSjsCj8gHLv$/VcqU6FLi6CT2Oxn0MJQ2C2tqnRDrYKNF8HIYWJp68nvXvPdFccDsT04.WtigUONbKYrgKg8d6rEs8PjljMkH0' set system script SCRIPT_1 advisor ADVISOR1 set system script SCRIPT_1 configuration 'set system description \'advisor applied\'' set system script SCRIPT_1 number-of-triggers 3