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.
Overwriting Values
By default, if an attribute already exists in the IP Fabric environment, the utility will not overwrite it. This can be 
modified by setting the overwrite attribute in the rule or globally in the default or default_config section.
default:
  overwrite: true  # Defaults to null, setting to a boolean value will propagate to all rules
default_config:
  overwrite: null
rules:
  - name: Overwrite Example
    overwrite: null  # Since this is null, the default true will be used when merging rules
  - name: Do Not Overwrite Example
    overwrite: false  # Set to false to not overwrite existing attributes and ignore the default
  - name: Config Rule Example
    overwrite: null
    config: current
In the above example:
- The default.overwriteis a boolean value and not null so it will propagate to all rules ifoverwriteis not set.
- “Overwrite Example” is a nullvalue the defaulttruewill be used when merging rules.
- “Do Not Overwrite Example” is explicitly set to false, so it will not overwrite existing attributes.
- “Config Rule Example” will evaluate to falsesince thedefault_config.overwriteand therule.overwritearenull.
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_TYPEtoExternal.
- If Multicast is enabled set attribute MULTICAST_ENABLEDtoTrue.
 
- If External BGP Neighbor found set attribute 
- Device Configuration:- If no ip http serveris found in the device configuration, set the attributeHTTP_SERVERtoDisabled.
 
- 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_REGIONtoGlobal; Region Example.
 
- If a Cloud construct is not attached to a Location or Region, set the attribute 
- Device Configuration:- If no ip http serveris not found in the device configuration, set the attributeHTTP_SERVERtoEnabled; 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 staticvalue to apply a single attribute value to any data that matches.- Example: If vendorcolumn matchesaws|azure|gcpthen set a static value ofCLOUDto theREGIONattribute.
 
- 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
    default_mapping_value: Unknown  # Optional, used if no mapping is found
    value:
      mapping:
        "us-east": "US East"
        "us-west": "US West"
        "eu-central": "EU Central"
If the value is not found in the mapping, the default_mapping_value will be used. If no default_mapping_value is 
specified, the value will not be set.
Can be used in conjunction with Regex Values to map the extracted value to a predefined set of values.
Use Cases:
- IP Fabric Table- 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.
 
- Apply a SITE_STATUSattribute based on thesiteName
 
- Region Example:
- Device Configuration:- Extract a configuration line and map it to a standardized value.