16
16
// under the License.
17
17
package org .cloud .network .router .deployment ;
18
18
19
+ import java .util .ArrayList ;
20
+ import java .util .List ;
21
+ import java .util .Map ;
22
+
23
+ import org .apache .log4j .Logger ;
24
+
25
+ import org .apache .cloudstack .engine .orchestration .service .NetworkOrchestrationService ;
26
+
19
27
import com .cloud .dc .DataCenter .NetworkType ;
20
28
import com .cloud .dc .HostPodVO ;
21
29
import com .cloud .dc .Pod ;
60
68
import com .cloud .vm .dao .DomainRouterDao ;
61
69
import com .cloud .vm .dao .NicDao ;
62
70
import com .cloud .vm .dao .VMInstanceDao ;
63
- import org .apache .cloudstack .engine .orchestration .service .NetworkOrchestrationService ;
64
- import org .apache .log4j .Logger ;
65
-
66
- import java .util .ArrayList ;
67
- import java .util .List ;
68
- import java .util .Map ;
69
71
70
72
public class RouterDeploymentDefinition {
71
73
private static final Logger logger = Logger .getLogger (RouterDeploymentDefinition .class );
@@ -108,7 +110,7 @@ protected RouterDeploymentDefinition(final Network guestNetwork, final DeployDes
108
110
}
109
111
110
112
public Long getServiceOfferingId () {
111
- return this . serviceOfferingId ;
113
+ return serviceOfferingId ;
112
114
}
113
115
114
116
public Vpc getVpc () {
@@ -132,7 +134,7 @@ public Map<Param, Object> getParams() {
132
134
}
133
135
134
136
public boolean isRedundant () {
135
- return this . guestNetwork .isRedundant ();
137
+ return guestNetwork .isRedundant ();
136
138
}
137
139
138
140
public DeploymentPlan getPlan () {
@@ -200,6 +202,7 @@ protected void findOrDeployVirtualRouter() throws ConcurrentOperationException,
200
202
201
203
for (final DeployDestination destination : destinations ) {
202
204
dest = destination ;
205
+ planDeploymentRouters ();
203
206
generateDeploymentPlan ();
204
207
executeDeployment ();
205
208
}
@@ -285,7 +288,7 @@ protected int getNumberOfRoutersToDeploy() {
285
288
// If old network is redundant but new is single router, then
286
289
// routers.size() = 2 but routerCount = 1
287
290
int routersExpected = 1 ;
288
- if (this . isRedundant ()) {
291
+ if (isRedundant ()) {
289
292
routersExpected = 2 ;
290
293
}
291
294
return routersExpected < routers .size () ? 0 : routersExpected - routers .size ();
@@ -310,7 +313,7 @@ protected boolean prepareDeployment() {
310
313
isPublicNetwork = networkModel .isProviderSupportServiceInNetwork (guestNetwork .getId (), Service .SourceNat , Provider .VirtualRouter );
311
314
312
315
boolean canProceed = true ;
313
- if (this . isRedundant () && !this . isPublicNetwork ) {
316
+ if (isRedundant () && !isPublicNetwork ) {
314
317
// TODO Shouldn't be this throw an exception instead of log error and empty list of routers
315
318
logger .error ("Didn't support redundant virtual router without public network!" );
316
319
routers = new ArrayList <DomainRouterVO >();
@@ -333,13 +336,13 @@ protected void executeDeployment()
333
336
throws ConcurrentOperationException , InsufficientCapacityException , ResourceUnavailableException {
334
337
335
338
//Check current redundant routers, if possible(all routers are stopped), reset the priority
336
- this . setupPriorityOfRedundantRouter ();
339
+ setupPriorityOfRedundantRouter ();
337
340
338
- if (this . getNumberOfRoutersToDeploy () > 0 && this . prepareDeployment ()) {
339
- this . findVirtualProvider ();
340
- this . findServiceOfferingId ();
341
- this . findSourceNatIP ();
342
- this . deployAllVirtualRouters ();
341
+ if (getNumberOfRoutersToDeploy () > 0 && prepareDeployment ()) {
342
+ findVirtualProvider ();
343
+ findServiceOfferingId ();
344
+ findSourceNatIP ();
345
+ deployAllVirtualRouters ();
343
346
}
344
347
}
345
348
@@ -353,7 +356,7 @@ protected void findSourceNatIP() throws InsufficientAddressCapacityException, Co
353
356
protected void findServiceOfferingId () {
354
357
Long networkOfferingId = networkOfferingDao .findById (guestNetwork .getNetworkOfferingId ()).getServiceOfferingId ();
355
358
if (networkOfferingId != null ) {
356
- this . serviceOfferingId = networkOfferingId ;
359
+ serviceOfferingId = networkOfferingId ;
357
360
}
358
361
}
359
362
@@ -443,8 +446,8 @@ protected boolean routersNeedReset() {
443
446
* reset all routers priorities
444
447
*/
445
448
protected void setupPriorityOfRedundantRouter () {
446
- if (this . isRedundant () && this . routersNeedReset ()) {
447
- for (final DomainRouterVO router : this . routers ) {
449
+ if (isRedundant () && routersNeedReset ()) {
450
+ for (final DomainRouterVO router : routers ) {
448
451
// getUpdatedPriority() would update the value later
449
452
router .setPriority (0 );
450
453
router .setIsPriorityBumpUp (false );
0 commit comments