You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@cloudstack.apache.org by bh...@apache.org on 2014/11/26 14:21:21 UTC

[1/8] git commit: updated refs/heads/4.3 to 2b264e6

Repository: cloudstack
Updated Branches:
  refs/heads/4.3 67df5b9da -> 2b264e6b5


CLOUDSTACK-6269: [Simulator] Exception "Unable to send command"

Added fix for CLOUDSTACK-6269.More details inside the bug

Signed-off-by: Santhosh Edukulla <Sa...@citrix.com>
(cherry picked from commit 3060f884ab62d92ade9073a147dee204aba4a889)
Signed-off-by: Rohit Yadav <ro...@shapeblue.com>

Conflicts:
	plugins/hypervisors/simulator/src/com/cloud/agent/manager/MockVmManagerImpl.java


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

Branch: refs/heads/4.3
Commit: 7332ea8a1caa093ec5036098619d04317b269fd5
Parents: 67df5b9
Author: Santhosh Edukulla <Sa...@citrix.com>
Authored: Wed Mar 26 00:45:44 2014 +0530
Committer: Rohit Yadav <ro...@shapeblue.com>
Committed: Wed Nov 26 18:13:36 2014 +0530

----------------------------------------------------------------------
 .../com/cloud/agent/manager/MockVmManagerImpl.java  | 16 +++++++++++++++-
 1 file changed, 15 insertions(+), 1 deletion(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/cloudstack/blob/7332ea8a/plugins/hypervisors/simulator/src/com/cloud/agent/manager/MockVmManagerImpl.java
----------------------------------------------------------------------
diff --git a/plugins/hypervisors/simulator/src/com/cloud/agent/manager/MockVmManagerImpl.java b/plugins/hypervisors/simulator/src/com/cloud/agent/manager/MockVmManagerImpl.java
index 28e235e..6867470 100644
--- a/plugins/hypervisors/simulator/src/com/cloud/agent/manager/MockVmManagerImpl.java
+++ b/plugins/hypervisors/simulator/src/com/cloud/agent/manager/MockVmManagerImpl.java
@@ -16,6 +16,19 @@
 // under the License.
 package com.cloud.agent.manager;
 
+import java.util.HashMap;
+import java.util.List;
+import java.util.Map;
+import java.util.UUID;
+import java.util.concurrent.ConcurrentHashMap;
+
+import javax.ejb.Local;
+import javax.inject.Inject;
+import javax.naming.ConfigurationException;
+
+import com.cloud.network.VirtualNetworkApplianceService;
+import org.apache.log4j.Logger;
+import org.springframework.stereotype.Component;
 
 import com.cloud.agent.api.Answer;
 import com.cloud.agent.api.BumpUpPriorityCommand;
@@ -567,7 +580,8 @@ public class MockVmManagerImpl extends ManagerBase implements MockVmManager {
 
     @Override
     public GetDomRVersionAnswer getDomRVersion(GetDomRVersionCmd cmd) {
-        return new GetDomRVersionAnswer(cmd, null, null, null);
+        String template_version = "CloudStack Release "+ VirtualNetworkApplianceService._minVRVersion.toString();
+        return new GetDomRVersionAnswer(cmd, null, template_version, UUID.randomUUID().toString());
     }
 
     @Override


[5/8] git commit: updated refs/heads/4.3 to 2b264e6

Posted by bh...@apache.org.
CLOUDSTACK-6192: Return failure on StartCommand and PrepareForMigrationCommand
when connectPhysicalDisk fails, rather than continuing on

(cherry picked from commit fb0b2eb26731a6db00c65dcd799653a213475387)
Signed-off-by: Rohit Yadav <ro...@shapeblue.com>


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

Branch: refs/heads/4.3
Commit: a88c3dd8a4dd108aa434440c83d6ca5cc3985e83
Parents: c2c6ecf
Author: Marcus Sorensen <ma...@betterservers.com>
Authored: Tue Mar 4 14:18:51 2014 -0700
Committer: Rohit Yadav <ro...@shapeblue.com>
Committed: Wed Nov 26 18:21:20 2014 +0530

----------------------------------------------------------------------
 .../kvm/resource/LibvirtComputingResource.java       | 15 ++++++++++-----
 1 file changed, 10 insertions(+), 5 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/cloudstack/blob/a88c3dd8/plugins/hypervisors/kvm/src/com/cloud/hypervisor/kvm/resource/LibvirtComputingResource.java
----------------------------------------------------------------------
diff --git a/plugins/hypervisors/kvm/src/com/cloud/hypervisor/kvm/resource/LibvirtComputingResource.java b/plugins/hypervisors/kvm/src/com/cloud/hypervisor/kvm/resource/LibvirtComputingResource.java
index dbd2327..c65fed8 100755
--- a/plugins/hypervisors/kvm/src/com/cloud/hypervisor/kvm/resource/LibvirtComputingResource.java
+++ b/plugins/hypervisors/kvm/src/com/cloud/hypervisor/kvm/resource/LibvirtComputingResource.java
@@ -3075,7 +3075,7 @@ ServerResource {
 
         NicTO[] nics = vm.getNics();
 
-        boolean success = false;
+        boolean skipDisconnect = false;
 
         try {
             Connect conn = LibvirtConnection.getConnectionByVmName(vm.getName());
@@ -3091,13 +3091,16 @@ ServerResource {
                 }
             }
 
-            _storagePoolMgr.connectPhysicalDisksViaVmSpec(vm);
+            if (!_storagePoolMgr.connectPhysicalDisksViaVmSpec(vm)) {
+                skipDisconnect = true;
+                return new PrepareForMigrationAnswer(cmd, "failed to connect physical disks to host");
+            }
 
             synchronized (_vms) {
                 _vms.put(vm.getName(), State.Migrating);
             }
 
-            success = true;
+            skipDisconnect = true;
 
             return new PrepareForMigrationAnswer(cmd);
         } catch (LibvirtException e) {
@@ -3107,7 +3110,7 @@ ServerResource {
         } catch (URISyntaxException e) {
             return new PrepareForMigrationAnswer(cmd, e.toString());
         } finally {
-            if (!success) {
+            if (!skipDisconnect) {
                 _storagePoolMgr.disconnectPhysicalDisksViaVmSpec(vm);
             }
         }
@@ -3654,7 +3657,9 @@ ServerResource {
 
             createVbd(conn, vmSpec, vmName, vm);
 
-            _storagePoolMgr.connectPhysicalDisksViaVmSpec(vmSpec);
+            if (!_storagePoolMgr.connectPhysicalDisksViaVmSpec(vmSpec)) {
+                return new StartAnswer(cmd, "Failed to connect physical disks to host");
+            }
 
             createVifs(vmSpec, vm);
 


[6/8] git commit: updated refs/heads/4.3 to 2b264e6

Posted by bh...@apache.org.
CLOUDSTACK-6172: Volume is not retaining same uuid when migrating from one storage to another.

(cherry picked from commit 624139d8ef9ea9462ba81d2d3941ee5ac9467b20)
Signed-off-by: Rohit Yadav <ro...@shapeblue.com>


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

Branch: refs/heads/4.3
Commit: 77446d2716a4d174c4505123758310ba0fe48e2d
Parents: a88c3dd
Author: Sanjay Tripathi <sa...@citrix.com>
Authored: Wed Feb 26 14:41:48 2014 +0530
Committer: Rohit Yadav <ro...@shapeblue.com>
Committed: Wed Nov 26 18:23:04 2014 +0530

----------------------------------------------------------------------
 .../src/com/cloud/storage/dao/VolumeDao.java    |  8 ++++++++
 .../com/cloud/storage/dao/VolumeDaoImpl.java    | 20 ++++++++++++++++++++
 .../storage/volume/VolumeServiceImpl.java       |  1 +
 3 files changed, 29 insertions(+)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/cloudstack/blob/77446d27/engine/schema/src/com/cloud/storage/dao/VolumeDao.java
----------------------------------------------------------------------
diff --git a/engine/schema/src/com/cloud/storage/dao/VolumeDao.java b/engine/schema/src/com/cloud/storage/dao/VolumeDao.java
index 24ade51..47f1990 100755
--- a/engine/schema/src/com/cloud/storage/dao/VolumeDao.java
+++ b/engine/schema/src/com/cloud/storage/dao/VolumeDao.java
@@ -103,4 +103,12 @@ public interface VolumeDao extends GenericDao<VolumeVO, Long>, StateDao<Volume.S
      * @return the scope of the storage pool where the volume is present (ZONE/CLUSTER)
      */
     ScopeType getVolumeStoragePoolScope(long volumeId);
+
+    /***
+     * Updates the destVol uuid with srcVol uuid and sets the srcVol uuid as null.
+     * @param srcVolId
+     * @param destVolId
+     * @return returns true if transaction is successful.
+     */
+    boolean updateUuid(long srcVolId, long destVolId);
 }

http://git-wip-us.apache.org/repos/asf/cloudstack/blob/77446d27/engine/schema/src/com/cloud/storage/dao/VolumeDaoImpl.java
----------------------------------------------------------------------
diff --git a/engine/schema/src/com/cloud/storage/dao/VolumeDaoImpl.java b/engine/schema/src/com/cloud/storage/dao/VolumeDaoImpl.java
index 2fb9dba..697983c 100755
--- a/engine/schema/src/com/cloud/storage/dao/VolumeDaoImpl.java
+++ b/engine/schema/src/com/cloud/storage/dao/VolumeDaoImpl.java
@@ -555,6 +555,26 @@ public class VolumeDaoImpl extends GenericDaoBase<VolumeVO, Long> implements Vol
     }
 
     @Override
+    @DB
+    public boolean updateUuid(long srcVolId, long destVolId) {
+        TransactionLegacy txn = TransactionLegacy.currentTxn();
+        txn.start();
+        try {
+            VolumeVO srcVol = findById(srcVolId);
+            VolumeVO destVol = findById(destVolId);
+            String uuid = srcVol.getUuid();
+            srcVol.setUuid(null);
+            destVol.setUuid(uuid);
+            update(srcVolId, srcVol);
+            update(destVolId, destVol);
+        } catch (Exception e) {
+            throw new CloudRuntimeException("Unable to persist the sequence number for this host");
+        }
+        txn.commit();
+        return true;
+    }
+
+    @Override
     public ScopeType getVolumeStoragePoolScope(long volumeId) {
         // finding the storage scope where the volume is present
         TransactionLegacy txn = TransactionLegacy.currentTxn();

http://git-wip-us.apache.org/repos/asf/cloudstack/blob/77446d27/engine/storage/volume/src/org/apache/cloudstack/storage/volume/VolumeServiceImpl.java
----------------------------------------------------------------------
diff --git a/engine/storage/volume/src/org/apache/cloudstack/storage/volume/VolumeServiceImpl.java b/engine/storage/volume/src/org/apache/cloudstack/storage/volume/VolumeServiceImpl.java
index 4e07edd..18972ef 100644
--- a/engine/storage/volume/src/org/apache/cloudstack/storage/volume/VolumeServiceImpl.java
+++ b/engine/storage/volume/src/org/apache/cloudstack/storage/volume/VolumeServiceImpl.java
@@ -886,6 +886,7 @@ public class VolumeServiceImpl implements VolumeService {
             }
             srcVolume.processEvent(Event.OperationSuccessed);
             destVolume.processEvent(Event.OperationSuccessed, result.getAnswer());
+            _volumeDao.updateUuid(srcVolume.getId(), destVolume.getId());
             destroyVolume(srcVolume.getId());
             srcVolume = volFactory.getVolume(srcVolume.getId());
             AsyncCallFuture<VolumeApiResult> destroyFuture = expungeVolumeAsync(srcVolume);


[8/8] git commit: updated refs/heads/4.3 to 2b264e6

Posted by bh...@apache.org.
CLOUDSTACK-6020 ipv4 address can be a larger number then
Interger.MAX_VALUE
(cherry picked from commit b3829e54d6b7af426f797ffb9fa54b4cd2abffc0)

Signed-off-by: Rohit Yadav <ro...@shapeblue.com>


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

Branch: refs/heads/4.3
Commit: 2b264e6b57b90d6eb5d202c4fe72e64d867b3f9b
Parents: 11eab3d
Author: Daan Hoogland <da...@onecht.net>
Authored: Tue Feb 4 18:40:18 2014 +0100
Committer: Rohit Yadav <ro...@shapeblue.com>
Committed: Wed Nov 26 18:37:18 2014 +0530

----------------------------------------------------------------------
 utils/src/com/cloud/utils/net/Ip.java      |  2 +-
 utils/test/com/cloud/utils/net/IpTest.java | 43 +++++++++++++++++++++++++
 2 files changed, 44 insertions(+), 1 deletion(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/cloudstack/blob/2b264e6b/utils/src/com/cloud/utils/net/Ip.java
----------------------------------------------------------------------
diff --git a/utils/src/com/cloud/utils/net/Ip.java b/utils/src/com/cloud/utils/net/Ip.java
index 2cdfd9c..93972e7 100644
--- a/utils/src/com/cloud/utils/net/Ip.java
+++ b/utils/src/com/cloud/utils/net/Ip.java
@@ -56,7 +56,7 @@ public class Ip implements Serializable, Comparable<Ip> {
     }
     
     public boolean isIp4() {
-        return ip < Integer.MAX_VALUE;
+        return ip <= 2L * Integer.MAX_VALUE + 1;
     }
     
     public boolean isIp6() {

http://git-wip-us.apache.org/repos/asf/cloudstack/blob/2b264e6b/utils/test/com/cloud/utils/net/IpTest.java
----------------------------------------------------------------------
diff --git a/utils/test/com/cloud/utils/net/IpTest.java b/utils/test/com/cloud/utils/net/IpTest.java
new file mode 100644
index 0000000..48615d7
--- /dev/null
+++ b/utils/test/com/cloud/utils/net/IpTest.java
@@ -0,0 +1,43 @@
+// Licensed to the Apache Software Foundation (ASF) under one
+// or more contributor license agreements.  See the NOTICE file
+// distributed with this work for additional information
+// regarding copyright ownership.  The ASF licenses this file
+// to you under the Apache License, Version 2.0 (the
+// "License"); you may not use this file except in compliance
+// the License.  You may obtain a copy of the License at
+//
+// http://www.apache.org/licenses/LICENSE-2.0
+//
+// Unless required by applicable law or agreed to in writing,
+// software distributed under the License is distributed on an
+// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+// KIND, either express or implied.  See the License for the
+// specific language governing permissions and limitations
+// under the License.
+package com.cloud.utils.net;
+
+import static org.junit.Assert.assertEquals;
+
+import org.junit.Test;
+
+public class IpTest {
+
+    @Test
+    public void testUltimate() {
+        Ip max = new Ip(2L * Integer.MAX_VALUE +1 );
+        assertEquals("Maximal address not created", "255.255.255.255", max.addr());
+    }
+    @Test
+    public void testTurningOfTheCentury() {
+        Ip eve = new Ip(Integer.MAX_VALUE);
+        assertEquals("Minimal address not created", "127.255.255.255", eve.addr());
+        Ip dawn = new Ip(Integer.MAX_VALUE + 1L);
+        assertEquals("Minimal address not created", "128.0.0.0", dawn.addr());
+    }
+    @Test
+    public void testStart() {
+        Ip min = new Ip(0);
+        assertEquals("Minimal address not created", "0.0.0.0", min.addr());
+    }
+
+}


[2/8] git commit: updated refs/heads/4.3 to 2b264e6

Posted by bh...@apache.org.
CLOUDSTACK-6236:Negative ref_cnt of template(snapshot/volume)_store_ref results in out-of-range error in Mysql

(cherry picked from commit cd8af6a3e2a180ea4d2cfea8a273dbb0929e0a87)
Signed-off-by: Rohit Yadav <ro...@shapeblue.com>


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

Branch: refs/heads/4.3
Commit: 88ec08439dfc65178c56c365e276c0018ca03d6d
Parents: 7332ea8
Author: Min Chen <mi...@citrix.com>
Authored: Wed Mar 12 15:44:18 2014 -0700
Committer: Rohit Yadav <ro...@shapeblue.com>
Committed: Wed Nov 26 18:14:53 2014 +0530

----------------------------------------------------------------------
 .../storage/datastore/db/SnapshotDataStoreVO.java        | 11 ++++++++++-
 .../storage/datastore/db/TemplateDataStoreVO.java        | 11 ++++++++++-
 .../storage/datastore/db/VolumeDataStoreVO.java          | 11 ++++++++++-
 3 files changed, 30 insertions(+), 3 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/cloudstack/blob/88ec0843/engine/schema/src/org/apache/cloudstack/storage/datastore/db/SnapshotDataStoreVO.java
----------------------------------------------------------------------
diff --git a/engine/schema/src/org/apache/cloudstack/storage/datastore/db/SnapshotDataStoreVO.java b/engine/schema/src/org/apache/cloudstack/storage/datastore/db/SnapshotDataStoreVO.java
index db86c3f..7acc891 100644
--- a/engine/schema/src/org/apache/cloudstack/storage/datastore/db/SnapshotDataStoreVO.java
+++ b/engine/schema/src/org/apache/cloudstack/storage/datastore/db/SnapshotDataStoreVO.java
@@ -29,6 +29,8 @@ import javax.persistence.Table;
 import javax.persistence.Temporal;
 import javax.persistence.TemporalType;
 
+import org.apache.log4j.Logger;
+
 import org.apache.cloudstack.engine.subsystem.api.storage.DataObjectInStore;
 import org.apache.cloudstack.engine.subsystem.api.storage.ObjectInDataStoreStateMachine;
 import org.apache.cloudstack.engine.subsystem.api.storage.ObjectInDataStoreStateMachine.State;
@@ -44,6 +46,8 @@ import com.cloud.utils.fsm.StateObject;
 @Entity
 @Table(name = "snapshot_store_ref")
 public class SnapshotDataStoreVO implements StateObject<ObjectInDataStoreStateMachine.State>, DataObjectInStore {
+    private static final Logger s_logger = Logger.getLogger(SnapshotDataStoreVO.class);
+
     @Id
     @GeneratedValue(strategy = GenerationType.IDENTITY)
     Long id;
@@ -266,7 +270,12 @@ public class SnapshotDataStoreVO implements StateObject<ObjectInDataStoreStateMa
     }
 
     public void decrRefCnt() {
-        refCnt--;
+        if (refCnt > 0) {
+            refCnt--;
+        }
+        else {
+            s_logger.warn("We should not try to decrement a zero reference count even though our code has guarded");
+        }
     }
 
     public Long getVolumeId() {

http://git-wip-us.apache.org/repos/asf/cloudstack/blob/88ec0843/engine/schema/src/org/apache/cloudstack/storage/datastore/db/TemplateDataStoreVO.java
----------------------------------------------------------------------
diff --git a/engine/schema/src/org/apache/cloudstack/storage/datastore/db/TemplateDataStoreVO.java b/engine/schema/src/org/apache/cloudstack/storage/datastore/db/TemplateDataStoreVO.java
index a3696d8..af89ee5 100755
--- a/engine/schema/src/org/apache/cloudstack/storage/datastore/db/TemplateDataStoreVO.java
+++ b/engine/schema/src/org/apache/cloudstack/storage/datastore/db/TemplateDataStoreVO.java
@@ -29,6 +29,8 @@ import javax.persistence.Table;
 import javax.persistence.Temporal;
 import javax.persistence.TemporalType;
 
+import org.apache.log4j.Logger;
+
 import org.apache.cloudstack.engine.subsystem.api.storage.DataObjectInStore;
 import org.apache.cloudstack.engine.subsystem.api.storage.ObjectInDataStoreStateMachine;
 import org.apache.cloudstack.engine.subsystem.api.storage.ObjectInDataStoreStateMachine.State;
@@ -45,6 +47,8 @@ import com.cloud.utils.fsm.StateObject;
 @Entity
 @Table(name = "template_store_ref")
 public class TemplateDataStoreVO implements StateObject<ObjectInDataStoreStateMachine.State>, DataObjectInStore {
+    private static final Logger s_logger = Logger.getLogger(TemplateDataStoreVO.class);
+
     @Id
     @GeneratedValue(strategy = GenerationType.IDENTITY)
     Long id;
@@ -369,7 +373,12 @@ public class TemplateDataStoreVO implements StateObject<ObjectInDataStoreStateMa
     }
 
     public void decrRefCnt() {
-        refCnt--;
+        if (refCnt > 0) {
+            refCnt--;
+        }
+        else{
+            s_logger.warn("We should not try to decrement a zero reference count even though our code has guarded");
+        }
     }
 
 }

http://git-wip-us.apache.org/repos/asf/cloudstack/blob/88ec0843/engine/schema/src/org/apache/cloudstack/storage/datastore/db/VolumeDataStoreVO.java
----------------------------------------------------------------------
diff --git a/engine/schema/src/org/apache/cloudstack/storage/datastore/db/VolumeDataStoreVO.java b/engine/schema/src/org/apache/cloudstack/storage/datastore/db/VolumeDataStoreVO.java
index e34d4a6..bd15f1c 100755
--- a/engine/schema/src/org/apache/cloudstack/storage/datastore/db/VolumeDataStoreVO.java
+++ b/engine/schema/src/org/apache/cloudstack/storage/datastore/db/VolumeDataStoreVO.java
@@ -29,6 +29,8 @@ import javax.persistence.Table;
 import javax.persistence.Temporal;
 import javax.persistence.TemporalType;
 
+import org.apache.log4j.Logger;
+
 import org.apache.cloudstack.engine.subsystem.api.storage.DataObjectInStore;
 import org.apache.cloudstack.engine.subsystem.api.storage.ObjectInDataStoreStateMachine;
 import org.apache.cloudstack.engine.subsystem.api.storage.ObjectInDataStoreStateMachine.State;
@@ -44,6 +46,8 @@ import com.cloud.utils.fsm.StateObject;
 @Entity
 @Table(name = "volume_store_ref")
 public class VolumeDataStoreVO implements StateObject<ObjectInDataStoreStateMachine.State>, DataObjectInStore {
+    private static final Logger s_logger = Logger.getLogger(VolumeDataStoreVO.class);
+
     @Id
     @GeneratedValue(strategy = GenerationType.IDENTITY)
     Long id;
@@ -344,7 +348,12 @@ public class VolumeDataStoreVO implements StateObject<ObjectInDataStoreStateMach
     }
 
     public void setRefCnt(Long refCnt) {
-        this.refCnt = refCnt;
+        if (refCnt > 0) {
+            refCnt--;
+        }
+        else {
+            s_logger.warn("We should not try to decrement a zero reference count even though our code has guarded");
+        }
     }
 
     public void incrRefCnt() {


[4/8] git commit: updated refs/heads/4.3 to 2b264e6

Posted by bh...@apache.org.
CLOUDSTACK-6210: LDAP:listLdapUsers api throws exception when we click on "Add LDAP Account" This occurs when ldap basedn is not configured. Throwing an IAE and a proper message is returned from the api call

Signed-off-by: Ian Duffy <ia...@ianduffy.ie>
(cherry picked from commit 4552ec632201e7432afae7770f5854aaa244267c)
Signed-off-by: Rohit Yadav <ro...@shapeblue.com>

Conflicts:
	plugins/user-authenticators/ldap/src/org/apache/cloudstack/ldap/LdapUserManager.java


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

Branch: refs/heads/4.3
Commit: c2c6ecf828d85e3a5085ea28baed0ed9e1ba5d9e
Parents: 2534b54
Author: Rajani Karuturi <ra...@gmail.com>
Authored: Fri Mar 7 11:13:35 2014 +0530
Committer: Rohit Yadav <ro...@shapeblue.com>
Committed: Wed Nov 26 18:19:54 2014 +0530

----------------------------------------------------------------------
 .../apache/cloudstack/ldap/LdapUserManager.java |  10 +-
 .../cloudstack/ldap/LdapUserManagerSpec.groovy  | 263 ++++++++++---------
 2 files changed, 146 insertions(+), 127 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/cloudstack/blob/c2c6ecf8/plugins/user-authenticators/ldap/src/org/apache/cloudstack/ldap/LdapUserManager.java
----------------------------------------------------------------------
diff --git a/plugins/user-authenticators/ldap/src/org/apache/cloudstack/ldap/LdapUserManager.java b/plugins/user-authenticators/ldap/src/org/apache/cloudstack/ldap/LdapUserManager.java
index 59a41de..f80142f 100644
--- a/plugins/user-authenticators/ldap/src/org/apache/cloudstack/ldap/LdapUserManager.java
+++ b/plugins/user-authenticators/ldap/src/org/apache/cloudstack/ldap/LdapUserManager.java
@@ -25,6 +25,8 @@ import javax.naming.NamingEnumeration;
 import javax.naming.NamingException;
 import javax.naming.directory.*;
 
+import org.apache.commons.lang.StringUtils;
+
 public class LdapUserManager {
 
     @Inject
@@ -181,6 +183,10 @@ public class LdapUserManager {
 	controls.setSearchScope(_ldapConfiguration.getScope());
 	controls.setReturningAttributes(_ldapConfiguration.getReturnAttributes());
 
-	return context.search(_ldapConfiguration.getBaseDn(), generateSearchFilter(username), controls);
+        String basedn = _ldapConfiguration.getBaseDn();
+        if (StringUtils.isBlank(basedn)) {
+            throw new IllegalArgumentException("ldap basedn is not configured");
+        }
+        return context.search(basedn, generateSearchFilter(username), controls);
     }
-}
\ No newline at end of file
+}

http://git-wip-us.apache.org/repos/asf/cloudstack/blob/c2c6ecf8/plugins/user-authenticators/ldap/test/groovy/org/apache/cloudstack/ldap/LdapUserManagerSpec.groovy
----------------------------------------------------------------------
diff --git a/plugins/user-authenticators/ldap/test/groovy/org/apache/cloudstack/ldap/LdapUserManagerSpec.groovy b/plugins/user-authenticators/ldap/test/groovy/org/apache/cloudstack/ldap/LdapUserManagerSpec.groovy
index fa735d3..9fbc81f 100644
--- a/plugins/user-authenticators/ldap/test/groovy/org/apache/cloudstack/ldap/LdapUserManagerSpec.groovy
+++ b/plugins/user-authenticators/ldap/test/groovy/org/apache/cloudstack/ldap/LdapUserManagerSpec.groovy
@@ -21,10 +21,9 @@ import org.apache.cloudstack.ldap.LdapUserManager
 import spock.lang.Shared
 
 import javax.naming.NamingException
-import javax.naming.NamingEnumeration
 import javax.naming.directory.Attribute
 import javax.naming.directory.Attributes
-import javax.naming.directory.DirContext
+import javax.naming.directory.InitialDirContext
 import javax.naming.directory.SearchControls
 import javax.naming.directory.SearchResult
 import javax.naming.ldap.LdapContext
@@ -51,83 +50,83 @@ class LdapUserManagerSpec extends spock.lang.Specification {
 
     private def createGroupSearchContext() {
 
-	def umSearchResult = Mock(SearchResult)
-	umSearchResult.getName() >> principal;
-	umSearchResult.getAttributes() >> principal
+        def umSearchResult = Mock(SearchResult)
+        umSearchResult.getName() >> principal;
+        umSearchResult.getAttributes() >> principal
 
-	def uniqueMembers = new BasicNamingEnumerationImpl()
-	uniqueMembers.add(umSearchResult);
-	def attributes = Mock(Attributes)
-	def uniqueMemberAttribute = Mock(Attribute)
-	uniqueMemberAttribute.getId() >> "uniquemember"
-	uniqueMemberAttribute.getAll() >> uniqueMembers
-	attributes.get("uniquemember") >> uniqueMemberAttribute
+        def uniqueMembers = new BasicNamingEnumerationImpl()
+        uniqueMembers.add(umSearchResult);
+        def attributes = Mock(Attributes)
+        def uniqueMemberAttribute = Mock(Attribute)
+        uniqueMemberAttribute.getId() >> "uniquemember"
+        uniqueMemberAttribute.getAll() >> uniqueMembers
+        attributes.get("uniquemember") >> uniqueMemberAttribute
 
-	def groupSearchResult = Mock(SearchResult)
-	groupSearchResult.getName() >> principal;
-	groupSearchResult.getAttributes() >> attributes
+        def groupSearchResult = Mock(SearchResult)
+        groupSearchResult.getName() >> principal;
+        groupSearchResult.getAttributes() >> attributes
 
-	def searchGroupResults = new BasicNamingEnumerationImpl()
-	searchGroupResults.add(groupSearchResult);
+        def searchGroupResults = new BasicNamingEnumerationImpl()
+        searchGroupResults.add(groupSearchResult);
 
-	attributes = createUserAttributes(username, email, firstname, lastname)
-	SearchResult userSearchResult = createSearchResult(attributes)
-	def searchUsersResults = new BasicNamingEnumerationImpl()
-	searchUsersResults.add(userSearchResult);
+        attributes = createUserAttributes(username, email, firstname, lastname)
+        SearchResult userSearchResult = createSearchResult(attributes)
+        def searchUsersResults = new BasicNamingEnumerationImpl()
+        searchUsersResults.add(userSearchResult);
 
-	def context = Mock(LdapContext)
-	context.search(_, _, _) >>> [searchGroupResults, searchUsersResults];
+        def context = Mock(LdapContext)
+        context.search(_, _, _) >>> [searchGroupResults, searchUsersResults];
 
-	return context
+        return context
     }
 
     private def createContext() {
-		Attributes attributes = createUserAttributes(username, email, firstname, lastname)
-		SearchResult searchResults = createSearchResult(attributes)
-		def searchUsersResults = new BasicNamingEnumerationImpl()
-		searchUsersResults.add(searchResults);
+        Attributes attributes = createUserAttributes(username, email, firstname, lastname)
+        SearchResult searchResults = createSearchResult(attributes)
+        def searchUsersResults = new BasicNamingEnumerationImpl()
+        searchUsersResults.add(searchResults);
 
-		def context = Mock(LdapContext)
-		context.search(_, _, _) >> searchUsersResults;
+        def context = Mock(LdapContext)
+        context.search(_, _, _) >> searchUsersResults;
 
-		return context
+        return context
     }
 
     private SearchResult createSearchResult(attributes) {
-		def search = Mock(SearchResult)
+        def search = Mock(SearchResult)
 
-		search.getName() >> "cn=" + attributes.getAt("uid").get();
+        search.getName() >> "cn=" + attributes.getAt("uid").get();
 
-		search.getAttributes() >> attributes
-	search.getNameInNamespace() >> principal
+        search.getAttributes() >> attributes
+        search.getNameInNamespace() >> principal
 
-		return search
+        return search
     }
 
     private Attributes createUserAttributes(String username, String email, String firstname, String lastname) {
-		def attributes = Mock(Attributes)
+        def attributes = Mock(Attributes)
 
-		def nameAttribute = Mock(Attribute)
-		nameAttribute.getId() >> "uid"
-		nameAttribute.get() >> username
-		attributes.get("uid") >> nameAttribute
+        def nameAttribute = Mock(Attribute)
+        nameAttribute.getId() >> "uid"
+        nameAttribute.get() >> username
+        attributes.get("uid") >> nameAttribute
 
-		def mailAttribute = Mock(Attribute)
-		mailAttribute.getId() >> "mail"
-		mailAttribute.get() >> email
-		attributes.get("mail") >> mailAttribute
+        def mailAttribute = Mock(Attribute)
+        mailAttribute.getId() >> "mail"
+        mailAttribute.get() >> email
+        attributes.get("mail") >> mailAttribute
 
-		def givennameAttribute = Mock(Attribute)
-		givennameAttribute.getId() >> "givenname"
-		givennameAttribute.get() >> firstname
-		attributes.get("givenname") >> givennameAttribute
+        def givennameAttribute = Mock(Attribute)
+        givennameAttribute.getId() >> "givenname"
+        givennameAttribute.get() >> firstname
+        attributes.get("givenname") >> givennameAttribute
 
-		def snAttribute = Mock(Attribute)
-		snAttribute.getId() >> "sn"
-		snAttribute.get() >> lastname
-		attributes.get("sn") >> snAttribute
+        def snAttribute = Mock(Attribute)
+        snAttribute.getId() >> "sn"
+        snAttribute.get() >> lastname
+        attributes.get("sn") >> snAttribute
 
-		return attributes
+        return attributes
     }
 
     def setupSpec() {
@@ -140,144 +139,158 @@ class LdapUserManagerSpec extends spock.lang.Specification {
         ldapConfiguration.getFirstnameAttribute() >> "givenname"
         ldapConfiguration.getLastnameAttribute() >> "sn"
         ldapConfiguration.getBaseDn() >> "dc=cloudstack,dc=org"
-	ldapConfiguration.getCommonNameAttribute() >> "cn"
-	ldapConfiguration.getGroupObject() >> "groupOfUniqueNames"
-	ldapConfiguration.getGroupUniqueMemeberAttribute() >> "uniquemember"
+        ldapConfiguration.getCommonNameAttribute() >> "cn"
+        ldapConfiguration.getGroupObject() >> "groupOfUniqueNames"
+        ldapConfiguration.getGroupUniqueMemeberAttribute() >> "uniquemember"
 
         username = "rmurphy"
         email = "rmurphy@test.com"
         firstname = "Ryan"
         lastname = "Murphy"
-		principal = "cn=" + username + "," + ldapConfiguration.getBaseDn()
+        principal = "cn=" + username + "," + ldapConfiguration.getBaseDn()
     }
 
     def "Test successfully creating an Ldap User from Search result"() {
-		given: "We have attributes, a search and a user manager"
-		def attributes = createUserAttributes(username, email, firstname, lastname)
+        given: "We have attributes, a search and a user manager"
+        def attributes = createUserAttributes(username, email, firstname, lastname)
         def search = createSearchResult(attributes)
         def userManager = new LdapUserManager(ldapConfiguration)
         def result = userManager.createUser(search)
 
-		expect: "The crated user the data supplied from LDAP"
+        expect: "The crated user the data supplied from LDAP"
 
         result.username == username
         result.email == email
         result.firstname == firstname
         result.lastname == lastname
-		result.principal == principal
+        result.principal == principal
     }
 
     def "Test successfully returning a list from get users"() {
-		given: "We have a LdapUserManager"
+        given: "We have a LdapUserManager"
 
         def userManager = new LdapUserManager(ldapConfiguration)
 
-		when: "A request for users is made"
+        when: "A request for users is made"
         def result = userManager.getUsers(username, createContext())
 
-		then: "A list of users is returned"
+        then: "A list of users is returned"
         result.size() == 1
     }
 
     def "Test successfully returning a list from get users when no username is given"() {
-		given: "We have a LdapUserManager"
+        given: "We have a LdapUserManager"
 
         def userManager = new LdapUserManager(ldapConfiguration)
 
-		when: "Get users is called without a username"
+        when: "Get users is called without a username"
         def result = userManager.getUsers(createContext())
 
-		then: "All users are returned"
-		result.size() == 1
+        then: "All users are returned"
+        result.size() == 1
     }
 
     def "Test successfully returning a NamingEnumeration from searchUsers"() {
-		given: "We have a LdapUserManager"
-		def userManager = new LdapUserManager(ldapConfiguration)
+        given: "We have a LdapUserManager"
+        def userManager = new LdapUserManager(ldapConfiguration)
 
-		when: "We search for users"
+        when: "We search for users"
         def result = userManager.searchUsers(createContext())
 
-		then: "A list of users are returned."
+        then: "A list of users are returned."
         result.next().getName() + "," + ldapConfiguration.getBaseDn() == principal
     }
 
     def "Test successfully returning an Ldap user from a get user request"() {
-		given: "We have a LdapUserMaanger"
+        given: "We have a LdapUserMaanger"
 
-		def userManager = new LdapUserManager(ldapConfiguration)
+        def userManager = new LdapUserManager(ldapConfiguration)
 
-		when: "A request for a user is made"
-		def result = userManager.getUser(username, createContext())
+        when: "A request for a user is made"
+        def result = userManager.getUser(username, createContext())
 
-		then: "The user is returned"
-		result.username == username
-		result.email == email
-		result.firstname == firstname
-		result.lastname == lastname
-		result.principal == principal
+        then: "The user is returned"
+        result.username == username
+        result.email == email
+        result.firstname == firstname
+        result.lastname == lastname
+        result.principal == principal
     }
 
     def "Test successfully throwing an exception when no users are found with getUser"() {
-		given: "We have a seachResult of users and a User Manager"
+        given: "We have a seachResult of users and a User Manager"
 
-		def searchUsersResults = new BasicNamingEnumerationImpl()
+        def searchUsersResults = new BasicNamingEnumerationImpl()
 
-		def context = Mock(LdapContext)
-		context.search(_, _, _) >> searchUsersResults;
+        def context = Mock(LdapContext)
+        context.search(_, _, _) >> searchUsersResults;
 
-		def userManager = new LdapUserManager(ldapConfiguration)
+        def userManager = new LdapUserManager(ldapConfiguration)
 
-		when: "a get user request is made and no user is found"
-		def result = userManager.getUser(username, context)
+        when: "a get user request is made and no user is found"
+        def result = userManager.getUser(username, context)
 
-		then: "An exception is thrown."
-		thrown NamingException
+        then: "An exception is thrown."
+        thrown NamingException
     }
 
     def "Test that a newly created Ldap User Manager is not null"() {
-		given: "You have created a new Ldap user manager object"
-		def result = new LdapUserManager();
-		expect: "The result is not null"
-		result != null
+        given: "You have created a new Ldap user manager object"
+        def result = new LdapUserManager();
+        expect: "The result is not null"
+        result != null
     }
 
     def "test successful generateGroupSearchFilter"() {
-	given: "ldap user manager and ldap config"
-	def ldapUserManager = new LdapUserManager(ldapConfiguration)
-	def groupName = varGroupName == null ? "*" : varGroupName
-	def expectedResult = "(&(objectClass=groupOfUniqueNames)(cn="+groupName+"))";
-
-	def result = ldapUserManager.generateGroupSearchFilter(varGroupName)
-	expect:
-	result == expectedResult
-	where: "The group name passed is set to "
-	varGroupName << ["", null, "Murphy"]
+        given: "ldap user manager and ldap config"
+        def ldapUserManager = new LdapUserManager(ldapConfiguration)
+        def groupName = varGroupName == null ? "*" : varGroupName
+        def expectedResult = "(&(objectClass=groupOfUniqueNames)(cn=" + groupName + "))";
+
+        def result = ldapUserManager.generateGroupSearchFilter(varGroupName)
+        expect:
+        result == expectedResult
+        where: "The group name passed is set to "
+        varGroupName << ["", null, "Murphy"]
     }
 
-    def "test successful getUsersInGroup"(){
-	given: "ldap user manager and ldap config"
-	def ldapUserManager = new LdapUserManager(ldapConfiguration)
+    def "test successful getUsersInGroup"() {
+        given: "ldap user manager and ldap config"
+        def ldapUserManager = new LdapUserManager(ldapConfiguration)
+
+        when: "A request for users is made"
+        def result = ldapUserManager.getUsersInGroup("engineering", createGroupSearchContext())
+        then: "one user is returned"
+        result.size() == 1
+    }
+
+    def "test successful getUserForDn"() {
+        given: "ldap user manager and ldap config"
+        def ldapUserManager = new LdapUserManager(ldapConfiguration)
+
+        when: "A request for users is made"
+        def result = ldapUserManager.getUserForDn("cn=Ryan Murphy,ou=engineering,dc=cloudstack,dc=org", createContext())
+        then: "A list of users is returned"
+        result != 1
+        result.username == username
+        result.email == email
+        result.firstname == firstname
+        result.lastname == lastname
+        result.principal == principal
 
-	when: "A request for users is made"
-	def result = ldapUserManager.getUsersInGroup("engineering", createGroupSearchContext())
-	then: "one user is returned"
-	result.size() == 1
     }
 
-    def "test successful getUserForDn"(){
-	given: "ldap user manager and ldap config"
-	def ldapUserManager = new LdapUserManager(ldapConfiguration)
+    def "test searchUsers when ldap basedn in not set"() {
+        given: "ldap configuration where basedn is not set"
+        def ldapconfig = Mock(LdapConfiguration)
+        ldapconfig.getBaseDn() >> null
+        def ldapUserManager = new LdapUserManager(ldapconfig)
 
-	when: "A request for users is made"
-	def result = ldapUserManager.getUserForDn("cn=Ryan Murphy,ou=engineering,dc=cloudstack,dc=org",createContext())
-	then: "A list of users is returned"
-	result != 1
-	result.username == username
-	result.email == email
-	result.firstname == firstname
-	result.lastname == lastname
-	result.principal == principal
+        when: "A request for search users is made"
+        def result = ldapUserManager.searchUsers(new InitialDirContext())
 
+        then: "An exception with no basedn defined is returned"
+        def e = thrown(IllegalArgumentException)
+        e.message == "ldap basedn is not configured"
     }
 }


[7/8] git commit: updated refs/heads/4.3 to 2b264e6

Posted by bh...@apache.org.
CLOUDSTACK-6172: Adding new test case to verify this fix

Signed-off-by: Rohit Yadav <ro...@shapeblue.com>

Conflicts:

	test/integration/component/test_volumes.py

Signed-off-by: sanjeev <sa...@apache.org>

CLOUDSTACK-6172: Fixed review comments provided in RR 25771
(cherry picked from commit 2d19bcb46ad7c78b4842c1f52f552998a33f8836)
Signed-off-by: Rohit Yadav <ro...@shapeblue.com>


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

Branch: refs/heads/4.3
Commit: 11eab3d285620b2a62078bd48f6b9e4089ef10e9
Parents: 77446d2
Author: sanjeev <sa...@apache.org>
Authored: Thu Sep 18 14:18:14 2014 +0530
Committer: Rohit Yadav <ro...@shapeblue.com>
Committed: Wed Nov 26 18:23:19 2014 +0530

----------------------------------------------------------------------
 test/integration/component/test_volumes.py | 138 ++++++++++++++++++++++++
 1 file changed, 138 insertions(+)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/cloudstack/blob/11eab3d2/test/integration/component/test_volumes.py
----------------------------------------------------------------------
diff --git a/test/integration/component/test_volumes.py b/test/integration/component/test_volumes.py
index ee0f91d..89a3372 100644
--- a/test/integration/component/test_volumes.py
+++ b/test/integration/component/test_volumes.py
@@ -1264,3 +1264,141 @@ class TestDeployVmWithCustomDisk(cloudstackTestCase):
         except Exception as e:
             self.fail("Create volume failed with exception: %s" % e)
         return
+
+class TestMigrateVolume(cloudstackTestCase):
+
+    @classmethod
+    def setUpClass(cls):
+        cls.testClient = super(TestMigrateVolume, cls).getClsTestClient()
+        cls.api_client = cls.testClient.getApiClient()
+
+        cls.services = Services().services
+        # Get Zone, Domain and templates
+        cls.domain = get_domain(cls.api_client)
+        cls.zone = get_zone(cls.api_client, cls.testClient.getZoneForTests())
+        cls.services['mode'] = cls.zone.networktype
+        cls.disk_offering = DiskOffering.create(
+            cls.api_client,
+            cls.services["disk_offering"]
+        )
+        template = get_template(
+            cls.api_client,
+            cls.zone.id,
+            cls.services["ostype"]
+        )
+        cls.services["zoneid"] = cls.zone.id
+        cls.services["virtual_machine"]["zoneid"] = cls.zone.id
+        cls.services["virtual_machine"]["template"] = template.id
+        cls.services["virtual_machine"]["diskofferingid"] = cls.disk_offering.id
+
+        # Create VMs, VMs etc
+        cls.account = Account.create(
+            cls.api_client,
+            cls.services["account"],
+            domainid=cls.domain.id
+        )
+        cls.small_offering = ServiceOffering.create(
+            cls.api_client,
+            cls.services["service_offering"]
+        )
+        cls.virtual_machine = VirtualMachine.create(
+            cls.api_client,
+            cls.services["virtual_machine"],
+            accountid=cls.account.name,
+            domainid=cls.account.domainid,
+            serviceofferingid=cls.small_offering.id,
+            mode=cls.services["mode"]
+        )
+        cls._cleanup = [
+                        cls.small_offering,
+                        cls.account
+                       ]
+        return
+
+    @classmethod
+    def tearDownClass(cls):
+        try:
+            cleanup_resources(cls.api_client, cls._cleanup)
+        except Exception as e:
+            raise Exception("Warning: Exception during cleanup : %s" % e)
+        return
+
+    def setUp(self):
+        self.apiclient = self.testClient.getApiClient()
+        self.dbclient = self.testClient.getDbConnection()
+        self.cleanup = []
+        return
+
+    def tearDown(self):
+        cleanup_resources(self.apiclient, self.cleanup)
+        return
+
+    @attr(tags=["advanced","sg","advancedsg"], required_hardware='true')
+    def test_01_migrateVolume(self):
+        """
+        @Desc:Volume is not retaining same uuid when migrating from one storage to another.
+        Step1:Create a volume/data disk
+        Step2:Verify UUID of the volume
+        Step3:Migrate the volume to another primary storage within the cluster
+        Step4:Migrating volume to new primary storage should succeed
+        Step5:volume UUID should not change even after migration
+        """
+        vol = Volume.create(
+            self.apiclient,
+            self.services["volume"],
+            diskofferingid=self.disk_offering.id,
+            zoneid=self.zone.id,
+            account=self.account.name,
+            domainid=self.account.domainid,
+            )
+        self.assertIsNotNone(vol,"Failed to create volume")
+        vol_res = Volume.list(
+            self.apiclient,
+            id=vol.id
+        )
+        self.assertEqual(validateList(vol_res)[0],PASS,"Invalid response returned for list volumes")
+        vol_uuid=vol_res[0].id
+        try:
+            self.virtual_machine.attach_volume(
+                self.apiclient,
+                vol
+            )
+        except Exception as e:
+            self.fail("Attaching data disk to vm failed with error %s" % e)
+        pools = StoragePool.listForMigration(
+            self.apiclient,
+            id=vol.id
+        )
+        if not pools:
+            self.skipTest("No suitable storage pools found for volume migration. Skipping")
+        self.assertEqual(validateList(pools)[0],PASS,"invalid pool response from findStoragePoolsForMigration")
+        pool=pools[0]
+        self.debug("Migrating Volume-ID: %s to Pool: %s" % (vol.id,pool.id))
+        try:
+            Volume.migrate(
+                self.apiclient,
+                volumeid=vol.id,
+                storageid=pool.id,
+                livemigrate='true'
+            )
+        except Exception as e:
+            self.fail("Volume migration failed with error %s" % e)
+        migrated_vols = Volume.list(
+            self.apiclient,
+            virtualmachineid=self.virtual_machine.id,
+            listall='true',
+            type='DATADISK'
+        )
+        self.assertEqual(validateList(migrated_vols)[0],PASS,"invalid volumes response after migration")
+        migrated_vol_uuid=migrated_vols[0].id
+        self.assertEqual(
+            vol_uuid,
+            migrated_vol_uuid,
+            "Volume is not retaining same uuid when migrating from one storage to another"
+        )
+        self.virtual_machine.detach_volume(
+            self.apiclient,
+            vol
+        )
+        self.cleanup.append(vol)
+        return


[3/8] git commit: updated refs/heads/4.3 to 2b264e6

Posted by bh...@apache.org.
CLOUDSTACK-6236:fix a copy-and-paste error for decrRefCnt in
VolumeDataStoreVO.
(cherry picked from commit 672bb353be2f159966f351ab2de914b433a934f9)

Signed-off-by: Rohit Yadav <ro...@shapeblue.com>


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

Branch: refs/heads/4.3
Commit: 2534b54853d81d41e364348e0cc0cecb3c950294
Parents: 88ec084
Author: Min Chen <mi...@citrix.com>
Authored: Wed Sep 3 10:33:11 2014 -0700
Committer: Rohit Yadav <ro...@shapeblue.com>
Committed: Wed Nov 26 18:15:05 2014 +0530

----------------------------------------------------------------------
 .../storage/datastore/db/VolumeDataStoreVO.java       | 14 +++++++-------
 1 file changed, 7 insertions(+), 7 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/cloudstack/blob/2534b548/engine/schema/src/org/apache/cloudstack/storage/datastore/db/VolumeDataStoreVO.java
----------------------------------------------------------------------
diff --git a/engine/schema/src/org/apache/cloudstack/storage/datastore/db/VolumeDataStoreVO.java b/engine/schema/src/org/apache/cloudstack/storage/datastore/db/VolumeDataStoreVO.java
index bd15f1c..f5589da 100755
--- a/engine/schema/src/org/apache/cloudstack/storage/datastore/db/VolumeDataStoreVO.java
+++ b/engine/schema/src/org/apache/cloudstack/storage/datastore/db/VolumeDataStoreVO.java
@@ -348,12 +348,7 @@ public class VolumeDataStoreVO implements StateObject<ObjectInDataStoreStateMach
     }
 
     public void setRefCnt(Long refCnt) {
-        if (refCnt > 0) {
-            refCnt--;
-        }
-        else {
-            s_logger.warn("We should not try to decrement a zero reference count even though our code has guarded");
-        }
+        this.refCnt = refCnt;
     }
 
     public void incrRefCnt() {
@@ -361,7 +356,12 @@ public class VolumeDataStoreVO implements StateObject<ObjectInDataStoreStateMach
     }
 
     public void decrRefCnt() {
-        refCnt--;
+        if (refCnt > 0) {
+            refCnt--;
+        }
+        else {
+            s_logger.warn("We should not try to decrement a zero reference count even though our code has guarded");
+        }
     }
 
     public String getExtractUrl() {