mirror of https://github.com/apache/cloudstack.git
Fixing the priority in the setup guest network command
Fixing the deploy router in VPC method formatting some classes
This commit is contained in:
parent
84bf46dc2f
commit
381c0e1c69
|
|
@ -887,7 +887,7 @@ public class CommandSetupHelper {
|
|||
}
|
||||
}
|
||||
|
||||
public SetupGuestNetworkCommand createSetupGuestNetworkCommand(final VirtualRouter router, final boolean add, final NicProfile guestNic) {
|
||||
public SetupGuestNetworkCommand createSetupGuestNetworkCommand(final DomainRouterVO router, final boolean add, final NicProfile guestNic) {
|
||||
final Network network = _networkModel.getNetwork(guestNic.getNetworkId());
|
||||
|
||||
String defaultDns1 = null;
|
||||
|
|
@ -908,8 +908,9 @@ public class CommandSetupHelper {
|
|||
final String dhcpRange = getGuestDhcpRange(guestNic, network, _entityMgr.findById(DataCenter.class, network.getDataCenterId()));
|
||||
|
||||
final NicProfile nicProfile = _networkModel.getNicProfile(router, nic.getNetworkId(), null);
|
||||
final int priority = _networkHelper.getRealPriority(router);
|
||||
|
||||
final SetupGuestNetworkCommand setupCmd = new SetupGuestNetworkCommand(dhcpRange, networkDomain, router.getIsRedundantRouter(), null, defaultDns1, defaultDns2, add, _itMgr.toNicTO(nicProfile,
|
||||
final SetupGuestNetworkCommand setupCmd = new SetupGuestNetworkCommand(dhcpRange, networkDomain, router.getIsRedundantRouter(), priority, defaultDns1, defaultDns2, add, _itMgr.toNicTO(nicProfile,
|
||||
router.getHypervisorType()));
|
||||
|
||||
final String brd = NetUtils.long2Ip(NetUtils.ip2Long(guestNic.getIp4Address()) | ~NetUtils.ip2Long(guestNic.getNetmask()));
|
||||
|
|
|
|||
|
|
@ -199,17 +199,17 @@ public class NetworkHelperImpl implements NetworkHelper {
|
|||
if (connectedRouters.isEmpty() || disconnectedRouters.isEmpty()) {
|
||||
return;
|
||||
}
|
||||
if (connectedRouters.size() != 1 || disconnectedRouters.size() != 1) {
|
||||
s_logger.warn("How many redundant routers do we have?? ");
|
||||
return;
|
||||
|
||||
for (final VirtualRouter virtualRouter : connectedRouters) {
|
||||
if (!virtualRouter.getIsRedundantRouter()) {
|
||||
throw new ResourceUnavailableException("Who is calling this with non-redundant router or non-domain router?", DataCenter.class, virtualRouter.getDataCenterId());
|
||||
}
|
||||
}
|
||||
if (!connectedRouters.get(0).getIsRedundantRouter()) {
|
||||
throw new ResourceUnavailableException("Who is calling this with non-redundant router or non-domain router?", DataCenter.class, connectedRouters.get(0)
|
||||
.getDataCenterId());
|
||||
}
|
||||
if (!disconnectedRouters.get(0).getIsRedundantRouter()) {
|
||||
throw new ResourceUnavailableException("Who is calling this with non-redundant router or non-domain router?", DataCenter.class, disconnectedRouters.get(0)
|
||||
.getDataCenterId());
|
||||
|
||||
for (final VirtualRouter virtualRouter : disconnectedRouters) {
|
||||
if (!virtualRouter.getIsRedundantRouter()) {
|
||||
throw new ResourceUnavailableException("Who is calling this with non-redundant router or non-domain router?", DataCenter.class, virtualRouter.getDataCenterId());
|
||||
}
|
||||
}
|
||||
|
||||
final DomainRouterVO connectedRouter = (DomainRouterVO) connectedRouters.get(0);
|
||||
|
|
|
|||
|
|
@ -209,7 +209,7 @@ public class VpcVirtualNetworkApplianceManagerImpl extends VirtualNetworkApplian
|
|||
|
||||
boolean result = true;
|
||||
if (router.getState() == State.Running) {
|
||||
final SetupGuestNetworkCommand setupCmd = _commandSetupHelper.createSetupGuestNetworkCommand(router, add, guestNic);
|
||||
final SetupGuestNetworkCommand setupCmd = _commandSetupHelper.createSetupGuestNetworkCommand((DomainRouterVO) router, add, guestNic);
|
||||
|
||||
final Commands cmds = new Commands(Command.OnError.Stop);
|
||||
cmds.addCommand("setupguestnetwork", setupCmd);
|
||||
|
|
|
|||
|
|
@ -133,7 +133,7 @@ public class BasicNetworkTopology implements NetworkTopology {
|
|||
throw new ResourceUnavailableException("Unable to assign ip addresses, domR is not in right state " + router.getState(), DataCenter.class, network.getDataCenterId());
|
||||
}
|
||||
|
||||
DhcpSubNetRules subNetRules = new DhcpSubNetRules(network, nic, profile);
|
||||
final DhcpSubNetRules subNetRules = new DhcpSubNetRules(network, nic, profile);
|
||||
|
||||
return subNetRules.accept(_basicVisitor, router);
|
||||
}
|
||||
|
|
@ -158,7 +158,7 @@ public class BasicNetworkTopology implements NetworkTopology {
|
|||
|
||||
final boolean failWhenDisconnect = false;
|
||||
|
||||
DhcpEntryRules dhcpRules = new DhcpEntryRules(network, nic, profile, dest);
|
||||
final DhcpEntryRules dhcpRules = new DhcpEntryRules(network, nic, profile, dest);
|
||||
|
||||
return applyRules(network, routers, typeString, isPodLevelException, podId, failWhenDisconnect, new RuleApplierWrapper<RuleApplier>(dhcpRules));
|
||||
}
|
||||
|
|
@ -180,7 +180,7 @@ public class BasicNetworkTopology implements NetworkTopology {
|
|||
|
||||
final boolean failWhenDisconnect = false;
|
||||
|
||||
UserdataPwdRules pwdRules = new UserdataPwdRules(network, nic, profile, dest);
|
||||
final UserdataPwdRules pwdRules = new UserdataPwdRules(network, nic, profile, dest);
|
||||
|
||||
return applyRules(network, routers, typeString, isPodLevelException, podId, failWhenDisconnect, new RuleApplierWrapper<RuleApplier>(pwdRules));
|
||||
}
|
||||
|
|
@ -201,7 +201,7 @@ public class BasicNetworkTopology implements NetworkTopology {
|
|||
final boolean failWhenDisconnect = false;
|
||||
final Long podId = null;
|
||||
|
||||
LoadBalancingRules loadBalancingRules = new LoadBalancingRules(network, rules);
|
||||
final LoadBalancingRules loadBalancingRules = new LoadBalancingRules(network, rules);
|
||||
|
||||
return applyRules(network, routers, typeString, isPodLevelException, podId, failWhenDisconnect, new RuleApplierWrapper<RuleApplier>(loadBalancingRules));
|
||||
}
|
||||
|
|
@ -221,7 +221,7 @@ public class BasicNetworkTopology implements NetworkTopology {
|
|||
final boolean failWhenDisconnect = false;
|
||||
final Long podId = null;
|
||||
|
||||
FirewallRules firewallRules = new FirewallRules(network, rules);
|
||||
final FirewallRules firewallRules = new FirewallRules(network, rules);
|
||||
|
||||
return applyRules(network, routers, typeString, isPodLevelException, podId, failWhenDisconnect, new RuleApplierWrapper<RuleApplier>(firewallRules));
|
||||
}
|
||||
|
|
@ -240,7 +240,7 @@ public class BasicNetworkTopology implements NetworkTopology {
|
|||
final boolean failWhenDisconnect = false;
|
||||
final Long podId = null;
|
||||
|
||||
StaticNatRules natRules = new StaticNatRules(network, rules);
|
||||
final StaticNatRules natRules = new StaticNatRules(network, rules);
|
||||
|
||||
return applyRules(network, routers, typeString, isPodLevelException, podId, failWhenDisconnect, new RuleApplierWrapper<RuleApplier>(natRules));
|
||||
}
|
||||
|
|
@ -260,7 +260,7 @@ public class BasicNetworkTopology implements NetworkTopology {
|
|||
final boolean failWhenDisconnect = false;
|
||||
final Long podId = null;
|
||||
|
||||
IpAssociationRules ipAddresses = new IpAssociationRules(network, ipAddress);
|
||||
final IpAssociationRules ipAddresses = new IpAssociationRules(network, ipAddress);
|
||||
|
||||
return applyRules(network, routers, typeString, isPodLevelException, podId, failWhenDisconnect, new RuleApplierWrapper<RuleApplier>(ipAddresses));
|
||||
}
|
||||
|
|
@ -274,7 +274,7 @@ public class BasicNetworkTopology implements NetworkTopology {
|
|||
|
||||
s_logger.debug("APPLYING BASIC VPN RULES");
|
||||
|
||||
BasicVpnRules vpnRules = new BasicVpnRules(network, users);
|
||||
final BasicVpnRules vpnRules = new BasicVpnRules(network, users);
|
||||
boolean agentResults = true;
|
||||
|
||||
for (final DomainRouterVO router : routers) {
|
||||
|
|
@ -314,7 +314,7 @@ public class BasicNetworkTopology implements NetworkTopology {
|
|||
final boolean failWhenDisconnect = false;
|
||||
final Long podId = null;
|
||||
|
||||
PasswordToRouterRules routerRules = new PasswordToRouterRules(network, nic, profile);
|
||||
final PasswordToRouterRules routerRules = new PasswordToRouterRules(network, nic, profile);
|
||||
|
||||
return applyRules(network, routers, typeString, isPodLevelException, podId, failWhenDisconnect, new RuleApplierWrapper<RuleApplier>(routerRules));
|
||||
}
|
||||
|
|
@ -329,7 +329,7 @@ public class BasicNetworkTopology implements NetworkTopology {
|
|||
final boolean failWhenDisconnect = false;
|
||||
final Long podId = null;
|
||||
|
||||
SshKeyToRouterRules keyToRouterRules = new SshKeyToRouterRules(network, nic, profile, sshPublicKey);
|
||||
final SshKeyToRouterRules keyToRouterRules = new SshKeyToRouterRules(network, nic, profile, sshPublicKey);
|
||||
|
||||
return applyRules(network, routers, typeString, isPodLevelException, podId, failWhenDisconnect, new RuleApplierWrapper<RuleApplier>(keyToRouterRules));
|
||||
}
|
||||
|
|
@ -344,7 +344,7 @@ public class BasicNetworkTopology implements NetworkTopology {
|
|||
final boolean failWhenDisconnect = false;
|
||||
final Long podId = null;
|
||||
|
||||
UserdataToRouterRules userdataToRouterRules = new UserdataToRouterRules(network, nic, profile);
|
||||
final UserdataToRouterRules userdataToRouterRules = new UserdataToRouterRules(network, nic, profile);
|
||||
|
||||
return applyRules(network, routers, typeString, isPodLevelException, podId, failWhenDisconnect, new RuleApplierWrapper<RuleApplier>(userdataToRouterRules));
|
||||
}
|
||||
|
|
@ -358,7 +358,7 @@ public class BasicNetworkTopology implements NetworkTopology {
|
|||
throw new ResourceUnavailableException("Unable to apply " + typeString, DataCenter.class, network.getDataCenterId());
|
||||
}
|
||||
|
||||
RuleApplier ruleApplier = ruleApplierWrapper.getRuleType();
|
||||
final RuleApplier ruleApplier = ruleApplierWrapper.getRuleType();
|
||||
|
||||
final DataCenter dc = _dcDao.findById(network.getDataCenterId());
|
||||
final boolean isZoneBasic = dc.getNetworkType() == NetworkType.Basic;
|
||||
|
|
@ -414,10 +414,16 @@ public class BasicNetworkTopology implements NetworkTopology {
|
|||
|
||||
if (!connectedRouters.isEmpty()) {
|
||||
// Shouldn't we include this check inside the method?
|
||||
if (!isZoneBasic && !disconnectedRouters.isEmpty() && disconnectedRouters.get(0).getIsRedundantRouter()) {
|
||||
if (!isZoneBasic && !disconnectedRouters.isEmpty()) {
|
||||
// These disconnected redundant virtual routers are out of sync
|
||||
// now, stop them for synchronization
|
||||
_networkHelper.handleSingleWorkingRedundantRouter(connectedRouters, disconnectedRouters, msg);
|
||||
for (final VirtualRouter virtualRouter : disconnectedRouters) {
|
||||
// If we have at least 1 disconnected redundant router, callhandleSingleWorkingRedundantRouter().
|
||||
if (virtualRouter.getIsRedundantRouter()) {
|
||||
_networkHelper.handleSingleWorkingRedundantRouter(connectedRouters, disconnectedRouters, msg);
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
} else if (!disconnectedRouters.isEmpty()) {
|
||||
for (final VirtualRouter router : disconnectedRouters) {
|
||||
|
|
|
|||
|
|
@ -20,9 +20,8 @@ import java.util.ArrayList;
|
|||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
import org.apache.log4j.Logger;
|
||||
|
||||
import org.apache.cloudstack.engine.orchestration.service.NetworkOrchestrationService;
|
||||
import org.apache.log4j.Logger;
|
||||
|
||||
import com.cloud.dc.DataCenter.NetworkType;
|
||||
import com.cloud.dc.HostPodVO;
|
||||
|
|
@ -197,6 +196,7 @@ public class RouterDeploymentDefinition {
|
|||
try {
|
||||
lock();
|
||||
checkPreconditions();
|
||||
|
||||
// dest has pod=null, for Basic Zone findOrDeployVRs for all Pods
|
||||
final List<DeployDestination> destinations = findDestinations();
|
||||
|
||||
|
|
@ -353,7 +353,7 @@ public class RouterDeploymentDefinition {
|
|||
}
|
||||
|
||||
protected void findServiceOfferingId() {
|
||||
Long networkOfferingId = networkOfferingDao.findById(guestNetwork.getNetworkOfferingId()).getServiceOfferingId();
|
||||
final Long networkOfferingId = networkOfferingDao.findById(guestNetwork.getNetworkOfferingId()).getServiceOfferingId();
|
||||
if (networkOfferingId != null) {
|
||||
serviceOfferingId = networkOfferingId;
|
||||
}
|
||||
|
|
@ -376,11 +376,11 @@ public class RouterDeploymentDefinition {
|
|||
}
|
||||
|
||||
protected void deployAllVirtualRouters() throws ConcurrentOperationException, InsufficientCapacityException, ResourceUnavailableException {
|
||||
int routersToDeploy = getNumberOfRoutersToDeploy();
|
||||
final int routersToDeploy = getNumberOfRoutersToDeploy();
|
||||
for (int i = 0; i < routersToDeploy; i++) {
|
||||
// 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);
|
||||
final DomainRouterVO router = nwHelper.deployRouter(this, false);
|
||||
|
||||
if (router != null) {
|
||||
routerDao.addRouterToGuestNetwork(router, guestNetwork);
|
||||
|
|
|
|||
|
|
@ -16,6 +16,12 @@
|
|||
// under the License.
|
||||
package org.cloud.network.router.deployment;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
import org.apache.log4j.Logger;
|
||||
|
||||
import com.cloud.dc.dao.VlanDao;
|
||||
import com.cloud.deploy.DataCenterDeployment;
|
||||
import com.cloud.deploy.DeployDestination;
|
||||
|
|
@ -35,11 +41,6 @@ import com.cloud.user.Account;
|
|||
import com.cloud.utils.exception.CloudRuntimeException;
|
||||
import com.cloud.vm.DomainRouterVO;
|
||||
import com.cloud.vm.VirtualMachineProfile.Param;
|
||||
import org.apache.log4j.Logger;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
public class VpcRouterDeploymentDefinition extends RouterDeploymentDefinition {
|
||||
private static final Logger logger = Logger.getLogger(VpcRouterDeploymentDefinition.class);
|
||||
|
|
@ -77,7 +78,7 @@ public class VpcRouterDeploymentDefinition extends RouterDeploymentDefinition {
|
|||
|
||||
@Override
|
||||
protected void lock() {
|
||||
Vpc vpcLock = vpcDao.acquireInLockTable(vpc.getId());
|
||||
final Vpc vpcLock = vpcDao.acquireInLockTable(vpc.getId());
|
||||
if (vpcLock == null) {
|
||||
throw new ConcurrentOperationException("Unable to lock vpc " + vpc.getId());
|
||||
}
|
||||
|
|
@ -136,11 +137,26 @@ public class VpcRouterDeploymentDefinition extends RouterDeploymentDefinition {
|
|||
}
|
||||
|
||||
@Override
|
||||
protected void findVirtualProvider() {
|
||||
List<? extends PhysicalNetwork> pNtwks = pNtwkDao.listByZone(vpc.getZoneId());
|
||||
protected void findOrDeployVirtualRouter() throws ConcurrentOperationException, InsufficientCapacityException, ResourceUnavailableException {
|
||||
final Vpc vpc = getVpc();
|
||||
if (vpc != null) {
|
||||
// This call will associate any existing router to the "routers" attribute.
|
||||
// It's needed in order to continue with the VMs deployment.
|
||||
planDeploymentRouters();
|
||||
if (!routers.isEmpty()) {
|
||||
// If routers are found, just return: nothing need to be done here.
|
||||
return;
|
||||
}
|
||||
}
|
||||
super.findOrDeployVirtualRouter();
|
||||
}
|
||||
|
||||
for (PhysicalNetwork pNtwk : pNtwks) {
|
||||
PhysicalNetworkServiceProvider provider = physicalProviderDao.findByServiceProvider(pNtwk.getId(), Type.VPCVirtualRouter.toString());
|
||||
@Override
|
||||
protected void findVirtualProvider() {
|
||||
final List<? extends PhysicalNetwork> pNtwks = pNtwkDao.listByZone(vpc.getZoneId());
|
||||
|
||||
for (final PhysicalNetwork pNtwk : pNtwks) {
|
||||
final PhysicalNetworkServiceProvider provider = physicalProviderDao.findByServiceProvider(pNtwk.getId(), Type.VPCVirtualRouter.toString());
|
||||
if (provider == null) {
|
||||
throw new CloudRuntimeException("Cannot find service provider " + Type.VPCVirtualRouter.toString() + " in physical network " + pNtwk.getId());
|
||||
}
|
||||
|
|
@ -153,7 +169,7 @@ public class VpcRouterDeploymentDefinition extends RouterDeploymentDefinition {
|
|||
|
||||
@Override
|
||||
protected void findServiceOfferingId() {
|
||||
Long vpcOfferingId = vpcOffDao.findById(vpc.getVpcOfferingId()).getServiceOfferingId();
|
||||
final Long vpcOfferingId = vpcOffDao.findById(vpc.getVpcOfferingId()).getServiceOfferingId();
|
||||
if (vpcOfferingId != null) {
|
||||
serviceOfferingId = vpcOfferingId;
|
||||
}
|
||||
|
|
@ -161,17 +177,17 @@ public class VpcRouterDeploymentDefinition extends RouterDeploymentDefinition {
|
|||
|
||||
@Override
|
||||
protected void deployAllVirtualRouters() throws ConcurrentOperationException, InsufficientCapacityException,
|
||||
ResourceUnavailableException {
|
||||
ResourceUnavailableException {
|
||||
|
||||
// Implement Redundant Vpc
|
||||
int routersToDeploy = this.getNumberOfRoutersToDeploy();
|
||||
final int routersToDeploy = getNumberOfRoutersToDeploy();
|
||||
for(int i = 0; i < routersToDeploy; i++) {
|
||||
// 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 = this.nwHelper.deployRouter(this, false);
|
||||
final DomainRouterVO router = nwHelper.deployRouter(this, false);
|
||||
|
||||
if (router != null) {
|
||||
// TODO this.routerDao.addRouterToGuestNetwork(router, this.guestNetwork);
|
||||
this.routers.add(router);
|
||||
routers.add(router);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
@ -188,6 +204,6 @@ public class VpcRouterDeploymentDefinition extends RouterDeploymentDefinition {
|
|||
|
||||
@Override
|
||||
public boolean isRedundant() {
|
||||
return this.vpc.isRedundant();
|
||||
return vpc.isRedundant();
|
||||
}
|
||||
}
|
||||
|
|
|
|||
Loading…
Reference in New Issue