@@ -1205,8 +1205,9 @@ Pair<NetworkGuru, NetworkVO> implementNetwork(final long networkId, final Deploy
12051205 * Creates a dummy NicTO object which is used by the respective hypervisors to setup network elements / resources
12061206 * - bridges(KVM), VLANs(Xen) and portgroups(VMWare) for L2 network
12071207 */
1208- private NicTO createNicTOFromNetworkAndOffering (NetworkVO networkVO , NetworkOfferingVO networkOfferingVO ) {
1208+ private NicTO createNicTOFromNetworkAndOffering (NetworkVO networkVO , NetworkOfferingVO networkOfferingVO , HostVO hostVO ) {
12091209 NicTO to = new NicTO ();
1210+ to .setName (_networkModel .getNetworkTag (hostVO .getHypervisorType (), networkVO ));
12101211 to .setBroadcastType (networkVO .getBroadcastDomainType ());
12111212 to .setType (networkVO .getTrafficType ());
12121213 to .setBroadcastUri (networkVO .getBroadcastUri ());
@@ -1216,7 +1217,7 @@ private NicTO createNicTOFromNetworkAndOffering(NetworkVO networkVO, NetworkOffe
12161217 return to ;
12171218 }
12181219
1219- private boolean isNtwConfiguredInCluster (HostVO hostVO , Map <Long , List <Long >> clusterToHostsMap ) {
1220+ private Pair < Boolean , NicTO > isNtwConfiguredInCluster (HostVO hostVO , Map <Long , List <Long >> clusterToHostsMap , NetworkVO networkVO , NetworkOfferingVO networkOfferingVO ) {
12201221 Long clusterId = hostVO .getClusterId ();
12211222 List <Long > hosts = clusterToHostsMap .get (clusterId );
12221223 if (hosts == null ) {
@@ -1225,26 +1226,28 @@ private boolean isNtwConfiguredInCluster(HostVO hostVO, Map<Long, List<Long>> cl
12251226 if (hostVO .getHypervisorType () == HypervisorType .KVM ) {
12261227 hosts .add (hostVO .getId ());
12271228 clusterToHostsMap .put (clusterId , hosts );
1228- return false ;
1229+ return new Pair <>( false , createNicTOFromNetworkAndOffering ( networkVO , networkOfferingVO , hostVO )) ;
12291230 }
12301231 if (hosts != null && !hosts .isEmpty ()) {
1231- return true ;
1232+ return new Pair <>( true , createNicTOFromNetworkAndOffering ( networkVO , networkOfferingVO , hostVO )) ;
12321233 }
12331234 hosts .add (hostVO .getId ());
12341235 clusterToHostsMap .put (clusterId , hosts );
1235- return false ;
1236+ return new Pair <>( false , createNicTOFromNetworkAndOffering ( networkVO , networkOfferingVO , hostVO )) ;
12361237 }
12371238
12381239 private void setupPersistentNetwork (NetworkVO network , NetworkOfferingVO offering , Long dcId ) throws AgentUnavailableException , OperationTimedoutException {
1239- NicTO to = createNicTOFromNetworkAndOffering (network , offering );
12401240 List <ClusterVO > clusterVOS = clusterDao .listClustersByDcId (dcId );
12411241 List <HostVO > hosts = resourceManager .listAllUpAndEnabledHostsInOneZoneByType (Host .Type .Routing , dcId );
12421242 Map <Long , List <Long >> clusterToHostsMap = new HashMap <>();
1243- SetupPersistentNetworkCommand cmd = new SetupPersistentNetworkCommand ( to );
1243+
12441244 for (HostVO host : hosts ) {
1245- if (isNtwConfiguredInCluster (host , clusterToHostsMap )) {
1245+ Pair <Boolean , NicTO > networkCfgStateAndDetails = isNtwConfiguredInCluster (host , clusterToHostsMap , network , offering );
1246+ if (networkCfgStateAndDetails .first ()) {
12461247 continue ;
12471248 }
1249+ NicTO to = networkCfgStateAndDetails .second ();
1250+ SetupPersistentNetworkCommand cmd = new SetupPersistentNetworkCommand (to );
12481251 final SetupPersistentNetworkAnswer answer = (SetupPersistentNetworkAnswer )_agentMgr .send (host .getId (), cmd );
12491252
12501253 if (answer == null ) {
@@ -3145,7 +3148,6 @@ public void reallyRun() {
31453148 s_logger .info ("NetworkGarbageCollector uses '" + netGcWait + "' seconds for GC interval." );
31463149
31473150 for (final Long networkId : networkIds ) {
3148-
31493151 if (!_networkModel .isNetworkReadyForGc (networkId )) {
31503152 continue ;
31513153 }
0 commit comments