You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@cloudstack.apache.org by mu...@apache.org on 2014/06/12 13:19:04 UTC
git commit: updated refs/heads/master to 93c75c7
Repository: cloudstack
Updated Branches:
refs/heads/master f4d4e3ffe -> 93c75c73a
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/93c75c73
Tree: http://git-wip-us.apache.org/repos/asf/cloudstack/tree/93c75c73
Diff: http://git-wip-us.apache.org/repos/asf/cloudstack/diff/93c75c73
Branch: refs/heads/master
Commit: 93c75c73a4c6f634c52ddf703301f24a04a4658d
Parents: f4d4e3f
Author: Santhosh Edukulla <sa...@gmail.com>
Authored: Thu Jun 12 16:22:32 2014 +0530
Committer: Murali Reddy <mu...@gmail.com>
Committed: Thu Jun 12 16:48:44 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/93c75c73/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