cloudstack-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From sw...@apache.org
Subject [24/39] git commit: updated refs/heads/master to 3c800b4
Date Thu, 26 May 2016 03:06:03 GMT
CLOUDSTACK-9294 : Make sure to remove VR from VSD when removing the VPC


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

Branch: refs/heads/master
Commit: 4b6179940d8f29873a0cc0b4b0bc5b2f8e248ca5
Parents: b0c27e4
Author: Nick Livens <nick.livens@nuagenetworks.net>
Authored: Mon May 2 10:16:06 2016 +0200
Committer: Nick Livens <nick.livens@nuagenetworks.net>
Committed: Tue May 24 11:12:19 2016 +0200

----------------------------------------------------------------------
 .../src/com/cloud/vm/dao/DomainRouterDao.java   |  2 ++
 .../com/cloud/vm/dao/DomainRouterDaoImpl.java   |  8 ++++++++
 .../api/element/ShutDownVpcVspCommand.java      | 13 ++++++++++++-
 .../cloud/network/element/NuageVspElement.java  | 20 +++++++++++++++++++-
 .../network/resource/NuageVspResource.java      |  2 +-
 .../network/element/NuageVspElementTest.java    | 11 ++++++++++-
 .../network/resource/NuageVspResourceTest.java  |  4 ++--
 7 files changed, 54 insertions(+), 6 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/cloudstack/blob/4b617994/engine/schema/src/com/cloud/vm/dao/DomainRouterDao.java
----------------------------------------------------------------------
diff --git a/engine/schema/src/com/cloud/vm/dao/DomainRouterDao.java b/engine/schema/src/com/cloud/vm/dao/DomainRouterDao.java
index d555e79..ef8829e 100644
--- a/engine/schema/src/com/cloud/vm/dao/DomainRouterDao.java
+++ b/engine/schema/src/com/cloud/vm/dao/DomainRouterDao.java
@@ -156,4 +156,6 @@ public interface DomainRouterDao extends GenericDao<DomainRouterVO,
Long> {
     List<DomainRouterVO> listRunningByDataCenter(long dcId);
 
     List<DomainRouterVO> listStopped(long networkId);
+
+    List<DomainRouterVO> listIncludingRemovedByVpcId(long vpcId);
 }

http://git-wip-us.apache.org/repos/asf/cloudstack/blob/4b617994/engine/schema/src/com/cloud/vm/dao/DomainRouterDaoImpl.java
----------------------------------------------------------------------
diff --git a/engine/schema/src/com/cloud/vm/dao/DomainRouterDaoImpl.java b/engine/schema/src/com/cloud/vm/dao/DomainRouterDaoImpl.java
index 271644f..85a8a93 100644
--- a/engine/schema/src/com/cloud/vm/dao/DomainRouterDaoImpl.java
+++ b/engine/schema/src/com/cloud/vm/dao/DomainRouterDaoImpl.java
@@ -432,4 +432,12 @@ public class DomainRouterDaoImpl extends GenericDaoBase<DomainRouterVO,
Long> im
         sc.setParameters("states", State.Stopped);
         return listBy(sc);
     }
+
+    @Override
+    public List<DomainRouterVO> listIncludingRemovedByVpcId(long vpcId) {
+        SearchCriteria<DomainRouterVO> sc = VpcSearch.create();
+        sc.setParameters("vpcId", vpcId);
+        sc.setParameters("role", Role.VIRTUAL_ROUTER);
+        return listIncludingRemovedBy(sc);
+    }
 }

http://git-wip-us.apache.org/repos/asf/cloudstack/blob/4b617994/plugins/network-elements/nuage-vsp/src/com/cloud/agent/api/element/ShutDownVpcVspCommand.java
----------------------------------------------------------------------
diff --git a/plugins/network-elements/nuage-vsp/src/com/cloud/agent/api/element/ShutDownVpcVspCommand.java
b/plugins/network-elements/nuage-vsp/src/com/cloud/agent/api/element/ShutDownVpcVspCommand.java
index d91734b..6ad4ec6 100644
--- a/plugins/network-elements/nuage-vsp/src/com/cloud/agent/api/element/ShutDownVpcVspCommand.java
+++ b/plugins/network-elements/nuage-vsp/src/com/cloud/agent/api/element/ShutDownVpcVspCommand.java
@@ -21,17 +21,21 @@ package com.cloud.agent.api.element;
 
 import com.cloud.agent.api.Command;
 
+import java.util.List;
+
 public class ShutDownVpcVspCommand extends Command {
 
     private final String _domainUuid;
     private final String _vpcUuid;
     private final String _domainTemplateName;
+    private final List<String> _domainRouterUuids;
 
-    public ShutDownVpcVspCommand(String domainUuid, String vpcUuid, String domainTemplateName)
{
+    public ShutDownVpcVspCommand(String domainUuid, String vpcUuid, String domainTemplateName,
List<String> domainRouterUuids) {
         super();
         this._domainUuid = domainUuid;
         this._vpcUuid = vpcUuid;
         this._domainTemplateName = domainTemplateName;
+        this._domainRouterUuids = domainRouterUuids;
     }
 
     public String getDomainUuid() {
@@ -46,6 +50,10 @@ public class ShutDownVpcVspCommand extends Command {
         return _domainTemplateName;
     }
 
+    public List<String> getDomainRouterUuids() {
+        return _domainRouterUuids;
+    }
+
     @Override
     public boolean executeInSequence() {
         return false;
@@ -59,6 +67,8 @@ public class ShutDownVpcVspCommand extends Command {
 
         ShutDownVpcVspCommand that = (ShutDownVpcVspCommand) o;
 
+        if (_domainRouterUuids != null ? !_domainRouterUuids.equals(that._domainRouterUuids)
: that._domainRouterUuids != null)
+            return false;
         if (_domainTemplateName != null ? !_domainTemplateName.equals(that._domainTemplateName)
: that._domainTemplateName != null)
             return false;
         if (_domainUuid != null ? !_domainUuid.equals(that._domainUuid) : that._domainUuid
!= null) return false;
@@ -73,6 +83,7 @@ public class ShutDownVpcVspCommand extends Command {
         result = 31 * result + (_domainUuid != null ? _domainUuid.hashCode() : 0);
         result = 31 * result + (_vpcUuid != null ? _vpcUuid.hashCode() : 0);
         result = 31 * result + (_domainTemplateName != null ? _domainTemplateName.hashCode()
: 0);
+        result = 31 * result + (_domainRouterUuids != null ? _domainRouterUuids.hashCode()
: 0);
         return result;
     }
 }

http://git-wip-us.apache.org/repos/asf/cloudstack/blob/4b617994/plugins/network-elements/nuage-vsp/src/com/cloud/network/element/NuageVspElement.java
----------------------------------------------------------------------
diff --git a/plugins/network-elements/nuage-vsp/src/com/cloud/network/element/NuageVspElement.java
b/plugins/network-elements/nuage-vsp/src/com/cloud/network/element/NuageVspElement.java
index 531c828..1f36ae0 100644
--- a/plugins/network-elements/nuage-vsp/src/com/cloud/network/element/NuageVspElement.java
+++ b/plugins/network-elements/nuage-vsp/src/com/cloud/network/element/NuageVspElement.java
@@ -82,10 +82,12 @@ import com.cloud.resource.ServerResource;
 import com.cloud.resource.UnableDeleteHostException;
 import com.cloud.utils.component.AdapterBase;
 import com.cloud.utils.exception.CloudRuntimeException;
+import com.cloud.vm.DomainRouterVO;
 import com.cloud.vm.NicProfile;
 import com.cloud.vm.NicVO;
 import com.cloud.vm.ReservationContext;
 import com.cloud.vm.VirtualMachineProfile;
+import com.cloud.vm.dao.DomainRouterDao;
 import com.cloud.vm.dao.NicDao;
 import com.google.common.base.Function;
 import com.google.common.collect.Lists;
@@ -98,6 +100,7 @@ import org.apache.cloudstack.framework.config.dao.ConfigurationDao;
 import org.apache.cloudstack.network.ExternalNetworkDeviceManager;
 import org.apache.cloudstack.resourcedetail.VpcDetailVO;
 import org.apache.cloudstack.resourcedetail.dao.VpcDetailsDao;
+import org.apache.commons.collections.CollectionUtils;
 import org.apache.log4j.Logger;
 
 import javax.annotation.Nullable;
@@ -166,6 +169,8 @@ public class NuageVspElement extends AdapterBase implements ConnectivityProvider
     NuageVspEntityBuilder _nuageVspEntityBuilder;
     @Inject
     VpcDetailsDao _vpcDetailsDao;
+    @Inject
+    DomainRouterDao _routerDao;
 
     @Override
     public boolean applyIps(Network network, List<? extends PublicIpAddress> ipAddress,
Set<Service> service) throws ResourceUnavailableException {
@@ -552,6 +557,19 @@ public class NuageVspElement extends AdapterBase implements ConnectivityProvider
     @Override
     public boolean shutdownVpc(Vpc vpc, ReservationContext context) throws ConcurrentOperationException,
ResourceUnavailableException {
         if (vpc.getState().equals(Vpc.State.Inactive)) {
+            List<DomainRouterVO> routers = _routerDao.listByVpcId(vpc.getId());
+            if (CollectionUtils.isEmpty(routers)) {
+                routers = _routerDao.listIncludingRemovedByVpcId(vpc.getId());
+            }
+
+            List<String> domainRouterUuids = Lists.transform(routers, new Function<DomainRouterVO,
String>() {
+                @Nullable
+                @Override
+                public String apply(@Nullable DomainRouterVO input) {
+                    return input != null ? input.getUuid() : null;
+                }
+            });
+
             Domain vpcDomain = _domainDao.findById(vpc.getDomainId());
             HostVO nuageVspHost = getNuageVspHost(getPhysicalNetworkId(vpc.getZoneId()));
 
@@ -563,7 +581,7 @@ public class NuageVspElement extends AdapterBase implements ConnectivityProvider
                 preConfiguredDomainTemplateName = _configDao.getValue(NuageVspManager.NuageVspVpcDomainTemplateName.key());
             }
 
-            ShutDownVpcVspCommand cmd = new ShutDownVpcVspCommand(vpcDomain.getUuid(), vpc.getUuid(),
preConfiguredDomainTemplateName);
+            ShutDownVpcVspCommand cmd = new ShutDownVpcVspCommand(vpcDomain.getUuid(), vpc.getUuid(),
preConfiguredDomainTemplateName, domainRouterUuids);
             Answer answer =  _agentMgr.easySend(nuageVspHost.getId(), cmd);
             if (answer == null || !answer.getResult()) {
                 s_logger.error("ShutDownVpcVspCommand for VPC " + vpc.getUuid() + " failed
on Nuage VSD " + nuageVspHost.getDetail("hostname"));

http://git-wip-us.apache.org/repos/asf/cloudstack/blob/4b617994/plugins/network-elements/nuage-vsp/src/com/cloud/network/resource/NuageVspResource.java
----------------------------------------------------------------------
diff --git a/plugins/network-elements/nuage-vsp/src/com/cloud/network/resource/NuageVspResource.java
b/plugins/network-elements/nuage-vsp/src/com/cloud/network/resource/NuageVspResource.java
index 677fa9f..bdcb481 100644
--- a/plugins/network-elements/nuage-vsp/src/com/cloud/network/resource/NuageVspResource.java
+++ b/plugins/network-elements/nuage-vsp/src/com/cloud/network/resource/NuageVspResource.java
@@ -423,7 +423,7 @@ public class NuageVspResource extends ManagerBase implements ServerResource
{
     private Answer executeRequest(ShutDownVpcVspCommand cmd) {
         try {
             isNuageVspElementLoaded();
-            _nuageVspElementClient.shutdownVpc(cmd.getDomainUuid(), cmd.getVpcUuid(), cmd.getDomainTemplateName());
+            _nuageVspElementClient.shutdownVpc(cmd.getDomainUuid(), cmd.getVpcUuid(), cmd.getDomainTemplateName(),
cmd.getDomainRouterUuids());
             return new Answer(cmd, true, "Shutdown VPC " + cmd.getVpcUuid() + " on Nuage
VSD " + _hostName);
         } catch (ExecutionException | ConfigurationException e) {
             s_logger.error("Failure during " + cmd + " on Nuage VSD " + _hostName, e);

http://git-wip-us.apache.org/repos/asf/cloudstack/blob/4b617994/plugins/network-elements/nuage-vsp/test/com/cloud/network/element/NuageVspElementTest.java
----------------------------------------------------------------------
diff --git a/plugins/network-elements/nuage-vsp/test/com/cloud/network/element/NuageVspElementTest.java
b/plugins/network-elements/nuage-vsp/test/com/cloud/network/element/NuageVspElementTest.java
index e9f92b6..85cbb36 100644
--- a/plugins/network-elements/nuage-vsp/test/com/cloud/network/element/NuageVspElementTest.java
+++ b/plugins/network-elements/nuage-vsp/test/com/cloud/network/element/NuageVspElementTest.java
@@ -60,7 +60,9 @@ import com.cloud.offerings.dao.NetworkOfferingServiceMapDao;
 import com.cloud.resource.ResourceManager;
 import com.cloud.user.Account;
 import com.cloud.util.NuageVspEntityBuilder;
+import com.cloud.vm.DomainRouterVO;
 import com.cloud.vm.ReservationContext;
+import com.cloud.vm.dao.DomainRouterDao;
 import com.google.common.collect.Lists;
 import org.apache.cloudstack.resourcedetail.dao.VpcDetailsDao;
 import org.junit.Before;
@@ -98,6 +100,7 @@ public class NuageVspElementTest extends NuageTest {
     private PhysicalNetworkDao _physicalNetworkDao = mock(PhysicalNetworkDao.class);
     private NuageVspEntityBuilder _nuageVspEntityBuilder = mock(NuageVspEntityBuilder.class);
     private VpcDetailsDao _vpcDetailsDao = mock(VpcDetailsDao.class);
+    private DomainRouterDao _domainRouterDao = mock(DomainRouterDao.class);
 
     @Before
     public void setUp() throws Exception {
@@ -119,6 +122,7 @@ public class NuageVspElementTest extends NuageTest {
         _nuageVspElement._physicalNetworkDao = _physicalNetworkDao;
         _nuageVspElement._nuageVspEntityBuilder = _nuageVspEntityBuilder;
         _nuageVspElement._vpcDetailsDao = _vpcDetailsDao;
+        _nuageVspElement._routerDao = _domainRouterDao;
 
         _nuageVspElement.configure("NuageVspTestElement", Collections.<String, Object>emptyMap());
     }
@@ -314,6 +318,7 @@ public class NuageVspElementTest extends NuageTest {
         when(vpc.getState()).thenReturn(Vpc.State.Inactive);
         when(vpc.getDomainId()).thenReturn(NETWORK_ID);
         when(vpc.getZoneId()).thenReturn(NETWORK_ID);
+        when(vpc.getId()).thenReturn(NETWORK_ID);
 
         final DomainVO dom = mock(DomainVO.class);
         when(dom.getName()).thenReturn("domain");
@@ -333,9 +338,13 @@ public class NuageVspElementTest extends NuageTest {
         when(host.getId()).thenReturn(NETWORK_ID);
         final NuageVspDeviceVO nuageVspDevice = mock(NuageVspDeviceVO.class);
         when(nuageVspDevice.getHostId()).thenReturn(NETWORK_ID);
-        when(_nuageVspDao.listByPhysicalNetwork(NETWORK_ID)).thenReturn(Arrays.asList(new
NuageVspDeviceVO[]{nuageVspDevice}));
+        when(_nuageVspDao.listByPhysicalNetwork(NETWORK_ID)).thenReturn(Lists.newArrayList(nuageVspDevice));
         when(_hostDao.findById(NETWORK_ID)).thenReturn(host);
 
+        DomainRouterVO domainRouter = mock(DomainRouterVO.class);
+        when(domainRouter.getUuid()).thenReturn("aaaaaa");
+        when(_domainRouterDao.listByVpcId(NETWORK_ID)).thenReturn(Lists.newArrayList(domainRouter));
+
         final Answer answer = mock(Answer.class);
         when(answer.getResult()).thenReturn(true);
         when(_agentManager.easySend(eq(NETWORK_ID), (Command)any())).thenReturn(answer);

http://git-wip-us.apache.org/repos/asf/cloudstack/blob/4b617994/plugins/network-elements/nuage-vsp/test/com/cloud/network/resource/NuageVspResourceTest.java
----------------------------------------------------------------------
diff --git a/plugins/network-elements/nuage-vsp/test/com/cloud/network/resource/NuageVspResourceTest.java
b/plugins/network-elements/nuage-vsp/test/com/cloud/network/resource/NuageVspResourceTest.java
index 9c51864..66d2632 100644
--- a/plugins/network-elements/nuage-vsp/test/com/cloud/network/resource/NuageVspResourceTest.java
+++ b/plugins/network-elements/nuage-vsp/test/com/cloud/network/resource/NuageVspResourceTest.java
@@ -223,8 +223,8 @@ public class NuageVspResourceTest extends NuageTest {
     public void testShutDownVpcVspCommand() throws Exception {
         _resource.configure("NuageVspResource", _hostDetails);
 
-        ShutDownVpcVspCommand cmd = new ShutDownVpcVspCommand("domainUuid", "vpcUuid", "domainTemplateName");
-        doAnswer(genericAnswer).when(_mockNuageVspElementClient).shutdownVpc("domainUuid",
"vpcUuid", "domainTemplateName");
+        ShutDownVpcVspCommand cmd = new ShutDownVpcVspCommand("domainUuid", "vpcUuid", "domainTemplateName",
Lists.<String>newArrayList());
+        doAnswer(genericAnswer).when(_mockNuageVspElementClient).shutdownVpc("domainUuid",
"vpcUuid", "domainTemplateName", Lists.<String>newArrayList());
         Answer shutVpcAns = _resource.executeRequest(cmd);
         assertTrue(shutVpcAns.getResult());
     }


Mime
View raw message