@@ -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 ;
@@ -30,6 +33,8 @@ public class NetworkingWorkloadExecutor : VirtualClientComponent
3033 {
3134 private static readonly object LockObject = new object ( ) ;
3235 private static Task heartbeatTask ;
36+ private static Regex layoutServerIPRegex = new Regex ( @"\$\.\s*layout\.serverip\b" , RegexOptions . Compiled | RegexOptions . IgnoreCase ) ;
37+ private static Regex layoutClientIPRegex = new Regex ( @"\$\.\s*layout\.clientip\b" , RegexOptions . Compiled | RegexOptions . IgnoreCase ) ;
3338
3439 // Contains the background running process for the server-side
3540 // networking workload tool.
@@ -599,6 +604,8 @@ protected override async Task InitializeAsync(EventContext telemetryContext, Can
599604 EventContext . PersistentProperties [ "role" ] = this . Role ;
600605
601606 this . InitializeApiClients ( ) ;
607+
608+ this . InlineLayoutReferences ( ) ;
602609 }
603610
604611 /// <summary>
@@ -1137,6 +1144,23 @@ private void StopServerTool(EventContext telemetryContext)
11371144 }
11381145 }
11391146
1147+ private void InlineLayoutReferences ( )
1148+ {
1149+ string serverIPAddress = this . GetLayoutClientInstances ( ClientRole . Server ) . First ( ) . IPAddress ;
1150+ string clientIPAddress = this . GetLayoutClientInstances ( ClientRole . Client ) . First ( ) . IPAddress ;
1151+
1152+ foreach ( var key in this . Parameters . Keys . ToList ( ) )
1153+ {
1154+ var original = this . Parameters [ key ] ? . ToString ( ) ;
1155+
1156+ var updated = layoutServerIPRegex . Replace ( original , serverIPAddress ) ;
1157+ updated = layoutClientIPRegex . Replace ( updated , clientIPAddress ) ;
1158+
1159+ this . Parameters [ key ] = updated ;
1160+
1161+ }
1162+ }
1163+
11401164 /// <summary>
11411165 /// Used to track and managed the execution of the background server-side workload
11421166 /// process over a long running period of time.
0 commit comments