cloudstack-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From d...@apache.org
Subject git commit: updated refs/heads/4.4 to ce334b4
Date Thu, 12 Jun 2014 11:43:57 GMT
Repository: cloudstack
Updated Branches:
  refs/heads/4.4 1c17df853 -> ce334b4ee


CLOUDSTACK-6791 Fixed the issue

(cherry picked from commit 62cc238e1276bad1af7934fe5c150fe801b89140)


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

Branch: refs/heads/4.4
Commit: ce334b4ee58a8da0d75c52521c7e5080ceb429d6
Parents: 1c17df8
Author: Santhosh Edukulla <santhosh.edukulla@gmail.com>
Authored: Thu Jun 12 16:22:32 2014 +0530
Committer: Daan Hoogland <daan@onecht.net>
Committed: Thu Jun 12 13:43:44 2014 +0200

----------------------------------------------------------------------
 .../cloud/network/guru/DirectNetworkGuru.java   | 51 ++++++++++++--------
 1 file changed, 31 insertions(+), 20 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/cloudstack/blob/ce334b4e/server/src/com/cloud/network/guru/DirectNetworkGuru.java
----------------------------------------------------------------------
diff --git a/server/src/com/cloud/network/guru/DirectNetworkGuru.java b/server/src/com/cloud/network/guru/DirectNetworkGuru.java
index e570ddd..d558a57 100755
--- a/server/src/com/cloud/network/guru/DirectNetworkGuru.java
+++ b/server/src/com/cloud/network/guru/DirectNetworkGuru.java
@@ -21,6 +21,7 @@ import java.util.List;
 import javax.ejb.Local;
 import javax.inject.Inject;
 
+import com.cloud.utils.exception.CloudRuntimeException;
 import org.apache.log4j.Logger;
 
 import org.apache.cloudstack.engine.orchestration.service.NetworkOrchestrationService;
@@ -47,10 +48,6 @@ import com.cloud.network.NetworkProfile;
 import com.cloud.network.Networks.BroadcastDomainType;
 import com.cloud.network.Networks.Mode;
 import com.cloud.network.Networks.TrafficType;
-import com.cloud.network.dao.IPAddressDao;
-import com.cloud.network.dao.IPAddressVO;
-import com.cloud.network.dao.NetworkVO;
-import com.cloud.network.dao.UserIpv6AddressDao;
 import com.cloud.offering.NetworkOffering;
 import com.cloud.offerings.dao.NetworkOfferingDao;
 import com.cloud.user.Account;
@@ -70,6 +67,11 @@ import com.cloud.vm.VirtualMachine;
 import com.cloud.vm.VirtualMachineProfile;
 import com.cloud.vm.dao.NicDao;
 import com.cloud.vm.dao.NicSecondaryIpDao;
+import com.cloud.network.dao.IPAddressDao;
+import com.cloud.network.dao.IPAddressVO;
+import com.cloud.network.dao.NetworkVO;
+import com.cloud.network.dao.UserIpv6AddressDao;
+
 
 @Local(value = {NetworkGuru.class})
 public class DirectNetworkGuru extends AdapterBase implements NetworkGuru {
@@ -323,24 +325,33 @@ public class DirectNetworkGuru extends AdapterBase implements NetworkGuru
{
     @DB
     public boolean trash(Network network, NetworkOffering offering) {
         //Have to remove all placeholder nics
-        final List<NicVO> nics = _nicDao.listPlaceholderNicsByNetworkId(network.getId());
-        Transaction.execute(new TransactionCallbackNoReturn() {
-            @Override
-            public void doInTransactionWithoutResult(TransactionStatus status) {
-                for (Nic nic : nics) {
-                    if (nic.getIp4Address() != null) {
-                        s_logger.debug("Releasing ip " + nic.getIp4Address() + " of placeholder
nic " + nic);
-                        IPAddressVO ip = _ipAddressDao.findByIpAndSourceNetworkId(nic.getNetworkId(),
nic.getIp4Address());
-                        _ipAddrMgr.markIpAsUnavailable(ip.getId());
-                        _ipAddressDao.unassignIpAddress(ip.getId());
-                        s_logger.debug("Removing placeholder nic " + nic);
-                        _nicDao.remove(nic.getId());
+        try {
+            long id = network.getId();
+            final List<NicVO> nics = _nicDao.listPlaceholderNicsByNetworkId(id);
+            if (nics != null) {
+                Transaction.execute(new TransactionCallbackNoReturn() {
+                    @Override
+                    public void doInTransactionWithoutResult(TransactionStatus status) {
+                        for (Nic nic : nics) {
+                            if (nic.getIp4Address() != null) {
+                                s_logger.debug("Releasing ip " + nic.getIp4Address() + "
of placeholder nic " + nic);
+                                IPAddressVO ip = _ipAddressDao.findByIpAndSourceNetworkId(nic.getNetworkId(),
nic.getIp4Address());
+                                if (ip != null) {
+                                    _ipAddrMgr.markIpAsUnavailable(ip.getId());
+                                    _ipAddressDao.unassignIpAddress(ip.getId());
+                                    s_logger.debug("Removing placeholder nic " + nic);
+                                    _nicDao.remove(nic.getId());
+                                }
+                            }
+                        }
                     }
-                }
+                });
             }
-        });
-
-        return true;
+            return true;
+        }catch (Exception e) {
+            s_logger.error("trash. Exception:" + e.getMessage());
+            throw new CloudRuntimeException("trash. Exception:" + e.getMessage(),e);
+        }
     }
 
     @Override


Mime
View raw message