<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
<style type="text/css" style="display:none;"> P {margin-top:0;margin-bottom:0;} </style>
</head>
<body dir="ltr">
<div style="font-family: Calibri, Helvetica, sans-serif; font-size: 12pt; color: rgb(0, 0, 0);">
Hi,</div>
<div style="font-family: Calibri, Helvetica, sans-serif; font-size: 12pt; color: rgb(0, 0, 0);">
<br>
</div>
<div style="font-family: Calibri, Helvetica, sans-serif; font-size: 12pt; color: rgb(0, 0, 0);">
I'm experimenting with user defined variables, and when using them in regular string concatenation, and in synch output, it works fine. But I would like to use them in the backend definitions, and I simply can't get it to work.</div>
<div style="font-family: Calibri, Helvetica, sans-serif; font-size: 12pt; color: rgb(0, 0, 0);">
<br>
</div>
<div style="font-family: Calibri, Helvetica, sans-serif; font-size: 12pt; color: rgb(0, 0, 0);">
<div style="color: #000000; background-color: #ffffff; font-family: Consolas, 'Courier New', monospace; font-weight: normal; font-size: 14px; line-height: 19px">
<div><span style="color: #0000ff">backend</span><span> myBackend {</span></div>
<div> .<span style="color: rgb(0, 0, 255);">host</span> = var.get(<span style="color: rgb(163, 21, 21);">"myBackendHost"</span>);</div>
<div><span>}</span></div>
</div>
<br>
</div>
<div style="font-family: Calibri, Helvetica, sans-serif; font-size: 12pt; color: rgb(0, 0, 0);">
But that fails with a VCC-compiler error on that line, saying "Expected CSTR got 'var.get'".</div>
<div style="font-family: Calibri, Helvetica, sans-serif; font-size: 12pt; color: rgb(0, 0, 0);">
I also tried with the "variable" vmod, but it resulted in the same type of error.</div>
<div style="font-family: Calibri, Helvetica, sans-serif; font-size: 12pt; color: rgb(0, 0, 0);">
<br>
</div>
<div style="font-family: Calibri, Helvetica, sans-serif; font-size: 12pt; color: rgb(0, 0, 0);">
Is there any way to get this to work? I would really like to have all environment specific configuration (including backend hostnames) in an environment specific vcl file, and then include it in the main vcl where the backend definitions should be (and use
the variables). And I would like to achive this using just VCL (and vmods), so no custom script that does search and replace or anything like that.</div>
<div style="font-family: Calibri, Helvetica, sans-serif; font-size: 12pt; color: rgb(0, 0, 0);">
<br>
</div>
<div style="font-family: Calibri, Helvetica, sans-serif; font-size: 12pt; color: rgb(0, 0, 0);">
So, I would like something like this to work:</div>
<div style="font-family: Calibri, Helvetica, sans-serif; font-size: 12pt; color: rgb(0, 0, 0);">
<br>
</div>
<div style="font-family: Calibri, Helvetica, sans-serif; font-size: 12pt; color: rgb(0, 0, 0);">
default.vcl:</div>
<div style="font-family: Calibri, Helvetica, sans-serif; font-size: 12pt; color: rgb(0, 0, 0);">
...</div>
<div style="font-family: Calibri, Helvetica, sans-serif; font-size: 12pt; color: rgb(0, 0, 0);">
<div style="color: #000000; background-color: #ffffff; font-family: Consolas, 'Courier New', monospace; font-weight: normal; font-size: 14px; line-height: 19px">
<div><span style="color: rgb(0, 0, 255);">import</span> var;<br>
</div>
<br>
<div><span style="color: #0000ff">include</span><span> </span><span style="color: #a31515">"environment.vcl"</span><span>;</span></div>
</div>
<br>
</div>
<div style="font-family: Calibri, Helvetica, sans-serif; font-size: 12pt; color: rgb(0, 0, 0);">
<div style="margin: 0px; font-size: 14px; font-family: Consolas, "Courier New", monospace">
<span style="margin: 0px; color: rgb(0, 0, 255)">backend</span><span style="margin: 0px"> myBackend {</span></div>
<div style="margin: 0px; font-size: 14px; font-family: Consolas, "Courier New", monospace">
.<span style="margin: 0px; color: rgb(0, 0, 255)">host</span> = var.get(<span style="margin: 0px; color: rgb(163, 21, 21)">"myBackendHost"</span>);</div>
<div style="margin: 0px; font-size: 14px; font-family: Consolas, "Courier New", monospace">
<span style="margin: 0px">}</span></div>
...</div>
<div style="font-family: Calibri, Helvetica, sans-serif; font-size: 12pt; color: rgb(0, 0, 0);">
<br>
</div>
<div style="font-family: Calibri, Helvetica, sans-serif; font-size: 12pt; color: rgb(0, 0, 0);">
environment.vcl:<br>
</div>
<div style="font-family: Calibri, Helvetica, sans-serif; font-size: 12pt; color: rgb(0, 0, 0);">
<div style="color: #000000; background-color: #ffffff; font-family: Consolas, 'Courier New', monospace; font-weight: normal; font-size: 14px; line-height: 19px">
<div><span style="color: #0000ff">sub</span><span> vcl_init {</span></div>
<div><span> var.</span><span style="color: #0000ff">set</span><span>(</span><span style="color: #a31515">"<span style="font-family: Consolas, "Courier New", monospace; background-color: rgb(255, 255, 255); display: inline !important">myBackendHost</span>"</span><span>, </span><span style="color: #a31515">"myHostName"</span><span>);</span></div>
<div><span>}</span></div>
<div><span><br>
</span></div>
<div><span><br>
</span></div>
</div>
<br>
</div>
<div style="font-family: Calibri, Helvetica, sans-serif; font-size: 12pt; color: rgb(0, 0, 0);">
<br>
</div>
<div style="font-family: Calibri, Helvetica, sans-serif; font-size: 12pt; color: rgb(0, 0, 0);">
<br>
</div>
</body>
</html>