@@ -9,8 +9,11 @@ namespace VirtualClient.Actions.NetworkPerformance
99 using System . Linq ;
1010 using System . Net ;
1111 using System . Net . Http ;
12+ using System . Text . RegularExpressions ;
1213 using System . Threading ;
1314 using System . Threading . Tasks ;
15+ using Microsoft . AspNetCore . Hosting . Server ;
16+ using Microsoft . CodeAnalysis . CSharp . Syntax ;
1417 using Microsoft . Extensions . DependencyInjection ;
1518 using Newtonsoft . Json . Linq ;
1619 using Polly ;
@@ -28,6 +31,8 @@ public class NetworkingWorkloadExecutor : VirtualClientComponent
2831 {
2932 private static readonly object LockObject = new object ( ) ;
3033 private static Task heartbeatTask ;
34+ private static Regex layoutServerIPRegex = new Regex ( @"\$\.\s*layout\.serverip\b" , RegexOptions . Compiled | RegexOptions . IgnoreCase ) ;
35+ private static Regex layoutClientIPRegex = new Regex ( @"\$\.\s*layout\.clientip\b" , RegexOptions . Compiled | RegexOptions . IgnoreCase ) ;
3136
3237 // Contains the background running process for the server-side
3338 // networking workload tool.
@@ -597,6 +602,8 @@ protected override async Task InitializeAsync(EventContext telemetryContext, Can
597602 EventContext . PersistentProperties [ "role" ] = this . Role ;
598603
599604 this . InitializeApiClients ( ) ;
605+
606+ this . InlineLayoutReferences ( ) ;
600607 }
601608
602609 /// <summary>
@@ -1135,6 +1142,23 @@ private void StopServerTool(EventContext telemetryContext)
11351142 }
11361143 }
11371144
1145+ private void InlineLayoutReferences ( )
1146+ {
1147+ string serverIPAddress = this . GetLayoutClientInstances ( ClientRole . Server ) . First ( ) . IPAddress ;
1148+ string clientIPAddress = this . GetLayoutClientInstances ( ClientRole . Client ) . First ( ) . IPAddress ;
1149+
1150+ foreach ( var key in this . Parameters . Keys . ToList ( ) )
1151+ {
1152+ var original = this . Parameters [ key ] ? . ToString ( ) ;
1153+
1154+ var updated = layoutServerIPRegex . Replace ( original , serverIPAddress ) ;
1155+ updated = layoutClientIPRegex . Replace ( updated , clientIPAddress ) ;
1156+
1157+ this . Parameters [ key ] = updated ;
1158+
1159+ }
1160+ }
1161+
11381162 /// <summary>
11391163 /// Used to track and managed the execution of the background server-side workload
11401164 /// process over a long running period of time.
0 commit comments