Return-Path: X-Original-To: archive-asf-public-internal@cust-asf2.ponee.io Delivered-To: archive-asf-public-internal@cust-asf2.ponee.io Received: from cust-asf.ponee.io (cust-asf.ponee.io [163.172.22.183]) by cust-asf2.ponee.io (Postfix) with ESMTP id 160CF200C28 for ; Mon, 13 Mar 2017 15:57:12 +0100 (CET) Received: by cust-asf.ponee.io (Postfix) id 149DF160B60; Mon, 13 Mar 2017 14:57:12 +0000 (UTC) Delivered-To: archive-asf-public@cust-asf.ponee.io Received: from mail.apache.org (hermes.apache.org [140.211.11.3]) by cust-asf.ponee.io (Postfix) with SMTP id 61494160B6C for ; Mon, 13 Mar 2017 15:57:11 +0100 (CET) Received: (qmail 96143 invoked by uid 500); 13 Mar 2017 14:57:08 -0000 Mailing-List: contact dev-help@cloudstack.apache.org; run by ezmlm Precedence: bulk List-Help: List-Unsubscribe: List-Post: List-Id: Reply-To: dev@cloudstack.apache.org Delivered-To: mailing list dev@cloudstack.apache.org Received: (qmail 95979 invoked by uid 99); 13 Mar 2017 14:57:07 -0000 Received: from git1-us-west.apache.org (HELO git1-us-west.apache.org) (140.211.11.23) by apache.org (qpsmtpd/0.29) with ESMTP; Mon, 13 Mar 2017 14:57:07 +0000 Received: by git1-us-west.apache.org (ASF Mail Server at git1-us-west.apache.org, from userid 33) id ED93CDFF58; Mon, 13 Mar 2017 14:57:06 +0000 (UTC) From: rafaelweingartner To: dev@cloudstack.apache.org Reply-To: dev@cloudstack.apache.org References: In-Reply-To: Subject: [GitHub] cloudstack pull request #1878: CLOUDSTACK-9717: [VMware] RVRs have mismatchi... Content-Type: text/plain Message-Id: <20170313145706.ED93CDFF58@git1-us-west.apache.org> Date: Mon, 13 Mar 2017 14:57:06 +0000 (UTC) archived-at: Mon, 13 Mar 2017 14:57:12 -0000 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 infrastructure@apache.org or file a JIRA ticket with INFRA. ---