Could someone help me to solve this odd behavior ? Created ExtractVariables policy to fetch proxyname and based on that proxyname fetch host from kvm, and inject host to request.unfortunately Extracted.basepath is not setting and host_value is not pulling from kvm. Did i miss something ?
Extract base basepath:
------------------------------
Input: https://<domain>//proxy1
Expected output: proxy1
Actual output: null
<?xml version="1.0" encoding="UTF-8" standalone="yes"?>
<ExtractVariables continueOnError="false" enabled="true" name="EV-ExtractBasePath">
<DisplayName>EV-ExtractBasePath</DisplayName>
<Properties/>
<URIPath name="basepath">
<Segment fragment="2"/>
</URIPath>
<VariablePrefix>Extracted</VariablePrefix>
<IgnoreUnresolvedVariables>true</IgnoreUnresolvedVariables>
</ExtractVariables>
KeyValueMapOperations
----------------------
extracting the kvm
{
"name": "KVM-Host",
"encrypted": false,
"entry": [
{
"name": "proxy1",
"value": "proxy1.anthos.domain.com"
}, {
"name": "proxy2",
"value": "proxy2.anthos.domain.com"
}
]
}
expected output: proxy1.anthos.domain.com
Actual output: null
<?xml version="1.0" encoding="UTF-8" standalone="yes"?>
<KeyValueMapOperations async="false" continueOnError="false" enabled="true" name="KVM-GetHostValue">
<DisplayName>KVM-GetHostValue</DisplayName>
<ExpiryTimeInSecs>300</ExpiryTimeInSecs>
<Get assignTo="host_value">
<Key>
<Parameter>{Extracted.basepath}</Parameter>
</Key>
<Scope>environment</Scope>
</Get>
<KeyValueMapRef>KVM-Host</KeyValueMapRef>
</KeyValueMapOperations>
This should work if i hardcode
<?xml version="1.0" encoding="UTF-8" standalone="yes"?>
<AssignMessage async="false" continueOnError="false" enabled="true" name="AM-AddHostHeader">
<DisplayName>AM-AddHostHeader</DisplayName>
<Set>
<Headers>
<Header name="Host">{host_value}</Header>
</Headers>
</Set>
<IgnoreUnresolvedVariables>true</IgnoreUnresolvedVariables>
<AssignTo createNew="false" transport="http" type="request"/>
</AssignMessage>
Solved! Go to Solution.
I think your problem is in the extract variables. The policy docs only mention the <Pattern> as child of <URIPath>.
<URIPath>
<Pattern ignoreCase="true">/something/{basepath}</Pattern>
</URIPath>
Input: https://<domain>/proxy1
I think your problem is in the extract variables. The policy docs only mention the <Pattern> as child of <URIPath>.
<URIPath>
<Pattern ignoreCase="true">/something/{basepath}</Pattern>
</URIPath>
Thanks for your response. I'm still wondering why KeyValueMapOperations policy still not working.
Revised the implementation and extracted base path using a js policy and assigned my basepath to variable like this
var url = context.getVariable('request.uri');
var pathSuffix = context.getVariable('proxy.pathsuffix');
var basePath = url.replace(pathSuffix, '');
basePath = basePath.replace(/^\//, '');
context.setVariable('custom.basepath', basePath);
Now i'm getting the base path as expected:
Here is my kvm get
<KeyValueMapOperations name="KVM-GetHostValue" enabled="true" continueOnError="false" async="false" mapIdentifier="KVM-Host">
<DisplayName>KVM-GetHostValue</DisplayName>
<ExpiryTimeInSecs>300</ExpiryTimeInSecs>
<Scope>environment</Scope>
<Get assignTo="host_value">
<Key>
<Parameter>{custom.basepath}</Parameter>
</Key>
</Get>
</KeyValueMapOperations>
Here i'm trying to assign my kvm to host_value variable, unfortunately not getting any value. if i hard code the value in custom.basepath here
<Parameter>basepathvalue</Parameter>
, getting the response and my variable is set.
User | Count |
---|---|
1 | |
1 | |
1 | |
1 | |
1 |