Applygin fix from commit ID aaeadc5c44e3fe16a1deea5348b085b08b5f4f4d

Sheng Yang changed 2 classes, ut only one was related to the bug CLOUDSTACK-7605.
I applied the changed on the routerslist, used during the deployment of the virtual routers.

Tested Advanced Zone against the simulator. 69 happy tests in place
This commit is contained in:
Wilder Rodrigues 2014-09-30 14:18:52 +02:00 committed by wilderrodrigues
parent c81b3380df
commit db86bdfb2c
3 changed files with 125 additions and 137 deletions

View File

@ -100,8 +100,7 @@ public class RouterDeploymentDefinition {
protected boolean isPublicNetwork; protected boolean isPublicNetwork;
protected PublicIp sourceNatIp; protected PublicIp sourceNatIp;
protected RouterDeploymentDefinition(final Network guestNetwork, final DeployDestination dest, protected RouterDeploymentDefinition(final Network guestNetwork, final DeployDestination dest, final Account owner, final Map<Param, Object> params, final boolean isRedundant) {
final Account owner, final Map<Param, Object> params, final boolean isRedundant) {
this.guestNetwork = guestNetwork; this.guestNetwork = guestNetwork;
this.dest = dest; this.dest = dest;
@ -111,98 +110,103 @@ public class RouterDeploymentDefinition {
} }
public Long getOfferingId() { public Long getOfferingId() {
return this.offeringId; return offeringId;
} }
public Vpc getVpc() { public Vpc getVpc() {
return null; return null;
} }
public Network getGuestNetwork() { public Network getGuestNetwork() {
return guestNetwork; return guestNetwork;
} }
public DeployDestination getDest() { public DeployDestination getDest() {
return dest; return dest;
} }
public Account getOwner() { public Account getOwner() {
return owner; return owner;
} }
public Map<Param, Object> getParams() { public Map<Param, Object> getParams() {
return params; return params;
} }
public boolean isRedundant() { public boolean isRedundant() {
return isRedundant; return isRedundant;
} }
public DeploymentPlan getPlan() { public DeploymentPlan getPlan() {
return plan; return plan;
} }
public boolean isVpcRouter() { public boolean isVpcRouter() {
return false; return false;
} }
public Pod getPod() { public Pod getPod() {
return dest.getPod(); return dest.getPod();
} }
public Long getPodId() { public Long getPodId() {
return dest.getPod() == null ? null : dest.getPod().getId(); return dest.getPod() == null ? null : dest.getPod().getId();
} }
public List<DomainRouterVO> getRouters() { public List<DomainRouterVO> getRouters() {
return routers; return routers;
} }
public VirtualRouterProvider getVirtualProvider() { public VirtualRouterProvider getVirtualProvider() {
return this.vrProvider; return vrProvider;
} }
public boolean isBasic() { public boolean isBasic() {
return this.dest.getDataCenter().getNetworkType() == NetworkType.Basic; return dest.getDataCenter().getNetworkType() == NetworkType.Basic;
} }
public boolean isPublicNetwork() { public boolean isPublicNetwork() {
return this.isPublicNetwork; return isPublicNetwork;
} }
public PublicIp getSourceNatIP() { public PublicIp getSourceNatIP() {
return this.sourceNatIp; return sourceNatIp;
} }
protected void generateDeploymentPlan() { protected void generateDeploymentPlan() {
final long dcId = this.dest.getDataCenter().getId(); final long dcId = dest.getDataCenter().getId();
Long podId = null; Long podId = null;
if (this.isBasic()) { if (isBasic()) {
if (this.dest.getPod() == null) { if (dest.getPod() == null) {
throw new CloudRuntimeException("Pod id is expected in deployment destination"); throw new CloudRuntimeException("Pod id is expected in deployment destination");
} }
podId = this.dest.getPod().getId(); podId = dest.getPod().getId();
} }
this.plan = new DataCenterDeployment(dcId, podId, null, null, null, null); plan = new DataCenterDeployment(dcId, podId, null, null, null, null);
} }
public List<DomainRouterVO> deployVirtualRouter() public List<DomainRouterVO> deployVirtualRouter() throws InsufficientCapacityException, ConcurrentOperationException, ResourceUnavailableException {
throws InsufficientCapacityException,
ConcurrentOperationException, ResourceUnavailableException {
this.findOrDeployVirtualRouter(); findOrDeployVirtualRouter();
return nwHelper.startRouters(this); return nwHelper.startRouters(this);
} }
@DB @DB
protected void findOrDeployVirtualRouter() protected void findOrDeployVirtualRouter() throws ConcurrentOperationException, InsufficientCapacityException, ResourceUnavailableException {
throws ConcurrentOperationException, InsufficientCapacityException, ResourceUnavailableException {
try { try {
this.lock(); lock();
this.checkPreconditions(); checkPreconditions();
// dest has pod=null, for Basic Zone findOrDeployVRs for all Pods // dest has pod=null, for Basic Zone findOrDeployVRs for all Pods
final List<DeployDestination> destinations = findDestinations(); final List<DeployDestination> destinations = findDestinations();
for (final DeployDestination destination : destinations) { for (final DeployDestination destination : destinations) {
this.dest = destination; dest = destination;
this.planDeploymentRouters(); generateDeploymentPlan();
this.generateDeploymentPlan(); executeDeployment();
this.executeDeployment();
} }
} finally { } finally {
this.unlock(); unlock();
} }
} }
@ -211,30 +215,25 @@ public class RouterDeploymentDefinition {
if (lock == null) { if (lock == null) {
throw new ConcurrentOperationException("Unable to lock network " + guestNetwork.getId()); throw new ConcurrentOperationException("Unable to lock network " + guestNetwork.getId());
} }
this.tableLockId = lock.getId(); tableLockId = lock.getId();
} }
protected void unlock() { protected void unlock() {
if (this.tableLockId != null) { if (tableLockId != null) {
networkDao.releaseFromLockTable(this.tableLockId); networkDao.releaseFromLockTable(tableLockId);
if (logger.isDebugEnabled()) { if (logger.isDebugEnabled()) {
logger.debug("Lock is released for network id " + this.tableLockId logger.debug("Lock is released for network id " + tableLockId + " as a part of router startup in " + dest);
+ " as a part of router startup in " + dest);
} }
} }
} }
protected void checkPreconditions() throws ResourceUnavailableException { protected void checkPreconditions() throws ResourceUnavailableException {
if (guestNetwork.getState() != Network.State.Implemented && if (guestNetwork.getState() != Network.State.Implemented && guestNetwork.getState() != Network.State.Setup && guestNetwork.getState() != Network.State.Implementing) {
guestNetwork.getState() != Network.State.Setup && throw new ResourceUnavailableException("Network is not yet fully implemented: " + guestNetwork, Network.class, guestNetwork.getId());
guestNetwork.getState() != Network.State.Implementing) {
throw new ResourceUnavailableException("Network is not yet fully implemented: " + guestNetwork,
Network.class, this.guestNetwork.getId());
} }
if (guestNetwork.getTrafficType() != TrafficType.Guest) { if (guestNetwork.getTrafficType() != TrafficType.Guest) {
throw new ResourceUnavailableException("Network is not type Guest as expected: " + guestNetwork, throw new ResourceUnavailableException("Network is not type Guest as expected: " + guestNetwork, Network.class, guestNetwork.getId());
Network.class, this.guestNetwork.getId());
} }
} }
@ -242,8 +241,9 @@ public class RouterDeploymentDefinition {
// dest has pod=null, for Basic Zone findOrDeployVRs for all Pods // dest has pod=null, for Basic Zone findOrDeployVRs for all Pods
final List<DeployDestination> destinations = new ArrayList<DeployDestination>(); final List<DeployDestination> destinations = new ArrayList<DeployDestination>();
// for basic zone, if 'dest' has pod set to null then this is network restart scenario otherwise it is a vm deployment scenario // for basic zone, if 'dest' has pod set to null then this is network
if (this.isBasic() && dest.getPod() == null) { // restart scenario otherwise it is a vm deployment scenario
if (isBasic() && dest.getPod() == null) {
// Find all pods in the data center with running or starting user vms // Find all pods in the data center with running or starting user vms
final long dcId = dest.getDataCenter().getId(); final long dcId = dest.getDataCenter().getId();
final List<HostPodVO> pods = listByDataCenterIdVMTypeAndStates(dcId, VirtualMachine.Type.User, VirtualMachine.State.Starting, VirtualMachine.State.Running); final List<HostPodVO> pods = listByDataCenterIdVMTypeAndStates(dcId, VirtualMachine.Type.User, VirtualMachine.State.Starting, VirtualMachine.State.Running);
@ -261,7 +261,7 @@ public class RouterDeploymentDefinition {
// Add virtualRouters to the routers, this avoids the situation when // Add virtualRouters to the routers, this avoids the situation when
// all routers are skipped and VirtualRouterElement throws exception // all routers are skipped and VirtualRouterElement throws exception
this.routers.addAll(virtualRouters); routers.addAll(virtualRouters);
// If List size is one, we already have a starting or running VR, skip deployment // If List size is one, we already have a starting or running VR, skip deployment
if (virtualRouters.size() == 1) { if (virtualRouters.size() == 1) {
@ -280,43 +280,42 @@ public class RouterDeploymentDefinition {
protected int getNumberOfRoutersToDeploy() { protected int getNumberOfRoutersToDeploy() {
// TODO Are we sure this makes sense? Somebody said 5 was too many? // TODO Are we sure this makes sense? Somebody said 5 was too many?
if (this.routers.size() >= 5) { if (routers.size() >= 5) {
logger.error("Too many redundant routers!"); logger.error("Too many redundant routers!");
} }
// If old network is redundant but new is single router, then routers.size() = 2 but routerCount = 1 // If old network is redundant but new is single router, then
// routers.size() = 2 but routerCount = 1
int routersExpected = 1; int routersExpected = 1;
if (this.isRedundant) { if (isRedundant) {
routersExpected = 2; routersExpected = 2;
} }
return routersExpected < this.routers.size() ? return routersExpected < routers.size() ? 0 : routersExpected - routers.size();
0 : routersExpected - this.routers.size();
} }
protected void setupAccountOwner() { protected void setupAccountOwner() {
if (networkModel.isNetworkSystem(guestNetwork) || guestNetwork.getGuestType() == Network.GuestType.Shared) { if (networkModel.isNetworkSystem(guestNetwork) || guestNetwork.getGuestType() == Network.GuestType.Shared) {
this.owner = accountMgr.getAccount(Account.ACCOUNT_ID_SYSTEM); owner = accountMgr.getAccount(Account.ACCOUNT_ID_SYSTEM);
} }
} }
/** /**
* It executes last pending tasks to prepare the deployment and checks the deployment * It executes last pending tasks to prepare the deployment and checks the
* can proceed. If it can't it return false * deployment can proceed. If it can't it return false
* *
* @return if the deployment can proceed * @return if the deployment can proceed
*/ */
protected boolean prepareDeployment() { protected boolean prepareDeployment() {
this.setupAccountOwner(); setupAccountOwner();
// Check if public network has to be set on VR // Check if public network has to be set on VR
this.isPublicNetwork = networkModel.isProviderSupportServiceInNetwork( isPublicNetwork = networkModel.isProviderSupportServiceInNetwork(guestNetwork.getId(), Service.SourceNat, Provider.VirtualRouter);
guestNetwork.getId(), Service.SourceNat, Provider.VirtualRouter);
boolean canProceed = true; boolean canProceed = true;
if (this.isRedundant && !this.isPublicNetwork) { if (isRedundant && !isPublicNetwork) {
// TODO Shouldn't be this throw an exception instead of log error and empty list of routers // TODO Shouldn't be this throw an exception instead of log error and empty list of routers
logger.error("Didn't support redundant virtual router without public network!"); logger.error("Didn't support redundant virtual router without public network!");
this.routers = new ArrayList<>(); routers = new ArrayList<DomainRouterVO>();
canProceed = false; canProceed = false;
} }
@ -324,39 +323,39 @@ public class RouterDeploymentDefinition {
} }
/** /**
* Executes preparation and deployment of the routers. After this method ends, {@link this#routers} * Executes preparation and deployment of the routers. After this method
* should have all of the deployed routers ready for start, and no more. * ends, {@link this#routers} should have all of the deployed routers ready
* for start, and no more.
* *
* @throws ConcurrentOperationException * @throws ConcurrentOperationException
* @throws InsufficientCapacityException * @throws InsufficientCapacityException
* @throws ResourceUnavailableException * @throws ResourceUnavailableException
*/ */
protected void executeDeployment() protected void executeDeployment() throws ConcurrentOperationException, InsufficientCapacityException, ResourceUnavailableException {
throws ConcurrentOperationException, InsufficientCapacityException, ResourceUnavailableException { // Check current redundant routers, if possible(all routers are
// stopped), reset the priority
planDeploymentRouters();
setupPriorityOfRedundantRouter();
//Check current redundant routers, if possible(all routers are stopped), reset the priority if (getNumberOfRoutersToDeploy() > 0 && prepareDeployment()) {
this.setupPriorityOfRedundantRouter(); findVirtualProvider();
findOfferingId();
if (this.getNumberOfRoutersToDeploy() > 0 && this.prepareDeployment()) { findSourceNatIP();
this.findVirtualProvider(); deployAllVirtualRouters();
this.findOfferingId();
this.findSourceNatIP();
this.deployAllVirtualRouters();
} }
} }
protected void findSourceNatIP() throws InsufficientAddressCapacityException, ConcurrentOperationException { protected void findSourceNatIP() throws InsufficientAddressCapacityException, ConcurrentOperationException {
this.sourceNatIp = null; sourceNatIp = null;
if (this.isPublicNetwork) { if (isPublicNetwork) {
this.sourceNatIp = this.ipAddrMgr.assignSourceNatIpAddressToGuestNetwork( sourceNatIp = ipAddrMgr.assignSourceNatIpAddressToGuestNetwork(owner, guestNetwork);
this.owner,this.guestNetwork);
} }
} }
protected void findOfferingId() { protected void findOfferingId() {
Long networkOfferingId = networkOfferingDao.findById(guestNetwork.getNetworkOfferingId()).getServiceOfferingId(); Long networkOfferingId = networkOfferingDao.findById(guestNetwork.getNetworkOfferingId()).getServiceOfferingId();
if (networkOfferingId != null) { if (networkOfferingId != null) {
this.offeringId = networkOfferingId; offeringId = networkOfferingId;
} }
} }
@ -364,42 +363,36 @@ public class RouterDeploymentDefinition {
// Check if providers are supported in the physical networks // Check if providers are supported in the physical networks
final Type type = Type.VirtualRouter; final Type type = Type.VirtualRouter;
final Long physicalNetworkId = networkModel.getPhysicalNetworkId(guestNetwork); final Long physicalNetworkId = networkModel.getPhysicalNetworkId(guestNetwork);
final PhysicalNetworkServiceProvider provider = final PhysicalNetworkServiceProvider provider = physicalProviderDao.findByServiceProvider(physicalNetworkId, type.toString());
physicalProviderDao.findByServiceProvider(physicalNetworkId, type.toString());
if (provider == null) { if (provider == null) {
throw new CloudRuntimeException( throw new CloudRuntimeException(String.format("Cannot find service provider %s in physical network %s", type.toString(), physicalNetworkId));
String.format("Cannot find service provider %s in physical network %s",
type.toString(), physicalNetworkId));
} }
this.vrProvider = vrProviderDao.findByNspIdAndType(provider.getId(), type); vrProvider = vrProviderDao.findByNspIdAndType(provider.getId(), type);
if (this.vrProvider == null) { if (vrProvider == null) {
throw new CloudRuntimeException( throw new CloudRuntimeException(String.format("Cannot find virtual router provider %s as service provider %s", type.toString(), provider.getId()));
String.format("Cannot find virtual router provider %s as service provider %s",
type.toString(), provider.getId()));
} }
} }
protected void deployAllVirtualRouters() protected void deployAllVirtualRouters() throws ConcurrentOperationException, InsufficientCapacityException, ResourceUnavailableException {
throws ConcurrentOperationException, InsufficientCapacityException, ResourceUnavailableException { int routersToDeploy = getNumberOfRoutersToDeploy();
for (int i = 0; i < routersToDeploy; i++) {
int routersToDeploy = this.getNumberOfRoutersToDeploy(); // Don't start the router as we are holding the network lock that
for(int i = 0; i < routersToDeploy; i++) { // needs to be released at the end of router allocation
// Don't start the router as we are holding the network lock that needs to be released at the end of router allocation DomainRouterVO router = nwHelper.deployRouter(this, false);
DomainRouterVO router = this.nwHelper.deployRouter(this, false);
if (router != null) { if (router != null) {
this.routerDao.addRouterToGuestNetwork(router, this.guestNetwork); routerDao.addRouterToGuestNetwork(router, guestNetwork);
this.routers.add(router); //Fix according to changes by Sheng Yang in commit ID cb4513379996b262ae378daf00c6388c6b7313cf
routers.add(router);
} }
} }
} }
/** /**
* Lists all pods given a Data Center Id, a {@link VirtualMachine.Type} and a list of * Lists all pods given a Data Center Id, a {@link VirtualMachine.Type} and
* {@link VirtualMachine.State} * a list of {@link VirtualMachine.State}
*
* @param id * @param id
* @param type * @param type
* @param states * @param states
@ -419,28 +412,25 @@ public class RouterDeploymentDefinition {
final SearchCriteria<HostPodVO> sc = podIdSearch.create(); final SearchCriteria<HostPodVO> sc = podIdSearch.create();
sc.setParameters("dc", id); sc.setParameters("dc", id);
sc.setJoinParameters("vmInstanceSearch", "type", type); sc.setJoinParameters("vmInstanceSearch", "type", type);
sc.setJoinParameters("vmInstanceSearch", "states", (Object[])states); sc.setJoinParameters("vmInstanceSearch", "states", (Object[]) states);
return podDao.search(sc, null); return podDao.search(sc, null);
} }
protected void planDeploymentRouters() { protected void planDeploymentRouters() {
if (this.isBasic()) { if (isBasic()) {
this.routers = routerDao.listByNetworkAndPodAndRole(this.guestNetwork.getId(), routers.addAll(routerDao.listByNetworkAndPodAndRole(guestNetwork.getId(), getPodId(), Role.VIRTUAL_ROUTER));
this.getPodId(), Role.VIRTUAL_ROUTER);
} else { } else {
this.routers = routerDao.listByNetworkAndRole(this.guestNetwork.getId(), routers.addAll(routerDao.listByNetworkAndRole(guestNetwork.getId(), Role.VIRTUAL_ROUTER));
Role.VIRTUAL_ROUTER);
} }
} }
/** /**
* Routers need reset if at least one of the routers is not redundant or stopped. * Routers need reset if at least one of the routers is not redundant or
* * stopped.
* @return
*/ */
protected boolean routersNeedReset() { protected boolean routersNeedReset() {
boolean needReset = true; boolean needReset = true;
for (final DomainRouterVO router : this.routers) { for (final DomainRouterVO router : routers) {
if (!router.getIsRedundantRouter() || router.getState() != VirtualMachine.State.Stopped) { if (!router.getIsRedundantRouter() || router.getState() != VirtualMachine.State.Stopped) {
needReset = false; needReset = false;
break; break;
@ -451,18 +441,17 @@ public class RouterDeploymentDefinition {
} }
/** /**
* Only for redundant deployment and if any routers needed reset, we shall reset all * Only for redundant deployment and if any routers needed reset, we shall
* routers priorities * reset all routers priorities
*/ */
protected void setupPriorityOfRedundantRouter() { protected void setupPriorityOfRedundantRouter() {
if (this.isRedundant && this.routersNeedReset()) { if (isRedundant && routersNeedReset()) {
for (final DomainRouterVO router : this.routers) { for (final DomainRouterVO router : routers) {
// getUpdatedPriority() would update the value later // getUpdatedPriority() would update the value later
router.setPriority(0); router.setPriority(0);
router.setIsPriorityBumpUp(false); router.setIsPriorityBumpUp(false);
routerDao.update(router.getId(), router); routerDao.update(router.getId(), router);
}
} }
}
} }
} }

View File

@ -53,9 +53,7 @@ public class VpcRouterDeploymentDefinition extends RouterDeploymentDefinition {
protected Vpc vpc; protected Vpc vpc;
protected VpcRouterDeploymentDefinition(final Vpc vpc, final DeployDestination dest, final Account owner, final Map<Param, Object> params, final boolean isRedundant) {
protected VpcRouterDeploymentDefinition(final Vpc vpc, final DeployDestination dest, final Account owner,
final Map<Param, Object> params, final boolean isRedundant) {
super(null, dest, owner, params, isRedundant); super(null, dest, owner, params, isRedundant);
@ -64,7 +62,7 @@ public class VpcRouterDeploymentDefinition extends RouterDeploymentDefinition {
@Override @Override
public Vpc getVpc() { public Vpc getVpc() {
return this.vpc; return vpc;
} }
@Override @Override
@ -83,16 +81,15 @@ public class VpcRouterDeploymentDefinition extends RouterDeploymentDefinition {
if (vpcLock == null) { if (vpcLock == null) {
throw new ConcurrentOperationException("Unable to lock vpc " + vpc.getId()); throw new ConcurrentOperationException("Unable to lock vpc " + vpc.getId());
} }
this.tableLockId = vpcLock.getId(); tableLockId = vpcLock.getId();
} }
@Override @Override
protected void unlock() { protected void unlock() {
if (this.tableLockId != null) { if (tableLockId != null) {
vpcDao.releaseFromLockTable(this.tableLockId); vpcDao.releaseFromLockTable(tableLockId);
if (logger.isDebugEnabled()) { if (logger.isDebugEnabled()) {
logger.debug("Lock is released for vpc id " + this.tableLockId logger.debug("Lock is released for vpc id " + tableLockId + " as a part of router startup in " + dest);
+ " as a part of router startup in " + dest);
} }
} }
} }
@ -105,14 +102,15 @@ public class VpcRouterDeploymentDefinition extends RouterDeploymentDefinition {
@Override @Override
protected List<DeployDestination> findDestinations() { protected List<DeployDestination> findDestinations() {
final List<DeployDestination> destinations = new ArrayList<>(); final List<DeployDestination> destinations = new ArrayList<>();
destinations.add(this.dest); destinations.add(dest);
return destinations; return destinations;
} }
@Override @Override
protected int getNumberOfRoutersToDeploy() { protected int getNumberOfRoutersToDeploy() {
// TODO Should we make our changes here in order to enable Redundant Router for VPC? // TODO Should we make our changes here in order to enable Redundant
return this.routers.isEmpty() ? 1 : 0; // Router for VPC?
return routers.isEmpty() ? 1 : 0;
} }
/** /**
@ -128,12 +126,13 @@ public class VpcRouterDeploymentDefinition extends RouterDeploymentDefinition {
@Override @Override
protected void setupPriorityOfRedundantRouter() { protected void setupPriorityOfRedundantRouter() {
// Nothing to do for now // Nothing to do for now
// TODO Shouldn't we add this behavior once Redundant Router works for Vpc too // TODO Shouldn't we add this behavior once Redundant Router works for
// Vpc too
} }
@Override @Override
protected void findSourceNatIP() throws InsufficientAddressCapacityException, ConcurrentOperationException { protected void findSourceNatIP() throws InsufficientAddressCapacityException, ConcurrentOperationException {
this.sourceNatIp = vpcMgr.assignSourceNatIpAddressToVpc(this.owner, vpc); sourceNatIp = vpcMgr.assignSourceNatIpAddressToVpc(owner, vpc);
} }
@Override @Override
@ -145,8 +144,8 @@ public class VpcRouterDeploymentDefinition extends RouterDeploymentDefinition {
if (provider == null) { if (provider == null) {
throw new CloudRuntimeException("Cannot find service provider " + Type.VPCVirtualRouter.toString() + " in physical network " + pNtwk.getId()); throw new CloudRuntimeException("Cannot find service provider " + Type.VPCVirtualRouter.toString() + " in physical network " + pNtwk.getId());
} }
this.vrProvider = vrProviderDao.findByNspIdAndType(provider.getId(), Type.VPCVirtualRouter); vrProvider = vrProviderDao.findByNspIdAndType(provider.getId(), Type.VPCVirtualRouter);
if (this.vrProvider != null) { if (vrProvider != null) {
break; break;
} }
} }
@ -156,28 +155,28 @@ public class VpcRouterDeploymentDefinition extends RouterDeploymentDefinition {
protected void findOfferingId() { protected void findOfferingId() {
Long vpcOfferingId = vpcOffDao.findById(vpc.getVpcOfferingId()).getServiceOfferingId(); Long vpcOfferingId = vpcOffDao.findById(vpc.getVpcOfferingId()).getServiceOfferingId();
if (vpcOfferingId != null) { if (vpcOfferingId != null) {
this.offeringId = vpcOfferingId; offeringId = vpcOfferingId;
} }
} }
@Override @Override
protected void deployAllVirtualRouters() protected void deployAllVirtualRouters() throws ConcurrentOperationException, InsufficientCapacityException,
throws ConcurrentOperationException, InsufficientCapacityException, ResourceUnavailableException { ResourceUnavailableException {
DomainRouterVO router = this.nwHelper.deployRouter(this, true); DomainRouterVO router = nwHelper.deployRouter(this, true);
if (router != null) { if (router != null) {
this.routers.add(router); routers.add(router);
} }
} }
@Override @Override
protected void planDeploymentRouters() { protected void planDeploymentRouters() {
this.routers = this.routerDao.listByVpcId(this.vpc.getId()); routers = routerDao.listByVpcId(vpc.getId());
} }
@Override @Override
protected void generateDeploymentPlan() { protected void generateDeploymentPlan() {
this.plan = new DataCenterDeployment(this.dest.getDataCenter().getId()); plan = new DataCenterDeployment(dest.getDataCenter().getId());
} }
} }

View File

@ -525,9 +525,9 @@ public class RouterDeploymentDefinitionTest extends RouterDeploymentDefinitionTe
verify(deploymentUT, times(1)).lock(); verify(deploymentUT, times(1)).lock();
verify(deploymentUT, times(1)).checkPreconditions(); verify(deploymentUT, times(1)).checkPreconditions();
verify(deploymentUT, times(1)).findDestinations(); verify(deploymentUT, times(1)).findDestinations();
verify(deploymentUT, times(2)).planDeploymentRouters();
verify(deploymentUT, times(2)).generateDeploymentPlan(); verify(deploymentUT, times(2)).generateDeploymentPlan();
verify(deploymentUT, times(2)).executeDeployment(); verify(deploymentUT, times(2)).executeDeployment();
//verify(deploymentUT, times(2)).planDeploymentRouters();
verify(deploymentUT, times(1)).unlock(); verify(deploymentUT, times(1)).unlock();
} }