cloudstack-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From mlsoren...@apache.org
Subject git commit: updated refs/heads/4.2 to bb01aad
Date Fri, 14 Feb 2014 07:51:06 GMT
Updated Branches:
  refs/heads/4.2 433a2e44b -> bb01aad37


CLOUDSTACK-6103: Pass VM iso information along with
PrepareForMigrationCommand, so that destination hypervisor can
mount pool. This further exposed an issue for KVM where iso
was not getting cleaned up upon successful migration, fixed as well.


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

Branch: refs/heads/4.2
Commit: bb01aad377e97b65dd31e4c4ba60d8a1297b25d9
Parents: 433a2e4
Author: Marcus Sorensen <marcus@betterservers.com>
Authored: Fri Feb 14 00:50:45 2014 -0700
Committer: Marcus Sorensen <marcus@betterservers.com>
Committed: Fri Feb 14 00:50:45 2014 -0700

----------------------------------------------------------------------
 .../kvm/resource/LibvirtComputingResource.java  |  8 +++++
 .../com/cloud/storage/VolumeManagerImpl.java    | 10 +++---
 .../src/com/cloud/template/TemplateManager.java |  7 ++++
 .../com/cloud/template/TemplateManagerImpl.java | 35 ++++++++++++++++++++
 server/src/com/cloud/vm/UserVmManagerImpl.java  | 31 ++---------------
 5 files changed, 58 insertions(+), 33 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/cloudstack/blob/bb01aad3/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 3bf97b0..204bc9e 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
@@ -2909,6 +2909,7 @@ ServerResource {
         }
 
         List<InterfaceDef> ifaces = null;
+        List<DiskDef> disks = null;
 
         Domain dm = null;
         Connect dconn = null;
@@ -2917,6 +2918,7 @@ ServerResource {
         try {
             conn = LibvirtConnection.getConnectionByVmName(cmd.getVmName());
             ifaces = getInterfaces(conn, vmName);
+            disks = getDisks(conn, vmName);
             dm = conn.domainLookupByName(vmName);
             dconn = new Connect("qemu+tcp://" + cmd.getDestinationIp()
                     + "/system");
@@ -2926,6 +2928,12 @@ ServerResource {
              */
             destDomain = dm.migrate(dconn, (1 << 0) | (1 << 3), vmName, "tcp:"
                     + cmd.getDestinationIp(), _migrateSpeed);
+            for (DiskDef disk : disks) {
+                if (disk.getDeviceType() == DiskDef.deviceType.CDROM
+                        && disk.getDiskPath() != null) {
+                    cleanupDisk(conn, disk);
+                }
+            }
         } catch (LibvirtException e) {
             s_logger.debug("Can't migrate domain: " + e.getMessage());
             result = e.getMessage();

http://git-wip-us.apache.org/repos/asf/cloudstack/blob/bb01aad3/server/src/com/cloud/storage/VolumeManagerImpl.java
----------------------------------------------------------------------
diff --git a/server/src/com/cloud/storage/VolumeManagerImpl.java b/server/src/com/cloud/storage/VolumeManagerImpl.java
index 10d4239..a0c2acf 100644
--- a/server/src/com/cloud/storage/VolumeManagerImpl.java
+++ b/server/src/com/cloud/storage/VolumeManagerImpl.java
@@ -2410,10 +2410,12 @@ public class VolumeManagerImpl extends ManagerBase implements VolumeManager
{
             vm.addDisk(disk);
         }
 
-        if (vm.getType() == VirtualMachine.Type.User && vm.getTemplate().getFormat()
== ImageFormat.ISO) {
-            DataTO dataTO = tmplFactory.getTemplate(vm.getTemplate().getId(), DataStoreRole.Image,
vm.getVirtualMachine().getDataCenterId()).getTO();
-            DiskTO iso = new DiskTO(dataTO, 3L, null, Volume.Type.ISO);
-            vm.addDisk(iso);
+        //if (vm.getType() == VirtualMachine.Type.User && vm.getTemplate().getFormat()
== ImageFormat.ISO) {
+        if (vm.getType() == VirtualMachine.Type.User) {
+            _tmpltMgr.prepareIsoForVmProfile(vm);
+            //DataTO dataTO = tmplFactory.getTemplate(vm.getTemplate().getId(), DataStoreRole.Image,
vm.getVirtualMachine().getDataCenterId()).getTO();
+            //DiskTO iso = new DiskTO(dataTO, 3L, null, Volume.Type.ISO);
+            //vm.addDisk(iso);
         }
     }
 

http://git-wip-us.apache.org/repos/asf/cloudstack/blob/bb01aad3/server/src/com/cloud/template/TemplateManager.java
----------------------------------------------------------------------
diff --git a/server/src/com/cloud/template/TemplateManager.java b/server/src/com/cloud/template/TemplateManager.java
index 8427fa9..72f4836 100755
--- a/server/src/com/cloud/template/TemplateManager.java
+++ b/server/src/com/cloud/template/TemplateManager.java
@@ -33,6 +33,7 @@ import com.cloud.storage.VMTemplateHostVO;
 import com.cloud.storage.VMTemplateStoragePoolVO;
 import com.cloud.storage.VMTemplateVO;
 import com.cloud.utils.Pair;
+import com.cloud.vm.VirtualMachineProfile;
 
 /**
  * TemplateManager manages the templates stored on secondary storage. It is responsible for
creating private/public templates.
@@ -112,6 +113,12 @@ public interface TemplateManager extends TemplateApiService{
     TemplateInfo prepareIso(long isoId, long dcId);
 
 
+    /**
+     * Adds ISO definition to given vm profile
+     *
+     * @param VirtualMachineProfile
+     */
+    void prepareIsoForVmProfile(VirtualMachineProfile profile);
 
 
 }

http://git-wip-us.apache.org/repos/asf/cloudstack/blob/bb01aad3/server/src/com/cloud/template/TemplateManagerImpl.java
----------------------------------------------------------------------
diff --git a/server/src/com/cloud/template/TemplateManagerImpl.java b/server/src/com/cloud/template/TemplateManagerImpl.java
index 396ae61..57f7ff6 100755
--- a/server/src/com/cloud/template/TemplateManagerImpl.java
+++ b/server/src/com/cloud/template/TemplateManagerImpl.java
@@ -75,6 +75,7 @@ import org.apache.cloudstack.storage.datastore.db.StoragePoolVO;
 import org.apache.cloudstack.storage.datastore.db.TemplateDataStoreDao;
 import org.apache.cloudstack.storage.datastore.db.TemplateDataStoreVO;
 import org.apache.cloudstack.storage.image.datastore.ImageStoreEntity;
+import org.apache.cloudstack.storage.to.TemplateObjectTO;
 import org.apache.log4j.Logger;
 import org.springframework.stereotype.Component;
 
@@ -156,6 +157,7 @@ import com.cloud.storage.download.DownloadMonitor;
 import com.cloud.storage.secondary.SecondaryStorageVmManager;
 import com.cloud.storage.upload.UploadMonitor;
 import com.cloud.template.TemplateAdapter.TemplateAdapterType;
+import com.cloud.template.VirtualMachineTemplate.BootloaderType;
 import com.cloud.user.Account;
 import com.cloud.user.AccountManager;
 import com.cloud.user.AccountService;
@@ -181,6 +183,7 @@ import com.cloud.vm.UserVmManager;
 import com.cloud.vm.UserVmVO;
 import com.cloud.vm.VMInstanceVO;
 import com.cloud.vm.VirtualMachine.State;
+import com.cloud.vm.VirtualMachineProfile;
 import com.cloud.vm.dao.UserVmDao;
 import com.cloud.vm.dao.UserVmDetailsDao;
 import com.cloud.vm.dao.VMInstanceDao;
@@ -498,6 +501,38 @@ public class TemplateManagerImpl extends ManagerBase implements TemplateManager,
         return extractUrl;
     }
 
+    @Override
+    public void prepareIsoForVmProfile(VirtualMachineProfile profile) {
+        UserVmVO vm = _userVmDao.findById(profile.getId());
+        if (vm.getIsoId() != null) {
+            TemplateInfo template = prepareIso(vm.getIsoId(), vm.getDataCenterId());
+            if (template == null){
+                s_logger.error("Failed to prepare ISO on secondary or cache storage");
+                throw new CloudRuntimeException("Failed to prepare ISO on secondary or cache
storage");
+            }
+            if (template.isBootable()) {
+                profile.setBootLoaderType(BootloaderType.CD);
+            }
+
+            GuestOSVO guestOS = _guestOSDao.findById(template.getGuestOSId());
+            String displayName = null;
+            if (guestOS != null) {
+                displayName = guestOS.getDisplayName();
+            }
+
+            TemplateObjectTO iso = (TemplateObjectTO)template.getTO();
+            iso.setGuestOsType(displayName);
+            DiskTO disk = new DiskTO(iso, 3L, null, Volume.Type.ISO);
+            profile.addDisk(disk);
+        } else {
+            TemplateObjectTO iso = new TemplateObjectTO();
+            iso.setFormat(ImageFormat.ISO);
+            DiskTO disk = new DiskTO(iso, 3L, null, Volume.Type.ISO);
+            profile.addDisk(disk);
+        }
+
+    }
+
     public void prepareTemplateInAllStoragePools(final VMTemplateVO template, long zoneId)
{
         List<StoragePoolVO> pools = _poolDao.listByStatus(StoragePoolStatus.Up);
         for (final StoragePoolVO pool : pools) {

http://git-wip-us.apache.org/repos/asf/cloudstack/blob/bb01aad3/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 df11597..b9cffcf 100755
--- a/server/src/com/cloud/vm/UserVmManagerImpl.java
+++ b/server/src/com/cloud/vm/UserVmManagerImpl.java
@@ -402,7 +402,7 @@ public class UserVmManagerImpl extends ManagerBase implements UserVmManager,
Use
     @Inject
     VpcManager _vpcMgr;
     @Inject
-    TemplateManager templateMgr;
+    TemplateManager _templateMgr;
     @Inject
     protected GuestOSCategoryDao _guestOSCategoryDao;
     @Inject
@@ -3023,34 +3023,7 @@ public class UserVmManagerImpl extends ManagerBase implements UserVmManager,
Use
         UserVmVO vm = profile.getVirtualMachine();
         Map<String, String> details = _vmDetailsDao.findDetails(vm.getId());
         vm.setDetails(details);
-
-        if (vm.getIsoId() != null) {
-            TemplateInfo template = this.templateMgr.prepareIso(vm.getIsoId(), vm.getDataCenterId());
-            if (template == null){
-                s_logger.error("Failed to prepare ISO on secondary or cache storage");
-                throw new CloudRuntimeException("Failed to prepare ISO on secondary or cache
storage");
-            }
-            if (template.isBootable()) {
-                profile.setBootLoaderType(BootloaderType.CD);
-            }
-
-            GuestOSVO guestOS = _guestOSDao.findById(template.getGuestOSId());
-            String displayName = null;
-            if (guestOS != null) {
-                displayName = guestOS.getDisplayName();
-            }
-
-            TemplateObjectTO iso = (TemplateObjectTO)template.getTO();
-            iso.setGuestOsType(displayName);
-            DiskTO disk = new DiskTO(iso, 3L, null, Volume.Type.ISO);
-            profile.addDisk(disk);
-        } else {
-            TemplateObjectTO iso = new TemplateObjectTO();
-            iso.setFormat(ImageFormat.ISO);
-            DiskTO disk = new DiskTO(iso, 3L, null, Volume.Type.ISO);
-            profile.addDisk(disk);
-        }
-
+        _templateMgr.prepareIsoForVmProfile(profile);
         return true;
     }
 


Mime
View raw message