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.5 # Thu 20 Jun 2024 19:23:04 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-06-20 19:23:10 UTC, end at Thu 2024-06-20 19:23:13 UTC. -- Jun 20 19:23:10.437739 osdx systemd-journald[4691]: Runtime journal (/run/log/journal/4bdaa9d5a32b43918ba3b0d5647305f4) is 2.0M, max 16.0M, 14.0M free. Jun 20 19:23:10.470579 osdx OSDxCLI[25352]: User 'admin' executed a new command: 'system journal clear'. Jun 20 19:23:11.152502 osdx osdx-coredump[9087]: Deleting all coredumps in /opt/vyatta/etc/config/coredump... Jun 20 19:23:11.164018 osdx OSDxCLI[25352]: User 'admin' executed a new command: 'system coredump delete all'. Jun 20 19:23:12.117237 osdx OSDxCLI[25352]: User 'admin' entered the configuration menu. Jun 20 19:23:12.241060 osdx OSDxCLI[25352]: User 'admin' added a new cfg line: 'set system script SCRIPT_1 advisor ADVISOR1'. Jun 20 19:23:12.330934 osdx OSDxCLI[25352]: User 'admin' added a new cfg line: 'set system advisor ADVISOR1 test false'. Jun 20 19:23:12.424042 osdx OSDxCLI[25352]: User 'admin' added a new cfg line: 'set system cli configuration logging global info'. Jun 20 19:23:12.515504 osdx OSDxCLI[25352]: User 'admin' added a new cfg line: 'set system script SCRIPT_1 advisor ADVISOR1'. Jun 20 19:23:12.622907 osdx OSDxCLI[25352]: User 'admin' added a new cfg line: 'set interfaces ethernet eth0 address 10.215.200.50/24'. Jun 20 19:23:12.714780 osdx OSDxCLI[25352]: User 'admin' added a new cfg line: 'set system script SCRIPT_1 operational 1 command 'interfaces ethernet show''. Jun 20 19:23:12.848029 osdx OSDxCLI[25352]: User 'admin' added a new cfg line: 'set system script SCRIPT_1 operational 2 command 'license show''. Jun 20 19:23:12.967434 osdx modulelauncher[1181]: + Received data: ['25352', 'osdx.utils.xos', 'set_console_log_level', 'info'] Jun 20 19:23:12.980792 osdx OSDxCLI[25352]: Signal 10 received Jun 20 19:23:12.988490 osdx ifmon[1188]: Changed log-level to info Jun 20 19:23:13.026315 osdx kernel: 8021q: adding VLAN 0 to HW filter on device eth0 Jun 20 19:23:13.054212 osdx cfgd[1341]: [25352]Completed change to active configuration Jun 20 19:23:13.057394 osdx OSDxCLI[25352]: User 'admin' committed the configuration. Jun 20 19:23:13.091749 osdx OSDxCLI[25352]: User 'admin' left the configuration menu. Jun 20 19:23:13.311397 osdx OSDxCLI[25352]: pam_unix(cli:session): session opened for user admin by admin(uid=1000) Jun 20 19:23:13.312145 osdx OSDxCLI[25352]: pam_unix(cli:session): session closed for user admin Jun 20 19:23:13.312616 osdx OSDxCLI[25352]: User 'admin' entered the configuration menu. Jun 20 19:23:13.413797 osdx OSDxCLI[25352]: pam_unix(cli:session): session opened for user admin by admin(uid=1000) Jun 20 19:23:13.414271 osdx cfgd[1341]: Execute action [syntax] for node [(null)] Jun 20 19:23:13.414480 osdx cfgd[1341]: Execute action [syntax] for node [(null)] Jun 20 19:23:13.414905 osdx OSDxCLI[25352]: pam_unix(cli:session): session closed for user admin Jun 20 19:23:13.415303 osdx OSDxCLI[25352]: User 'admin' added a new cfg line: 'set system advisor ADVISOR1 test true'. Jun 20 19:23:13.536574 osdx OSDxCLI[25352]: pam_unix(cli:session): session opened for user admin by admin(uid=1000) Jun 20 19:23:13.548063 osdx cfgd[1341]: [25352]must validation for [system login user admin role] was skipped Jun 20 19:23:13.548090 osdx cfgd[1341]: Execute action [commit-subtree] for node [system advisor ADVISOR1] Jun 20 19:23:13.560447 osdx cfgd[1341]: Execute action [end] for node [system advisor ADVISOR1] Jun 20 19:23:13.569570 osdx cfgd[1341]: [25352]Completed change to active configuration Jun 20 19:23:13.573490 osdx OSDxCLI[25352]: pam_unix(cli:session): session closed for user admin Jun 20 19:23:13.573825 osdx OSDxCLI[25352]: User 'admin' committed the configuration. Jun 20 19:23:13.582685 osdx INFO[9208]: SCRIPT SCRIPT_1 operations: Jun 20 19:23:13.593738 osdx OSDxCLI[9217]: Tecla::GetLine tcgetattr error Jun 20 19:23:13.593753 osdx OSDxCLI[9217]: User 'admin' has logged in. Jun 20 19:23:13.607287 osdx OSDxCLI[9217]: User 'admin' executed a new command: 'interfaces ethernet show'. Jun 20 19:23:13.609499 osdx OSDxCLI[9217]: User 'admin' has logged out. Jun 20 19:23:13.609513 osdx OSDxCLI[9217]: Tecla::GetLine tcgetattr error Jun 20 19:23:13.610492 osdx INFO[9208]: Operation 1 'interfaces ethernet show ': ----------------------------------------------- Name IP Address Admin Oper Vrf Description ----------------------------------------------- eth0 down down eth1 down down Jun 20 19:23:13.612697 osdx modulelauncher[9208]: 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 Jun 20 19:23:13.613974 osdx cfgd[1341]: External python command [cfg.auto_scripts process ADVISOR1 SCRIPT_1 true] finished with status 1 Jun 20 19:23:13.614004 osdx cfgd[1341]: Run trap command [cfg.auto_scripts process ADVISOR1 SCRIPT_1 true]: 1 Jun 20 19:23:13.618044 osdx OSDxCLI[25352]: User 'admin' left the configuration menu. Jun 20 19:23:13.779805 osdx OSDxCLI[25352]: 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-06-20 19:23:10 UTC, end at Thu 2024-06-20 19:23:14 UTC. -- Jun 20 19:23:10.437739 osdx systemd-journald[4691]: Runtime journal (/run/log/journal/4bdaa9d5a32b43918ba3b0d5647305f4) is 2.0M, max 16.0M, 14.0M free. Jun 20 19:23:10.470579 osdx OSDxCLI[25352]: User 'admin' executed a new command: 'system journal clear'. Jun 20 19:23:11.152502 osdx osdx-coredump[9087]: Deleting all coredumps in /opt/vyatta/etc/config/coredump... Jun 20 19:23:11.164018 osdx OSDxCLI[25352]: User 'admin' executed a new command: 'system coredump delete all'. Jun 20 19:23:12.117237 osdx OSDxCLI[25352]: User 'admin' entered the configuration menu. Jun 20 19:23:12.241060 osdx OSDxCLI[25352]: User 'admin' added a new cfg line: 'set system script SCRIPT_1 advisor ADVISOR1'. Jun 20 19:23:12.330934 osdx OSDxCLI[25352]: User 'admin' added a new cfg line: 'set system advisor ADVISOR1 test false'. Jun 20 19:23:12.424042 osdx OSDxCLI[25352]: User 'admin' added a new cfg line: 'set system cli configuration logging global info'. Jun 20 19:23:12.515504 osdx OSDxCLI[25352]: User 'admin' added a new cfg line: 'set system script SCRIPT_1 advisor ADVISOR1'. Jun 20 19:23:12.622907 osdx OSDxCLI[25352]: User 'admin' added a new cfg line: 'set interfaces ethernet eth0 address 10.215.200.50/24'. Jun 20 19:23:12.714780 osdx OSDxCLI[25352]: User 'admin' added a new cfg line: 'set system script SCRIPT_1 operational 1 command 'interfaces ethernet show''. Jun 20 19:23:12.848029 osdx OSDxCLI[25352]: User 'admin' added a new cfg line: 'set system script SCRIPT_1 operational 2 command 'license show''. Jun 20 19:23:12.967434 osdx modulelauncher[1181]: + Received data: ['25352', 'osdx.utils.xos', 'set_console_log_level', 'info'] Jun 20 19:23:12.980792 osdx OSDxCLI[25352]: Signal 10 received Jun 20 19:23:12.988490 osdx ifmon[1188]: Changed log-level to info Jun 20 19:23:13.026315 osdx kernel: 8021q: adding VLAN 0 to HW filter on device eth0 Jun 20 19:23:13.054212 osdx cfgd[1341]: [25352]Completed change to active configuration Jun 20 19:23:13.057394 osdx OSDxCLI[25352]: User 'admin' committed the configuration. Jun 20 19:23:13.091749 osdx OSDxCLI[25352]: User 'admin' left the configuration menu. Jun 20 19:23:13.311397 osdx OSDxCLI[25352]: pam_unix(cli:session): session opened for user admin by admin(uid=1000) Jun 20 19:23:13.312145 osdx OSDxCLI[25352]: pam_unix(cli:session): session closed for user admin Jun 20 19:23:13.312616 osdx OSDxCLI[25352]: User 'admin' entered the configuration menu. Jun 20 19:23:13.413797 osdx OSDxCLI[25352]: pam_unix(cli:session): session opened for user admin by admin(uid=1000) Jun 20 19:23:13.414271 osdx cfgd[1341]: Execute action [syntax] for node [(null)] Jun 20 19:23:13.414480 osdx cfgd[1341]: Execute action [syntax] for node [(null)] Jun 20 19:23:13.414905 osdx OSDxCLI[25352]: pam_unix(cli:session): session closed for user admin Jun 20 19:23:13.415303 osdx OSDxCLI[25352]: User 'admin' added a new cfg line: 'set system advisor ADVISOR1 test true'. Jun 20 19:23:13.536574 osdx OSDxCLI[25352]: pam_unix(cli:session): session opened for user admin by admin(uid=1000) Jun 20 19:23:13.548063 osdx cfgd[1341]: [25352]must validation for [system login user admin role] was skipped Jun 20 19:23:13.548090 osdx cfgd[1341]: Execute action [commit-subtree] for node [system advisor ADVISOR1] Jun 20 19:23:13.560447 osdx cfgd[1341]: Execute action [end] for node [system advisor ADVISOR1] Jun 20 19:23:13.569570 osdx cfgd[1341]: [25352]Completed change to active configuration Jun 20 19:23:13.573490 osdx OSDxCLI[25352]: pam_unix(cli:session): session closed for user admin Jun 20 19:23:13.573825 osdx OSDxCLI[25352]: User 'admin' committed the configuration. Jun 20 19:23:13.582685 osdx INFO[9208]: SCRIPT SCRIPT_1 operations: Jun 20 19:23:13.593738 osdx OSDxCLI[9217]: Tecla::GetLine tcgetattr error Jun 20 19:23:13.593753 osdx OSDxCLI[9217]: User 'admin' has logged in. Jun 20 19:23:13.607287 osdx OSDxCLI[9217]: User 'admin' executed a new command: 'interfaces ethernet show'. Jun 20 19:23:13.609499 osdx OSDxCLI[9217]: User 'admin' has logged out. Jun 20 19:23:13.609513 osdx OSDxCLI[9217]: Tecla::GetLine tcgetattr error Jun 20 19:23:13.610492 osdx INFO[9208]: Operation 1 'interfaces ethernet show ': ----------------------------------------------- Name IP Address Admin Oper Vrf Description ----------------------------------------------- eth0 down down eth1 down down Jun 20 19:23:13.612697 osdx modulelauncher[9208]: 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 Jun 20 19:23:13.613974 osdx cfgd[1341]: External python command [cfg.auto_scripts process ADVISOR1 SCRIPT_1 true] finished with status 1 Jun 20 19:23:13.614004 osdx cfgd[1341]: Run trap command [cfg.auto_scripts process ADVISOR1 SCRIPT_1 true]: 1 Jun 20 19:23:13.618044 osdx OSDxCLI[25352]: User 'admin' left the configuration menu. Jun 20 19:23:13.779805 osdx OSDxCLI[25352]: pam_unix(cli:session): session opened for user admin by admin(uid=1000) Jun 20 19:23:13.838810 osdx OSDxCLI[25352]: pam_unix(cli:session): session closed for user admin Jun 20 19:23:13.839171 osdx OSDxCLI[25352]: User 'admin' executed a new command: 'system journal show | cat'. Jun 20 19:23:14.021870 osdx OSDxCLI[25352]: 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::5429:e0ff:fe89:db72/64 up up dum1 fe80::c0f3:fff:fe52:e22/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.5 # Thu 20 Jun 2024 19:23:32 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.5 # Thu 20 Jun 2024 19:23:33 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.5 # Thu 20 Jun 2024 19:23:35 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