cloudstack-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From d...@apache.org
Subject [11/50] [abbrv] git commit: updated refs/heads/feature/systemvm-persistent-config to 4fe7264
Date Wed, 04 Feb 2015 20:28:31 GMT
Fixing the priority in the setup guest network command
Fixing the deploy router in VPC method

formatting some classes


Project: http://git-wip-us.apache.org/repos/asf/cloudstack/repo
Commit: http://git-wip-us.apache.org/repos/asf/cloudstack/commit/0cad98b6
Tree: http://git-wip-us.apache.org/repos/asf/cloudstack/tree/0cad98b6
Diff: http://git-wip-us.apache.org/repos/asf/cloudstack/diff/0cad98b6

Branch: refs/heads/feature/systemvm-persistent-config
Commit: 0cad98b638465b88da71314a944afd8347461e84
Parents: b53c1e7
Author: wilderrodrigues <wrodrigues@schubergphilis.com>
Authored: Mon Dec 22 17:57:06 2014 +0100
Committer: wilderrodrigues <wrodrigues@schubergphilis.com>
Committed: Wed Feb 4 18:41:11 2015 +0100

----------------------------------------------------------------------
 .../network/router/CommandSetupHelper.java      |  5 ++-
 .../cloud/network/router/NetworkHelperImpl.java | 20 ++++-----
 .../VpcVirtualNetworkApplianceManagerImpl.java  |  2 +-
 .../network/topology/BasicNetworkTopology.java  | 34 +++++++++------
 .../deployment/RouterDeploymentDefinition.java  | 10 ++---
 .../VpcRouterDeploymentDefinition.java          | 46 +++++++++++++-------
 6 files changed, 70 insertions(+), 47 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/cloudstack/blob/0cad98b6/server/src/com/cloud/network/router/CommandSetupHelper.java
----------------------------------------------------------------------
diff --git a/server/src/com/cloud/network/router/CommandSetupHelper.java b/server/src/com/cloud/network/router/CommandSetupHelper.java
index 3e0b2d0..7002136 100644
--- a/server/src/com/cloud/network/router/CommandSetupHelper.java
+++ b/server/src/com/cloud/network/router/CommandSetupHelper.java
@@ -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()));

http://git-wip-us.apache.org/repos/asf/cloudstack/blob/0cad98b6/server/src/com/cloud/network/router/NetworkHelperImpl.java
----------------------------------------------------------------------
diff --git a/server/src/com/cloud/network/router/NetworkHelperImpl.java b/server/src/com/cloud/network/router/NetworkHelperImpl.java
index 33b1242..7019ef3 100644
--- a/server/src/com/cloud/network/router/NetworkHelperImpl.java
+++ b/server/src/com/cloud/network/router/NetworkHelperImpl.java
@@ -195,17 +195,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;
-        }
-        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());
+
+        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 (!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);

http://git-wip-us.apache.org/repos/asf/cloudstack/blob/0cad98b6/server/src/com/cloud/network/router/VpcVirtualNetworkApplianceManagerImpl.java
----------------------------------------------------------------------
diff --git a/server/src/com/cloud/network/router/VpcVirtualNetworkApplianceManagerImpl.java
b/server/src/com/cloud/network/router/VpcVirtualNetworkApplianceManagerImpl.java
index feb5d47..3b33083 100644
--- a/server/src/com/cloud/network/router/VpcVirtualNetworkApplianceManagerImpl.java
+++ b/server/src/com/cloud/network/router/VpcVirtualNetworkApplianceManagerImpl.java
@@ -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);

http://git-wip-us.apache.org/repos/asf/cloudstack/blob/0cad98b6/server/src/org/apache/cloudstack/network/topology/BasicNetworkTopology.java
----------------------------------------------------------------------
diff --git a/server/src/org/apache/cloudstack/network/topology/BasicNetworkTopology.java b/server/src/org/apache/cloudstack/network/topology/BasicNetworkTopology.java
index 23aefb5..1f488e1 100644
--- a/server/src/org/apache/cloudstack/network/topology/BasicNetworkTopology.java
+++ b/server/src/org/apache/cloudstack/network/topology/BasicNetworkTopology.java
@@ -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) {

http://git-wip-us.apache.org/repos/asf/cloudstack/blob/0cad98b6/server/src/org/cloud/network/router/deployment/RouterDeploymentDefinition.java
----------------------------------------------------------------------
diff --git a/server/src/org/cloud/network/router/deployment/RouterDeploymentDefinition.java
b/server/src/org/cloud/network/router/deployment/RouterDeploymentDefinition.java
index be1246e..3d985cd 100644
--- a/server/src/org/cloud/network/router/deployment/RouterDeploymentDefinition.java
+++ b/server/src/org/cloud/network/router/deployment/RouterDeploymentDefinition.java
@@ -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);

http://git-wip-us.apache.org/repos/asf/cloudstack/blob/0cad98b6/server/src/org/cloud/network/router/deployment/VpcRouterDeploymentDefinition.java
----------------------------------------------------------------------
diff --git a/server/src/org/cloud/network/router/deployment/VpcRouterDeploymentDefinition.java
b/server/src/org/cloud/network/router/deployment/VpcRouterDeploymentDefinition.java
index a978404..672838a 100644
--- a/server/src/org/cloud/network/router/deployment/VpcRouterDeploymentDefinition.java
+++ b/server/src/org/cloud/network/router/deployment/VpcRouterDeploymentDefinition.java
@@ -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 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();
+    }
+
+    @Override
     protected void findVirtualProvider() {
-        List<? extends PhysicalNetwork> pNtwks = pNtwkDao.listByZone(vpc.getZoneId());
+        final List<? extends PhysicalNetwork> pNtwks = pNtwkDao.listByZone(vpc.getZoneId());
 
-        for (PhysicalNetwork pNtwk : pNtwks) {
-            PhysicalNetworkServiceProvider provider = physicalProviderDao.findByServiceProvider(pNtwk.getId(),
Type.VPCVirtualRouter.toString());
+        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();
     }
 }


Mime
View raw message