cloudstack-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From muralire...@apache.org
Subject [1/2] git commit: updated refs/heads/4.3 to b6698f3
Date Mon, 13 Jan 2014 17:55:32 GMT
Updated Branches:
  refs/heads/4.3 6bb15a000 -> b6698f354


CLOUDSTACK-5861: networks that failed to implement can not be destroyed

introduces a force option in delete network to forcifully delete a
network. This comes handy in rare cases where network fails to implenet
and network is in shutdown state, but network shutdown to rollback
implement process fails as well.


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

Branch: refs/heads/4.3
Commit: b6698f354cbda8c7cbafa84be40a86e39ca7d857
Parents: e1a15ea
Author: Murali Reddy <muralimmreddy@gmail.com>
Authored: Mon Jan 13 23:20:54 2014 +0530
Committer: Murali Reddy <muralimmreddy@gmail.com>
Committed: Mon Jan 13 23:24:12 2014 +0530

----------------------------------------------------------------------
 api/src/com/cloud/network/NetworkService.java                | 2 +-
 .../api/command/user/network/DeleteNetworkCmd.java           | 8 +++++++-
 .../orchestration/service/NetworkOrchestrationService.java   | 2 +-
 .../cloudstack/engine/orchestration/NetworkOrchestrator.java | 4 ++--
 .../network/contrail/management/NetworkProviderTest.java     | 2 +-
 server/src/com/cloud/network/NetworkServiceImpl.java         | 8 ++++++--
 server/src/com/cloud/network/vpc/VpcManagerImpl.java         | 2 +-
 server/src/com/cloud/user/AccountManagerImpl.java            | 2 +-
 server/src/com/cloud/user/DomainManagerImpl.java             | 2 +-
 server/test/com/cloud/vpc/MockNetworkManagerImpl.java        | 4 ++--
 10 files changed, 23 insertions(+), 13 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/cloudstack/blob/b6698f35/api/src/com/cloud/network/NetworkService.java
----------------------------------------------------------------------
diff --git a/api/src/com/cloud/network/NetworkService.java b/api/src/com/cloud/network/NetworkService.java
index 1b805a6..b2b5053 100755
--- a/api/src/com/cloud/network/NetworkService.java
+++ b/api/src/com/cloud/network/NetworkService.java
@@ -66,7 +66,7 @@ public interface NetworkService {
 
     Pair<List<? extends Network>, Integer> searchForNetworks(ListNetworksCmd
cmd);
 
-    boolean deleteNetwork(long networkId);
+    boolean deleteNetwork(long networkId, boolean forced);
 
     boolean restartNetwork(RestartNetworkCmd cmd, boolean cleanup) throws ConcurrentOperationException,
     ResourceUnavailableException, InsufficientCapacityException;

http://git-wip-us.apache.org/repos/asf/cloudstack/blob/b6698f35/api/src/org/apache/cloudstack/api/command/user/network/DeleteNetworkCmd.java
----------------------------------------------------------------------
diff --git a/api/src/org/apache/cloudstack/api/command/user/network/DeleteNetworkCmd.java
b/api/src/org/apache/cloudstack/api/command/user/network/DeleteNetworkCmd.java
index 6e1b380..4a749a4 100644
--- a/api/src/org/apache/cloudstack/api/command/user/network/DeleteNetworkCmd.java
+++ b/api/src/org/apache/cloudstack/api/command/user/network/DeleteNetworkCmd.java
@@ -46,6 +46,9 @@ public class DeleteNetworkCmd extends BaseAsyncCmd{
             required=true, description="the ID of the network")
     private Long id;
 
+    @Parameter(name = ApiConstants.FORCED, type = CommandType.BOOLEAN, required = false,
description = "Force delete a network." +
+            " Network will be marked as 'Destroy' even when commands to shutdown and cleanup
to the backend fails.")
+    private Boolean forced;
 
     /////////////////////////////////////////////////////
     /////////////////// Accessors ///////////////////////
@@ -55,6 +58,9 @@ public class DeleteNetworkCmd extends BaseAsyncCmd{
         return id;
     }
 
+    public boolean isForced() {
+        return (forced != null) ? forced : false;
+    }
 
     /////////////////////////////////////////////////////
     /////////////// API Implementation///////////////////
@@ -68,7 +74,7 @@ public class DeleteNetworkCmd extends BaseAsyncCmd{
     @Override
     public void execute(){
         CallContext.current().setEventDetails("Network Id: " + id);
-        boolean result = _networkService.deleteNetwork(id);
+        boolean result = _networkService.deleteNetwork(id, isForced());
         if (result) {
             SuccessResponse response = new SuccessResponse(getCommandName());
             this.setResponseObject(response);

http://git-wip-us.apache.org/repos/asf/cloudstack/blob/b6698f35/engine/api/src/org/apache/cloudstack/engine/orchestration/service/NetworkOrchestrationService.java
----------------------------------------------------------------------
diff --git a/engine/api/src/org/apache/cloudstack/engine/orchestration/service/NetworkOrchestrationService.java
b/engine/api/src/org/apache/cloudstack/engine/orchestration/service/NetworkOrchestrationService.java
index 173feef..2559167 100755
--- a/engine/api/src/org/apache/cloudstack/engine/orchestration/service/NetworkOrchestrationService.java
+++ b/engine/api/src/org/apache/cloudstack/engine/orchestration/service/NetworkOrchestrationService.java
@@ -123,7 +123,7 @@ public interface NetworkOrchestrationService {
 
     boolean shutdownNetwork(long networkId, ReservationContext context, boolean cleanupElements);
 
-    boolean destroyNetwork(long networkId, ReservationContext context);
+    boolean destroyNetwork(long networkId, ReservationContext context, boolean forced);
 
     Network createGuestNetwork(long networkOfferingId, String name, String displayText, String
gateway, String cidr, String vlanId, String networkDomain, Account owner,
         Long domainId, PhysicalNetwork physicalNetwork, long zoneId, ACLType aclType, Boolean
subdomainAccess, Long vpcId, String ip6Gateway, String ip6Cidr,

http://git-wip-us.apache.org/repos/asf/cloudstack/blob/b6698f35/engine/orchestration/src/org/apache/cloudstack/engine/orchestration/NetworkOrchestrator.java
----------------------------------------------------------------------
diff --git a/engine/orchestration/src/org/apache/cloudstack/engine/orchestration/NetworkOrchestrator.java
b/engine/orchestration/src/org/apache/cloudstack/engine/orchestration/NetworkOrchestrator.java
index bb02cc9..3cf93cd 100755
--- a/engine/orchestration/src/org/apache/cloudstack/engine/orchestration/NetworkOrchestrator.java
+++ b/engine/orchestration/src/org/apache/cloudstack/engine/orchestration/NetworkOrchestrator.java
@@ -2070,7 +2070,7 @@ public class NetworkOrchestrator extends ManagerBase implements NetworkOrchestra
 
     @Override
     @DB
-    public boolean destroyNetwork(long networkId, final ReservationContext context) {
+    public boolean destroyNetwork(long networkId, final ReservationContext context, boolean
forced) {
         final Account callerAccount = context.getAccount();
 
         NetworkVO network = _networksDao.findById(networkId);
@@ -2113,7 +2113,7 @@ public class NetworkOrchestrator extends ManagerBase implements NetworkOrchestra
 
         // get updated state for the network
         network = _networksDao.findById(networkId);
-        if (network.getState() != Network.State.Allocated && network.getState() !=
Network.State.Setup) {
+        if (network.getState() != Network.State.Allocated && network.getState() !=
Network.State.Setup && !forced) {
             s_logger.debug("Network is not not in the correct state to be destroyed: " +
network.getState());
             return false;
         }

http://git-wip-us.apache.org/repos/asf/cloudstack/blob/b6698f35/plugins/network-elements/juniper-contrail/test/org/apache/cloudstack/network/contrail/management/NetworkProviderTest.java
----------------------------------------------------------------------
diff --git a/plugins/network-elements/juniper-contrail/test/org/apache/cloudstack/network/contrail/management/NetworkProviderTest.java
b/plugins/network-elements/juniper-contrail/test/org/apache/cloudstack/network/contrail/management/NetworkProviderTest.java
index 86e973e..930ac4d 100644
--- a/plugins/network-elements/juniper-contrail/test/org/apache/cloudstack/network/contrail/management/NetworkProviderTest.java
+++ b/plugins/network-elements/juniper-contrail/test/org/apache/cloudstack/network/contrail/management/NetworkProviderTest.java
@@ -177,7 +177,7 @@ public class NetworkProviderTest extends TestCase {
                 _networkService.getIsolatedNetworksOwnedByAccountInZone(zone.getId(), system);
         for (Network net : list) {
             s_logger.debug("Delete network " + net.getName());
-            _networkService.deleteNetwork(net.getId());
+            _networkService.deleteNetwork(net.getId(), false);
         }
     }
 

http://git-wip-us.apache.org/repos/asf/cloudstack/blob/b6698f35/server/src/com/cloud/network/NetworkServiceImpl.java
----------------------------------------------------------------------
diff --git a/server/src/com/cloud/network/NetworkServiceImpl.java b/server/src/com/cloud/network/NetworkServiceImpl.java
index 11313d5..d4310d4 100755
--- a/server/src/com/cloud/network/NetworkServiceImpl.java
+++ b/server/src/com/cloud/network/NetworkServiceImpl.java
@@ -1770,7 +1770,7 @@ public class NetworkServiceImpl extends ManagerBase implements NetworkService
{
 
     @Override
     @ActionEvent(eventType = EventTypes.EVENT_NETWORK_DELETE, eventDescription = "deleting
network", async = true)
-    public boolean deleteNetwork(long networkId) {
+    public boolean deleteNetwork(long networkId, boolean forced) {
 
         Account caller = CallContext.current().getCallingAccount();
 
@@ -1796,10 +1796,14 @@ public class NetworkServiceImpl extends ManagerBase implements NetworkService
{
         // Perform permission check
         _accountMgr.checkAccess(caller, null, true, network);
 
+        if (forced && !_accountMgr.isRootAdmin(caller.getType())) {
+            throw new InvalidParameterValueException("Delete network with 'forced' option
can only be called by root admins");
+        }
+
         User callerUser = _accountMgr.getActiveUser(CallContext.current().getCallingUserId());
         ReservationContext context = new ReservationContextImpl(null, null, callerUser, owner);
 
-        return _networkMgr.destroyNetwork(networkId, context);
+        return _networkMgr.destroyNetwork(networkId, context, forced);
     }
 
     @Override

http://git-wip-us.apache.org/repos/asf/cloudstack/blob/b6698f35/server/src/com/cloud/network/vpc/VpcManagerImpl.java
----------------------------------------------------------------------
diff --git a/server/src/com/cloud/network/vpc/VpcManagerImpl.java b/server/src/com/cloud/network/vpc/VpcManagerImpl.java
index c34ad23..b9dd729 100644
--- a/server/src/com/cloud/network/vpc/VpcManagerImpl.java
+++ b/server/src/com/cloud/network/vpc/VpcManagerImpl.java
@@ -1605,7 +1605,7 @@ public class VpcManagerImpl extends ManagerBase implements VpcManager,
VpcProvis
                     User callerUser = _accountMgr.getActiveUser(CallContext.current().getCallingUserId());
                     Account owner = _accountMgr.getAccount(Account.ACCOUNT_ID_SYSTEM);
                     ReservationContext context = new ReservationContextImpl(null, null, callerUser,
owner);
-                    _ntwkMgr.destroyNetwork(networkId, context);
+                    _ntwkMgr.destroyNetwork(networkId, context, false);
                     s_logger.debug("Deleted private network id=" + networkId);
                 }
 

http://git-wip-us.apache.org/repos/asf/cloudstack/blob/b6698f35/server/src/com/cloud/user/AccountManagerImpl.java
----------------------------------------------------------------------
diff --git a/server/src/com/cloud/user/AccountManagerImpl.java b/server/src/com/cloud/user/AccountManagerImpl.java
index 22abf78..0655f8c 100755
--- a/server/src/com/cloud/user/AccountManagerImpl.java
+++ b/server/src/com/cloud/user/AccountManagerImpl.java
@@ -679,7 +679,7 @@ public class AccountManagerImpl extends ManagerBase implements AccountManager,
M
 
                     ReservationContext context = new ReservationContextImpl(null, null, getActiveUser(callerUserId),
caller);
 
-                    if (!_networkMgr.destroyNetwork(network.getId(), context)) {
+                    if (!_networkMgr.destroyNetwork(network.getId(), context, false)) {
                         s_logger.warn("Unable to destroy network " + network + " as a part
of account id=" + accountId + " cleanup.");
                         accountCleanupNeeded = true;
                         networksDeleted = false;

http://git-wip-us.apache.org/repos/asf/cloudstack/blob/b6698f35/server/src/com/cloud/user/DomainManagerImpl.java
----------------------------------------------------------------------
diff --git a/server/src/com/cloud/user/DomainManagerImpl.java b/server/src/com/cloud/user/DomainManagerImpl.java
index 8416645..036110b 100644
--- a/server/src/com/cloud/user/DomainManagerImpl.java
+++ b/server/src/com/cloud/user/DomainManagerImpl.java
@@ -390,7 +390,7 @@ public class DomainManagerImpl extends ManagerBase implements DomainManager,
Dom
         for (Long networkId : networkIds) {
             s_logger.debug("Deleting network id=" + networkId + " as a part of domain id="
+ domainId + " cleanup");
             
-            if (!_networkMgr.destroyNetwork(networkId, context)) {
+            if (!_networkMgr.destroyNetwork(networkId, context, false)) {
                 s_logger.warn("Unable to destroy network id=" + networkId + " as a part of
domain id=" + domainId + " cleanup.");
                 networksDeleted = false;
             } else {

http://git-wip-us.apache.org/repos/asf/cloudstack/blob/b6698f35/server/test/com/cloud/vpc/MockNetworkManagerImpl.java
----------------------------------------------------------------------
diff --git a/server/test/com/cloud/vpc/MockNetworkManagerImpl.java b/server/test/com/cloud/vpc/MockNetworkManagerImpl.java
index 9eda6b9..130a8ae 100644
--- a/server/test/com/cloud/vpc/MockNetworkManagerImpl.java
+++ b/server/test/com/cloud/vpc/MockNetworkManagerImpl.java
@@ -237,7 +237,7 @@ public class MockNetworkManagerImpl extends ManagerBase implements NetworkOrches
      * @see com.cloud.network.NetworkService#deleteNetwork(long)
      */
     @Override
-    public boolean deleteNetwork(long networkId) {
+    public boolean deleteNetwork(long networkId, boolean forced) {
         // TODO Auto-generated method stub
         return false;
     }
@@ -792,7 +792,7 @@ public class MockNetworkManagerImpl extends ManagerBase implements NetworkOrches
      * @see com.cloud.network.NetworkManager#destroyNetwork(long, com.cloud.vm.ReservationContext)
      */
     @Override
-    public boolean destroyNetwork(long networkId, ReservationContext context) {
+    public boolean destroyNetwork(long networkId, ReservationContext context, boolean forced)
{
         // TODO Auto-generated method stub
         return false;
     }


Mime
View raw message