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.2
# Tue 30 Jul 2024 10:04:40 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 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
Jul 30 10:04:45.325747 osdx systemd-journald[1579]: Runtime Journal (/run/log/journal/22c37bf8be29452e87aca50c6265032f) is 2.1M, max 15.3M, 13.1M free.
Jul 30 10:04:45.327730 osdx systemd-journald[1579]: Received client request to rotate journal, rotating.
Jul 30 10:04:45.327778 osdx systemd-journald[1579]: Vacuuming done, freed 0B of archived journals from /run/log/journal/22c37bf8be29452e87aca50c6265032f.
Jul 30 10:04:45.338120 osdx OSDxCLI[1789]: User 'admin' executed a new command: 'system journal clear'.
Jul 30 10:04:45.697822 osdx osdx-coredump[41622]: Deleting all coredumps in /opt/vyatta/etc/config/coredump...
Jul 30 10:04:45.705327 osdx OSDxCLI[1789]: User 'admin' executed a new command: 'system coredump delete all'.
Jul 30 10:04:46.159122 osdx OSDxCLI[1789]: User 'admin' entered the configuration menu.
Jul 30 10:04:46.217643 osdx OSDxCLI[1789]: User 'admin' added a new cfg line: 'set system script SCRIPT_1 advisor ADVISOR1'.
Jul 30 10:04:46.310948 osdx OSDxCLI[1789]: User 'admin' added a new cfg line: 'set system advisor ADVISOR1 test false'.
Jul 30 10:04:46.367267 osdx OSDxCLI[1789]: User 'admin' added a new cfg line: 'set system cli configuration logging global info'.
Jul 30 10:04:46.458320 osdx OSDxCLI[1789]: User 'admin' added a new cfg line: 'set system script SCRIPT_1 advisor ADVISOR1'.
Jul 30 10:04:46.531896 osdx OSDxCLI[1789]: User 'admin' added a new cfg line: 'set interfaces ethernet eth0 address 10.215.200.50/24'.
Jul 30 10:04:46.616363 osdx OSDxCLI[1789]: User 'admin' added a new cfg line: 'set system script SCRIPT_1 operational 1 command 'interfaces ethernet show''.
Jul 30 10:04:46.670103 osdx OSDxCLI[1789]: User 'admin' added a new cfg line: 'set system script SCRIPT_1 operational 2 command 'license show''.
Jul 30 10:04:46.781517 osdx OSDxCLI[1789]: User 'admin' added a new cfg line: 'show working'.
Jul 30 10:04:46.852927 osdx modulelauncher[1112]: + Received data: ['1789', 'osdx.utils.xos', 'set_console_log_level', 'info']
Jul 30 10:04:46.866407 osdx OSDxCLI[1789]: Signal 10 received
Jul 30 10:04:46.874854 osdx ifmon[1142]: Changed log-level to info
Jul 30 10:04:46.903743 osdx kernel: 8021q: adding VLAN 0 to HW filter on device eth0
Jul 30 10:04:46.939019 osdx cfgd[1242]: [1789]Completed change to active configuration
Jul 30 10:04:46.941143 osdx OSDxCLI[1789]: User 'admin' committed the configuration.
Jul 30 10:04:46.960232 osdx OSDxCLI[1789]: User 'admin' left the configuration menu.
Jul 30 10:04:47.129929 osdx OSDxCLI[1789]: pam_unix(cli:session): session opened for user admin(uid=1000) by admin(uid=1000)
Jul 30 10:04:47.130423 osdx OSDxCLI[1789]: pam_unix(cli:session): session closed for user admin
Jul 30 10:04:47.130637 osdx OSDxCLI[1789]: User 'admin' entered the configuration menu.
Jul 30 10:04:47.208176 osdx OSDxCLI[1789]: pam_unix(cli:session): session opened for user admin(uid=1000) by admin(uid=1000)
Jul 30 10:04:47.208451 osdx cfgd[1242]: Execute action [syntax] for node [system advisor ADVISOR1]
Jul 30 10:04:47.208838 osdx OSDxCLI[1789]: pam_unix(cli:session): session closed for user admin
Jul 30 10:04:47.209122 osdx OSDxCLI[1789]: User 'admin' added a new cfg line: 'set system advisor ADVISOR1 test true'.
Jul 30 10:04:47.313724 osdx OSDxCLI[1789]: pam_unix(cli:session): session opened for user admin(uid=1000) by admin(uid=1000)
Jul 30 10:04:47.322250 osdx OSDxCLI[1789]: pam_unix(cli:session): session closed for user admin
Jul 30 10:04:47.322563 osdx OSDxCLI[1789]: User 'admin' added a new cfg line: 'show changes'.
Jul 30 10:04:47.377367 osdx OSDxCLI[1789]: pam_unix(cli:session): session opened for user admin(uid=1000) by admin(uid=1000)
Jul 30 10:04:47.385317 osdx cfgd[1242]: [1789]must validation for [system login user admin role] was skipped
Jul 30 10:04:47.385328 osdx cfgd[1242]: Execute action [commit-subtree] for node [system advisor ADVISOR1]
Jul 30 10:04:47.393469 osdx cfgd[1242]: Execute action [end] for node [system advisor ADVISOR1]
Jul 30 10:04:47.399579 osdx cfgd[1242]: [1789]Completed change to active configuration
Jul 30 10:04:47.401938 osdx OSDxCLI[1789]: pam_unix(cli:session): session closed for user admin
Jul 30 10:04:47.402258 osdx OSDxCLI[1789]: User 'admin' committed the configuration.
Jul 30 10:04:47.405400 osdx INFO[41757]: SCRIPT SCRIPT_1 operations:
Jul 30 10:04:47.411597 osdx OSDxCLI[41765]: Tecla::GetLine tcgetattr error
Jul 30 10:04:47.411606 osdx OSDxCLI[41765]: User 'admin' has logged in.
Jul 30 10:04:47.420356 osdx OSDxCLI[41765]: User 'admin' executed a new command: 'interfaces ethernet show'.
Jul 30 10:04:47.422017 osdx OSDxCLI[41765]: User 'admin' has logged out.
Jul 30 10:04:47.422020 osdx OSDxCLI[41765]: Tecla::GetLine tcgetattr error
Jul 30 10:04:47.422602 osdx INFO[41757]: Operation 1 'interfaces ethernet show
                                         ':

                                         -----------------------------------------------
                                         Name  IP Address  Admin  Oper  Vrf  Description
                                         -----------------------------------------------
                                         eth0              down   down
                                         eth1              down   down
Jul 30 10:04:47.424397 osdx modulelauncher[41757]: 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
Jul 30 10:04:47.424810 osdx cfgd[1242]: External python command [cfg.auto_scripts process ADVISOR1 SCRIPT_1 true] finished with status 1
Jul 30 10:04:47.424824 osdx cfgd[1242]: Run trap command [cfg.auto_scripts process ADVISOR1 SCRIPT_1 true]: 1
Jul 30 10:04:47.449536 osdx OSDxCLI[1789]: User 'admin' left the configuration menu.
Jul 30 10:04:47.583566 osdx OSDxCLI[1789]: 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
Jul 30 10:04:45.325747 osdx systemd-journald[1579]: Runtime Journal (/run/log/journal/22c37bf8be29452e87aca50c6265032f) is 2.1M, max 15.3M, 13.1M free.
Jul 30 10:04:45.327730 osdx systemd-journald[1579]: Received client request to rotate journal, rotating.
Jul 30 10:04:45.327778 osdx systemd-journald[1579]: Vacuuming done, freed 0B of archived journals from /run/log/journal/22c37bf8be29452e87aca50c6265032f.
Jul 30 10:04:45.338120 osdx OSDxCLI[1789]: User 'admin' executed a new command: 'system journal clear'.
Jul 30 10:04:45.697822 osdx osdx-coredump[41622]: Deleting all coredumps in /opt/vyatta/etc/config/coredump...
Jul 30 10:04:45.705327 osdx OSDxCLI[1789]: User 'admin' executed a new command: 'system coredump delete all'.
Jul 30 10:04:46.159122 osdx OSDxCLI[1789]: User 'admin' entered the configuration menu.
Jul 30 10:04:46.217643 osdx OSDxCLI[1789]: User 'admin' added a new cfg line: 'set system script SCRIPT_1 advisor ADVISOR1'.
Jul 30 10:04:46.310948 osdx OSDxCLI[1789]: User 'admin' added a new cfg line: 'set system advisor ADVISOR1 test false'.
Jul 30 10:04:46.367267 osdx OSDxCLI[1789]: User 'admin' added a new cfg line: 'set system cli configuration logging global info'.
Jul 30 10:04:46.458320 osdx OSDxCLI[1789]: User 'admin' added a new cfg line: 'set system script SCRIPT_1 advisor ADVISOR1'.
Jul 30 10:04:46.531896 osdx OSDxCLI[1789]: User 'admin' added a new cfg line: 'set interfaces ethernet eth0 address 10.215.200.50/24'.
Jul 30 10:04:46.616363 osdx OSDxCLI[1789]: User 'admin' added a new cfg line: 'set system script SCRIPT_1 operational 1 command 'interfaces ethernet show''.
Jul 30 10:04:46.670103 osdx OSDxCLI[1789]: User 'admin' added a new cfg line: 'set system script SCRIPT_1 operational 2 command 'license show''.
Jul 30 10:04:46.781517 osdx OSDxCLI[1789]: User 'admin' added a new cfg line: 'show working'.
Jul 30 10:04:46.852927 osdx modulelauncher[1112]: + Received data: ['1789', 'osdx.utils.xos', 'set_console_log_level', 'info']
Jul 30 10:04:46.866407 osdx OSDxCLI[1789]: Signal 10 received
Jul 30 10:04:46.874854 osdx ifmon[1142]: Changed log-level to info
Jul 30 10:04:46.903743 osdx kernel: 8021q: adding VLAN 0 to HW filter on device eth0
Jul 30 10:04:46.939019 osdx cfgd[1242]: [1789]Completed change to active configuration
Jul 30 10:04:46.941143 osdx OSDxCLI[1789]: User 'admin' committed the configuration.
Jul 30 10:04:46.960232 osdx OSDxCLI[1789]: User 'admin' left the configuration menu.
Jul 30 10:04:47.129929 osdx OSDxCLI[1789]: pam_unix(cli:session): session opened for user admin(uid=1000) by admin(uid=1000)
Jul 30 10:04:47.130423 osdx OSDxCLI[1789]: pam_unix(cli:session): session closed for user admin
Jul 30 10:04:47.130637 osdx OSDxCLI[1789]: User 'admin' entered the configuration menu.
Jul 30 10:04:47.208176 osdx OSDxCLI[1789]: pam_unix(cli:session): session opened for user admin(uid=1000) by admin(uid=1000)
Jul 30 10:04:47.208451 osdx cfgd[1242]: Execute action [syntax] for node [system advisor ADVISOR1]
Jul 30 10:04:47.208838 osdx OSDxCLI[1789]: pam_unix(cli:session): session closed for user admin
Jul 30 10:04:47.209122 osdx OSDxCLI[1789]: User 'admin' added a new cfg line: 'set system advisor ADVISOR1 test true'.
Jul 30 10:04:47.313724 osdx OSDxCLI[1789]: pam_unix(cli:session): session opened for user admin(uid=1000) by admin(uid=1000)
Jul 30 10:04:47.322250 osdx OSDxCLI[1789]: pam_unix(cli:session): session closed for user admin
Jul 30 10:04:47.322563 osdx OSDxCLI[1789]: User 'admin' added a new cfg line: 'show changes'.
Jul 30 10:04:47.377367 osdx OSDxCLI[1789]: pam_unix(cli:session): session opened for user admin(uid=1000) by admin(uid=1000)
Jul 30 10:04:47.385317 osdx cfgd[1242]: [1789]must validation for [system login user admin role] was skipped
Jul 30 10:04:47.385328 osdx cfgd[1242]: Execute action [commit-subtree] for node [system advisor ADVISOR1]
Jul 30 10:04:47.393469 osdx cfgd[1242]: Execute action [end] for node [system advisor ADVISOR1]
Jul 30 10:04:47.399579 osdx cfgd[1242]: [1789]Completed change to active configuration
Jul 30 10:04:47.401938 osdx OSDxCLI[1789]: pam_unix(cli:session): session closed for user admin
Jul 30 10:04:47.402258 osdx OSDxCLI[1789]: User 'admin' committed the configuration.
Jul 30 10:04:47.405400 osdx INFO[41757]: SCRIPT SCRIPT_1 operations:
Jul 30 10:04:47.411597 osdx OSDxCLI[41765]: Tecla::GetLine tcgetattr error
Jul 30 10:04:47.411606 osdx OSDxCLI[41765]: User 'admin' has logged in.
Jul 30 10:04:47.420356 osdx OSDxCLI[41765]: User 'admin' executed a new command: 'interfaces ethernet show'.
Jul 30 10:04:47.422017 osdx OSDxCLI[41765]: User 'admin' has logged out.
Jul 30 10:04:47.422020 osdx OSDxCLI[41765]: Tecla::GetLine tcgetattr error
Jul 30 10:04:47.422602 osdx INFO[41757]: Operation 1 'interfaces ethernet show
                                         ':

                                         -----------------------------------------------
                                         Name  IP Address  Admin  Oper  Vrf  Description
                                         -----------------------------------------------
                                         eth0              down   down
                                         eth1              down   down
Jul 30 10:04:47.424397 osdx modulelauncher[41757]: 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
Jul 30 10:04:47.424810 osdx cfgd[1242]: External python command [cfg.auto_scripts process ADVISOR1 SCRIPT_1 true] finished with status 1
Jul 30 10:04:47.424824 osdx cfgd[1242]: Run trap command [cfg.auto_scripts process ADVISOR1 SCRIPT_1 true]: 1
Jul 30 10:04:47.449536 osdx OSDxCLI[1789]: User 'admin' left the configuration menu.
Jul 30 10:04:47.583566 osdx OSDxCLI[1789]: pam_unix(cli:session): session opened for user admin(uid=1000) by admin(uid=1000)
Jul 30 10:04:47.625528 osdx OSDxCLI[1789]: pam_unix(cli:session): session closed for user admin
Jul 30 10:04:47.625828 osdx OSDxCLI[1789]: User 'admin' executed a new command: 'system journal show | cat'.
Jul 30 10:04:47.784714 osdx OSDxCLI[1789]: 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::e4f0:ccff:fe2e:b721/64  up     up
dum1  fe80::5c68:6eff:fec6:9915/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.2
# Tue 30 Jul 2024 10:05:02 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: 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.2
# Tue 30 Jul 2024 10:05:03 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: 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.2
# Tue 30 Jul 2024 10:05:04 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