Learn F5 Technologies, Get Answers & Share Community Solutions Join DevCentral

Filter by:
  • Solution
  • Technology
Clear all filters
Answers

Is there a way in an iRule to determine if an ASM policy exists before doing an ASM::enable on it?

I am trying to base the ASM policy i assign to my inbound connections on the URL in my iRule. If i do an ASM::enable on a policy that does not yet exist the connection/session fails.

Is there a way to check if the ASM policy exists before doing an enable? Something like:

if { [AMS::policy exists $policy] } { ASM::enable $policy }

0
Rate this Question

Answers to this Question

placeholder+image
USER ACCEPTED ANSWER & F5 ACCEPTED ANSWER

KWH,

It seems like what you are looking for is the iRules 'catch' statement. This will try to run a piece of code and check for any runtime errors. If there is any error, it will run a second block of code instead. This will help you check if a certain policy exists. I haven't properly tested this code, but I believe your solution should look something like this.

if { [catch {
     ASM::enable $policy
     log local0. "$policy was enabled"  
     }] } then {
        # This block only triggers if the above code would fail
        log local0. "$policy does not exist"
    }

More information here, if you would like to research some more yourself.

0
Comments on this Answer
Comment made 2 months ago by sogboj 2

Hi, thanks for the response. I will give it a try. I was hoping from something more built-in that doesn't force a failure. Like using 'exists' for a class.

0