# Parent Group Merge Algorithm

The parent group merge algorithm enables the system to merge policies that contain references to parent groups and create an internal parent group for each internal parent group in a component policy in the final merged policy. There is a one-to-one correspondence between an internal parent group in the merged policy and an internal parent group in a component policy.

| Note: The naive parent group merging algorithm is not compatible with this parent group merge algorithm. If you have service definitions that used the naive parent group algorithm, you need to modify those service definitions to work with this algorithm.

- If there is no existing internal parent group with the same name in the merged policy, the system creates a corresponding internal parent group with the same name.
- If an internal parent group with the same name already exists, the system uses a name built by appending an internally generated sequence number to the name of the internal parent group in the component policy.
- If the length of the name exceeds the maximum length allowed, the policy merge fails.
- If a classifier group in a component policy refers to an internal parent group, the same classifier group in the merged policy corresponds to the internal parent group in the merged policy.
- If a classifier group in a component policy refers to an external parent group, the same classifier group in the merged policy refers to the same external parent group.
- If there is a conflict where two or more component policies contain the same classifier group referring to an internal parent group in a corresponding component policy or to an external parent group, then last one is used.

In the following example, component policies P1 and P2 create the merged policy mpl_88000001.

    host1#show policy-list P1

                                      Policy Table
                                      ------ -----
    IP Policy P1
       Administrative state: enable
       Reference count:      1
       Classifier control list: *, precedence 100, parent-group Z
       forward
       Classifier control list: A, precedence 100, parent-group X
    forward
       Classifier control list: B, precedence 100, parent-group X
    forward
       Classifier control list: C, precedence 100, external parent-group EPG1
    parameter foo
    forward
       Classifier control list: D, precedence 100, external parent-group EPG1 parameter foo
    forward

       Parent group: X, parent-group Z
          rate-limit-profile R1
       Parent group: Z
          rate-limit-profile R2

    host1#show policy-list P2

                                      Policy Table
                                      ------ -----
    IP Policy P2
       Administrative state: enable
       Reference count:      1
       Classifier control list: B, precedence 100, parent-group X
    forward
       Classifier control list: C, precedence 100, parent-group Y
           forward
       Classifier control list: D, precedence 100, external parent-group EPG2 parameter abcd
    forward

       Parent group: X, parent-group Y
          rate-limit-profile R3
       Parent group: Y
          rate-limit-profile R4

    host1#show policy-list mpl_88000001

                                      Policy Table
                                      ------ -----

    IP Policy mpl_88000001
    Administrative state: enable
    Reference count:      1
       Classifier control list: *, precedence 100, parent-group Z
    forward
       Classifier control list: A, precedence 100, parent-group X
    forward
       Classifier control list: B, precedence 100, parent-group X_1
    forward
       Classifier control list: C, precedence 100, parent-group Y
    forward
       Classifier control list: D, precedence 100, external parent-group EPG2 parameter abcd
    forward

       Parent group: X, parent-group Z
          rate-limit-profile R1
       Parent group: Z
          rate-limit-profile R2
       Parent group: X_1, parent-group P2_Y
          rate-limit-profile R3
       Parent group: Y
          rate-limit-profile R4

       Referenced by interfaces:
          ATM5/0.1  input policy, statistics enabled, virtual-router default

       Referenced by profiles:
          None

       Component policies:
          P1
          P2