Forum Discussion

J_LE_42749's avatar
J_LE_42749
Icon for Nimbostratus rankNimbostratus
Sep 26, 2014

TCL & regex - help to parse APM configuration in tmsh

Hello World,

I'm using a script to bring some automation to APM and provision resources to my AP from an external server.

I'm stuck when comes the time to capture the macro name that I want to provision to the VPE.

In a full APM config dump I can get the full resource assign objects using a regex like:

apm policy policy-item AP_NAME-resources_assignment_act_full_resource_assign.+?caption "Dynamic Resource Assign"

(in the VPE I have my macro named Dynamic Resource Assign of course)

This returns me a string that contains (in my environment) 2 macros:

apm policy policy-item AP_NAME-resources_assignment_act_full_resource_assign {
    agents {
        AP_SAG_NAME-resources_assignment_act_full_resource_assign_ag {
            type resource-assign
        }
    }
    app-service none
    caption "webtop Assign"
    color 1
    item-type action
    loop false
    macro none
    partition Common
    rules {
        {
            caption fallback
            expression none
            next-item AP_NAME-resources_assignment_act_empty_2
        }
    }
}
apm policy policy-item AP_NAME-resources_assignment_act_full_resource_assign_1 {
    agents {
        AP_NAME-resources_assignment_act_full_resource_assign_1_ag {
            type resource-assign
        }
    }
    app-service none
    caption "Dynamic Resource Assign"

I'm stuck in finding the right regex to capture the macro name of the second occurrence (AP_NAME-resources_assignment_act_full_resource_assign_1_ag).

I tried:

AP_SAG_E11TST-resources_assignment_act_full_resource_assign.?.?_ag

but of course it returns two entries:

AP_SAG_NAME-resources_assignment_act_full_resource_assign_ag
AP_SAG_NAME-resources_assignment_act_full_resource_assign_1_ag

If anyone has a clue on how to filter out the caption "webtop Assign" entry or (better) make sure only the caption "Dynamic Resource Assign" one is returned that would help me quite a lot...

Thank you all!

Jérôme

No RepliesBe the first to reply