Attribute Values
This section describes how to assign values to dynamic attributes in IP Fabric using the ipf_dynamic_attributes
utility. Values can be static, calculated, or derived from device configurations or tables.
In the next sections we will go into more detail with examples of how to use these features effectively.
Static Values
Static values are hard coded values assigned to attributes. They can be used when the value does not change or is known in advance.
rules:
- name: Static Value Example
value:
static: example_value
Use Cases:
- IP Fabric Table:
- If External BGP Neighbor found set attribute
BGP_PEER_TYPE
toExternal
. - If Multicast is enabled set attribute
MULTICAST_ENABLED
toTrue
.
- If External BGP Neighbor found set attribute
- Device Configuration:
- If
no ip http server
is found in the device configuration, set the attributeHTTP_SERVER
toDisabled
.
- If
Null Values
Null values are hard coded values assigned to attributes when data is not found or a config is not matched.
Please note if a device has multiple rows in the table, the first row will be used. For example, devices can
have multiple interfaces or routing neighbors, but only the first row will be used to set the attribute value. If the
first row does not contain data then the null_value
will be set and further processing will not take place. Please
ensure that the table is filtered correctly or sorted to avoid unexpected results.
rules:
- name: Null Value Example
value:
null_value: N/A
Use Cases:
- IP Fabric Table:
- If a Cloud construct is not attached to a Location or Region, set the attribute
CLOUD_REGION
toGlobal
; Region Example.
- If a Cloud construct is not attached to a Location or Region, set the attribute
- Device Configuration:
- If
no ip http server
is not found in the device configuration, set the attributeHTTP_SERVER
toEnabled
; HTTP Server Example.
- If
Regex Values
Regex values are used to extend the data from either the IP Fabric Table or searching in the Device Configuration.
Configuration Rules requires the use of a Regex configuration.
rules:
- name: Regex Value Example
value:
regex:
pattern: ^(\w\w)-
group: 1
flags:
- IGNORECASE
- MULTILINE
- Pattern is the regex pattern to match.
- If quoting the pattern ensure to escape the backslashes,
"^(\\w\\w)-"
.
- If quoting the pattern ensure to escape the backslashes,
- Group is the regex group to extract from the match, example
us-east
:- Group 0 is the entire match (
us-
). - Group 1 is the first capturing group (
us
), and so on.
- Group 0 is the entire match (
- Flags are an optional list of Python regex flags to modify the behavior of the regex engine.
Use Cases:
- IP Fabric Table:
- Extract a Region from a Hostname or Site Name.
- Can be used in conjunction with a
static
value to apply a single attribute value to any data that matches.- Example: If
vendor
column matchesaws|azure|gcp
then set a static value ofCLOUD
to theREGION
attribute.
- Example: If
- Device Configuration:
- Search for a specific configuration line and extract a value from it or assign a static value if a match is found.
- Extract SSH Version from the configuration
Value Mapping
Value mapping allows you to map specific values from the IP Fabric Table or Device Configuration to a predefined set of values. This is useful for standardizing values or converting them to a specific format.
rules:
- name: Value Mapping Example
value:
mapping:
"us-east": "US East"
"us-west": "US West"
"eu-central": "EU Central"
Can be used in conjunction with Regex Values to map the extracted value to a predefined set of values.
Use Cases:
- IP Fabric Table; see Region Example:
- Extract a Region Code from a Hostname or Site Name and map it to a Region Name.
- Convert a Cloud Location or Region into a standardized format.
- Device Configuration:
- Extract a configuration line and map it to a standardized value.