sureshanaparti commented on a change in pull request #1878: CLOUDSTACK-9717:
[VMware] RVRs have mismatching MAC addresses for extra public NICs.
URL: https://github.com/apache/cloudstack/pull/1878#discussion_r115655899
##########
File path:
plugins/hypervisors/vmware/src/com/cloud/hypervisor/vmware/resource/VmwareResource.java
##########
@@ -1928,6 +1929,54 @@ protected StartAnswer execute(StartCommand cmd) {
VirtualDevice nic;
int nicMask = 0;
int nicCount = 0;
+
+ if (vmSpec.getType() == VirtualMachine.Type.DomainRouter) {
+ int extraPublicNics = mgr.getRouterExtraPublicNics();
+ if (extraPublicNics > 0 &&
vmSpec.getDetails().containsKey("PeerRouterInstanceName")) {
+ //Set identical MAC address for RvR on extra public
interfaces
+ String peerRouterInstanceName =
vmSpec.getDetails().get("PeerRouterInstanceName");
+
+ VirtualMachineMO peerVmMo =
hyperHost.findVmOnHyperHost(peerRouterInstanceName);
+ if (peerVmMo == null) {
+ peerVmMo =
hyperHost.findVmOnPeerHyperHost(peerRouterInstanceName);
+ }
+
+ if (peerVmMo != null) {
+ StringBuffer sbOldMacSequence = new StringBuffer();
+ for (NicTO oldNicTo : sortNicsByDeviceId(nics)) {
+
sbOldMacSequence.append(oldNicTo.getMac()).append("|");
+ }
+ if (!sbOldMacSequence.toString().isEmpty()) {
+
sbOldMacSequence.deleteCharAt(sbOldMacSequence.length() - 1); //Remove extra
'|' char appended at the end
+ }
+
+ for (int nicIndex = nics.length - extraPublicNics;
nicIndex < nics.length; nicIndex++) {
+ VirtualDevice nicDevice =
peerVmMo.getNicDeviceByIndex(nics[nicIndex].getDeviceId());
+ if (nicDevice != null) {
+ String mac =
((VirtualEthernetCard)nicDevice).getMacAddress();
+ if (mac != null) {
+ s_logger.info("Use same MAC as previous
RvR, the MAC is " + mac + " for extra NIC with device id: " +
nics[nicIndex].getDeviceId());
+ nics[nicIndex].setMac(mac);
+ }
+ }
+ }
+
+ String bootArgs = vmSpec.getBootArgs();
+ if (!StringUtils.isEmpty(bootArgs)) {
+ StringBuffer sbNewMacSequence = new StringBuffer();
Review comment:
Moved generating new nics mac sequence to a new private method.
----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on GitHub and use the
URL above to go to the specific comment.
For queries about this service, please contact Infrastructure at:
[email protected]
With regards,
Apache Git Services