Modify multiple physical address atributes in stress-client payload. 54/19154/3
authorMaros Marsalek <mmarsale@cisco.com>
Wed, 29 Apr 2015 14:39:45 +0000 (16:39 +0200)
committerMaros Marsalek <mmarsale@cisco.com>
Wed, 29 Apr 2015 14:39:45 +0000 (16:39 +0200)
Change-Id: Ic719c519eb0735d00014e51851dd958db5098ff0
Signed-off-by: Tomas Cere <tcere@cisco.com>
Signed-off-by: Maros Marsalek <mmarsale@cisco.com>
opendaylight/netconf/netconf-testtool/src/main/java/org/opendaylight/controller/netconf/test/tool/client/stress/StressClient.java

index 0e87604..206e82a 100644 (file)
@@ -86,6 +86,7 @@ public final class StressClient {
 
     private static final String MSG_ID_PLACEHOLDER_REGEX = "\\{MSG_ID\\}";
     private static final String PHYS_ADDR_PLACEHOLDER_REGEX = "\\{PHYS_ADDR\\}";
+    private static long idCounter = 0;
 
     public static void main(final String[] args) {
         final Parameters params = parseArgs(args, Parameters.getParser());
@@ -191,8 +192,11 @@ public final class StressClient {
             // Insert message id where needed
             String specificEditContent = editContentString.replaceAll(MSG_ID_PLACEHOLDER_REGEX, Integer.toString(id));
 
-            specificEditContent =
-                    specificEditContent.replaceAll(PHYS_ADDR_PLACEHOLDER_REGEX, getMac(id));
+            while (specificEditContent.contains("{PHYS_ADDR}")) {
+                specificEditContent =
+                        specificEditContent.replaceFirst(PHYS_ADDR_PLACEHOLDER_REGEX, getMac(idCounter));
+                idCounter++;
+            }
 
             editContentElement = XmlUtil.readXmlToElement(specificEditContent);
             final Node config = ((Element) msg.getDocumentElement().getElementsByTagName("edit-config").item(0)).
@@ -223,8 +227,8 @@ public final class StressClient {
         return netconfClientDispatcher;
     }
 
-    private static String getMac(final int i) {
-        final String hex = Integer.toHexString(i);
+    private static String getMac(final long i) {
+        final String hex = Long.toHexString(i);
         final Iterable<String> macGroups = Splitter.fixedLength(2).split(hex);
 
         final int additional = 6 - Iterables.size(macGroups);

©2013 OpenDaylight, A Linux Foundation Collaborative Project. All Rights Reserved.
OpenDaylight is a registered trademark of The OpenDaylight Project, Inc.
Linux Foundation and OpenDaylight are registered trademarks of the Linux Foundation.
Linux is a registered trademark of Linus Torvalds.