You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@cloudstack.apache.org by mc...@apache.org on 2013/08/21 00:59:55 UTC

git commit: updated refs/heads/master to e65a302

Updated Branches:
  refs/heads/master bcd36508d -> e65a302f1


CLOUDSTACK-3950: add "regionsecondaryenabled" in listCapabilitiesCmd
response.


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

Branch: refs/heads/master
Commit: e65a302f15ac4abefd2757ae78c30126f4d4bd7b
Parents: bcd3650
Author: Min Chen <mi...@citrix.com>
Authored: Tue Aug 20 15:59:18 2013 -0700
Committer: Min Chen <mi...@citrix.com>
Committed: Tue Aug 20 15:59:46 2013 -0700

----------------------------------------------------------------------
 .../user/config/ListCapabilitiesCmd.java        |   4 +-
 .../api/response/CapabilitiesResponse.java      |  10 +-
 .../storage/allocator/StorageAllocatorTest.java | 108 +++++++++----------
 3 files changed, 66 insertions(+), 56 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/cloudstack/blob/e65a302f/api/src/org/apache/cloudstack/api/command/user/config/ListCapabilitiesCmd.java
----------------------------------------------------------------------
diff --git a/api/src/org/apache/cloudstack/api/command/user/config/ListCapabilitiesCmd.java b/api/src/org/apache/cloudstack/api/command/user/config/ListCapabilitiesCmd.java
index a30e26c..90e0d41 100644
--- a/api/src/org/apache/cloudstack/api/command/user/config/ListCapabilitiesCmd.java
+++ b/api/src/org/apache/cloudstack/api/command/user/config/ListCapabilitiesCmd.java
@@ -18,10 +18,11 @@ package org.apache.cloudstack.api.command.user.config;
 
 import java.util.Map;
 
+import org.apache.log4j.Logger;
+
 import org.apache.cloudstack.api.APICommand;
 import org.apache.cloudstack.api.BaseCmd;
 import org.apache.cloudstack.api.response.CapabilitiesResponse;
-import org.apache.log4j.Logger;
 
 import com.cloud.user.Account;
 
@@ -52,6 +53,7 @@ public class ListCapabilitiesCmd extends BaseCmd {
         response.setProjectInviteRequired((Boolean)capabilities.get("projectInviteRequired"));
         response.setAllowUsersCreateProjects((Boolean)capabilities.get("allowusercreateprojects"));
         response.setDiskOffMaxSize((Long)capabilities.get("customDiskOffMaxSize"));
+        response.setRegionSecondaryEnabled((Boolean)capabilities.get("regionSecondaryEnabled"));
         if (capabilities.containsKey("apiLimitInterval")) {
             response.setApiLimitInterval((Integer) capabilities.get("apiLimitInterval"));
         }

http://git-wip-us.apache.org/repos/asf/cloudstack/blob/e65a302f/api/src/org/apache/cloudstack/api/response/CapabilitiesResponse.java
----------------------------------------------------------------------
diff --git a/api/src/org/apache/cloudstack/api/response/CapabilitiesResponse.java b/api/src/org/apache/cloudstack/api/response/CapabilitiesResponse.java
index c2996f0..2189ae0 100644
--- a/api/src/org/apache/cloudstack/api/response/CapabilitiesResponse.java
+++ b/api/src/org/apache/cloudstack/api/response/CapabilitiesResponse.java
@@ -16,11 +16,12 @@
 // under the License.
 package org.apache.cloudstack.api.response;
 
+import com.google.gson.annotations.SerializedName;
+
 import org.apache.cloudstack.api.ApiConstants;
 import org.apache.cloudstack.api.BaseResponse;
 
 import com.cloud.serializer.Param;
-import com.google.gson.annotations.SerializedName;
 
 @SuppressWarnings("unused")
 public class CapabilitiesResponse extends BaseResponse {
@@ -46,6 +47,9 @@ public class CapabilitiesResponse extends BaseResponse {
             "create disk from disk offering with custom size")
     private Long diskOffMaxSize;
 
+    @SerializedName("regionsecondaryenabled") @Param(description = "true if region wide secondary is enabled, false otherwise")
+    private boolean regionSecondaryEnabled;
+
     @SerializedName("apilimitinterval") @Param(description="time interval (in seconds) to reset api count")
     private Integer apiLimitInterval;
 
@@ -81,6 +85,10 @@ public class CapabilitiesResponse extends BaseResponse {
         this.diskOffMaxSize = diskOffMaxSize;
     }
 
+    public void setRegionSecondaryEnabled(boolean regionSecondaryEnabled){
+        this.regionSecondaryEnabled = regionSecondaryEnabled;
+    }
+
     public void setApiLimitInterval(Integer apiLimitInterval) {
         this.apiLimitInterval = apiLimitInterval;
     }

http://git-wip-us.apache.org/repos/asf/cloudstack/blob/e65a302f/engine/storage/integration-test/test/org/apache/cloudstack/storage/allocator/StorageAllocatorTest.java
----------------------------------------------------------------------
diff --git a/engine/storage/integration-test/test/org/apache/cloudstack/storage/allocator/StorageAllocatorTest.java b/engine/storage/integration-test/test/org/apache/cloudstack/storage/allocator/StorageAllocatorTest.java
index 2fc701a..2a57904 100644
--- a/engine/storage/integration-test/test/org/apache/cloudstack/storage/allocator/StorageAllocatorTest.java
+++ b/engine/storage/integration-test/test/org/apache/cloudstack/storage/allocator/StorageAllocatorTest.java
@@ -22,21 +22,8 @@ import java.util.UUID;
 
 import javax.inject.Inject;
 
-import com.cloud.configuration.Config;
-import com.cloud.configuration.ConfigurationVO;
-import com.cloud.configuration.dao.ConfigurationDao;
-import com.cloud.user.Account;
-import com.cloud.utils.db.DB;
-import com.cloud.vm.VMInstanceVO;
 import junit.framework.Assert;
 
-import org.apache.cloudstack.engine.subsystem.api.storage.DataStoreProvider;
-import org.apache.cloudstack.engine.subsystem.api.storage.DataStoreProviderManager;
-import org.apache.cloudstack.engine.subsystem.api.storage.StoragePoolAllocator;
-import org.apache.cloudstack.storage.datastore.db.PrimaryDataStoreDao;
-import org.apache.cloudstack.storage.datastore.db.StoragePoolDetailVO;
-import org.apache.cloudstack.storage.datastore.db.StoragePoolDetailsDao;
-import org.apache.cloudstack.storage.datastore.db.StoragePoolVO;
 import org.junit.Before;
 import org.junit.Test;
 import org.junit.runner.RunWith;
@@ -45,10 +32,21 @@ import org.mockito.Mockito;
 import org.springframework.test.context.ContextConfiguration;
 import org.springframework.test.context.junit4.SpringJUnit4ClassRunner;
 
+import org.apache.cloudstack.engine.subsystem.api.storage.DataStoreProvider;
+import org.apache.cloudstack.engine.subsystem.api.storage.DataStoreProviderManager;
+import org.apache.cloudstack.engine.subsystem.api.storage.StoragePoolAllocator;
+import org.apache.cloudstack.framework.config.ConfigurationVO;
+import org.apache.cloudstack.framework.config.dao.ConfigurationDao;
+import org.apache.cloudstack.storage.datastore.db.PrimaryDataStoreDao;
+import org.apache.cloudstack.storage.datastore.db.StoragePoolDetailVO;
+import org.apache.cloudstack.storage.datastore.db.StoragePoolDetailsDao;
+import org.apache.cloudstack.storage.datastore.db.StoragePoolVO;
+
+import com.cloud.configuration.Config;
 import com.cloud.dc.ClusterVO;
+import com.cloud.dc.DataCenter.NetworkType;
 import com.cloud.dc.DataCenterVO;
 import com.cloud.dc.HostPodVO;
-import com.cloud.dc.DataCenter.NetworkType;
 import com.cloud.dc.dao.ClusterDao;
 import com.cloud.dc.dao.DataCenterDao;
 import com.cloud.dc.dao.HostPodDao;
@@ -60,15 +58,17 @@ import com.cloud.org.Cluster.ClusterType;
 import com.cloud.org.Managed.ManagedState;
 import com.cloud.storage.DiskOfferingVO;
 import com.cloud.storage.ScopeType;
+import com.cloud.storage.Storage.StoragePoolType;
 import com.cloud.storage.StorageManager;
 import com.cloud.storage.StoragePool;
 import com.cloud.storage.StoragePoolStatus;
 import com.cloud.storage.Volume;
 import com.cloud.storage.VolumeVO;
-import com.cloud.storage.Storage.StoragePoolType;
 import com.cloud.storage.dao.DiskOfferingDao;
 import com.cloud.storage.dao.VolumeDao;
+import com.cloud.user.Account;
 import com.cloud.utils.component.ComponentContext;
+import com.cloud.utils.db.DB;
 import com.cloud.vm.DiskProfile;
 import com.cloud.vm.VirtualMachineProfile;
 
@@ -361,45 +361,45 @@ public class StorageAllocatorTest {
 
     @Test
     public void testCLOUDSTACK3481() {
-      try {
-          createDb();
-
-          StoragePoolVO pool = storagePoolDao.findById(storagePoolId);
-          pool.setHypervisor(HypervisorType.KVM);
-          pool.setScope(ScopeType.ZONE);
-          pool.setClusterId(null);
-          pool.setPodId(null);
-          storagePoolDao.update(pool.getId(), pool);
-
-
-          DiskProfile profile = new DiskProfile(volume, diskOffering, HypervisorType.KVM);
-          VirtualMachineProfile vmProfile = Mockito.mock(VirtualMachineProfile.class);
-          Account account = Mockito.mock(Account.class);
-          Mockito.when(account.getAccountId()).thenReturn(1L);
-          Mockito.when(vmProfile.getHypervisorType()).thenReturn(HypervisorType.KVM);
-          Mockito.when(vmProfile.getOwner()).thenReturn(account);
-          Mockito.when(
-                  storageMgr.storagePoolHasEnoughSpace(Matchers.anyListOf(Volume.class),
-                          Matchers.any(StoragePool.class))).thenReturn(true);
-          Mockito.when(storageMgr.storagePoolHasEnoughIops(Matchers.anyListOf(Volume.class),
-                  Matchers.any(StoragePool.class))).thenReturn(true);
-          DeploymentPlan plan = new DataCenterDeployment(dcId, podId, clusterId, null, null, null);
-          int foundAcct = 0;
-          for (StoragePoolAllocator allocator : allocators) {
-              List<StoragePool> pools = allocator.allocateToPool(profile, vmProfile, plan, new ExcludeList(), 1);
-              if (!pools.isEmpty()) {
-                  Assert.assertEquals(pools.get(0).getId(), storage.getId());
-                  foundAcct++;
-              }
-          }
-
-          if (foundAcct > 1 || foundAcct == 0) {
-              Assert.fail();
-          }
-      } catch (Exception e) {
-          cleanDb();
-          Assert.fail();
-      }
+        try {
+            createDb();
+
+            StoragePoolVO pool = storagePoolDao.findById(storagePoolId);
+            pool.setHypervisor(HypervisorType.KVM);
+            pool.setScope(ScopeType.ZONE);
+            pool.setClusterId(null);
+            pool.setPodId(null);
+            storagePoolDao.update(pool.getId(), pool);
+
+
+            DiskProfile profile = new DiskProfile(volume, diskOffering, HypervisorType.KVM);
+            VirtualMachineProfile vmProfile = Mockito.mock(VirtualMachineProfile.class);
+            Account account = Mockito.mock(Account.class);
+            Mockito.when(account.getAccountId()).thenReturn(1L);
+            Mockito.when(vmProfile.getHypervisorType()).thenReturn(HypervisorType.KVM);
+            Mockito.when(vmProfile.getOwner()).thenReturn(account);
+            Mockito.when(
+                    storageMgr.storagePoolHasEnoughSpace(Matchers.anyListOf(Volume.class),
+                            Matchers.any(StoragePool.class))).thenReturn(true);
+            Mockito.when(storageMgr.storagePoolHasEnoughIops(Matchers.anyListOf(Volume.class),
+                    Matchers.any(StoragePool.class))).thenReturn(true);
+            DeploymentPlan plan = new DataCenterDeployment(dcId, podId, clusterId, null, null, null);
+            int foundAcct = 0;
+            for (StoragePoolAllocator allocator : allocators) {
+                List<StoragePool> pools = allocator.allocateToPool(profile, vmProfile, plan, new ExcludeList(), 1);
+                if (!pools.isEmpty()) {
+                    Assert.assertEquals(pools.get(0).getId(), storage.getId());
+                    foundAcct++;
+                }
+            }
+
+            if (foundAcct > 1 || foundAcct == 0) {
+                Assert.fail();
+            }
+        } catch (Exception e) {
+            cleanDb();
+            Assert.fail();
+        }
     }
 
     @Test