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.2.2.1
# Fri 10 Jan 2025 14:52:31 +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 'show version'
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:

v4.2.2.1
Show output
Jan 10 14:52:35.300672 osdx systemd-journald[24675]: Runtime Journal (/run/log/journal/dd2bda757d8d4ac3988ff4b660081a06) is 2.7M, max 15.3M, 12.5M free.
Jan 10 14:52:35.301959 osdx systemd-journald[24675]: Received client request to rotate journal, rotating.
Jan 10 14:52:35.302004 osdx systemd-journald[24675]: Vacuuming done, freed 0B of archived journals from /run/log/journal/dd2bda757d8d4ac3988ff4b660081a06.
Jan 10 14:52:35.309797 osdx OSDxCLI[26131]: User 'admin' executed a new command: 'system journal clear'.
Jan 10 14:52:35.613316 osdx osdx-coredump[38249]: Deleting all coredumps in /opt/vyatta/etc/config/coredump...
Jan 10 14:52:35.620904 osdx OSDxCLI[26131]: User 'admin' executed a new command: 'system coredump delete all'.
Jan 10 14:52:36.063421 osdx OSDxCLI[26131]: User 'admin' entered the configuration menu.
Jan 10 14:52:36.121690 osdx OSDxCLI[26131]: User 'admin' added a new cfg line: 'set system script SCRIPT_1 advisor ADVISOR1'.
Jan 10 14:52:36.217255 osdx OSDxCLI[26131]: User 'admin' added a new cfg line: 'set system advisor ADVISOR1 test false'.
Jan 10 14:52:36.276029 osdx OSDxCLI[26131]: User 'admin' added a new cfg line: 'set system cli configuration logging global info'.
Jan 10 14:52:36.373994 osdx OSDxCLI[26131]: User 'admin' added a new cfg line: 'set system script SCRIPT_1 advisor ADVISOR1'.
Jan 10 14:52:36.446823 osdx OSDxCLI[26131]: User 'admin' added a new cfg line: 'set interfaces ethernet eth0 address 10.215.200.50/24'.
Jan 10 14:52:36.532385 osdx OSDxCLI[26131]: User 'admin' added a new cfg line: 'set system script SCRIPT_1 operational 1 command show version'.
Jan 10 14:52:36.590132 osdx OSDxCLI[26131]: User 'admin' added a new cfg line: 'set system script SCRIPT_1 operational 2 command license show'.
Jan 10 14:52:36.698811 osdx OSDxCLI[26131]: User 'admin' added a new cfg line: 'show working'.
Jan 10 14:52:36.767742 osdx INFO[38284]: FRR daemons did not change
Jan 10 14:52:36.768377 osdx modulelauncher[1289]: + Received data: ['26131', 'osdx.utils.xos', 'set_console_log_level', 'info']
Jan 10 14:52:36.787838 osdx OSDxCLI[26131]: Signal 10 received
Jan 10 14:52:36.895127 osdx cfgd[1453]: [26131]Completed change to active configuration
Jan 10 14:52:36.920916 osdx OSDxCLI[26131]: User 'admin' committed the configuration.
Jan 10 14:52:36.938383 osdx OSDxCLI[26131]: User 'admin' left the configuration menu.
Jan 10 14:52:37.105904 osdx OSDxCLI[26131]: pam_unix(cli:session): session opened for user admin(uid=1000) by admin(uid=1000)
Jan 10 14:52:37.106358 osdx OSDxCLI[26131]: pam_unix(cli:session): session closed for user admin
Jan 10 14:52:37.106583 osdx OSDxCLI[26131]: User 'admin' entered the configuration menu.
Jan 10 14:52:37.164251 osdx OSDxCLI[26131]: pam_unix(cli:session): session opened for user admin(uid=1000) by admin(uid=1000)
Jan 10 14:52:37.164436 osdx cfgd[1453]: Execute action [syntax] for node [system advisor ADVISOR1]
Jan 10 14:52:37.164736 osdx OSDxCLI[26131]: pam_unix(cli:session): session closed for user admin
Jan 10 14:52:37.164928 osdx OSDxCLI[26131]: User 'admin' added a new cfg line: 'set system advisor ADVISOR1 test true'.
Jan 10 14:52:37.262151 osdx OSDxCLI[26131]: pam_unix(cli:session): session opened for user admin(uid=1000) by admin(uid=1000)
Jan 10 14:52:37.270456 osdx OSDxCLI[26131]: pam_unix(cli:session): session closed for user admin
Jan 10 14:52:37.270666 osdx OSDxCLI[26131]: User 'admin' added a new cfg line: 'show changes'.
Jan 10 14:52:37.318639 osdx OSDxCLI[26131]: pam_unix(cli:session): session opened for user admin(uid=1000) by admin(uid=1000)
Jan 10 14:52:37.326451 osdx cfgd[1453]: [26131]must validation for [system login user admin role] was skipped
Jan 10 14:52:37.326465 osdx cfgd[1453]: Execute action [commit-subtree] for node [system advisor ADVISOR1]
Jan 10 14:52:37.333131 osdx INFO[38399]: FRR daemons did not change
Jan 10 14:52:37.333286 osdx cfgd[1453]: Execute action [end] for node [system advisor ADVISOR1]
Jan 10 14:52:37.341553 osdx cfgd[1453]: [26131]Completed change to active configuration
Jan 10 14:52:37.343274 osdx OSDxCLI[26131]: pam_unix(cli:session): session closed for user admin
Jan 10 14:52:37.343557 osdx OSDxCLI[26131]: User 'admin' committed the configuration.
Jan 10 14:52:37.345939 osdx INFO[38408]: SCRIPT SCRIPT_1 operations:
Jan 10 14:52:37.351033 osdx OSDxCLI[38416]: Tecla::GetLine tcgetattr error
Jan 10 14:52:37.351038 osdx OSDxCLI[38416]: User 'admin' has logged in.
Jan 10 14:52:37.359285 osdx OSDxCLI[38416]: User 'admin' executed a new command: 'show version'.
Jan 10 14:52:37.360202 osdx OSDxCLI[38416]: User 'admin' has logged out.
Jan 10 14:52:37.360207 osdx OSDxCLI[38416]: Tecla::GetLine tcgetattr error
Jan 10 14:52:37.360716 osdx INFO[38408]: Operation 1 'show version
                                         ':

                                           OS vendor:                 Teldat
                                           OS name:                   OSDx
                                           OS version:                v4.2.2.1
                                           OS Linux kernel:           6.1.119
                                           OS built by:               jenkins@daphne
                                           OS build date:             Fri Jan 10 11:41:52 UTC 2025
                                           OS installation:           physical
                                           OS boot mode:              user
                                           License:                   VM_BASE Firewall eth-Rate-Permit-Full

                                           Hardware vendor:           QEMU
                                           Hardware model:            VM
                                           Hardware OEM model:        Standard PC (i440FX + PIIX, 1996)
                                           Hardware version:          pc-i440fx-5.2
                                           Hardware UUID:             47c1ad2b-ef33-58c7-8543-b4475054713e
                                           Hardware architecture:     amd64
                                           Hardware fwid:             iso
                                           Hardware base MAC:         de:ad:be:ef:6c:00
                                           Hardware cpu:              4 x QEMU Virtual CPU version 2.5+ (4 cores)

                                           Last reboot reason:        Panic

                                           Date:                      Fri 10 Jan 2025 14:52:36 +00:00
                                           Uptime:                    0:21:06
                                           CPU load (1m, 5m, 15m):    0.12 0.08 0.05
                                           CPU usage % (1m):          2.30
                                           Storage usage (kB):        368240/8144384
                                           Memory usage (kB):         362932/1570512
                                           Users logged in:           1
                                           Mode (current/next boot):  user/user

                                           Hostname:                  osdx
Jan 10 14:52:37.365414 osdx OSDxCLI[38422]: Tecla::GetLine tcgetattr error
Jan 10 14:52:37.365419 osdx OSDxCLI[38422]: User 'admin' has logged in.
Jan 10 14:52:37.367877 osdx OSDxCLI[38422]: Tecla::GetLine tcgetattr error
Jan 10 14:52:37.369795 osdx OSDxCLI[38422]: Tecla::GetLine tcgetattr error
Jan 10 14:52:37.369942 osdx OSDxCLI[38422]: User 'admin' executed a new command: 'license show'.
Jan 10 14:52:37.370880 osdx OSDxCLI[38422]: User 'admin' has logged out.
Jan 10 14:52:37.370885 osdx OSDxCLI[38422]: Tecla::GetLine tcgetattr error
Jan 10 14:52:37.371397 osdx INFO[38408]: Operation 2 'license show
                                         ':
                                         License: VM_BASE Firewall eth-Rate-Permit-Full

                                         +-----------------+---------+----------+
                                         | License Item    | Status  | Validity |
                                         +-----------------+---------+----------+
                                         | Firewall        | Enabled | Forever  |
                                         | eth-Rate-Permit | Full    | Forever  |
                                         +-----------------+---------+----------+
Jan 10 14:52:37.387727 osdx OSDxCLI[26131]: User 'admin' left the configuration menu.
Jan 10 14:52:37.512244 osdx OSDxCLI[26131]: 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::5471:46ff:fe1b:8354/64  up     up
dum1  fe80::f44a:37ff:fe75:f488/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.2.2.1
# Fri 10 Jan 2025 14:52:49 +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.2.2.1
# Fri 10 Jan 2025 14:52:50 +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.2.2.1
# Fri 10 Jan 2025 14:52:51 +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