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 script SCRIPT_1 advisor ADVISOR1 set system advisor ADVISOR1 test false set system cli configuration logging global info set system script SCRIPT_1 configuration 'set system description \'advisor applied\''
Step 2: Set the following configuration 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 v3.10.1.8 # Thu 10 Oct 2024 09:04:27 UTC +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 system script SCRIPT_1 advisor ADVISOR1 set system advisor ADVISOR1 test false set system cli configuration logging global info set system script SCRIPT_1 advisor ADVISOR1 set interfaces ethernet eth0 address 10.215.200.50/24 set system script SCRIPT_1 operational 1 command 'interfaces ethernet show' set system script SCRIPT_1 operational 2 command 'license show'
Step 2: Set the following configuration 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
-- Logs begin at Thu 2024-10-10 09:04:33 UTC, end at Thu 2024-10-10 09:04:36 UTC. -- Oct 10 09:04:33.410129 osdx systemd-journald[1712]: Runtime journal (/run/log/journal/c2d6011d26b547ba87daa360869210a1) is 2.0M, max 16.0M, 14.0M free. Oct 10 09:04:33.436417 osdx OSDxCLI[15783]: User 'admin' executed a new command: 'system journal clear'. Oct 10 09:04:34.052831 osdx osdx-coredump[19673]: Deleting all coredumps in /opt/vyatta/etc/config/coredump... Oct 10 09:04:34.062312 osdx OSDxCLI[15783]: User 'admin' executed a new command: 'system coredump delete all'. Oct 10 09:04:34.974149 osdx OSDxCLI[15783]: User 'admin' entered the configuration menu. Oct 10 09:04:35.070426 osdx OSDxCLI[15783]: User 'admin' added a new cfg line: 'set system script SCRIPT_1 advisor ADVISOR1'. Oct 10 09:04:35.210663 osdx OSDxCLI[15783]: User 'admin' added a new cfg line: 'set system advisor ADVISOR1 test false'. Oct 10 09:04:35.313042 osdx OSDxCLI[15783]: User 'admin' added a new cfg line: 'set system cli configuration logging global info'. Oct 10 09:04:35.433619 osdx OSDxCLI[15783]: User 'admin' added a new cfg line: 'set system script SCRIPT_1 advisor ADVISOR1'. Oct 10 09:04:35.552477 osdx OSDxCLI[15783]: User 'admin' added a new cfg line: 'set interfaces ethernet eth0 address 10.215.200.50/24'. Oct 10 09:04:35.638459 osdx OSDxCLI[15783]: User 'admin' added a new cfg line: 'set system script SCRIPT_1 operational 1 command 'interfaces ethernet show''. Oct 10 09:04:35.810880 osdx OSDxCLI[15783]: User 'admin' added a new cfg line: 'set system script SCRIPT_1 operational 2 command 'license show''. Oct 10 09:04:35.942005 osdx modulelauncher[1141]: + Received data: ['15783', 'osdx.utils.xos', 'set_console_log_level', 'info'] Oct 10 09:04:35.952260 osdx OSDxCLI[15783]: Signal 10 received Oct 10 09:04:35.960154 osdx ifmon[1186]: Changed log-level to info Oct 10 09:04:35.995621 osdx kernel: 8021q: adding VLAN 0 to HW filter on device eth0 Oct 10 09:04:36.026546 osdx cfgd[1328]: [15783]Completed change to active configuration Oct 10 09:04:36.029678 osdx OSDxCLI[15783]: User 'admin' committed the configuration. Oct 10 09:04:36.059361 osdx OSDxCLI[15783]: User 'admin' left the configuration menu. Oct 10 09:04:36.314543 osdx OSDxCLI[15783]: pam_unix(cli:session): session opened for user admin by admin(uid=1000) Oct 10 09:04:36.315515 osdx OSDxCLI[15783]: pam_unix(cli:session): session closed for user admin Oct 10 09:04:36.316019 osdx OSDxCLI[15783]: User 'admin' entered the configuration menu. Oct 10 09:04:36.442364 osdx OSDxCLI[15783]: pam_unix(cli:session): session opened for user admin by admin(uid=1000) Oct 10 09:04:36.442940 osdx cfgd[1328]: Execute action [syntax] for node [(null)] Oct 10 09:04:36.443058 osdx cfgd[1328]: Execute action [syntax] for node [(null)] Oct 10 09:04:36.443727 osdx OSDxCLI[15783]: pam_unix(cli:session): session closed for user admin Oct 10 09:04:36.444119 osdx OSDxCLI[15783]: User 'admin' added a new cfg line: 'set system advisor ADVISOR1 test true'. Oct 10 09:04:36.560939 osdx OSDxCLI[15783]: pam_unix(cli:session): session opened for user admin by admin(uid=1000) Oct 10 09:04:36.578497 osdx cfgd[1328]: [15783]must validation for [system login user admin role] was skipped Oct 10 09:04:36.578668 osdx cfgd[1328]: Execute action [commit-subtree] for node [system advisor ADVISOR1] Oct 10 09:04:36.588368 osdx cfgd[1328]: Execute action [end] for node [system advisor ADVISOR1] Oct 10 09:04:36.595617 osdx cfgd[1328]: [15783]Completed change to active configuration Oct 10 09:04:36.599658 osdx OSDxCLI[15783]: pam_unix(cli:session): session closed for user admin Oct 10 09:04:36.599996 osdx OSDxCLI[15783]: User 'admin' committed the configuration. Oct 10 09:04:36.603184 osdx INFO[19795]: SCRIPT SCRIPT_1 operations: Oct 10 09:04:36.615228 osdx OSDxCLI[19803]: Tecla::GetLine tcgetattr error Oct 10 09:04:36.615241 osdx OSDxCLI[19803]: User 'admin' has logged in. Oct 10 09:04:36.629250 osdx OSDxCLI[19803]: User 'admin' executed a new command: 'interfaces ethernet show'. Oct 10 09:04:36.631324 osdx OSDxCLI[19803]: User 'admin' has logged out. Oct 10 09:04:36.631339 osdx OSDxCLI[19803]: Tecla::GetLine tcgetattr error Oct 10 09:04:36.632321 osdx INFO[19795]: Operation 1 'interfaces ethernet show ': ----------------------------------------------- Name IP Address Admin Oper Vrf Description ----------------------------------------------- eth0 down down eth1 down down Oct 10 09:04:36.633931 osdx modulelauncher[19795]: Traceback (most recent call last): File "/osdx/sbin/modulelauncher.py", line 37, in run_file result = getattr(module, args[0])(args, cfg_ses_id) File "osdx/sbin/cfg/auto_scripts.py", line 62, in process File "osdx/sbin/cfg/auto_scripts.py", line 107, in _execute_script File "usr/lib/python2.7/subprocess.py", line 483, in communicate File "usr/lib/python2.7/subprocess.py", line 1119, in _communicate ValueError: I/O operation on closed file Oct 10 09:04:36.634888 osdx cfgd[1328]: External python command [cfg.auto_scripts process ADVISOR1 SCRIPT_1 true] finished with status 1 Oct 10 09:04:36.634913 osdx cfgd[1328]: Run trap command [cfg.auto_scripts process ADVISOR1 SCRIPT_1 true]: 1 Oct 10 09:04:36.637371 osdx OSDxCLI[15783]: User 'admin' left the configuration menu. Oct 10 09:04:36.786822 osdx OSDxCLI[15783]: pam_unix(cli:session): session opened for user admin 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
-- Logs begin at Thu 2024-10-10 09:04:33 UTC, end at Thu 2024-10-10 09:04:37 UTC. -- Oct 10 09:04:33.410129 osdx systemd-journald[1712]: Runtime journal (/run/log/journal/c2d6011d26b547ba87daa360869210a1) is 2.0M, max 16.0M, 14.0M free. Oct 10 09:04:33.436417 osdx OSDxCLI[15783]: User 'admin' executed a new command: 'system journal clear'. Oct 10 09:04:34.052831 osdx osdx-coredump[19673]: Deleting all coredumps in /opt/vyatta/etc/config/coredump... Oct 10 09:04:34.062312 osdx OSDxCLI[15783]: User 'admin' executed a new command: 'system coredump delete all'. Oct 10 09:04:34.974149 osdx OSDxCLI[15783]: User 'admin' entered the configuration menu. Oct 10 09:04:35.070426 osdx OSDxCLI[15783]: User 'admin' added a new cfg line: 'set system script SCRIPT_1 advisor ADVISOR1'. Oct 10 09:04:35.210663 osdx OSDxCLI[15783]: User 'admin' added a new cfg line: 'set system advisor ADVISOR1 test false'. Oct 10 09:04:35.313042 osdx OSDxCLI[15783]: User 'admin' added a new cfg line: 'set system cli configuration logging global info'. Oct 10 09:04:35.433619 osdx OSDxCLI[15783]: User 'admin' added a new cfg line: 'set system script SCRIPT_1 advisor ADVISOR1'. Oct 10 09:04:35.552477 osdx OSDxCLI[15783]: User 'admin' added a new cfg line: 'set interfaces ethernet eth0 address 10.215.200.50/24'. Oct 10 09:04:35.638459 osdx OSDxCLI[15783]: User 'admin' added a new cfg line: 'set system script SCRIPT_1 operational 1 command 'interfaces ethernet show''. Oct 10 09:04:35.810880 osdx OSDxCLI[15783]: User 'admin' added a new cfg line: 'set system script SCRIPT_1 operational 2 command 'license show''. Oct 10 09:04:35.942005 osdx modulelauncher[1141]: + Received data: ['15783', 'osdx.utils.xos', 'set_console_log_level', 'info'] Oct 10 09:04:35.952260 osdx OSDxCLI[15783]: Signal 10 received Oct 10 09:04:35.960154 osdx ifmon[1186]: Changed log-level to info Oct 10 09:04:35.995621 osdx kernel: 8021q: adding VLAN 0 to HW filter on device eth0 Oct 10 09:04:36.026546 osdx cfgd[1328]: [15783]Completed change to active configuration Oct 10 09:04:36.029678 osdx OSDxCLI[15783]: User 'admin' committed the configuration. Oct 10 09:04:36.059361 osdx OSDxCLI[15783]: User 'admin' left the configuration menu. Oct 10 09:04:36.314543 osdx OSDxCLI[15783]: pam_unix(cli:session): session opened for user admin by admin(uid=1000) Oct 10 09:04:36.315515 osdx OSDxCLI[15783]: pam_unix(cli:session): session closed for user admin Oct 10 09:04:36.316019 osdx OSDxCLI[15783]: User 'admin' entered the configuration menu. Oct 10 09:04:36.442364 osdx OSDxCLI[15783]: pam_unix(cli:session): session opened for user admin by admin(uid=1000) Oct 10 09:04:36.442940 osdx cfgd[1328]: Execute action [syntax] for node [(null)] Oct 10 09:04:36.443058 osdx cfgd[1328]: Execute action [syntax] for node [(null)] Oct 10 09:04:36.443727 osdx OSDxCLI[15783]: pam_unix(cli:session): session closed for user admin Oct 10 09:04:36.444119 osdx OSDxCLI[15783]: User 'admin' added a new cfg line: 'set system advisor ADVISOR1 test true'. Oct 10 09:04:36.560939 osdx OSDxCLI[15783]: pam_unix(cli:session): session opened for user admin by admin(uid=1000) Oct 10 09:04:36.578497 osdx cfgd[1328]: [15783]must validation for [system login user admin role] was skipped Oct 10 09:04:36.578668 osdx cfgd[1328]: Execute action [commit-subtree] for node [system advisor ADVISOR1] Oct 10 09:04:36.588368 osdx cfgd[1328]: Execute action [end] for node [system advisor ADVISOR1] Oct 10 09:04:36.595617 osdx cfgd[1328]: [15783]Completed change to active configuration Oct 10 09:04:36.599658 osdx OSDxCLI[15783]: pam_unix(cli:session): session closed for user admin Oct 10 09:04:36.599996 osdx OSDxCLI[15783]: User 'admin' committed the configuration. Oct 10 09:04:36.603184 osdx INFO[19795]: SCRIPT SCRIPT_1 operations: Oct 10 09:04:36.615228 osdx OSDxCLI[19803]: Tecla::GetLine tcgetattr error Oct 10 09:04:36.615241 osdx OSDxCLI[19803]: User 'admin' has logged in. Oct 10 09:04:36.629250 osdx OSDxCLI[19803]: User 'admin' executed a new command: 'interfaces ethernet show'. Oct 10 09:04:36.631324 osdx OSDxCLI[19803]: User 'admin' has logged out. Oct 10 09:04:36.631339 osdx OSDxCLI[19803]: Tecla::GetLine tcgetattr error Oct 10 09:04:36.632321 osdx INFO[19795]: Operation 1 'interfaces ethernet show ': ----------------------------------------------- Name IP Address Admin Oper Vrf Description ----------------------------------------------- eth0 down down eth1 down down Oct 10 09:04:36.633931 osdx modulelauncher[19795]: Traceback (most recent call last): File "/osdx/sbin/modulelauncher.py", line 37, in run_file result = getattr(module, args[0])(args, cfg_ses_id) File "osdx/sbin/cfg/auto_scripts.py", line 62, in process File "osdx/sbin/cfg/auto_scripts.py", line 107, in _execute_script File "usr/lib/python2.7/subprocess.py", line 483, in communicate File "usr/lib/python2.7/subprocess.py", line 1119, in _communicate ValueError: I/O operation on closed file Oct 10 09:04:36.634888 osdx cfgd[1328]: External python command [cfg.auto_scripts process ADVISOR1 SCRIPT_1 true] finished with status 1 Oct 10 09:04:36.634913 osdx cfgd[1328]: Run trap command [cfg.auto_scripts process ADVISOR1 SCRIPT_1 true]: 1 Oct 10 09:04:36.637371 osdx OSDxCLI[15783]: User 'admin' left the configuration menu. Oct 10 09:04:36.786822 osdx OSDxCLI[15783]: pam_unix(cli:session): session opened for user admin by admin(uid=1000) Oct 10 09:04:36.843347 osdx OSDxCLI[15783]: pam_unix(cli:session): session closed for user admin Oct 10 09:04:36.843755 osdx OSDxCLI[15783]: User 'admin' executed a new command: 'system journal show | cat'. Oct 10 09:04:37.040560 osdx OSDxCLI[15783]: pam_unix(cli:session): session opened for user admin 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 script SCRIPT_1 advisor ADVISOR1 set system advisor ADVISOR1 test false set system cli configuration logging global info set system script SCRIPT_1 advisor ADVISOR1 set system advisor ADVISOR1 test false 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::6c37:49ff:fea6:bed9/64 up up dum1 fe80::6c18:80ff:fe5c:37ed/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 script SCRIPT_1 advisor ADVISOR1 set system advisor ADVISOR1 test false set system cli configuration logging global info 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: Set the following configuration in DUT0
:
set system advisor ADVISOR1 test true
Step 3: Set the following configuration 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 v3.10.1.8 # Thu 10 Oct 2024 09:04:54 UTC +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: Set the following configuration in DUT0
:
set system advisor ADVISOR1 test true
Step 6: Set the following configuration 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 v3.10.1.8 # Thu 10 Oct 2024 09:04:56 UTC +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: Set the following configuration in DUT0
:
set system advisor ADVISOR1 test true
Step 9: Set the following configuration 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 v3.10.1.8 # Thu 10 Oct 2024 09:04:57 UTC +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