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 to 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 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.8.1.9 # Tue 23 Apr 2024 05:24:18 PM UTC # Warning: Configuration has not been saved set system advisor ADVISOR1 test true set system 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 to 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 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 Tue 2024-04-23 17:24:22 UTC, end at Tue 2024-04-23 17:24:23 UTC. -- Apr 23 17:24:22.265089 osdx systemd-journald[567]: Runtime journal (/run/log/journal/6df91b3cebc34c1981199ddec73128ac) is 2.0M, max 16.0M, 14.0M free. Apr 23 17:24:22.273056 osdx OSDxCLI[12455]: User 'admin' executed a new command: 'system journal clear'. Apr 23 17:24:22.476655 osdx OSDxCLI[12455]: User 'admin' entered the configuration menu. Apr 23 17:24:22.572183 osdx OSDxCLI[12455]: User 'admin' added a new cfg line: 'set system script SCRIPT_1 advisor ADVISOR1'. Apr 23 17:24:22.619263 osdx OSDxCLI[12455]: User 'admin' added a new cfg line: 'set system advisor ADVISOR1 test false'. Apr 23 17:24:22.711482 osdx OSDxCLI[12455]: User 'admin' added a new cfg line: 'set system configuration logging global info'. Apr 23 17:24:22.759145 osdx OSDxCLI[12455]: User 'admin' added a new cfg line: 'set system script SCRIPT_1 advisor ADVISOR1'. Apr 23 17:24:22.853965 osdx OSDxCLI[12455]: User 'admin' added a new cfg line: 'set interfaces ethernet eth0 address 10.215.200.50/24'. Apr 23 17:24:22.904801 osdx OSDxCLI[12455]: User 'admin' added a new cfg line: 'set system script SCRIPT_1 operational 1 command 'interfaces ethernet show''. Apr 23 17:24:22.995470 osdx OSDxCLI[12455]: User 'admin' added a new cfg line: 'set system script SCRIPT_1 operational 2 command 'license show''. Apr 23 17:24:23.049618 osdx modulelauncher[888]: + Received data: ['12455', 'osdx.utils.xos', 'set_console_log_level', 'info'] Apr 23 17:24:23.054972 osdx OSDxCLI[12455]: Signal 10 received Apr 23 17:24:23.087564 osdx kernel: 8021q: adding VLAN 0 to HW filter on device eth0 Apr 23 17:24:23.112481 osdx cfgd[1182]: [12455]Completed change to active configuration Apr 23 17:24:23.118838 osdx OSDxCLI[12455]: User 'admin' committed the configuration. Apr 23 17:24:23.140827 osdx OSDxCLI[12455]: User 'admin' left the configuration menu. Apr 23 17:24:23.325456 osdx OSDxCLI[12455]: pam_unix(cli:session): session opened for user admin by admin(uid=1000) Apr 23 17:24:23.325932 osdx OSDxCLI[12455]: pam_unix(cli:session): session closed for user admin Apr 23 17:24:23.326085 osdx OSDxCLI[12455]: User 'admin' entered the configuration menu. Apr 23 17:24:23.376470 osdx OSDxCLI[12455]: pam_unix(cli:session): session opened for user admin by admin(uid=1000) Apr 23 17:24:23.376786 osdx OSDxCLI[12455]: pam_unix(cli:session): session closed for user admin Apr 23 17:24:23.376923 osdx OSDxCLI[12455]: User 'admin' added a new cfg line: 'set system advisor ADVISOR1 test true'. Apr 23 17:24:23.466630 osdx OSDxCLI[12455]: pam_unix(cli:session): session opened for user admin by admin(uid=1000) Apr 23 17:24:23.481451 osdx cfgd[1182]: [12455]Completed change to active configuration Apr 23 17:24:23.484414 osdx OSDxCLI[12455]: pam_unix(cli:session): session closed for user admin Apr 23 17:24:23.484575 osdx OSDxCLI[12455]: User 'admin' committed the configuration. Apr 23 17:24:23.486416 osdx INFO[17286]: SCRIPT SCRIPT_1 operations: Apr 23 17:24:23.494725 osdx OSDxCLI[17291]: Tecla::GetLine tcgetattr error Apr 23 17:24:23.494915 osdx OSDxCLI[17291]: User 'admin' has logged in. Apr 23 17:24:23.499027 osdx OSDxCLI[12455]: User 'admin' left the configuration menu. Apr 23 17:24:23.505626 osdx OSDxCLI[17291]: User 'admin' executed a new command: 'interfaces ethernet show'. Apr 23 17:24:23.506414 osdx OSDxCLI[17291]: User 'admin' has logged out. Apr 23 17:24:23.506416 osdx OSDxCLI[17291]: Tecla::GetLine tcgetattr error Apr 23 17:24:23.506876 osdx INFO[17286]: Operation 1 'interfaces ethernet show ': ----------------------------------------------- Name IP Address Admin Oper Vrf Description ----------------------------------------------- eth0 down down eth1 down down Apr 23 17:24:23.508370 osdx modulelauncher[17286]: 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 Apr 23 17:24:23.509064 osdx cfgd[1182]: External python command [cfg.auto_scripts process ADVISOR1 SCRIPT_1 true] finished with status 1 Apr 23 17:24:23.509075 osdx cfgd[1182]: Run trap command [cfg.auto_scripts process ADVISOR1 SCRIPT_1 true]: 1 Apr 23 17:24:23.615876 osdx OSDxCLI[12455]: 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 Tue 2024-04-23 17:24:22 UTC, end at Tue 2024-04-23 17:24:23 UTC. -- Apr 23 17:24:22.265089 osdx systemd-journald[567]: Runtime journal (/run/log/journal/6df91b3cebc34c1981199ddec73128ac) is 2.0M, max 16.0M, 14.0M free. Apr 23 17:24:22.273056 osdx OSDxCLI[12455]: User 'admin' executed a new command: 'system journal clear'. Apr 23 17:24:22.476655 osdx OSDxCLI[12455]: User 'admin' entered the configuration menu. Apr 23 17:24:22.572183 osdx OSDxCLI[12455]: User 'admin' added a new cfg line: 'set system script SCRIPT_1 advisor ADVISOR1'. Apr 23 17:24:22.619263 osdx OSDxCLI[12455]: User 'admin' added a new cfg line: 'set system advisor ADVISOR1 test false'. Apr 23 17:24:22.711482 osdx OSDxCLI[12455]: User 'admin' added a new cfg line: 'set system configuration logging global info'. Apr 23 17:24:22.759145 osdx OSDxCLI[12455]: User 'admin' added a new cfg line: 'set system script SCRIPT_1 advisor ADVISOR1'. Apr 23 17:24:22.853965 osdx OSDxCLI[12455]: User 'admin' added a new cfg line: 'set interfaces ethernet eth0 address 10.215.200.50/24'. Apr 23 17:24:22.904801 osdx OSDxCLI[12455]: User 'admin' added a new cfg line: 'set system script SCRIPT_1 operational 1 command 'interfaces ethernet show''. Apr 23 17:24:22.995470 osdx OSDxCLI[12455]: User 'admin' added a new cfg line: 'set system script SCRIPT_1 operational 2 command 'license show''. Apr 23 17:24:23.049618 osdx modulelauncher[888]: + Received data: ['12455', 'osdx.utils.xos', 'set_console_log_level', 'info'] Apr 23 17:24:23.054972 osdx OSDxCLI[12455]: Signal 10 received Apr 23 17:24:23.087564 osdx kernel: 8021q: adding VLAN 0 to HW filter on device eth0 Apr 23 17:24:23.112481 osdx cfgd[1182]: [12455]Completed change to active configuration Apr 23 17:24:23.118838 osdx OSDxCLI[12455]: User 'admin' committed the configuration. Apr 23 17:24:23.140827 osdx OSDxCLI[12455]: User 'admin' left the configuration menu. Apr 23 17:24:23.325456 osdx OSDxCLI[12455]: pam_unix(cli:session): session opened for user admin by admin(uid=1000) Apr 23 17:24:23.325932 osdx OSDxCLI[12455]: pam_unix(cli:session): session closed for user admin Apr 23 17:24:23.326085 osdx OSDxCLI[12455]: User 'admin' entered the configuration menu. Apr 23 17:24:23.376470 osdx OSDxCLI[12455]: pam_unix(cli:session): session opened for user admin by admin(uid=1000) Apr 23 17:24:23.376786 osdx OSDxCLI[12455]: pam_unix(cli:session): session closed for user admin Apr 23 17:24:23.376923 osdx OSDxCLI[12455]: User 'admin' added a new cfg line: 'set system advisor ADVISOR1 test true'. Apr 23 17:24:23.466630 osdx OSDxCLI[12455]: pam_unix(cli:session): session opened for user admin by admin(uid=1000) Apr 23 17:24:23.481451 osdx cfgd[1182]: [12455]Completed change to active configuration Apr 23 17:24:23.484414 osdx OSDxCLI[12455]: pam_unix(cli:session): session closed for user admin Apr 23 17:24:23.484575 osdx OSDxCLI[12455]: User 'admin' committed the configuration. Apr 23 17:24:23.486416 osdx INFO[17286]: SCRIPT SCRIPT_1 operations: Apr 23 17:24:23.494725 osdx OSDxCLI[17291]: Tecla::GetLine tcgetattr error Apr 23 17:24:23.494915 osdx OSDxCLI[17291]: User 'admin' has logged in. Apr 23 17:24:23.499027 osdx OSDxCLI[12455]: User 'admin' left the configuration menu. Apr 23 17:24:23.505626 osdx OSDxCLI[17291]: User 'admin' executed a new command: 'interfaces ethernet show'. Apr 23 17:24:23.506414 osdx OSDxCLI[17291]: User 'admin' has logged out. Apr 23 17:24:23.506416 osdx OSDxCLI[17291]: Tecla::GetLine tcgetattr error Apr 23 17:24:23.506876 osdx INFO[17286]: Operation 1 'interfaces ethernet show ': ----------------------------------------------- Name IP Address Admin Oper Vrf Description ----------------------------------------------- eth0 down down eth1 down down Apr 23 17:24:23.508370 osdx modulelauncher[17286]: 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 Apr 23 17:24:23.509064 osdx cfgd[1182]: External python command [cfg.auto_scripts process ADVISOR1 SCRIPT_1 true] finished with status 1 Apr 23 17:24:23.509075 osdx cfgd[1182]: Run trap command [cfg.auto_scripts process ADVISOR1 SCRIPT_1 true]: 1 Apr 23 17:24:23.615876 osdx OSDxCLI[12455]: pam_unix(cli:session): session opened for user admin by admin(uid=1000) Apr 23 17:24:23.643117 osdx OSDxCLI[12455]: pam_unix(cli:session): session closed for user admin Apr 23 17:24:23.643317 osdx OSDxCLI[12455]: User 'admin' executed a new command: 'system journal show | cat'. Apr 23 17:24:23.706396 osdx OSDxCLI[12455]: 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 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::f89b:f7ff:fe5d:bb63/64 up up dum1 fe80::dce6:7dff:feab:3941/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 to 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 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.8.1.9 # Tue 23 Apr 2024 05:24:32 PM UTC # Warning: Configuration has not been saved set system advisor ADVISOR1 test false set system 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.8.1.9 # Tue 23 Apr 2024 05:24:32 PM UTC # Warning: Configuration has not been saved set system advisor ADVISOR1 test false set system 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.8.1.9 # Tue 23 Apr 2024 05:24:34 PM UTC # Warning: Configuration has not been saved set system advisor ADVISOR1 test false set system 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