Forum Discussion

Ryan_M_362715's avatar
Ryan_M_362715
Icon for Altocumulus rankAltocumulus
Nov 16, 2018

Resource Assignment based on Virtual Server?

Hey all,

I have two virtual servers that are associated with the same access policy and need to assign an IP pool based on the virtual server that the user connected to. In my resource assignment, I'm using the following expression to make the decision:

expr { [mcget {session.server.listener.name}] == "/Common/VSTest-01"  }

The session variable appears to match correctly in the logs, but it throws the following error in the access logs:

Rule evaluation failed with error: syntax error in expression " [mcget {session.server.listener.name}] == /Common/VSTest-...": unexpected operator /

It seems to not like something about the "/" character in the string. I've tried using the escape character "\" before each "/" with the same result.

I've also tried changing the operator to "contains" and dropping the "/Common/" portion, but end up with this error:

Rule evaluation failed with error: syntax error in expression " [mcget {session.server.listener.name}] contains VSTest-...": variable references require preceding $

Any ideas what I'm doing wrong? I feel as though I've tried every combination with no success.

  • Hey Ryan!

    So I did some testing in my lab and I discovered that this is way easier to do with an iRule. I used the following syntax:

        when HTTP_REQUEST {
        if {[virtual name] equals "/Common/VSTest-01"} {
            pool PoolTest-01
          } 
        if {[virtual name] equals "/Common/VSTest-02"} {
            pool PoolTest-02
          }
    }
    

    The behavior was that I authenticated to first virtual server and accessed the back-end server on pool1. Then I killed my record in the hosts file and changed to other VS address. I was automatically switched over to the pool2 without having to log on again. So in my setup I do not use any resource assignment, I let the iRule dictate this.

    Let me know how that works out for you 🙂

    I hope this helps!