Removing the VirtualNetworkStatus, it was not being used properly;
fixing the injection of the network DAO in the PrivateGatewayRules;
all tests that were failing in Travis have been tested before the commit.

Conflicts:
        server/src/com/cloud/network/router/NetworkHelperImpl.java
        
server/src/com/cloud/network/router/VirtualNetworkApplianceManagerImpl.java


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

Branch: refs/heads/master
Commit: f2f4732854e2d24f2a9afb932aebc48bb91eb762
Parents: 251e7ff
Author: Wilder Rodrigues <wrodrig...@schubergphilis.com>
Authored: Thu Sep 4 16:49:49 2014 +0200
Committer: wilderrodrigues <wrodrig...@schubergphilis.com>
Committed: Tue Oct 14 15:08:11 2014 +0200

----------------------------------------------------------------------
 .../com/cloud/network/router/NetworkHelper.java |  1 -
 .../cloud/network/router/NetworkHelperImpl.java | 18 +++++++++++---
 .../VirtualNetworkApplianceManagerImpl.java     | 25 ++++++++++---------
 .../network/router/VirtualNetworkStatus.java    | 26 --------------------
 .../network/router/VpcNetworkHelperImpl.java    | 23 +++++++++--------
 .../rules/VirtualNetworkApplianceFactory.java   |  3 ++-
 6 files changed, 40 insertions(+), 56 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/cloudstack/blob/f2f47328/server/src/com/cloud/network/router/NetworkHelper.java
----------------------------------------------------------------------
diff --git a/server/src/com/cloud/network/router/NetworkHelper.java 
b/server/src/com/cloud/network/router/NetworkHelper.java
index 59338f7..711c02d 100644
--- a/server/src/com/cloud/network/router/NetworkHelper.java
+++ b/server/src/com/cloud/network/router/NetworkHelper.java
@@ -78,5 +78,4 @@ public interface NetworkHelper {
                     throws InsufficientAddressCapacityException,
                     InsufficientServerCapacityException, 
InsufficientCapacityException,
                     StorageUnavailableException, ResourceUnavailableException;
-
 }
\ No newline at end of file

http://git-wip-us.apache.org/repos/asf/cloudstack/blob/f2f47328/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 6c695d5..357802f 100644
--- a/server/src/com/cloud/network/router/NetworkHelperImpl.java
+++ b/server/src/com/cloud/network/router/NetworkHelperImpl.java
@@ -106,6 +106,9 @@ public class NetworkHelperImpl implements NetworkHelper {
 
     private static final Logger s_logger = 
Logger.getLogger(NetworkHelperImpl.class);
 
+    protected static Account s_systemAccount;
+    protected static String s_vmInstanceName;
+
     @Inject
     protected NicDao _nicDao;
     @Inject
@@ -559,7 +562,7 @@ public class NetworkHelperImpl implements NetworkHelper {
                 Long vpcId = routerDeploymentDefinition.getVpc() != null ? 
routerDeploymentDefinition.getVpc().getId() : null;
 
                 router = new DomainRouterVO(id, routerOffering.getId(), 
routerDeploymentDefinition.getVirtualProvider().getId(), 
VirtualMachineName.getRouterName(id,
-                        VirtualNetworkStatus.instance), template.getId(), 
template.getHypervisorType(), template.getGuestOSId(), owner.getDomainId(), 
owner.getId(),
+                        s_vmInstanceName), template.getId(), 
template.getHypervisorType(), template.getGuestOSId(), owner.getDomainId(), 
owner.getId(),
                         routerDeploymentDefinition.isRedundant(), 0, false, 
RedundantState.UNKNOWN, offerHA, false, vpcId);
 
                 
router.setDynamicallyScalable(template.isDynamicallyScalable());
@@ -747,7 +750,7 @@ public class NetworkHelperImpl implements NetworkHelper {
         s_logger.debug("Adding nic for Virtual Router in Control network ");
         List<? extends NetworkOffering> offerings = 
_networkModel.getSystemAccountNetworkOfferings(NetworkOffering.SystemControlNetwork);
         NetworkOffering controlOffering = offerings.get(0);
-        Network controlConfig = 
_networkMgr.setupNetwork(VirtualNetworkStatus.account, controlOffering, 
routerDeploymentDefinition.getPlan(), null, null, false).get(0);
+        Network controlConfig = _networkMgr.setupNetwork(s_systemAccount, 
controlOffering, routerDeploymentDefinition.getPlan(), null, null, 
false).get(0);
         networks.put(controlConfig, new ArrayList<NicProfile>());
         // 3) Public network
         if (routerDeploymentDefinition.isPublicNetwork()) {
@@ -776,8 +779,7 @@ public class NetworkHelperImpl implements NetworkHelper {
                 defaultNic.setDeviceId(2);
             }
             final NetworkOffering publicOffering = 
_networkModel.getSystemAccountNetworkOfferings(NetworkOffering.SystemPublicNetwork).get(0);
-            final List<? extends Network> publicNetworks = 
_networkMgr.setupNetwork(VirtualNetworkStatus.account, publicOffering, 
routerDeploymentDefinition.getPlan(), null,
-                    null, false);
+            final List<? extends Network> publicNetworks = 
_networkMgr.setupNetwork(s_systemAccount, publicOffering, 
routerDeploymentDefinition.getPlan(), null, null, false);
             final String publicIp = defaultNic.getIp4Address();
             // We want to use the identical MAC address for RvR on public
             // interface if possible
@@ -791,4 +793,12 @@ public class NetworkHelperImpl implements NetworkHelper {
 
         return networks;
     }
+
+    public static void setSystemAccount(final Account systemAccount) {
+        s_systemAccount = systemAccount;
+    }
+
+    public static void setVMInstanceName(final String vmInstanceName) {
+        s_vmInstanceName = vmInstanceName;
+    }
 }

http://git-wip-us.apache.org/repos/asf/cloudstack/blob/f2f47328/server/src/com/cloud/network/router/VirtualNetworkApplianceManagerImpl.java
----------------------------------------------------------------------
diff --git 
a/server/src/com/cloud/network/router/VirtualNetworkApplianceManagerImpl.java 
b/server/src/com/cloud/network/router/VirtualNetworkApplianceManagerImpl.java
index cf5d3a4..d24ab43 100644
--- 
a/server/src/com/cloud/network/router/VirtualNetworkApplianceManagerImpl.java
+++ 
b/server/src/com/cloud/network/router/VirtualNetworkApplianceManagerImpl.java
@@ -59,6 +59,8 @@ import 
org.apache.cloudstack.network.topology.NetworkTopologyContext;
 import org.apache.cloudstack.utils.identity.ManagementServerNode;
 import org.apache.log4j.Logger;
 import org.cloud.network.router.deployment.RouterDeploymentDefinitionBuilder;
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.beans.factory.annotation.Qualifier;
 
 import com.cloud.agent.AgentManager;
 import com.cloud.agent.Listener;
@@ -356,8 +358,11 @@ Configurable, StateListener<State, VirtualMachine.Event, 
VirtualMachine> {
 
     @Inject
     protected NetworkTopologyContext _networkTopologyContext;
-    @Inject
+
+    @Autowired
+    @Qualifier("networkHelper")
     protected NetworkHelper _nwHelper;
+
     @Inject
     protected CommandSetupHelper _commandSetupHelper;
     @Inject
@@ -366,7 +371,6 @@ Configurable, StateListener<State, VirtualMachine.Event, 
VirtualMachine> {
     int _routerRamSize;
     int _routerCpuMHz;
     int _retry = 2;
-    String _instance;
     String _mgmtCidr;
 
     int _routerStatsInterval = 300;
@@ -597,11 +601,13 @@ Configurable, StateListener<State, VirtualMachine.Event, 
VirtualMachine> {
 
         _rvrStatusUpdateExecutor = 
Executors.newFixedThreadPool(_rvrStatusUpdatePoolSize, new 
NamedThreadFactory("RedundantRouterStatusMonitor"));
 
-        _instance = configs.get("instance.name");
-        if (_instance == null) {
-            _instance = "DEFAULT";
+        String instance = configs.get("instance.name");
+        if (instance == null) {
+            instance = "DEFAULT";
         }
 
+        NetworkHelperImpl.setVMInstanceName(instance);
+
         final String rpValue = configs.get("network.disable.rpfilter");
         if (rpValue != null && rpValue.equalsIgnoreCase("true")) {
             _disableRpFilter = true;
@@ -621,7 +627,7 @@ Configurable, StateListener<State, VirtualMachine.Event, 
VirtualMachine> {
         offering = _serviceOfferingDao.persistSystemServiceOffering(offering);
         _routerDeploymentManagerBuilder.setOfferingId(offering.getId());
 
-        VirtualNetworkStatus.account = _accountMgr.getSystemAccount();
+        NetworkHelperImpl.setSystemAccount(_accountMgr.getSystemAccount());
 
         final String aggregationRange = 
configs.get("usage.stats.job.aggregation.range");
         _usageAggregationRange = NumbersUtil.parseInt(aggregationRange, 1440);
@@ -2591,9 +2597,4 @@ Configurable, StateListener<State, VirtualMachine.Event, 
VirtualMachine> {
     public boolean completeAggregatedExecution(final Network network, final 
List<DomainRouterVO> routers) throws AgentUnavailableException {
         return aggregationExecution(Action.Finish, network, routers);
     }
-
-    @Override
-    public boolean cleanupAggregatedExecution(final Network network, final 
List<DomainRouterVO> routers) throws AgentUnavailableException {
-        return aggregationExecution(Action.Cleanup, network, routers);
-    }
-}
+}
\ No newline at end of file

http://git-wip-us.apache.org/repos/asf/cloudstack/blob/f2f47328/server/src/com/cloud/network/router/VirtualNetworkStatus.java
----------------------------------------------------------------------
diff --git a/server/src/com/cloud/network/router/VirtualNetworkStatus.java 
b/server/src/com/cloud/network/router/VirtualNetworkStatus.java
deleted file mode 100644
index dd77f5d..0000000
--- a/server/src/com/cloud/network/router/VirtualNetworkStatus.java
+++ /dev/null
@@ -1,26 +0,0 @@
-// Licensed to the Apache Software Foundation (ASF) under one
-// or more contributor license agreements.  See the NOTICE file
-// distributed with this work for additional information
-// regarding copyright ownership.  The ASF licenses this file
-// to you under the Apache License, Version 2.0 (the
-// "License"); you may not use this file except in compliance
-// with the License.  You may obtain a copy of the License at
-//
-//   http://www.apache.org/licenses/LICENSE-2.0
-//
-// Unless required by applicable law or agreed to in writing,
-// software distributed under the License is distributed on an
-// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
-// KIND, either express or implied.  See the License for the
-// specific language governing permissions and limitations
-// under the License.
-package com.cloud.network.router;
-
-import com.cloud.user.Account;
-
-public class VirtualNetworkStatus {
-
-    public static String instance = "";
-
-    public static Account account = null;
-}
\ No newline at end of file

http://git-wip-us.apache.org/repos/asf/cloudstack/blob/f2f47328/server/src/com/cloud/network/router/VpcNetworkHelperImpl.java
----------------------------------------------------------------------
diff --git a/server/src/com/cloud/network/router/VpcNetworkHelperImpl.java 
b/server/src/com/cloud/network/router/VpcNetworkHelperImpl.java
index aa57a54..58537d1 100644
--- a/server/src/com/cloud/network/router/VpcNetworkHelperImpl.java
+++ b/server/src/com/cloud/network/router/VpcNetworkHelperImpl.java
@@ -61,18 +61,18 @@ public class VpcNetworkHelperImpl extends NetworkHelperImpl 
{
 
     @PostConstruct
     protected void setupNoHypervisorsErrMsgDetails() {
-        this.noHypervisorsErrMsgDetails = 
StringUtils.join(this.vpcMgr.getSupportedVpcHypervisors(), ',');
-        this.noHypervisorsErrMsgDetails += " are the only supported 
Hypervisors";
+        noHypervisorsErrMsgDetails = 
StringUtils.join(vpcMgr.getSupportedVpcHypervisors(), ',');
+        noHypervisorsErrMsgDetails += " are the only supported Hypervisors";
     }
 
     @Override
     protected String getNoHypervisorsErrMsgDetails() {
-        return this.noHypervisorsErrMsgDetails;
+        return noHypervisorsErrMsgDetails;
     }
 
     @Override
     protected void filterSupportedHypervisors(final List<HypervisorType> 
hypervisors) {
-        hypervisors.retainAll(this.vpcMgr.getSupportedVpcHypervisors());
+        hypervisors.retainAll(vpcMgr.getSupportedVpcHypervisors());
     }
 
     @Override
@@ -90,23 +90,23 @@ public class VpcNetworkHelperImpl extends NetworkHelperImpl 
{
 
         final Long vpcId = vpcRouterDeploymentDefinition.getVpc().getId();
         //2) allocate nic for private gateways if needed
-        final List<PrivateGateway> privateGateways = 
this.vpcMgr.getVpcPrivateGateways(vpcId);
+        final List<PrivateGateway> privateGateways = 
vpcMgr.getVpcPrivateGateways(vpcId);
         if (privateGateways != null && !privateGateways.isEmpty()) {
             for (PrivateGateway privateGateway : privateGateways) {
-                NicProfile privateNic = 
this.nicProfileHelper.createPrivateNicProfileForGateway(privateGateway);
+                NicProfile privateNic = 
nicProfileHelper.createPrivateNicProfileForGateway(privateGateway);
                 Network privateNetwork = 
_networkModel.getNetwork(privateGateway.getNetworkId());
                 networks.put(privateNetwork, new 
ArrayList<NicProfile>(Arrays.asList(privateNic)));
             }
         }
 
         //3) allocate nic for guest gateway if needed
-        List<? extends Network> guestNetworks = 
this.vpcMgr.getVpcNetworks(vpcId);
+        List<? extends Network> guestNetworks = vpcMgr.getVpcNetworks(vpcId);
         for (Network guestNetwork : guestNetworks) {
             if (_networkModel.isPrivateGateway(guestNetwork.getId())) {
                 continue;
             }
             if (guestNetwork.getState() == Network.State.Implemented || 
guestNetwork.getState() == Network.State.Setup) {
-                NicProfile guestNic = 
this.nicProfileHelper.createGuestNicProfileForVpcRouter(guestNetwork);
+                NicProfile guestNic = 
nicProfileHelper.createGuestNicProfileForVpcRouter(guestNetwork);
                 networks.put(guestNetwork, new 
ArrayList<NicProfile>(Arrays.asList(guestNic)));
             }
         }
@@ -116,8 +116,8 @@ public class VpcNetworkHelperImpl extends NetworkHelperImpl 
{
         final List<NicProfile> publicNics = new ArrayList<NicProfile>();
         Network publicNetwork = null;
         for (IPAddressVO ip : ips) {
-            PublicIp publicIp = PublicIp.createFromAddrAndVlan(ip, 
this._vlanDao.findById(ip.getVlanId()));
-            if ((ip.getState() == IpAddress.State.Allocated || ip.getState() 
== IpAddress.State.Allocating) && this.vpcMgr.isIpAllocatedToVpc(ip) &&
+            PublicIp publicIp = PublicIp.createFromAddrAndVlan(ip, 
_vlanDao.findById(ip.getVlanId()));
+            if ((ip.getState() == IpAddress.State.Allocated || ip.getState() 
== IpAddress.State.Allocating) && vpcMgr.isIpAllocatedToVpc(ip) &&
                     !publicVlans.contains(publicIp.getVlanTag())) {
                 s_logger.debug("Allocating nic for router in vlan " + 
publicIp.getVlanTag());
                 NicProfile publicNic = new NicProfile();
@@ -131,8 +131,7 @@ public class VpcNetworkHelperImpl extends NetworkHelperImpl 
{
                 
publicNic.setIsolationUri(IsolationType.Vlan.toUri(publicIp.getVlanTag()));
                 NetworkOffering publicOffering = 
_networkModel.getSystemAccountNetworkOfferings(NetworkOffering.SystemPublicNetwork).get(0);
                 if (publicNetwork == null) {
-                    List<? extends Network> publicNetworks = 
_networkMgr.setupNetwork(VirtualNetworkStatus.account,
-                            publicOffering, 
vpcRouterDeploymentDefinition.getPlan(), null, null, false);
+                    List<? extends Network> publicNetworks = 
_networkMgr.setupNetwork(s_systemAccount, publicOffering, 
vpcRouterDeploymentDefinition.getPlan(), null, null, false);
                     publicNetwork = publicNetworks.get(0);
                 }
                 publicNics.add(publicNic);

http://git-wip-us.apache.org/repos/asf/cloudstack/blob/f2f47328/server/src/com/cloud/network/rules/VirtualNetworkApplianceFactory.java
----------------------------------------------------------------------
diff --git 
a/server/src/com/cloud/network/rules/VirtualNetworkApplianceFactory.java 
b/server/src/com/cloud/network/rules/VirtualNetworkApplianceFactory.java
index 5988fbd..a1944e0 100644
--- a/server/src/com/cloud/network/rules/VirtualNetworkApplianceFactory.java
+++ b/server/src/com/cloud/network/rules/VirtualNetworkApplianceFactory.java
@@ -285,7 +285,8 @@ public class VirtualNetworkApplianceFactory {
         gwRules._privateIpDao = _privateIpDao;
         gwRules._networkACLMgr = _networkACLMgr;
         gwRules._nicProfileHelper = _nicProfileHelper;
+        gwRules._networkDao = _networkDao;
 
         return gwRules;
     }
-}
\ No newline at end of file
+}

Reply via email to