Moti Asayag has posted comments on this change.
Change subject: engine: Prevent empty MAC Address range
......................................................................
Patch Set 2:
(4 comments)
....................................................
File
backend/manager/modules/utils/src/main/java/org/ovirt/engine/core/utils/MacAddressRangeUtils.java
Line 10:
Line 11: private static final String MAC_ADDRESS_MULTICAST_LSB =
"13579bBdDfF";
Line 12: private static final int HEX_RADIX = 16;
Line 13:
Line 14: public static Set<String> initRange(String start, String end) {
Done
Line 15:
Line 16: String parsedRangeStart = parseRangePart(start);
Line 17: String parsedRangeEnd = parseRangePart(end);
Line 18: if (parsedRangeEnd == null || parsedRangeStart == null) {
Line 27:
Line 28: Set<String> macAddresses = new HashSet<String>();
Line 29:
Line 30: for (long i = startNum; i <= endNum; i++) {
Line 31: String value = String.format("%x", i);
Done
Line 32: if (value.length() > 12) {
Line 33: return macAddresses;
Line 34: } else if (value.length() < 12) {
Line 35: value = StringUtils.leftPad(value, 12, '0');
Line 45:
Line 46: return macAddresses;
Line 47: }
Line 48:
Line 49: private static String parseRangePart(String start) {
Actually, there is more improvements to this part which is being called couple
of times redundantly.
Done
Line 50: StringBuilder builder = new StringBuilder();
Line 51: for (String part : start.split("[:]", -1)) {
Line 52: String tempPart = part.trim();
Line 53: if (tempPart.length() == 1) {
Line 61:
Line 62: return builder.toString();
Line 63: }
Line 64:
Line 65: private static String createMacAddress(String value) {
Done
Line 66: StringBuilder builder = new StringBuilder();
Line 67:
Line 68: for (int j = 0; j < value.length(); j += 2) {
Line 69: String group = value.substring(j, j + 2);
--
To view, visit http://gerrit.ovirt.org/20155
To unsubscribe, visit http://gerrit.ovirt.org/settings
Gerrit-MessageType: comment
Gerrit-Change-Id: I24113379e8fbbc15a63bdb1be4e6c719d7cb764f
Gerrit-PatchSet: 2
Gerrit-Project: ovirt-engine
Gerrit-Branch: master
Gerrit-Owner: Moti Asayag <[email protected]>
Gerrit-Reviewer: Mike Kolesnik <[email protected]>
Gerrit-Reviewer: Moti Asayag <[email protected]>
Gerrit-Reviewer: oVirt Jenkins CI Server
Gerrit-HasComments: Yes
_______________________________________________
Engine-patches mailing list
[email protected]
http://lists.ovirt.org/mailman/listinfo/engine-patches