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.1
# Mon 26 Feb 2024 20:21:24 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 show
Show output
-- Logs begin at Mon 2024-02-26 20:21:31 UTC, end at Mon 2024-02-26 20:21:35 UTC. --
Feb 26 20:21:31.421286 osdx systemd-journald[1369]: Runtime journal (/run/log/journal/bb5e03885d754db09ee63ec3d68ce029) is 2.0M, max 16.0M, 14.0M free.
Feb 26 20:21:31.438992 osdx OSDxCLI[21649]: User 'admin' executed a new command: 'system journal clear'.
Feb 26 20:21:32.116063 osdx osdx-coredump[27469]: Deleting all coredumps in /opt/vyatta/etc/config/coredump...
Feb 26 20:21:32.128148 osdx OSDxCLI[21649]: User 'admin' executed a new command: 'system coredump delete all'.
Feb 26 20:21:32.821191 osdx zebra[934]: [RZ3YY-GPH41][EC 100663310] snmp[warning]: Warning: Failed to connect to the agentx master agent ([NIL]):
Feb 26 20:21:32.878005 osdx zebra[934]: [RZ3YY-GPH41][EC 100663310] snmp[warning]: Warning: Failed to connect to the agentx master agent ([NIL]):
Feb 26 20:21:33.162831 osdx OSDxCLI[21649]: User 'admin' entered the configuration menu.
Feb 26 20:21:33.284200 osdx OSDxCLI[21649]: User 'admin' added a new cfg line: 'set system script SCRIPT_1 advisor ADVISOR1'.
Feb 26 20:21:33.421977 osdx OSDxCLI[21649]: User 'admin' added a new cfg line: 'set system advisor ADVISOR1 test false'.
Feb 26 20:21:33.538545 osdx OSDxCLI[21649]: User 'admin' added a new cfg line: 'set system cli configuration logging global info'.
Feb 26 20:21:33.652132 osdx OSDxCLI[21649]: User 'admin' added a new cfg line: 'set system script SCRIPT_1 advisor ADVISOR1'.
Feb 26 20:21:33.768712 osdx OSDxCLI[21649]: User 'admin' added a new cfg line: 'set interfaces ethernet eth0 address 10.215.200.50/24'.
Feb 26 20:21:33.889642 osdx OSDxCLI[21649]: User 'admin' added a new cfg line: 'set system script SCRIPT_1 operational 1 command 'interfaces ethernet show''.
Feb 26 20:21:34.005760 osdx OSDxCLI[21649]: User 'admin' added a new cfg line: 'set system script SCRIPT_1 operational 2 command 'license show''.
Feb 26 20:21:34.131247 osdx modulelauncher[834]: + Received data: ['21649', 'osdx.utils.xos', 'set_console_log_level', 'info']
Feb 26 20:21:34.144069 osdx OSDxCLI[21649]: Signal 10 received
Feb 26 20:21:34.152272 osdx ifmon[839]: Changed log-level to info
Feb 26 20:21:34.200924 osdx kernel: 8021q: adding VLAN 0 to HW filter on device eth0
Feb 26 20:21:34.257604 osdx cfgd[997]: [21649]Completed change to active configuration
Feb 26 20:21:34.271408 osdx OSDxCLI[21649]: User 'admin' committed the configuration.
Feb 26 20:21:34.331599 osdx OSDxCLI[21649]: User 'admin' left the configuration menu.
Feb 26 20:21:34.584447 osdx OSDxCLI[21649]: pam_unix(cli:session): session opened for user admin by admin(uid=1000)
Feb 26 20:21:34.585382 osdx OSDxCLI[21649]: pam_unix(cli:session): session closed for user admin
Feb 26 20:21:34.585656 osdx OSDxCLI[21649]: User 'admin' entered the configuration menu.
Feb 26 20:21:34.705499 osdx OSDxCLI[21649]: pam_unix(cli:session): session opened for user admin by admin(uid=1000)
Feb 26 20:21:34.706050 osdx OSDxCLI[21649]: pam_unix(cli:session): session closed for user admin
Feb 26 20:21:34.706369 osdx OSDxCLI[21649]: User 'admin' added a new cfg line: 'set system advisor ADVISOR1 test true'.
Feb 26 20:21:34.813973 osdx OSDxCLI[21649]: pam_unix(cli:session): session opened for user admin by admin(uid=1000)
Feb 26 20:21:34.817255 osdx cfgd[997]: [21649]must validation for [system login user admin role] was skipped
Feb 26 20:21:34.817392 osdx cfgd[997]: Execute action [commit-subtree] for node [system advisor ADVISOR1]
Feb 26 20:21:34.833248 osdx cfgd[997]: Execute action [end] for node [system advisor ADVISOR1]
Feb 26 20:21:34.844788 osdx cfgd[997]: [21649]Completed change to active configuration
Feb 26 20:21:34.850602 osdx OSDxCLI[21649]: pam_unix(cli:session): session closed for user admin
Feb 26 20:21:34.850941 osdx OSDxCLI[21649]: User 'admin' committed the configuration.
Feb 26 20:21:34.854149 osdx INFO[27606]: SCRIPT SCRIPT_1 operations:
Feb 26 20:21:34.869587 osdx OSDxCLI[27612]: Tecla::GetLine tcgetattr error
Feb 26 20:21:34.870000 osdx OSDxCLI[27612]: User 'admin' has logged in.
Feb 26 20:21:34.884077 osdx OSDxCLI[21649]: User 'admin' left the configuration menu.
Feb 26 20:21:34.889140 osdx OSDxCLI[27612]: User 'admin' executed a new command: 'interfaces ethernet show'.
Feb 26 20:21:34.891167 osdx OSDxCLI[27612]: User 'admin' has logged out.
Feb 26 20:21:34.891287 osdx OSDxCLI[27612]: Tecla::GetLine tcgetattr error
Feb 26 20:21:34.892400 osdx INFO[27606]: Operation 1 'interfaces ethernet show
                                         ':

                                         -----------------------------------------------
                                         Name  IP Address  Admin  Oper  Vrf  Description
                                         -----------------------------------------------
                                         eth0              down   down
                                         eth1              down   down
Feb 26 20:21:34.893966 osdx modulelauncher[27606]: 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
Feb 26 20:21:34.894981 osdx cfgd[997]: External python command [cfg.auto_scripts process ADVISOR1 SCRIPT_1 true] finished with status 1
Feb 26 20:21:34.895004 osdx cfgd[997]: Run trap command [cfg.auto_scripts process ADVISOR1 SCRIPT_1 true]: 1
Feb 26 20:21:35.053135 osdx OSDxCLI[21649]: 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 show
Show output
-- Logs begin at Mon 2024-02-26 20:21:31 UTC, end at Mon 2024-02-26 20:21:35 UTC. --
Feb 26 20:21:31.421286 osdx systemd-journald[1369]: Runtime journal (/run/log/journal/bb5e03885d754db09ee63ec3d68ce029) is 2.0M, max 16.0M, 14.0M free.
Feb 26 20:21:31.438992 osdx OSDxCLI[21649]: User 'admin' executed a new command: 'system journal clear'.
Feb 26 20:21:32.116063 osdx osdx-coredump[27469]: Deleting all coredumps in /opt/vyatta/etc/config/coredump...
Feb 26 20:21:32.128148 osdx OSDxCLI[21649]: User 'admin' executed a new command: 'system coredump delete all'.
Feb 26 20:21:32.821191 osdx zebra[934]: [RZ3YY-GPH41][EC 100663310] snmp[warning]: Warning: Failed to connect to the agentx master agent ([NIL]):
Feb 26 20:21:32.878005 osdx zebra[934]: [RZ3YY-GPH41][EC 100663310] snmp[warning]: Warning: Failed to connect to the agentx master agent ([NIL]):
Feb 26 20:21:33.162831 osdx OSDxCLI[21649]: User 'admin' entered the configuration menu.
Feb 26 20:21:33.284200 osdx OSDxCLI[21649]: User 'admin' added a new cfg line: 'set system script SCRIPT_1 advisor ADVISOR1'.
Feb 26 20:21:33.421977 osdx OSDxCLI[21649]: User 'admin' added a new cfg line: 'set system advisor ADVISOR1 test false'.
Feb 26 20:21:33.538545 osdx OSDxCLI[21649]: User 'admin' added a new cfg line: 'set system cli configuration logging global info'.
Feb 26 20:21:33.652132 osdx OSDxCLI[21649]: User 'admin' added a new cfg line: 'set system script SCRIPT_1 advisor ADVISOR1'.
Feb 26 20:21:33.768712 osdx OSDxCLI[21649]: User 'admin' added a new cfg line: 'set interfaces ethernet eth0 address 10.215.200.50/24'.
Feb 26 20:21:33.889642 osdx OSDxCLI[21649]: User 'admin' added a new cfg line: 'set system script SCRIPT_1 operational 1 command 'interfaces ethernet show''.
Feb 26 20:21:34.005760 osdx OSDxCLI[21649]: User 'admin' added a new cfg line: 'set system script SCRIPT_1 operational 2 command 'license show''.
Feb 26 20:21:34.131247 osdx modulelauncher[834]: + Received data: ['21649', 'osdx.utils.xos', 'set_console_log_level', 'info']
Feb 26 20:21:34.144069 osdx OSDxCLI[21649]: Signal 10 received
Feb 26 20:21:34.152272 osdx ifmon[839]: Changed log-level to info
Feb 26 20:21:34.200924 osdx kernel: 8021q: adding VLAN 0 to HW filter on device eth0
Feb 26 20:21:34.257604 osdx cfgd[997]: [21649]Completed change to active configuration
Feb 26 20:21:34.271408 osdx OSDxCLI[21649]: User 'admin' committed the configuration.
Feb 26 20:21:34.331599 osdx OSDxCLI[21649]: User 'admin' left the configuration menu.
Feb 26 20:21:34.584447 osdx OSDxCLI[21649]: pam_unix(cli:session): session opened for user admin by admin(uid=1000)
Feb 26 20:21:34.585382 osdx OSDxCLI[21649]: pam_unix(cli:session): session closed for user admin
Feb 26 20:21:34.585656 osdx OSDxCLI[21649]: User 'admin' entered the configuration menu.
Feb 26 20:21:34.705499 osdx OSDxCLI[21649]: pam_unix(cli:session): session opened for user admin by admin(uid=1000)
Feb 26 20:21:34.706050 osdx OSDxCLI[21649]: pam_unix(cli:session): session closed for user admin
Feb 26 20:21:34.706369 osdx OSDxCLI[21649]: User 'admin' added a new cfg line: 'set system advisor ADVISOR1 test true'.
Feb 26 20:21:34.813973 osdx OSDxCLI[21649]: pam_unix(cli:session): session opened for user admin by admin(uid=1000)
Feb 26 20:21:34.817255 osdx cfgd[997]: [21649]must validation for [system login user admin role] was skipped
Feb 26 20:21:34.817392 osdx cfgd[997]: Execute action [commit-subtree] for node [system advisor ADVISOR1]
Feb 26 20:21:34.833248 osdx cfgd[997]: Execute action [end] for node [system advisor ADVISOR1]
Feb 26 20:21:34.844788 osdx cfgd[997]: [21649]Completed change to active configuration
Feb 26 20:21:34.850602 osdx OSDxCLI[21649]: pam_unix(cli:session): session closed for user admin
Feb 26 20:21:34.850941 osdx OSDxCLI[21649]: User 'admin' committed the configuration.
Feb 26 20:21:34.854149 osdx INFO[27606]: SCRIPT SCRIPT_1 operations:
Feb 26 20:21:34.869587 osdx OSDxCLI[27612]: Tecla::GetLine tcgetattr error
Feb 26 20:21:34.870000 osdx OSDxCLI[27612]: User 'admin' has logged in.
Feb 26 20:21:34.884077 osdx OSDxCLI[21649]: User 'admin' left the configuration menu.
Feb 26 20:21:34.889140 osdx OSDxCLI[27612]: User 'admin' executed a new command: 'interfaces ethernet show'.
Feb 26 20:21:34.891167 osdx OSDxCLI[27612]: User 'admin' has logged out.
Feb 26 20:21:34.891287 osdx OSDxCLI[27612]: Tecla::GetLine tcgetattr error
Feb 26 20:21:34.892400 osdx INFO[27606]: Operation 1 'interfaces ethernet show
                                         ':

                                         -----------------------------------------------
                                         Name  IP Address  Admin  Oper  Vrf  Description
                                         -----------------------------------------------
                                         eth0              down   down
                                         eth1              down   down
Feb 26 20:21:34.893966 osdx modulelauncher[27606]: 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
Feb 26 20:21:34.894981 osdx cfgd[997]: External python command [cfg.auto_scripts process ADVISOR1 SCRIPT_1 true] finished with status 1
Feb 26 20:21:34.895004 osdx cfgd[997]: Run trap command [cfg.auto_scripts process ADVISOR1 SCRIPT_1 true]: 1
Feb 26 20:21:35.053135 osdx OSDxCLI[21649]: pam_unix(cli:session): session opened for user admin by admin(uid=1000)
Feb 26 20:21:35.113834 osdx OSDxCLI[21649]: pam_unix(cli:session): session closed for user admin
Feb 26 20:21:35.114149 osdx OSDxCLI[21649]: User 'admin' executed a new command: 'system journal show | cat'.
Feb 26 20:21:35.283347 osdx OSDxCLI[21649]: 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.*\ndum1
Show output
-----------------------------------------------------------------
Name           IP Address           Admin  Oper  Vrf  Description
-----------------------------------------------------------------
dum0  fe80::48ea:95ff:fe10:eea0/64  up     up
dum1  fe80::2ced:13ff:fe3b:c144/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.1
# Mon 26 Feb 2024 20:21:55 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.1
# Mon 26 Feb 2024 20:21: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.1
# Mon 26 Feb 2024 20:21: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