Device Templates

Warning

This feature is currently very complex to use and is thus considered experimental. The RADKit development team is working on simplifying the configuration.

Device templates allow sharing protocol configurations between devices and configuring protocols via YAML syntax. This enables advanced features like templating or using external sources for device authentication.

Templates can be found on the sidebar under Device Templates, which presents a table with all created device templates. This view can be used to search, sort, create, update, or delete device templates seamlessly, just like in other tables in the RADKit Service UI.

../_images/list.png

Adding a New Device Template

To add a new Device Template, navigate to Device Templates in the sidebar and then click Add Device Template.

../_images/add.png

Device Template configuration consists of:

  • Template Name: A unique identifier for the template.

  • Description: An optional description.

Variables

Variables are an optional list of template variables that will be used for YAML rendering. Each variable has a mandatory name, an optional default value, and an optional description. If a default value is set, devices using this template are not required to provide a value for this variable, but they can if they want. Otherwise, devices using this template must pass a value for the variable.

YAML Protocols Definition

This section describes protocol configurations for devices in YAML. It can be static or dynamic if variables are used in a template.

Schema

http:
  # HTTP configuration or null (default: null)
  authentication_extra: null
  # Optional string or template string (default: null)

  external_source:
    # Optional reference to external source (default: null)
    name: external_source_name
    # Mandatory string
    params:
      key1: value
      # Optional keys and values can use template strings

  password:
    # Password definition (default: null)
    external_source: external_source_name
    # Name of external source which contains the secret
    path:
    # String or template string which specifies external source path within external source

  port: 443
  # Integer or template string (default: 443)

  protocol: HTTPS
  # HTTP, HTTPS, or template string (default: HTTPS)

  use_insecure_algorithms: false
  # Boolean or template string (default: false)

  username:
    # Username definition (default: null)
    # Can be either a value:
    value: username

    # Or secret from external source
    # String or template string defining username
    external_source: external_source_name
    # Name of external source which contains the secret
    path:
    # String or template string which specifies external source path within external source

  verify: true
  # Boolean or template string (default: true)

netconf:
  # Netconf configuration or null
  external_source:
    # Optional reference to external source (default: null)
    name: external_source_name
    # Mandatory string
    params:
      key1: value1
      # Optional keys and values can use template strings

  password:
    # Password definition (default: null)
    external_source: external_source_name
    # Name of external source which contains the secret
    path:
    # String or template string which specifies external source path within external source

  port: 830
  # Integer or template string (default: 443)

  use_insecure_algorithms: false
  # Boolean or template string (default: false)

  username:
    # Username definition (default: null)
    # Can be either a value:
    value: username

    # Or secret from external source
    # String or template string defining username
    external_source: external_source_name
    # Name of external source which contains the secret
    path:
    # String or template string which specifies external source path within external source

snmp:
  # SNMP configuration or null
  community_string:
    # Optional external source secret (default: null)
    external_source: external_source_name
    # String
    path:
    # String or template string

  external_source:
    # Optional reference to external source (default: null)
    name: external_source_name
    # Mandatory string
    params:
      key1: value1
      # Optional keys and values can use template strings

  port: 161
  # Integer or template string (default: 161)

  version: 1
  # Integer or template string (default: 1)

swagger:
  # Swagger configuration or null
  external_source:
    # Optional reference to external source (default: null)
    name: external_source_name
    # Mandatory string
    params:
      key1: value1
      # Optional keys and values can use template strings

  password:
    # Password definition (default: null)
    external_source: external_source_name
    # Name of external source which contains the secret
    path:
    # String or template string which specifies external source path within external source

  port: 443
  # Integer or template string (default: 443)

  schema_path:
  # String or template string (default: <empty_string>)

  use_insecure_algorithms: false
  # Boolean or template string (default: false)

  username:
    # Username definition (default: null)
    # Can be either a value:
    value: username

    # Or secret from external source
    # String or template string defining username
    external_source: external_source_name
    # Name of external source which contains the secret
    path:
    # String or template string which specifies external source path within external source

  verify: true
  # Boolean or template string (default: true)

terminal:
  # Terminal configuration or null
  capabilities:
    # List of DOWNLOAD, INTERACTIVE, UPLOAD, or template string
    # (default: <list_of_all_possible_capabilities>)
    - DOWNLOAD
    - INTERACTIVE
    - UPLOAD
    - EXEC

  connection_method: SSH
  # SSH, TELNET, SSHPUBKEY, TELNET_NO_AUTH, or template string (default: SSH)

  enable_password:
    # Enable password definition (default: null)
    external_source: external_source_name
    # Name of external source which contains the secret
    path:
    # String or template string which specifies external source path within external source

  external_source:
    # Optional reference to external source (default: null)
    name: external_source_name
    # Mandatory string
    params:
      key1: value1
      # Optional keys and values can use template strings

  jumphost: false
  # Boolean or template string (default: false)

  password:
    # Password definition (default: null)
    external_source: external_source_name
    # Name of external source which contains the secret
    path:
    # String or template string which specifies external source path within external source

  port: 22
  # Integer or template string (default: 443)

  private_key:
    # Optional external source secret (default: null)
    external_source: external_source_name
    # String
    path:
    # String or template string

  provisioning_variant: DEFAULT
  # DEFAULT, LF1, or template string (default: DEFAULT)

  use_insecure_algorithms: false
  # Boolean or template string (default: false)

  use_tunneling_if_jumphost: true
  # Boolean or template string (default: true)

  username:
    # Username definition (default: null)
    # Can be either a value:
    value: username

    # Or secret from external source
    # String or template string defining username
    external_source: external_source_name
    # Name of external source which contains the secret
    path:
    # String or template string which specifies external source path within external source

Complete YAML Example with Defaults

http:
  authentication_extra: null
  external_source: null
  password: null
  port: 443
  protocol: HTTPS
  use_insecure_algorithms: false
  username: null
  verify: true
netconf:
  external_source: null
  password: null
  port: 830
  use_insecure_algorithms: false
  username: null
snmp:
  community_string: null
  external_source: null
  port: 161
  version: 2
swagger:
  external_source: null
  password: null
  port: 443
  schema_path: ''
  use_insecure_algorithms: false
  username: null
  verify: true
terminal:
  capabilities:
  - UPLOAD
  - EXEC
  - INTERACTIVE
  - DOWNLOAD
  connection_method: SSH
  enable_password: null
  external_source: null
  jumphost: false
  password: null
  port: 22
  private_key: null
  provisioning_variant: DEFAULT
  use_insecure_algorithms: false
  use_tunneling_if_jumphost: true
  username: null

Referencing Variables

Variables can be referenced in template strings. See where it’s possible here: schema. Template strings are a Python feature that provides basic substitution. For details, check here.

Example. We’ve defined the variable var1 and would like to use it in a template:

terminal:
  port: $var1

Warning

Using undefined variables in template strings results in errors. Devices with errors cannot be used later for device configuration.

Using External Sources

Device Templates allow the use of external sources for secret collections. To delegate secret collection from external sources, we can either:

Delegate collection for the whole protocol. Note that not all external sources can do this. Please refer to External sources for details.

terminal:
    external_source:
        name: <name_of_external_source>
        params: <optional parameters passed to external source>

To retrieve a specific secret from an external source, reference the external source by name in the secret’s configuration, including the secret’s path:

terminal:
    password:
        external_source: <name_of_external_source>
        path: <secret_path>

Using Device Templates in Devices

To use a device template in a device, open the device edit modal, select the desired template in the Template Selector, and provide all the mandatory and/or optional variable values.

../_images/device-use-single.png

Or use Bulk Edit if you want to modify more than a single device.

../_images/device-use-bulk.png

Selecting a template in the Template Selector changes this value for all the devices added to the cart. If no template is selected, the device template selection will be removed from all the devices. If a template is selected, it will add or override the template selection in every device in the cart.

Note

When a Device Template is selected, it takes precedence over other protocol configurations.