You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@cloudstack.apache.org by GitBox <gi...@apache.org> on 2020/01/30 01:46:21 UTC
[GitHub] [cloudstack] GabrielBrascher commented on a change in pull request
#3847: VR: Fix Redundant VRouter guest network on wrong interface
GabrielBrascher commented on a change in pull request #3847: VR: Fix Redundant VRouter guest network on wrong interface
URL: https://github.com/apache/cloudstack/pull/3847#discussion_r372717180
##########
File path: plugins/hypervisors/kvm/src/main/java/com/cloud/hypervisor/kvm/resource/LibvirtComputingResource.java
##########
@@ -1794,35 +1794,26 @@ public ExecutionResult prepareNetworkElementCommand(final IpAssocCommand cmd) {
final String routerIp = cmd.getAccessDetail(NetworkElementCommand.ROUTER_IP);
Connect conn;
try {
- conn = LibvirtConnection.getConnectionByVmName(routerName);
- final List<InterfaceDef> nics = getInterfaces(conn, routerName);
- final Map<String, Integer> broadcastUriAllocatedToVM = new HashMap<String, Integer>();
- Integer nicPos = 0;
- for (final InterfaceDef nic : nics) {
- if (nic.getBrName().equalsIgnoreCase(_linkLocalBridgeName)) {
- broadcastUriAllocatedToVM.put("LinkLocal", nicPos);
- } else {
- if (nic.getBrName().equalsIgnoreCase(_publicBridgeName) || nic.getBrName().equalsIgnoreCase(_privBridgeName) ||
- nic.getBrName().equalsIgnoreCase(_guestBridgeName)) {
- broadcastUriAllocatedToVM.put(BroadcastDomainType.Vlan.toUri(Vlan.UNTAGGED).toString(), nicPos);
- } else {
- final String broadcastUri = getBroadcastUriFromBridge(nic.getBrName());
- broadcastUriAllocatedToVM.put(broadcastUri, nicPos);
- }
- }
- nicPos++;
+ conn = getLibvirtUtilitiesHelper().getConnectionByVmName(routerName);
+ Integer devNum = 0;
+ final List<InterfaceDef> pluggedNics = getInterfaces(conn, routerName);
+ final Map<String, Integer> macAddressToNicNum = new HashMap<>(pluggedNics.size());
+ for (final InterfaceDef pluggedNic : pluggedNics) {
+ final String pluggedVlan = pluggedNic.getBrName();
+ macAddressToNicNum.put(pluggedNic.getMacAddress(), devNum);
+ devNum++;
Review comment:
Duplicated lines (_1797 - 1805_ **=** _1838 - 1847_). Can you please extract them into a method?
----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
With regards,
Apache Git Services