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.5
# Sun 11 May 2025 20:55:51 +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 show
Show output
May 11 20:55:58.436177 osdx systemd-journald[1583]: Runtime Journal (/run/log/journal/f55f446d40464b198e70fbabb9c21674) is 2.0M, max 15.3M, 13.2M free.
May 11 20:55:58.437910 osdx systemd-journald[1583]: Received client request to rotate journal, rotating.
May 11 20:55:58.437967 osdx systemd-journald[1583]: Vacuuming done, freed 0B of archived journals from /run/log/journal/f55f446d40464b198e70fbabb9c21674.
May 11 20:55:58.462423 osdx OSDxCLI[61757]: User 'admin' executed a new command: 'system journal clear'.
May 11 20:55:59.032886 osdx osdx-coredump[68357]: Deleting all coredumps in /opt/vyatta/etc/config/coredump...
May 11 20:55:59.048250 osdx OSDxCLI[61757]: User 'admin' executed a new command: 'system coredump delete all'.
May 11 20:56:00.041364 osdx OSDxCLI[61757]: User 'admin' entered the configuration menu.
May 11 20:56:00.188040 osdx OSDxCLI[61757]: User 'admin' added a new cfg line: 'set system script SCRIPT_1 advisor ADVISOR1'.
May 11 20:56:00.332639 osdx OSDxCLI[61757]: User 'admin' added a new cfg line: 'set system advisor ADVISOR1 test false'.
May 11 20:56:00.479260 osdx OSDxCLI[61757]: User 'admin' added a new cfg line: 'set system cli configuration logging global info'.
May 11 20:56:00.616835 osdx OSDxCLI[61757]: User 'admin' added a new cfg line: 'set system script SCRIPT_1 advisor ADVISOR1'.
May 11 20:56:00.779428 osdx OSDxCLI[61757]: User 'admin' added a new cfg line: 'set interfaces ethernet eth0 address 10.215.200.50/24'.
May 11 20:56:00.909440 osdx OSDxCLI[61757]: User 'admin' added a new cfg line: 'set system script SCRIPT_1 operational 1 command 'interfaces ethernet show''.
May 11 20:56:01.035789 osdx OSDxCLI[61757]: User 'admin' added a new cfg line: 'set system script SCRIPT_1 operational 2 command 'license show''.
May 11 20:56:01.200449 osdx OSDxCLI[61757]: User 'admin' added a new cfg line: 'show working'.
May 11 20:56:01.329651 osdx modulelauncher[1111]: + Received data: ['61757', 'osdx.utils.xos', 'set_console_log_level', 'info']
May 11 20:56:01.353452 osdx OSDxCLI[61757]: Signal 10 received
May 11 20:56:01.370353 osdx ifmon[1143]: Changed log-level to info
May 11 20:56:01.421920 osdx kernel: 8021q: adding VLAN 0 to HW filter on device eth0
May 11 20:56:01.557258 osdx cfgd[1244]: [61757]Completed change to active configuration
May 11 20:56:01.612374 osdx OSDxCLI[61757]: User 'admin' committed the configuration.
May 11 20:56:01.643213 osdx OSDxCLI[61757]: User 'admin' left the configuration menu.
May 11 20:56:01.931251 osdx OSDxCLI[61757]: pam_unix(cli:session): session opened for user admin(uid=1000) by admin(uid=1000)
May 11 20:56:01.932119 osdx OSDxCLI[61757]: pam_unix(cli:session): session closed for user admin
May 11 20:56:01.932607 osdx OSDxCLI[61757]: User 'admin' entered the configuration menu.
May 11 20:56:02.033647 osdx OSDxCLI[61757]: pam_unix(cli:session): session opened for user admin(uid=1000) by admin(uid=1000)
May 11 20:56:02.034273 osdx cfgd[1244]: Execute action [syntax] for node [system advisor ADVISOR1]
May 11 20:56:02.034910 osdx OSDxCLI[61757]: pam_unix(cli:session): session closed for user admin
May 11 20:56:02.035360 osdx OSDxCLI[61757]: User 'admin' added a new cfg line: 'set system advisor ADVISOR1 test true'.
May 11 20:56:02.144068 osdx OSDxCLI[61757]: pam_unix(cli:session): session opened for user admin(uid=1000) by admin(uid=1000)
May 11 20:56:02.163055 osdx OSDxCLI[61757]: pam_unix(cli:session): session closed for user admin
May 11 20:56:02.163467 osdx OSDxCLI[61757]: User 'admin' added a new cfg line: 'show changes'.
May 11 20:56:02.267142 osdx OSDxCLI[61757]: pam_unix(cli:session): session opened for user admin(uid=1000) by admin(uid=1000)
May 11 20:56:02.285113 osdx cfgd[1244]: [61757]must validation for [system login user admin role] was skipped
May 11 20:56:02.286742 osdx cfgd[1244]: Execute action [commit-subtree] for node [system advisor ADVISOR1]
May 11 20:56:02.306384 osdx cfgd[1244]: Execute action [end] for node [system advisor ADVISOR1]
May 11 20:56:02.318196 osdx cfgd[1244]: [61757]Completed change to active configuration
May 11 20:56:02.321097 osdx OSDxCLI[61757]: pam_unix(cli:session): session closed for user admin
May 11 20:56:02.321512 osdx OSDxCLI[61757]: User 'admin' committed the configuration.
May 11 20:56:02.325672 osdx INFO[68505]: SCRIPT SCRIPT_1 operations:
May 11 20:56:02.335019 osdx OSDxCLI[68513]: Tecla::GetLine tcgetattr error
May 11 20:56:02.335384 osdx OSDxCLI[68513]: User 'admin' has logged in.
May 11 20:56:02.349542 osdx OSDxCLI[68513]: User 'admin' executed a new command: 'interfaces ethernet show'.
May 11 20:56:02.351572 osdx OSDxCLI[68513]: User 'admin' has logged out.
May 11 20:56:02.351674 osdx OSDxCLI[68513]: Tecla::GetLine tcgetattr error
May 11 20:56:02.352422 osdx INFO[68505]: Operation 1 'interfaces ethernet show
                                         ':

                                         -----------------------------------------------
                                         Name  IP Address  Admin  Oper  Vrf  Description
                                         -----------------------------------------------
                                         eth0              down   down
                                         eth1              down   down
May 11 20:56:02.354419 osdx modulelauncher[68505]: 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
May 11 20:56:02.355221 osdx cfgd[1244]: External python command [cfg.auto_scripts process ADVISOR1 SCRIPT_1 true] finished with status 1
May 11 20:56:02.355242 osdx cfgd[1244]: Run trap command [cfg.auto_scripts process ADVISOR1 SCRIPT_1 true]: 1
May 11 20:56:02.366431 osdx OSDxCLI[61757]: User 'admin' left the configuration menu.
May 11 20:56:02.660925 osdx OSDxCLI[61757]: 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 show
Show output
May 11 20:55:58.436177 osdx systemd-journald[1583]: Runtime Journal (/run/log/journal/f55f446d40464b198e70fbabb9c21674) is 2.0M, max 15.3M, 13.2M free.
May 11 20:55:58.437910 osdx systemd-journald[1583]: Received client request to rotate journal, rotating.
May 11 20:55:58.437967 osdx systemd-journald[1583]: Vacuuming done, freed 0B of archived journals from /run/log/journal/f55f446d40464b198e70fbabb9c21674.
May 11 20:55:58.462423 osdx OSDxCLI[61757]: User 'admin' executed a new command: 'system journal clear'.
May 11 20:55:59.032886 osdx osdx-coredump[68357]: Deleting all coredumps in /opt/vyatta/etc/config/coredump...
May 11 20:55:59.048250 osdx OSDxCLI[61757]: User 'admin' executed a new command: 'system coredump delete all'.
May 11 20:56:00.041364 osdx OSDxCLI[61757]: User 'admin' entered the configuration menu.
May 11 20:56:00.188040 osdx OSDxCLI[61757]: User 'admin' added a new cfg line: 'set system script SCRIPT_1 advisor ADVISOR1'.
May 11 20:56:00.332639 osdx OSDxCLI[61757]: User 'admin' added a new cfg line: 'set system advisor ADVISOR1 test false'.
May 11 20:56:00.479260 osdx OSDxCLI[61757]: User 'admin' added a new cfg line: 'set system cli configuration logging global info'.
May 11 20:56:00.616835 osdx OSDxCLI[61757]: User 'admin' added a new cfg line: 'set system script SCRIPT_1 advisor ADVISOR1'.
May 11 20:56:00.779428 osdx OSDxCLI[61757]: User 'admin' added a new cfg line: 'set interfaces ethernet eth0 address 10.215.200.50/24'.
May 11 20:56:00.909440 osdx OSDxCLI[61757]: User 'admin' added a new cfg line: 'set system script SCRIPT_1 operational 1 command 'interfaces ethernet show''.
May 11 20:56:01.035789 osdx OSDxCLI[61757]: User 'admin' added a new cfg line: 'set system script SCRIPT_1 operational 2 command 'license show''.
May 11 20:56:01.200449 osdx OSDxCLI[61757]: User 'admin' added a new cfg line: 'show working'.
May 11 20:56:01.329651 osdx modulelauncher[1111]: + Received data: ['61757', 'osdx.utils.xos', 'set_console_log_level', 'info']
May 11 20:56:01.353452 osdx OSDxCLI[61757]: Signal 10 received
May 11 20:56:01.370353 osdx ifmon[1143]: Changed log-level to info
May 11 20:56:01.421920 osdx kernel: 8021q: adding VLAN 0 to HW filter on device eth0
May 11 20:56:01.557258 osdx cfgd[1244]: [61757]Completed change to active configuration
May 11 20:56:01.612374 osdx OSDxCLI[61757]: User 'admin' committed the configuration.
May 11 20:56:01.643213 osdx OSDxCLI[61757]: User 'admin' left the configuration menu.
May 11 20:56:01.931251 osdx OSDxCLI[61757]: pam_unix(cli:session): session opened for user admin(uid=1000) by admin(uid=1000)
May 11 20:56:01.932119 osdx OSDxCLI[61757]: pam_unix(cli:session): session closed for user admin
May 11 20:56:01.932607 osdx OSDxCLI[61757]: User 'admin' entered the configuration menu.
May 11 20:56:02.033647 osdx OSDxCLI[61757]: pam_unix(cli:session): session opened for user admin(uid=1000) by admin(uid=1000)
May 11 20:56:02.034273 osdx cfgd[1244]: Execute action [syntax] for node [system advisor ADVISOR1]
May 11 20:56:02.034910 osdx OSDxCLI[61757]: pam_unix(cli:session): session closed for user admin
May 11 20:56:02.035360 osdx OSDxCLI[61757]: User 'admin' added a new cfg line: 'set system advisor ADVISOR1 test true'.
May 11 20:56:02.144068 osdx OSDxCLI[61757]: pam_unix(cli:session): session opened for user admin(uid=1000) by admin(uid=1000)
May 11 20:56:02.163055 osdx OSDxCLI[61757]: pam_unix(cli:session): session closed for user admin
May 11 20:56:02.163467 osdx OSDxCLI[61757]: User 'admin' added a new cfg line: 'show changes'.
May 11 20:56:02.267142 osdx OSDxCLI[61757]: pam_unix(cli:session): session opened for user admin(uid=1000) by admin(uid=1000)
May 11 20:56:02.285113 osdx cfgd[1244]: [61757]must validation for [system login user admin role] was skipped
May 11 20:56:02.286742 osdx cfgd[1244]: Execute action [commit-subtree] for node [system advisor ADVISOR1]
May 11 20:56:02.306384 osdx cfgd[1244]: Execute action [end] for node [system advisor ADVISOR1]
May 11 20:56:02.318196 osdx cfgd[1244]: [61757]Completed change to active configuration
May 11 20:56:02.321097 osdx OSDxCLI[61757]: pam_unix(cli:session): session closed for user admin
May 11 20:56:02.321512 osdx OSDxCLI[61757]: User 'admin' committed the configuration.
May 11 20:56:02.325672 osdx INFO[68505]: SCRIPT SCRIPT_1 operations:
May 11 20:56:02.335019 osdx OSDxCLI[68513]: Tecla::GetLine tcgetattr error
May 11 20:56:02.335384 osdx OSDxCLI[68513]: User 'admin' has logged in.
May 11 20:56:02.349542 osdx OSDxCLI[68513]: User 'admin' executed a new command: 'interfaces ethernet show'.
May 11 20:56:02.351572 osdx OSDxCLI[68513]: User 'admin' has logged out.
May 11 20:56:02.351674 osdx OSDxCLI[68513]: Tecla::GetLine tcgetattr error
May 11 20:56:02.352422 osdx INFO[68505]: Operation 1 'interfaces ethernet show
                                         ':

                                         -----------------------------------------------
                                         Name  IP Address  Admin  Oper  Vrf  Description
                                         -----------------------------------------------
                                         eth0              down   down
                                         eth1              down   down
May 11 20:56:02.354419 osdx modulelauncher[68505]: 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
May 11 20:56:02.355221 osdx cfgd[1244]: External python command [cfg.auto_scripts process ADVISOR1 SCRIPT_1 true] finished with status 1
May 11 20:56:02.355242 osdx cfgd[1244]: Run trap command [cfg.auto_scripts process ADVISOR1 SCRIPT_1 true]: 1
May 11 20:56:02.366431 osdx OSDxCLI[61757]: User 'admin' left the configuration menu.
May 11 20:56:02.660925 osdx OSDxCLI[61757]: pam_unix(cli:session): session opened for user admin(uid=1000) by admin(uid=1000)
May 11 20:56:02.729508 osdx OSDxCLI[61757]: pam_unix(cli:session): session closed for user admin
May 11 20:56:02.729957 osdx OSDxCLI[61757]: User 'admin' executed a new command: 'system journal show | cat'.
May 11 20:56:02.881976 osdx OSDxCLI[61757]: 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.*\ndum1
Show output
-----------------------------------------------------------------
Name           IP Address           Admin  Oper  Vrf  Description
-----------------------------------------------------------------
dum0  fe80::78da:eff:feeb:a1e6/64   up     up
dum1  fe80::6cd8:5bff:fe53:ebdd/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.5
# Sun 11 May 2025 20:56:22 +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.5
# Sun 11 May 2025 20:56:24 +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.5
# Sun 11 May 2025 20:56:26 +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