save

The save command writes autogenerated Blitz snippets into a Blitz trigger file.

Basic usage

The command save <FILEPATH> collects all autogenerated Blitz test sections and their action snippets and writes them into a Blitz trigger YAML file at the specified filepath. The name of the Blitz trigger will match the file name.

Example:

(lamp-host1) list -a
default:
  - configure:
      device: host1
      command: no logging console
  - sleep:
      sleep_time: 2
  - execute:
      device: host1
      command: show ip route
      include:
        - 1.1.1.1
new:
  - configure:
      device: host1
      command: no ip domain lookup
(lamp-host1)
(lamp-host1) save pyats/testcases/TC1.yaml
2024-07-29 19:16:09: %LAMP-INFO: +------------------------------------------------------------------------------+
2024-07-29 19:16:09: %LAMP-INFO: :              File 'pyats/testcases/TC1.yaml' saved successfully              :
2024-07-29 19:16:09: %LAMP-INFO: +------------------------------------------------------------------------------+
(lamp-host1)

The resulting ‘TC1.yaml’ file will contain the following content:

# TC1.yaml
# 29 July 2024
# LAMP Generated testcase
TC1:
  source:
    pkg: genie.libs.sdk
    class: triggers.blitz.blitz.Blitz
  devices:
    - host1
  test_sections:
    - default:
        - configure:
            device: host1
            command: no logging console
        - sleep:
            sleep_time: 2
        - execute:
            device: host1
            command: show ip route
            include:
              - 1.1.1.1
    - new:
        - configure:
            device: host1
            command: no ip domain lookup

Adding comments

To include extra comments about the trigger, use the optional ‘-m’ argument:

(lamp-leaf2) list -a
default:
  - execute:
      device: leaf2
      command: show ip route
      include:
        - 3.3.3.3
(lamp-leaf2) save pyats/testcases/route_check.yaml -m "Check routes"
2024-08-10 13:11:22: %LAMP-INFO: +------------------------------------------------------------------------------+
2024-08-10 13:11:22: %LAMP-INFO: :          File 'pyats/testcases/route_check.yaml' saved successfully          :
2024-08-10 13:11:22: %LAMP-INFO: +------------------------------------------------------------------------------+
(lamp-leaf2)

The YAML file will include the comment:

# route_check.yaml
# 10 August 2024
# LAMP Generated testcase
# Check routes
route_check:
  source:
    pkg: genie.libs.sdk
    class: triggers.blitz.blitz.Blitz
  devices:
    - leaf2
  test_sections:
    - default:
        - execute:
            device: leaf2
            command: show ip route
            include:
              - 3.3.3.3

Update existing triggers

To append new autogenerated test sections to an existing Blitz trigger file, use the ‘-u’ option. This adds new sections and updates the ‘extends’ field with new trigger paths.

(lamp-leaf2) list -a
route_4_check:
  - execute:
      device: leaf2
      command: show ip route
      include:
        - 4.4.4.4
(lamp-leaf2) save route_check.yaml -u
2024-09-23 08:48:31: %LAMP-INFO: +------------------------------------------------------------------------------+
2024-09-23 08:48:31: %LAMP-INFO: :                  File 'route_check.yaml' saved successfully                  :
2024-09-23 08:48:31: %LAMP-INFO: +------------------------------------------------------------------------------+

The updated YAML will include the new test section:

# route_check.yaml
# 10 August 2024
# LAMP Generated testcase
# Check routes
route_check:
  source:
    pkg: genie.libs.sdk
    class: triggers.blitz.blitz.Blitz
  devices:
    - leaf2
  test_sections:
    - default:
        - execute:
            device: leaf2
            command: show ip route
            include:
              - 3.3.3.3
    - route_4_check:
        - execute:
            device: leaf2
            command: show ip route
            include:
              - 4.4.4.4