Github user rafaelweingartner commented on a diff in the pull request:

    https://github.com/apache/cloudstack/pull/1878#discussion_r105678507
  
    --- Diff: 
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();
    --- End diff --
    
    This method is still quite big.
    What about extracting lines 1966-1971 to a method? These lines are used to 
generate/create the `sbNewMacSequence`. Then we could have a documentation 
describing its workings and test cases.


---
If your project is set up for it, you can reply to this email and have your
reply appear on GitHub as well. If your project does not have this feature
enabled and wishes so, or if the feature is enabled but not working, please
contact infrastructure at infrastruct...@apache.org or file a JIRA ticket
with INFRA.
---

Reply via email to