cloudstack-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From ni...@apache.org
Subject git commit: updated refs/heads/master to ee0f0a1
Date Wed, 22 Oct 2014 22:03:35 GMT
Repository: cloudstack
Updated Branches:
  refs/heads/master b10f0a799 -> ee0f0a1cf


CLOUDSTACK-7771: Throw exception while restoring vm if the template is already deleted. Also
fix the usage event being generated from the right template id and fix the log message which
sometime showed incorrect template id.
CLOUDSTACK-4201: listServiceOfferings API needs to be able to take virtualmachineid of SystemVM
and return service offerings available for the vm to change service offering


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

Branch: refs/heads/master
Commit: ee0f0a1cffb96a8371d9a8c4210b428660f79d4f
Parents: b10f0a7
Author: Nitin Mehta <nitin.mehta@citrix.com>
Authored: Wed Oct 22 15:03:25 2014 -0700
Committer: Nitin Mehta <nitin.mehta@citrix.com>
Committed: Wed Oct 22 15:03:25 2014 -0700

----------------------------------------------------------------------
 server/src/com/cloud/api/query/QueryManagerImpl.java |  7 ++++++-
 server/src/com/cloud/vm/UserVmManagerImpl.java       | 12 ++++++++++--
 server/test/com/cloud/vm/UserVmManagerTest.java      |  8 ++++++++
 3 files changed, 24 insertions(+), 3 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/cloudstack/blob/ee0f0a1c/server/src/com/cloud/api/query/QueryManagerImpl.java
----------------------------------------------------------------------
diff --git a/server/src/com/cloud/api/query/QueryManagerImpl.java b/server/src/com/cloud/api/query/QueryManagerImpl.java
index 475b42c..824bb9b 100644
--- a/server/src/com/cloud/api/query/QueryManagerImpl.java
+++ b/server/src/com/cloud/api/query/QueryManagerImpl.java
@@ -27,6 +27,8 @@ import javax.ejb.Local;
 import javax.inject.Inject;
 
 import com.cloud.utils.StringUtils;
+import com.cloud.vm.VMInstanceVO;
+import com.cloud.vm.dao.VMInstanceDao;
 import org.apache.cloudstack.acl.ControlledEntity.ACLType;
 import org.apache.cloudstack.affinity.AffinityGroupDomainMapVO;
 import org.apache.cloudstack.affinity.AffinityGroupResponse;
@@ -248,6 +250,9 @@ public class QueryManagerImpl extends ManagerBase implements QueryService
{
     private UserVmDao _userVmDao;
 
     @Inject
+    private VMInstanceDao _vmInstanceDao;
+
+    @Inject
     private SecurityGroupJoinDao _securityGroupJoinDao;
 
     @Inject
@@ -2572,7 +2577,7 @@ public class QueryManagerImpl extends ManagerBase implements QueryService
{
         }
 
         if (vmId != null) {
-            UserVmVO vmInstance = _userVmDao.findById(vmId);
+            VMInstanceVO vmInstance = _vmInstanceDao.findById(vmId);
             if ((vmInstance == null) || (vmInstance.getRemoved() != null)) {
                 InvalidParameterValueException ex = new InvalidParameterValueException("unable
to find a virtual machine with specified id");
                 ex.addProxyObject(vmId.toString(), "vmId");

http://git-wip-us.apache.org/repos/asf/cloudstack/blob/ee0f0a1c/server/src/com/cloud/vm/UserVmManagerImpl.java
----------------------------------------------------------------------
diff --git a/server/src/com/cloud/vm/UserVmManagerImpl.java b/server/src/com/cloud/vm/UserVmManagerImpl.java
index fe7c32b..7fe1c2c 100755
--- a/server/src/com/cloud/vm/UserVmManagerImpl.java
+++ b/server/src/com/cloud/vm/UserVmManagerImpl.java
@@ -35,6 +35,8 @@ import javax.ejb.Local;
 import javax.inject.Inject;
 import javax.naming.ConfigurationException;
 
+import org.apache.cloudstack.storage.datastore.db.TemplateDataStoreDao;
+import org.apache.cloudstack.storage.datastore.db.TemplateDataStoreVO;
 import org.apache.commons.codec.binary.Base64;
 import org.apache.log4j.Logger;
 
@@ -306,6 +308,8 @@ public class UserVmManagerImpl extends ManagerBase implements UserVmManager,
Vir
     @Inject
     protected VMTemplateZoneDao _templateZoneDao = null;
     @Inject
+    protected TemplateDataStoreDao _templateStoreDao;
+    @Inject
     protected DomainDao _domainDao = null;
     @Inject
     protected UserVmCloneSettingDao _vmCloneSettingDao = null;
@@ -4723,6 +4727,10 @@ public class UserVmManagerImpl extends ManagerBase implements UserVmManager,
Vir
                     throw ex;
                 }
             }
+            TemplateDataStoreVO tmplStore = _templateStoreDao.findByTemplateZoneReady(template.getId(),
vm.getDataCenterId());
+            if (tmplStore == null) {
+                throw new InvalidParameterValueException("Cannot restore the vm as the template
" + template.getUuid() + " isn't available in the zone");
+            }
 
             if (needRestart) {
                 try {
@@ -4755,7 +4763,7 @@ public class UserVmManagerImpl extends ManagerBase implements UserVmManager,
Vir
             }
 
             // Create Usage event for the newly created volume
-            UsageEventVO usageEvent = new UsageEventVO(EventTypes.EVENT_VOLUME_CREATE, newVol.getAccountId(),
newVol.getDataCenterId(), newVol.getId(), newVol.getName(), newVol.getDiskOfferingId(), templateId,
newVol.getSize());
+            UsageEventVO usageEvent = new UsageEventVO(EventTypes.EVENT_VOLUME_CREATE, newVol.getAccountId(),
newVol.getDataCenterId(), newVol.getId(), newVol.getName(), newVol.getDiskOfferingId(), template.getId(),
newVol.getSize());
             _usageEventDao.persist(usageEvent);
 
             handleManagedStorage(vm, root);
@@ -4828,7 +4836,7 @@ public class UserVmManagerImpl extends ManagerBase implements UserVmManager,
Vir
             }
         }
 
-        s_logger.debug("Restore VM " + vmId + " with template " + newTemplateId + " done
successfully");
+        s_logger.debug("Restore VM " + vmId + " done successfully");
         return vm;
 
     }

http://git-wip-us.apache.org/repos/asf/cloudstack/blob/ee0f0a1c/server/test/com/cloud/vm/UserVmManagerTest.java
----------------------------------------------------------------------
diff --git a/server/test/com/cloud/vm/UserVmManagerTest.java b/server/test/com/cloud/vm/UserVmManagerTest.java
index aed468d..d86e55e 100755
--- a/server/test/com/cloud/vm/UserVmManagerTest.java
+++ b/server/test/com/cloud/vm/UserVmManagerTest.java
@@ -55,6 +55,7 @@ import org.apache.cloudstack.engine.orchestration.service.VolumeOrchestrationSer
 import org.apache.cloudstack.framework.config.dao.ConfigurationDao;
 import org.apache.cloudstack.storage.datastore.db.PrimaryDataStoreDao;
 import org.apache.cloudstack.storage.datastore.db.StoragePoolVO;
+import org.apache.cloudstack.storage.datastore.db.TemplateDataStoreVO;
 
 import com.cloud.capacity.CapacityManager;
 import com.cloud.configuration.ConfigurationManager;
@@ -89,6 +90,7 @@ import com.cloud.vm.dao.UserVmDao;
 import com.cloud.vm.dao.VMInstanceDao;
 import com.cloud.vm.snapshot.VMSnapshotVO;
 import com.cloud.vm.snapshot.dao.VMSnapshotDao;
+import org.apache.cloudstack.storage.datastore.db.TemplateDataStoreDao;
 
 public class UserVmManagerTest {
 
@@ -121,6 +123,8 @@ public class UserVmManagerTest {
     @Mock
     VMTemplateDao _templateDao;
     @Mock
+    TemplateDataStoreDao _templateStoreDao;
+    @Mock
     VolumeDao _volsDao;
     @Mock
     RestoreVMCmd _restoreVMCmd;
@@ -135,6 +139,8 @@ public class UserVmManagerTest {
     @Mock
     VMTemplateVO _templateMock;
     @Mock
+    TemplateDataStoreVO _templateDataStoreMock;
+    @Mock
     VolumeVO _volumeMock;
     @Mock
     List<VolumeVO> _rootVols;
@@ -162,6 +168,7 @@ public class UserVmManagerTest {
         _userVmMgr._vmDao = _vmDao;
         _userVmMgr._vmInstanceDao = _vmInstanceDao;
         _userVmMgr._templateDao = _templateDao;
+        _userVmMgr._templateStoreDao = _templateStoreDao;
         _userVmMgr._volsDao = _volsDao;
         _userVmMgr._usageEventDao = _usageEventDao;
         _userVmMgr._itMgr = _itMgr;
@@ -190,6 +197,7 @@ public class UserVmManagerTest {
         List<VMSnapshotVO> mockList = mock(List.class);
         when(_vmSnapshotDao.findByVm(anyLong())).thenReturn(mockList);
         when(mockList.size()).thenReturn(0);
+        when(_templateStoreDao.findByTemplateZoneReady(anyLong(),anyLong())).thenReturn(_templateDataStoreMock);
 
     }
 


Mime
View raw message