Conditions

Conditions are used to define and restrict the execution logic within device classes. They allow specifying which requests are sent to a device depending on wether these conditions are true or not. Conditions are also used to assign devices to a device class.

They consist of boolean expressions that always either return true or false. The following example shows how conditions can look like inside a YAML configuration file:

logical_operator: OR
conditions:
- type: SysObjectID
  match_mode: startsWith
  values:
    - .1.3.6.1.4.1.12148.10
- type: snmpget
  oid: .1.3.6.1.4.1.12148.10.2.6.0
  match_mode: regex
  values:
    - '(Micropack System|Smartpack S|SmartPack2 Touch)(\s*)?$'

Conditions in a YAML file always contain two parts, a logical_opertor and conditions. The logical_operator is used to combine multiple conditions. It defines how these conditions are evaluated. There are only two possible values, “OR” and “AND”.

The conditions section contains the actual conditions, which are combined by the logical_operator. A Condition always needs to have a specified type. There are different condition types and depending on the type being used, other parameters need to be set for a condition to be complete. For instance, the example above consist of two conditions, which have the types SysObjectID and snmpget. For the latter, an oid needs to be set which will be requested using snmpget. The value which will be returned by this request will be used to evaluate the condition. This is not needed for a SysObjectID condition, as the condition type already defines which value will be used for evaluation.

As of now, the following condition types are available:

Type Parameters Description
SysDescription
  • match_mode
  • values
  • The SysDescription of a device will be used to evaluate the condition.
    SysObjectID
  • match_mode
  • values
  • The SysObjectID of a device will be used to evaluate the condition.
    snmpget
  • match_mode
  • values
  • oid
  • The given OID will be requested using snmpget and the returned response will be used to evaluate the condition.
    HTTPGetBody
  • match_mode
  • values
  • path
  • A HTTP Get Request for the given path will be sent to the device and the returned HTTP body will be used to evaluate the condition.
    conditionSet
  • logical_operator
  • conditions
  • A condition of this type represents multiple conditions, which will be evaluated separately. A condition set has the same structure as conditions in general, which is described above. It consist of a logical operator and a list of conditions. This allows creating multiple levels of conditions and using different logical operators for evaluation.

    The match_mode and values parameters are mandatory for each condition type (except conditionSet). Every condition retrieves a value from the device and evaluates it by comparing it to given strings, which are defined as an array inside the values parameter. If one of these values matches the criteria, the condition will return true. match_mode describes what kind of comparison is done.

    There are four different match modes that compare the value which was read out from the device (String A) with the strings defined in the values list (String B) with :

    match_mode Description
    contains String A needs to contain String B as a substring
    equals String A must be equal to String B
    startsWith String A must start with String B
    regex String A has to match the regular expression defined in String B

    All match modes can also be negated by adding a ! in front of it.