@@ -109,7 +109,7 @@ public class NetworkHelperImpl implements NetworkHelper {
109109 @ Inject
110110 protected NicDao _nicDao ;
111111 @ Inject
112- private NetworkDao _networkDao ;
112+ protected NetworkDao _networkDao ;
113113 @ Inject
114114 protected DomainRouterDao _routerDao ;
115115 @ Inject
@@ -137,8 +137,6 @@ public class NetworkHelperImpl implements NetworkHelper {
137137 @ Inject
138138 private UserIpv6AddressDao _ipv6Dao ;
139139 @ Inject
140- private RouterControlHelper _routerControlHelper ;
141- @ Inject
142140 protected NetworkOrchestrationService _networkMgr ;
143141 @ Inject
144142 private UserDao _userDao ;
@@ -610,20 +608,22 @@ protected HypervisorType getClusterToStartDomainRouterForOvm(final long podId) {
610608 throw new CloudRuntimeException (errMsg );
611609 }
612610
613- @ Override
614- public LinkedHashMap <Network , List <? extends NicProfile >> configureDefaultNics (final RouterDeploymentDefinition routerDeploymentDefinition ) throws ConcurrentOperationException , InsufficientAddressCapacityException {
615-
616- final LinkedHashMap <Network , List <? extends NicProfile >> networks = new LinkedHashMap <Network , List <? extends NicProfile >>(3 );
611+ protected LinkedHashMap <Network , List <? extends NicProfile >> configureControlNic (final RouterDeploymentDefinition routerDeploymentDefinition ) {
612+ final LinkedHashMap <Network , List <? extends NicProfile >> controlConfig = new LinkedHashMap <Network , List <? extends NicProfile >>(3 );
617613
618- // 1) Control network
619614 s_logger .debug ("Adding nic for Virtual Router in Control network " );
620615 final List <? extends NetworkOffering > offerings = _networkModel .getSystemAccountNetworkOfferings (NetworkOffering .SystemControlNetwork );
621616 final NetworkOffering controlOffering = offerings .get (0 );
622- final Network controlConfig = _networkMgr .setupNetwork (s_systemAccount , controlOffering , routerDeploymentDefinition .getPlan (), null , null , false ).get (0 );
617+ final Network controlNic = _networkMgr .setupNetwork (s_systemAccount , controlOffering , routerDeploymentDefinition .getPlan (), null , null , false ).get (0 );
623618
624- networks .put (controlConfig , new ArrayList <NicProfile >());
619+ controlConfig .put (controlNic , new ArrayList <NicProfile >());
620+
621+ return controlConfig ;
622+ }
623+
624+ protected LinkedHashMap <Network , List <? extends NicProfile >> configurePublicNic (final RouterDeploymentDefinition routerDeploymentDefinition , final boolean hasGuestNic ) {
625+ final LinkedHashMap <Network , List <? extends NicProfile >> publicConfig = new LinkedHashMap <Network , List <? extends NicProfile >>(3 );
625626
626- // 2) Public network
627627 if (routerDeploymentDefinition .isPublicNetwork ()) {
628628 s_logger .debug ("Adding nic for Virtual Router in Public network " );
629629 // if source nat service is supported by the network, get the source
@@ -647,6 +647,11 @@ public LinkedHashMap<Network, List<? extends NicProfile>> configureDefaultNics(f
647647 defaultNic .setIsolationUri (IsolationType .Vlan .toUri (sourceNatIp .getVlanTag ()));
648648 }
649649
650+ //If guest nic has already been added we will have 2 devices in the list.
651+ if (hasGuestNic ) {
652+ defaultNic .setDeviceId (2 );
653+ }
654+
650655 final NetworkOffering publicOffering = _networkModel .getSystemAccountNetworkOfferings (NetworkOffering .SystemPublicNetwork ).get (0 );
651656 final List <? extends Network > publicNetworks = _networkMgr .setupNetwork (s_systemAccount , publicOffering , routerDeploymentDefinition .getPlan (), null , null , false );
652657 final String publicIp = defaultNic .getIPv4Address ();
@@ -657,14 +662,29 @@ public LinkedHashMap<Network, List<? extends NicProfile>> configureDefaultNics(f
657662 s_logger .info ("Use same MAC as previous RvR, the MAC is " + peerNic .getMacAddress ());
658663 defaultNic .setMacAddress (peerNic .getMacAddress ());
659664 }
660- networks .put (publicNetworks .get (0 ), new ArrayList <NicProfile >(Arrays .asList (defaultNic )));
665+ publicConfig .put (publicNetworks .get (0 ), new ArrayList <NicProfile >(Arrays .asList (defaultNic )));
661666 }
662667
663- // 3) Guest Network
668+ return publicConfig ;
669+ }
670+
671+ @ Override
672+ public LinkedHashMap <Network , List <? extends NicProfile >> configureDefaultNics (final RouterDeploymentDefinition routerDeploymentDefinition ) throws ConcurrentOperationException , InsufficientAddressCapacityException {
673+
674+ final LinkedHashMap <Network , List <? extends NicProfile >> networks = new LinkedHashMap <Network , List <? extends NicProfile >>(3 );
675+
676+ // 1) Guest Network
664677 final LinkedHashMap <Network , List <? extends NicProfile >> guestNic = configureGuestNic (routerDeploymentDefinition );
665- // The guest nic has to be added after the Control and Public nics.
666678 networks .putAll (guestNic );
667679
680+ // 2) Control network
681+ final LinkedHashMap <Network , List <? extends NicProfile >> controlNic = configureControlNic (routerDeploymentDefinition );
682+ networks .putAll (controlNic );
683+
684+ // 3) Public network
685+ final LinkedHashMap <Network , List <? extends NicProfile >> publicNic = configurePublicNic (routerDeploymentDefinition , networks .size () > 1 );
686+ networks .putAll (publicNic );
687+
668688 return networks ;
669689 }
670690
0 commit comments