refactor: move LAVA job definition templates into independent files

This change introduces a new script function to expand the variables in
a file. With this, we can move the LAVA YAML job template descriptions,
which are currently embedded inside individual HEREDOCs, into their own
files.

Signed-off-by: Chris Kay <chris.kay@arm.com>
Change-Id: I09805ab4b6894a371e63a944d113ca2f475a806b
diff --git a/script/lava-templates/n1sdp-linux.yaml b/script/lava-templates/n1sdp-linux.yaml
new file mode 100644
index 0000000..0903064
--- /dev/null
+++ b/script/lava-templates/n1sdp-linux.yaml
@@ -0,0 +1,178 @@
+device_type: n1sdp
+job_name: tf-n1sdp
+timeouts:
+  job:
+    minutes: 30
+
+priority: medium
+visibility: public
+context:
+  extra_nfsroot_args: ',vers=3'
+  extra_kernel_args: rootwait
+actions:
+#
+# Any firmware bundle deployed must be configured to boot automatically without
+# intervention. This means "PMIC_FORCE" must be set "TRUE" in the config file
+# to be deployed.
+#
+#
+# Deploy a firmware bundle with the customised "uefi.bin" installed. This
+# enables an EFI network driver, allowing us to force a TFTP boot from GRUB (assuming cobbler is setup)
+#
+- deploy:
+    namespace: recovery
+    to: flasher
+    images:
+      recovery_image:
+        url: http://files.oss.arm.com/downloads/lava/health-checks/n1sdp/4/n1sdp-board-firmware-force-netboot.zip
+        compression: zip
+
+- deploy:
+    namespace: debian
+    to: tftp
+    os: debian
+    kernel:
+      url: http://files.oss.arm.com/downloads/lava/health-checks/n1sdp/4/debian/linux
+      type: image
+    ramdisk:
+      url: http://files.oss.arm.com/downloads/lava/health-checks/n1sdp/4/debian/ramdisk.img
+    nfsrootfs:
+      url: http://files.oss.arm.com/downloads/lava/health-checks/n1sdp/4/debian/debian-buster-arm64-rootfs.tar.xz
+      compression: xz
+
+- boot:
+    namespace: recovery
+    timeout:
+      minutes: 3
+    method: minimal
+    parameters:
+      kernel-start-message: ''
+    prompts: ['Cmd>']
+
+- boot:
+    namespace: uart1
+    method: new_connection
+    connection: uart1
+
+- boot:
+    namespace: debian
+    connection-namespace: uart1
+    timeout:
+      minutes: 5
+    method: grub
+    commands: nfs
+    prompts:
+      - '/ # '
+
+- test:
+    namespace: debian
+    timeout:
+      minutes: 5
+    definitions:
+      - repository:
+          metadata:
+            format: Lava-Test Test Definition 1.0
+            name: device-network
+            description: '"Test device network connection"'
+            os:
+              - debian
+            scope:
+              - functional
+          run:
+            steps:
+              - apt -q update
+              - apt -q install -y iputils-ping
+              - ping -c 5 www.arm.com || lava-test-raise "Device failed to reach a remote host"
+              - hostname -I
+        from: inline
+        name: device-network
+        path: inline/device-network.yaml
+
+- test:
+    namespace: debian
+    timeout:
+      minutes: 5
+    definitions:
+      - repository:
+          metadata:
+            format: Lava-Test Test Definition 1.0
+            name: install-dependancies
+            description: '"Install dependancies for secondary media deployment"'
+            os:
+              - debian
+            scope:
+              - functional
+          run:
+            steps:
+              - apt-get update -q
+              - apt-get install -qy wget
+        from: inline
+        name: install-dependancies
+        path: inline/install-dependancies.yaml
+
+- deploy:
+    namespace: secondary_media
+    connection-namespace: uart1
+    timeout:
+      minutes: 10
+    to: usb
+    os: busybox
+    images:
+      image:
+        url: "$n1sdp_prebuilts/busybox.img"
+    uniquify: false
+    device: usb_storage_device
+    download:
+      tool: /usr/bin/wget
+      prompt: HTTP request sent, awaiting response
+      options: --no-check-certificate --no-proxy --connect-timeout=30 -S --progress=dot:giga -O - {DOWNLOAD_URL}
+
+#
+# Deploy the primary board firmware bundle (this time without the additinal
+# network driver).
+#
+- deploy:
+    namespace: recovery
+    to: flasher
+    images:
+      recovery_image:
+        url: $recovery_img_url
+        compression: zip
+
+#
+# Do not verify the flash second time around as cached serial output on the
+# connection will immediately match the prompt.
+#
+- boot:
+    namespace: secondary_media
+    timeout:
+      minutes: 10
+    method: minimal
+    prompts:
+      - '/ #'
+    transfer_overlay:
+      download_command: wget -S
+      unpack_command: tar -C / -xzf
+
+- test:
+    namespace: secondary_media
+    timeout:
+      minutes: 5
+    definitions:
+      - repository:
+          metadata:
+            format: Lava-Test Test Definition 1.0
+            name: linux-console-test-in-deployed-image
+            description: '"Run LAVA test steps inside the deployed image"'
+            os:
+              - oe
+            scope:
+              - functional
+          run:
+            steps:
+              - fdisk -l
+              - ip addr show
+              - cat /proc/cpuinfo
+        from: inline
+        name: linux-console-test
+        path: inline/linux-console-test.yaml