@@ -1351,7 +1351,7 @@ protected List<DomainRouterVO> findOrDeployVirtualRouterInGuestNetwork(Network g
13511351 new Pair <Boolean , PublicIp >(publicNetwork , sourceNatIp ));
13521352 //don't start the router as we are holding the network lock that needs to be released at the end of router allocation
13531353 DomainRouterVO router = deployRouter (owner , dest , plan , params , isRedundant , vrProvider , offeringId ,
1354- null , networks , false );
1354+ null , networks , false , null );
13551355
13561356 _routerDao .addRouterToGuestNetwork (router , guestNetwork );
13571357 routers .add (router );
@@ -1369,7 +1369,7 @@ protected List<DomainRouterVO> findOrDeployVirtualRouterInGuestNetwork(Network g
13691369
13701370 protected DomainRouterVO deployRouter (Account owner , DeployDestination dest , DeploymentPlan plan , Map <Param , Object > params ,
13711371 boolean isRedundant , VirtualRouterProvider vrProvider , long svcOffId ,
1372- Long vpcId , List <Pair <NetworkVO , NicProfile >> networks , boolean startRouter ) throws ConcurrentOperationException ,
1372+ Long vpcId , List <Pair <NetworkVO , NicProfile >> networks , boolean startRouter , List < HypervisorType > supportedHypervisors ) throws ConcurrentOperationException ,
13731373 InsufficientAddressCapacityException , InsufficientServerCapacityException , InsufficientCapacityException ,
13741374 StorageUnavailableException , ResourceUnavailableException {
13751375
@@ -1382,12 +1382,12 @@ protected DomainRouterVO deployRouter(Account owner, DeployDestination dest, Dep
13821382
13831383 // Router is the network element, we don't know the hypervisor type yet.
13841384 // Try to allocate the domR twice using diff hypervisors, and when failed both times, throw the exception up
1385- List <HypervisorType > supportedHypervisors = getSupportedHypervisors (dest , plan );
1385+ List <HypervisorType > hypervisors = getHypervisors (dest , plan , supportedHypervisors );
13861386
13871387 int allocateRetry = 0 ;
13881388 int startRetry = 0 ;
13891389 DomainRouterVO router = null ;
1390- for (Iterator <HypervisorType > iter = supportedHypervisors .iterator ();iter .hasNext ();) {
1390+ for (Iterator <HypervisorType > iter = hypervisors .iterator (); iter .hasNext ();) {
13911391 HypervisorType hType = iter .next ();
13921392 try {
13931393 s_logger .debug ("Allocating the domR with the hypervisor type " + hType );
@@ -1446,33 +1446,44 @@ protected DomainRouterVO deployRouter(Account owner, DeployDestination dest, Dep
14461446 }
14471447
14481448
1449- protected List <HypervisorType > getSupportedHypervisors (DeployDestination dest , DeploymentPlan plan ) throws InsufficientServerCapacityException {
1450- List <HypervisorType > supportedHypervisors = new ArrayList <HypervisorType >();
1449+ protected List <HypervisorType > getHypervisors (DeployDestination dest , DeploymentPlan plan ,
1450+ List <HypervisorType > supportedHypervisors ) throws InsufficientServerCapacityException {
1451+ List <HypervisorType > hypervisors = new ArrayList <HypervisorType >();
14511452 HypervisorType defaults = _resourceMgr .getDefaultHypervisor (dest .getDataCenter ().getId ());
14521453 if (defaults != HypervisorType .None ) {
1453- supportedHypervisors .add (defaults );
1454+ hypervisors .add (defaults );
14541455 }
14551456
14561457 if (dest .getCluster () != null ) {
14571458 if (dest .getCluster ().getHypervisorType () == HypervisorType .Ovm ) {
1458- supportedHypervisors .add (getClusterToStartDomainRouterForOvm (dest .getCluster ().getPodId ()));
1459+ hypervisors .add (getClusterToStartDomainRouterForOvm (dest .getCluster ().getPodId ()));
14591460 } else {
1460- supportedHypervisors .add (dest .getCluster ().getHypervisorType ());
1461+ hypervisors .add (dest .getCluster ().getHypervisorType ());
14611462 }
14621463 } else {
1463- supportedHypervisors = _resourceMgr .getSupportedHypervisorTypes (dest .getDataCenter ().getId (), true ,
1464+ hypervisors = _resourceMgr .getSupportedHypervisorTypes (dest .getDataCenter ().getId (), true ,
14641465 plan .getPodId ());
14651466 }
14661467
1467- if (supportedHypervisors .isEmpty ()) {
1468+ //keep only elements defined in supported hypervisors
1469+ StringBuilder hTypesStr = new StringBuilder ();
1470+ if (supportedHypervisors != null && !supportedHypervisors .isEmpty ()) {
1471+ hypervisors .retainAll (supportedHypervisors );
1472+ for (HypervisorType hType : supportedHypervisors ) {
1473+ hTypesStr .append (hType ).append (" " );
1474+ }
1475+ }
1476+
1477+ if (hypervisors .isEmpty ()) {
1478+ String errMsg = (hTypesStr .capacity () > 0 ) ? "supporting hypervisors " + hTypesStr .toString () : "" ;
14681479 if (plan .getPodId () != null ) {
14691480 throw new InsufficientServerCapacityException ("Unable to create virtual router, " +
1470- "there are no clusters in the pod " , Pod .class , plan .getPodId ());
1481+ "there are no clusters in the pod " + errMsg , Pod .class , plan .getPodId ());
14711482 }
14721483 throw new InsufficientServerCapacityException ("Unable to create virtual router, " +
1473- "there are no clusters in the zone " , DataCenter .class , dest .getDataCenter ().getId ());
1484+ "there are no clusters in the zone " + errMsg , DataCenter .class , dest .getDataCenter ().getId ());
14741485 }
1475- return supportedHypervisors ;
1486+ return hypervisors ;
14761487 }
14771488
14781489 protected List <Pair <NetworkVO , NicProfile >> createRouterNetworks (Account owner , boolean isRedundant ,
0 commit comments