<line> - Device Version Test
<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
More information on the version_command here: Tag:
This tag has the following attributes:
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
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.
type value options are defined as:
|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
|ci_le||Use the element text as a number and return true if the output of
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
So long as the
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.