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.3 # Wed 09 Oct 2024 10:12:01 +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
Oct 09 10:12:07.373918 osdx systemd-journald[1768]: Runtime Journal (/run/log/journal/da0729972954483f829d339572dde7c1) is 2.0M, max 15.3M, 13.3M free. Oct 09 10:12:07.376057 osdx systemd-journald[1768]: Received client request to rotate journal, rotating. Oct 09 10:12:07.376133 osdx systemd-journald[1768]: Vacuuming done, freed 0B of archived journals from /run/log/journal/da0729972954483f829d339572dde7c1. Oct 09 10:12:07.391435 osdx OSDxCLI[339745]: User 'admin' executed a new command: 'system journal clear'. Oct 09 10:12:07.904623 osdx osdx-coredump[344289]: Deleting all coredumps in /opt/vyatta/etc/config/coredump... Oct 09 10:12:07.914593 osdx OSDxCLI[339745]: User 'admin' executed a new command: 'system coredump delete all'. Oct 09 10:12:08.563647 osdx OSDxCLI[339745]: User 'admin' entered the configuration menu. Oct 09 10:12:08.695905 osdx OSDxCLI[339745]: User 'admin' added a new cfg line: 'set system script SCRIPT_1 advisor ADVISOR1'. Oct 09 10:12:08.786897 osdx OSDxCLI[339745]: User 'admin' added a new cfg line: 'set system advisor ADVISOR1 test false'. Oct 09 10:12:08.887880 osdx OSDxCLI[339745]: User 'admin' added a new cfg line: 'set system cli configuration logging global info'. Oct 09 10:12:09.004497 osdx OSDxCLI[339745]: User 'admin' added a new cfg line: 'set system script SCRIPT_1 advisor ADVISOR1'. Oct 09 10:12:09.121069 osdx OSDxCLI[339745]: User 'admin' added a new cfg line: 'set interfaces ethernet eth0 address 10.215.200.50/24'. Oct 09 10:12:09.237673 osdx OSDxCLI[339745]: User 'admin' added a new cfg line: 'set system script SCRIPT_1 operational 1 command 'interfaces ethernet show''. Oct 09 10:12:09.356013 osdx OSDxCLI[339745]: User 'admin' added a new cfg line: 'set system script SCRIPT_1 operational 2 command 'license show''. Oct 09 10:12:09.478504 osdx OSDxCLI[339745]: User 'admin' added a new cfg line: 'show working'. Oct 09 10:12:09.593045 osdx modulelauncher[1302]: + Received data: ['339745', 'osdx.utils.xos', 'set_console_log_level', 'info'] Oct 09 10:12:09.612351 osdx OSDxCLI[339745]: Signal 10 received Oct 09 10:12:09.625628 osdx ifmon[1333]: Changed log-level to info Oct 09 10:12:09.668076 osdx kernel: 8021q: adding VLAN 0 to HW filter on device eth0 Oct 09 10:12:09.766876 osdx cfgd[1434]: [339745]Completed change to active configuration Oct 09 10:12:09.815433 osdx OSDxCLI[339745]: User 'admin' committed the configuration. Oct 09 10:12:09.844514 osdx OSDxCLI[339745]: User 'admin' left the configuration menu. Oct 09 10:12:10.057546 osdx OSDxCLI[339745]: pam_unix(cli:session): session opened for user admin(uid=1000) by admin(uid=1000) Oct 09 10:12:10.058364 osdx OSDxCLI[339745]: pam_unix(cli:session): session closed for user admin Oct 09 10:12:10.059024 osdx OSDxCLI[339745]: User 'admin' entered the configuration menu. Oct 09 10:12:10.162061 osdx OSDxCLI[339745]: pam_unix(cli:session): session opened for user admin(uid=1000) by admin(uid=1000) Oct 09 10:12:10.162678 osdx cfgd[1434]: Execute action [syntax] for node [system advisor ADVISOR1] Oct 09 10:12:10.163342 osdx OSDxCLI[339745]: pam_unix(cli:session): session closed for user admin Oct 09 10:12:10.163786 osdx OSDxCLI[339745]: User 'admin' added a new cfg line: 'set system advisor ADVISOR1 test true'. Oct 09 10:12:10.277060 osdx OSDxCLI[339745]: pam_unix(cli:session): session opened for user admin(uid=1000) by admin(uid=1000) Oct 09 10:12:10.288937 osdx OSDxCLI[339745]: pam_unix(cli:session): session closed for user admin Oct 09 10:12:10.289363 osdx OSDxCLI[339745]: User 'admin' added a new cfg line: 'show changes'. Oct 09 10:12:10.396637 osdx OSDxCLI[339745]: pam_unix(cli:session): session opened for user admin(uid=1000) by admin(uid=1000) Oct 09 10:12:10.414743 osdx cfgd[1434]: [339745]must validation for [system login user admin role] was skipped Oct 09 10:12:10.414942 osdx cfgd[1434]: Execute action [commit-subtree] for node [system advisor ADVISOR1] Oct 09 10:12:10.428549 osdx cfgd[1434]: Execute action [end] for node [system advisor ADVISOR1] Oct 09 10:12:10.438843 osdx cfgd[1434]: [339745]Completed change to active configuration Oct 09 10:12:10.441238 osdx OSDxCLI[339745]: pam_unix(cli:session): session closed for user admin Oct 09 10:12:10.441567 osdx OSDxCLI[339745]: User 'admin' committed the configuration. Oct 09 10:12:10.449435 osdx INFO[344432]: SCRIPT SCRIPT_1 operations: Oct 09 10:12:10.458123 osdx OSDxCLI[344440]: Tecla::GetLine tcgetattr error Oct 09 10:12:10.458136 osdx OSDxCLI[344440]: User 'admin' has logged in. Oct 09 10:12:10.469988 osdx OSDxCLI[344440]: User 'admin' executed a new command: 'interfaces ethernet show'. Oct 09 10:12:10.472030 osdx OSDxCLI[339745]: User 'admin' left the configuration menu. Oct 09 10:12:10.472345 osdx OSDxCLI[344440]: User 'admin' has logged out. Oct 09 10:12:10.472350 osdx OSDxCLI[344440]: Tecla::GetLine tcgetattr error Oct 09 10:12:10.473241 osdx INFO[344432]: Operation 1 'interfaces ethernet show ': ----------------------------------------------- Name IP Address Admin Oper Vrf Description ----------------------------------------------- eth0 down down eth1 down down Oct 09 10:12:10.475005 osdx modulelauncher[344432]: 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 Oct 09 10:12:10.475400 osdx cfgd[1434]: External python command [cfg.auto_scripts process ADVISOR1 SCRIPT_1 true] finished with status 1 Oct 09 10:12:10.475426 osdx cfgd[1434]: Run trap command [cfg.auto_scripts process ADVISOR1 SCRIPT_1 true]: 1 Oct 09 10:12:10.619601 osdx OSDxCLI[339745]: 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
Oct 09 10:12:07.373918 osdx systemd-journald[1768]: Runtime Journal (/run/log/journal/da0729972954483f829d339572dde7c1) is 2.0M, max 15.3M, 13.3M free. Oct 09 10:12:07.376057 osdx systemd-journald[1768]: Received client request to rotate journal, rotating. Oct 09 10:12:07.376133 osdx systemd-journald[1768]: Vacuuming done, freed 0B of archived journals from /run/log/journal/da0729972954483f829d339572dde7c1. Oct 09 10:12:07.391435 osdx OSDxCLI[339745]: User 'admin' executed a new command: 'system journal clear'. Oct 09 10:12:07.904623 osdx osdx-coredump[344289]: Deleting all coredumps in /opt/vyatta/etc/config/coredump... Oct 09 10:12:07.914593 osdx OSDxCLI[339745]: User 'admin' executed a new command: 'system coredump delete all'. Oct 09 10:12:08.563647 osdx OSDxCLI[339745]: User 'admin' entered the configuration menu. Oct 09 10:12:08.695905 osdx OSDxCLI[339745]: User 'admin' added a new cfg line: 'set system script SCRIPT_1 advisor ADVISOR1'. Oct 09 10:12:08.786897 osdx OSDxCLI[339745]: User 'admin' added a new cfg line: 'set system advisor ADVISOR1 test false'. Oct 09 10:12:08.887880 osdx OSDxCLI[339745]: User 'admin' added a new cfg line: 'set system cli configuration logging global info'. Oct 09 10:12:09.004497 osdx OSDxCLI[339745]: User 'admin' added a new cfg line: 'set system script SCRIPT_1 advisor ADVISOR1'. Oct 09 10:12:09.121069 osdx OSDxCLI[339745]: User 'admin' added a new cfg line: 'set interfaces ethernet eth0 address 10.215.200.50/24'. Oct 09 10:12:09.237673 osdx OSDxCLI[339745]: User 'admin' added a new cfg line: 'set system script SCRIPT_1 operational 1 command 'interfaces ethernet show''. Oct 09 10:12:09.356013 osdx OSDxCLI[339745]: User 'admin' added a new cfg line: 'set system script SCRIPT_1 operational 2 command 'license show''. Oct 09 10:12:09.478504 osdx OSDxCLI[339745]: User 'admin' added a new cfg line: 'show working'. Oct 09 10:12:09.593045 osdx modulelauncher[1302]: + Received data: ['339745', 'osdx.utils.xos', 'set_console_log_level', 'info'] Oct 09 10:12:09.612351 osdx OSDxCLI[339745]: Signal 10 received Oct 09 10:12:09.625628 osdx ifmon[1333]: Changed log-level to info Oct 09 10:12:09.668076 osdx kernel: 8021q: adding VLAN 0 to HW filter on device eth0 Oct 09 10:12:09.766876 osdx cfgd[1434]: [339745]Completed change to active configuration Oct 09 10:12:09.815433 osdx OSDxCLI[339745]: User 'admin' committed the configuration. Oct 09 10:12:09.844514 osdx OSDxCLI[339745]: User 'admin' left the configuration menu. Oct 09 10:12:10.057546 osdx OSDxCLI[339745]: pam_unix(cli:session): session opened for user admin(uid=1000) by admin(uid=1000) Oct 09 10:12:10.058364 osdx OSDxCLI[339745]: pam_unix(cli:session): session closed for user admin Oct 09 10:12:10.059024 osdx OSDxCLI[339745]: User 'admin' entered the configuration menu. Oct 09 10:12:10.162061 osdx OSDxCLI[339745]: pam_unix(cli:session): session opened for user admin(uid=1000) by admin(uid=1000) Oct 09 10:12:10.162678 osdx cfgd[1434]: Execute action [syntax] for node [system advisor ADVISOR1] Oct 09 10:12:10.163342 osdx OSDxCLI[339745]: pam_unix(cli:session): session closed for user admin Oct 09 10:12:10.163786 osdx OSDxCLI[339745]: User 'admin' added a new cfg line: 'set system advisor ADVISOR1 test true'. Oct 09 10:12:10.277060 osdx OSDxCLI[339745]: pam_unix(cli:session): session opened for user admin(uid=1000) by admin(uid=1000) Oct 09 10:12:10.288937 osdx OSDxCLI[339745]: pam_unix(cli:session): session closed for user admin Oct 09 10:12:10.289363 osdx OSDxCLI[339745]: User 'admin' added a new cfg line: 'show changes'. Oct 09 10:12:10.396637 osdx OSDxCLI[339745]: pam_unix(cli:session): session opened for user admin(uid=1000) by admin(uid=1000) Oct 09 10:12:10.414743 osdx cfgd[1434]: [339745]must validation for [system login user admin role] was skipped Oct 09 10:12:10.414942 osdx cfgd[1434]: Execute action [commit-subtree] for node [system advisor ADVISOR1] Oct 09 10:12:10.428549 osdx cfgd[1434]: Execute action [end] for node [system advisor ADVISOR1] Oct 09 10:12:10.438843 osdx cfgd[1434]: [339745]Completed change to active configuration Oct 09 10:12:10.441238 osdx OSDxCLI[339745]: pam_unix(cli:session): session closed for user admin Oct 09 10:12:10.441567 osdx OSDxCLI[339745]: User 'admin' committed the configuration. Oct 09 10:12:10.449435 osdx INFO[344432]: SCRIPT SCRIPT_1 operations: Oct 09 10:12:10.458123 osdx OSDxCLI[344440]: Tecla::GetLine tcgetattr error Oct 09 10:12:10.458136 osdx OSDxCLI[344440]: User 'admin' has logged in. Oct 09 10:12:10.469988 osdx OSDxCLI[344440]: User 'admin' executed a new command: 'interfaces ethernet show'. Oct 09 10:12:10.472030 osdx OSDxCLI[339745]: User 'admin' left the configuration menu. Oct 09 10:12:10.472345 osdx OSDxCLI[344440]: User 'admin' has logged out. Oct 09 10:12:10.472350 osdx OSDxCLI[344440]: Tecla::GetLine tcgetattr error Oct 09 10:12:10.473241 osdx INFO[344432]: Operation 1 'interfaces ethernet show ': ----------------------------------------------- Name IP Address Admin Oper Vrf Description ----------------------------------------------- eth0 down down eth1 down down Oct 09 10:12:10.475005 osdx modulelauncher[344432]: 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 Oct 09 10:12:10.475400 osdx cfgd[1434]: External python command [cfg.auto_scripts process ADVISOR1 SCRIPT_1 true] finished with status 1 Oct 09 10:12:10.475426 osdx cfgd[1434]: Run trap command [cfg.auto_scripts process ADVISOR1 SCRIPT_1 true]: 1 Oct 09 10:12:10.619601 osdx OSDxCLI[339745]: pam_unix(cli:session): session opened for user admin(uid=1000) by admin(uid=1000) Oct 09 10:12:10.665667 osdx OSDxCLI[339745]: pam_unix(cli:session): session closed for user admin Oct 09 10:12:10.665973 osdx OSDxCLI[339745]: User 'admin' executed a new command: 'system journal show | cat'. Oct 09 10:12:10.809443 osdx OSDxCLI[339745]: 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::ca2:9aff:fe0d:60b4/64 up up dum1 fe80::ef:6dff:fe8d:2f0e/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.3 # Wed 09 Oct 2024 10:12:27 +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.3 # Wed 09 Oct 2024 10:12:29 +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.3 # Wed 09 Oct 2024 10:12:30 +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