cloudstack-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From muralire...@apache.org
Subject git commit: updated refs/heads/4.4-forward to 62cc238
Date Thu, 12 Jun 2014 11:17:49 GMT
Repository: cloudstack
Updated Branches:
  refs/heads/4.4-forward 9e4e62466 -> 62cc238e1


CLOUDSTACK-6791 Fixed the issue


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

Branch: refs/heads/4.4-forward
Commit: 62cc238e1276bad1af7934fe5c150fe801b89140
Parents: 9e4e624
Author: Santhosh Edukulla <santhosh.edukulla@gmail.com>
Authored: Thu Jun 12 16:22:32 2014 +0530
Committer: Murali Reddy <muralimmreddy@gmail.com>
Committed: Thu Jun 12 16:47:13 2014 +0530

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


http://git-wip-us.apache.org/repos/asf/cloudstack/blob/62cc238e/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