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.2
# Wed 19 Feb 2025 17:37:20 +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.2
Show output
Feb 19 17:37:27.496195 osdx systemd-journald[1662]: Runtime Journal (/run/log/journal/a4bff3775ff442739cbb447ef1abd30b) is 2.0M, max 15.3M, 13.2M free.
Feb 19 17:37:27.497785 osdx systemd-journald[1662]: Received client request to rotate journal, rotating.
Feb 19 17:37:27.497863 osdx systemd-journald[1662]: Vacuuming done, freed 0B of archived journals from /run/log/journal/a4bff3775ff442739cbb447ef1abd30b.
Feb 19 17:37:27.522568 osdx OSDxCLI[13781]: User 'admin' executed a new command: 'system journal clear'.
Feb 19 17:37:28.130156 osdx osdx-coredump[64667]: Deleting all coredumps in /opt/vyatta/etc/config/coredump...
Feb 19 17:37:28.142970 osdx OSDxCLI[13781]: User 'admin' executed a new command: 'system coredump delete all'.
Feb 19 17:37:29.165015 osdx OSDxCLI[13781]: User 'admin' entered the configuration menu.
Feb 19 17:37:29.311946 osdx OSDxCLI[13781]: User 'admin' added a new cfg line: 'set system script SCRIPT_1 advisor ADVISOR1'.
Feb 19 17:37:29.536498 osdx OSDxCLI[13781]: User 'admin' added a new cfg line: 'set system advisor ADVISOR1 test false'.
Feb 19 17:37:29.672179 osdx OSDxCLI[13781]: User 'admin' added a new cfg line: 'set system cli configuration logging global info'.
Feb 19 17:37:29.794563 osdx OSDxCLI[13781]: User 'admin' added a new cfg line: 'set system script SCRIPT_1 advisor ADVISOR1'.
Feb 19 17:37:29.923620 osdx OSDxCLI[13781]: User 'admin' added a new cfg line: 'set interfaces ethernet eth0 address 10.215.200.50/24'.
Feb 19 17:37:30.054223 osdx OSDxCLI[13781]: User 'admin' added a new cfg line: 'set system script SCRIPT_1 operational 1 command "show version"'.
Feb 19 17:37:30.227698 osdx OSDxCLI[13781]: User 'admin' added a new cfg line: 'set system script SCRIPT_1 operational 2 command "license show"'.
Feb 19 17:37:30.434546 osdx OSDxCLI[13781]: User 'admin' added a new cfg line: 'show working'.
Feb 19 17:37:30.602551 osdx INFO[64702]: FRR daemons did not change
Feb 19 17:37:30.603859 osdx modulelauncher[1297]: + Received data: ['13781', 'osdx.utils.xos', 'set_console_log_level', 'info']
Feb 19 17:37:30.638093 osdx OSDxCLI[13781]: Signal 10 received
Feb 19 17:37:30.731546 osdx kernel: 8021q: adding VLAN 0 to HW filter on device eth0
Feb 19 17:37:30.872586 osdx cfgd[1463]: [13781]Completed change to active configuration
Feb 19 17:37:30.923121 osdx OSDxCLI[13781]: User 'admin' committed the configuration.
Feb 19 17:37:30.962088 osdx OSDxCLI[13781]: User 'admin' left the configuration menu.
Feb 19 17:37:31.279893 osdx OSDxCLI[13781]: pam_unix(cli:session): session opened for user admin(uid=1000) by admin(uid=1000)
Feb 19 17:37:31.281083 osdx OSDxCLI[13781]: pam_unix(cli:session): session closed for user admin
Feb 19 17:37:31.282067 osdx OSDxCLI[13781]: User 'admin' entered the configuration menu.
Feb 19 17:37:31.421981 osdx OSDxCLI[13781]: pam_unix(cli:session): session opened for user admin(uid=1000) by admin(uid=1000)
Feb 19 17:37:31.422685 osdx cfgd[1463]: Execute action [syntax] for node [system advisor ADVISOR1]
Feb 19 17:37:31.423389 osdx OSDxCLI[13781]: pam_unix(cli:session): session closed for user admin
Feb 19 17:37:31.423959 osdx OSDxCLI[13781]: User 'admin' added a new cfg line: 'set system advisor ADVISOR1 test true'.
Feb 19 17:37:31.546789 osdx OSDxCLI[13781]: pam_unix(cli:session): session opened for user admin(uid=1000) by admin(uid=1000)
Feb 19 17:37:31.565213 osdx OSDxCLI[13781]: pam_unix(cli:session): session closed for user admin
Feb 19 17:37:31.565784 osdx OSDxCLI[13781]: User 'admin' added a new cfg line: 'show changes'.
Feb 19 17:37:31.689905 osdx OSDxCLI[13781]: pam_unix(cli:session): session opened for user admin(uid=1000) by admin(uid=1000)
Feb 19 17:37:31.709833 osdx cfgd[1463]: [13781]must validation for [system login user admin role] was skipped
Feb 19 17:37:31.709856 osdx cfgd[1463]: Execute action [commit-subtree] for node [system advisor ADVISOR1]
Feb 19 17:37:31.724238 osdx INFO[64817]: FRR daemons did not change
Feb 19 17:37:31.725138 osdx cfgd[1463]: Execute action [end] for node [system advisor ADVISOR1]
Feb 19 17:37:31.736397 osdx cfgd[1463]: [13781]Completed change to active configuration
Feb 19 17:37:31.739517 osdx OSDxCLI[13781]: pam_unix(cli:session): session closed for user admin
Feb 19 17:37:31.739952 osdx OSDxCLI[13781]: User 'admin' committed the configuration.
Feb 19 17:37:31.747662 osdx INFO[64826]: SCRIPT SCRIPT_1 operations:
Feb 19 17:37:31.762931 osdx OSDxCLI[64833]: Tecla::GetLine tcgetattr error
Feb 19 17:37:31.762941 osdx OSDxCLI[64833]: User 'admin' has logged in.
Feb 19 17:37:31.786733 osdx OSDxCLI[13781]: User 'admin' left the configuration menu.
Feb 19 17:37:31.799738 osdx OSDxCLI[64833]: User 'admin' executed a new command: 'show version'.
Feb 19 17:37:31.802158 osdx OSDxCLI[64833]: User 'admin' has logged out.
Feb 19 17:37:31.802166 osdx OSDxCLI[64833]: Tecla::GetLine tcgetattr error
Feb 19 17:37:31.804626 osdx INFO[64826]: Operation 1 'show version
                                         ':

                                           OS vendor:                 Teldat
                                           OS name:                   OSDx
                                           OS version:                v4.2.2.2
                                           OS Linux kernel:           6.1.119
                                           OS built by:               jenkins@daphne
                                           OS build date:             Mon Feb 17 15:05:06 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:             3ba71178-9ee5-5414-93c6-3ab24d94c850
                                           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:                      Wed 19 Feb 2025 17:37:31 +00:00
                                           Uptime:                    1:01:03
                                           CPU load (1m, 5m, 15m):    0.30 0.22 0.19
                                           CPU usage % (1m):          5.52
                                           Storage usage (kB):        363652/8144384
                                           Memory usage (kB):         370216/1570512
                                           Users logged in:           1
                                           Mode (current/next boot):  user/user

                                           Hostname:                  osdx
Feb 19 17:37:31.813558 osdx OSDxCLI[64849]: Tecla::GetLine tcgetattr error
Feb 19 17:37:31.813572 osdx OSDxCLI[64849]: User 'admin' has logged in.
Feb 19 17:37:31.817193 osdx OSDxCLI[64849]: Tecla::GetLine tcgetattr error
Feb 19 17:37:31.820001 osdx OSDxCLI[64849]: Tecla::GetLine tcgetattr error
Feb 19 17:37:31.820303 osdx OSDxCLI[64849]: User 'admin' executed a new command: 'license show'.
Feb 19 17:37:31.821904 osdx OSDxCLI[64849]: User 'admin' has logged out.
Feb 19 17:37:31.821913 osdx OSDxCLI[64849]: Tecla::GetLine tcgetattr error
Feb 19 17:37:31.822710 osdx INFO[64826]: Operation 2 'license show
                                         ':
                                         License: VM_BASE Firewall eth-Rate-Permit-Full

                                         +-----------------+---------+----------+
                                         | License Item    | Status  | Validity |
                                         +-----------------+---------+----------+
                                         | Firewall        | Enabled | Forever  |
                                         | eth-Rate-Permit | Full    | Forever  |
                                         +-----------------+---------+----------+
Feb 19 17:37:31.991814 osdx OSDxCLI[13781]: 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::40d7:99ff:fe3e:21bd/64  up     up
dum1  fe80::c099:dbff:fe45:d0d3/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.2
# Wed 19 Feb 2025 17:37:55 +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.2
# Wed 19 Feb 2025 17:37:56 +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.2
# Wed 19 Feb 2025 17:37:58 +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