Tag: <line>
- Device Version Test
Definition
The <line>
tag is used to check if the version of the device is correct for the template being used. The test is applied to the string that is returned from the specidal version_command
task.
More information on the version_command here: Tag: <tag-version>
This tag has the following attributes:
Parameters
-
nr (str): This is the line number to be tested. This should be set to 0 as the line count starts from 0 and the version_command only returns one line.
-
type (str): This is the type of test that will be performed on the
verison_command
output sting. -
Element Text (str): This is the test value. For the ci_in type, the element text is a regular expression, for ci_ge and ci_le it is a string that represents the version but can also a decimal point.
The type
value options are defined as:
Type | Meaning |
---|---|
ci_in | Use the element text as a regular expression and use this to test the version_command output. This test is case insensitive. |
ci_ge | Use the element text as a number and return true if the output of version_command is greater than or equal to the element text. This test is case insensitive. |
ci_le | Use the element text as a number and return true if the output of version_command is less than or equal to the element text. This test is case insensitive. |
Note
Both ci_ge and ci_le can have some confusing results if the output from version_command
contains more than one decimal point or contains text. It is advised to use ci_in as shown in the example below.
Example 1: Matching with a Regular Expression
The recommended approach to checking device versions is to use the ci_in type and match with a regular expression.
For example, if you wish to allow a template to work for both v10 and v11 of a particular device, then use the following:
1 2 3 4 5 |
|
version_command
task outputs just the decimal number of the version, i.e. no preceding v, then the above will match.
Example 2: Matching with Greater/Less Than or Equals To
The ci_ge and ci_le types can also be used to check a device version. These are usually both used together. Taking the same scenario as in example 1, you could use the following:
1 2 3 4 5 6 |
|
However, as already pointed out above it is advised to use the type ci_in and a regular expression for more consistent results.
Parent Tags
Child Tags
- None