cloudstack-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From aprat...@apache.org
Subject git commit: updated refs/heads/4.2 to 60585b5
Date Fri, 02 Aug 2013 11:52:51 GMT
Updated Branches:
  refs/heads/4.2 aa302387d -> 60585b518


[PATCH] upgrade to ASF 4.2  cloud Database Schema Inconsistencies


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

Branch: refs/heads/4.2
Commit: 60585b51819e4391373d71c63138e36f0a3c5898
Parents: aa30238
Author: Bharat Kumar <bharat.kumar@citrix.com>
Authored: Fri Aug 2 16:38:27 2013 +0530
Committer: Abhinandan Prateek <aprateek@apache.org>
Committed: Fri Aug 2 17:22:31 2013 +0530

----------------------------------------------------------------------
 engine/schema/src/com/cloud/storage/VolumeVO.java   | 11 +++++++++++
 server/src/com/cloud/storage/VolumeManager.java     |  2 +-
 server/src/com/cloud/storage/VolumeManagerImpl.java | 14 ++++++++++++--
 .../src/com/cloud/template/TemplateManagerImpl.java | 16 ++++++++++++++++
 .../src/com/cloud/vm/VirtualMachineManagerImpl.java |  4 ++--
 setup/db/db/schema-307to410.sql                     |  1 +
 setup/db/db/schema-410to420.sql                     |  3 ++-
 7 files changed, 45 insertions(+), 6 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/cloudstack/blob/60585b51/engine/schema/src/com/cloud/storage/VolumeVO.java
----------------------------------------------------------------------
diff --git a/engine/schema/src/com/cloud/storage/VolumeVO.java b/engine/schema/src/com/cloud/storage/VolumeVO.java
index 1445e99..bbecf03 100755
--- a/engine/schema/src/com/cloud/storage/VolumeVO.java
+++ b/engine/schema/src/com/cloud/storage/VolumeVO.java
@@ -152,6 +152,9 @@ public class VolumeVO implements Volume {
 
     @Column(name = "vm_snapshot_chain_size")
     private Long vmSnapshotChainSize;
+
+    @Column(name = "iso_id")
+    private long isoId;
     
     @Transient
     // @Column(name="reservation")
@@ -561,4 +564,12 @@ public class VolumeVO implements Volume {
     public Long getVmSnapshotChainSize(){
         return this.vmSnapshotChainSize;
     }
+
+    public Long getIsoId() {
+        return this.isoId;
+    }
+
+    public void setIsoId(long isoId) {
+        this.isoId =isoId;
+    }
 }

http://git-wip-us.apache.org/repos/asf/cloudstack/blob/60585b51/server/src/com/cloud/storage/VolumeManager.java
----------------------------------------------------------------------
diff --git a/server/src/com/cloud/storage/VolumeManager.java b/server/src/com/cloud/storage/VolumeManager.java
index 2e44a3c..c8adaeb 100644
--- a/server/src/com/cloud/storage/VolumeManager.java
+++ b/server/src/com/cloud/storage/VolumeManager.java
@@ -78,7 +78,7 @@ public interface VolumeManager extends VolumeApiService {
 
     void destroyVolume(VolumeVO volume);
 
-    DiskProfile allocateRawVolume(Type type, String name, DiskOfferingVO offering, Long size,
VMInstanceVO vm, Account owner);
+    DiskProfile allocateRawVolume(Type type, String name, DiskOfferingVO offering, Long size,
VMInstanceVO vm, VMTemplateVO template, Account owner);
     @Override
     Volume attachVolumeToVM(AttachVolumeCmd command);
 

http://git-wip-us.apache.org/repos/asf/cloudstack/blob/60585b51/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 abbc2f0..c484666 100644
--- a/server/src/com/cloud/storage/VolumeManagerImpl.java
+++ b/server/src/com/cloud/storage/VolumeManagerImpl.java
@@ -31,7 +31,13 @@ import java.util.concurrent.ExecutionException;
 import javax.inject.Inject;
 import javax.naming.ConfigurationException;
 
-import com.cloud.utils.*;
+import com.cloud.utils.DateUtil;
+import com.cloud.utils.EnumUtils;
+import com.cloud.utils.NumbersUtil;
+import com.cloud.utils.Pair;
+import com.cloud.utils.UriUtils;
+import com.cloud.utils.db.SearchCriteria;
+import org.apache.commons.lang.StringUtils;
 import org.apache.log4j.Logger;
 import org.springframework.stereotype.Component;
 
@@ -1380,7 +1386,8 @@ public class VolumeManagerImpl extends ManagerBase implements VolumeManager
{
 
     @Override
     public DiskProfile allocateRawVolume(Type type,
-            String name, DiskOfferingVO offering, Long size, VMInstanceVO vm, Account owner)
{
+            String name, DiskOfferingVO offering, Long size, VMInstanceVO vm, VMTemplateVO
template, Account owner) {
+        Long isoId=null;
         if (size == null) {
             size = offering.getDiskSize();
         } else {
@@ -1398,6 +1405,9 @@ public class VolumeManagerImpl extends ManagerBase implements VolumeManager
{
         } else {
             vol.setDeviceId(1l);
         }
+        if (template.getFormat() == ImageFormat.ISO) {
+            vol.setIsoId(template.getId());
+        }
 
         vol.setFormat(getSupportedImageFormatForCluster(vm.getHypervisorType()));
         vol = _volsDao.persist(vol);

http://git-wip-us.apache.org/repos/asf/cloudstack/blob/60585b51/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 8ccc567..efef80b 100755
--- a/server/src/com/cloud/template/TemplateManagerImpl.java
+++ b/server/src/com/cloud/template/TemplateManagerImpl.java
@@ -1376,6 +1376,22 @@ public class TemplateManagerImpl extends ManagerBase implements TemplateManager,
                 this._tmpltZoneDao.persist(templateZone);
 
                 privateTemplate = this._tmpltDao.findById(templateId);
+                if (snapshotId != null) {
+                    //getting the prent volume
+                    long parentVolumeId=_snapshotDao.findById(snapshotId).getVolumeId();
+                    VolumeVO parentVolume = _volumeDao.findById(parentVolumeId);
+                    if (parentVolume.getIsoId() != null) {
+                        privateTemplate.setSourceTemplateId(parentVolume.getIsoId());
+                        _tmpltDao.update(privateTemplate.getId(), privateTemplate);
+                    }
+                }
+                else if (volumeId != null) {
+                    VolumeVO parentVolume = _volumeDao.findById(volumeId);
+                    if (parentVolume.getIsoId() != null) {
+                        privateTemplate.setSourceTemplateId(parentVolume.getIsoId());
+                        _tmpltDao.update(privateTemplate.getId(), privateTemplate);
+                    }
+                }
                 TemplateDataStoreVO srcTmpltStore = this._tmplStoreDao.findByStoreTemplate(store.getId(),
templateId);
                 UsageEventVO usageEvent = new UsageEventVO(EventTypes.EVENT_TEMPLATE_CREATE,
privateTemplate.getAccountId(), zoneId,
                         privateTemplate.getId(), privateTemplate.getName(), null, privateTemplate.getSourceTemplateId(),
srcTmpltStore.getPhysicalSize(), privateTemplate.getSize());

http://git-wip-us.apache.org/repos/asf/cloudstack/blob/60585b51/server/src/com/cloud/vm/VirtualMachineManagerImpl.java
----------------------------------------------------------------------
diff --git a/server/src/com/cloud/vm/VirtualMachineManagerImpl.java b/server/src/com/cloud/vm/VirtualMachineManagerImpl.java
index 6d35539..cf24502 100755
--- a/server/src/com/cloud/vm/VirtualMachineManagerImpl.java
+++ b/server/src/com/cloud/vm/VirtualMachineManagerImpl.java
@@ -388,7 +388,7 @@ public class VirtualMachineManagerImpl extends ManagerBase implements
VirtualMac
         }
 
         if (template.getFormat() == ImageFormat.ISO) {
-            volumeMgr.allocateRawVolume(Type.ROOT, "ROOT-" + vm.getId(), rootDiskOffering.first(),
rootDiskOffering.second(), vm, owner);
+            volumeMgr.allocateRawVolume(Type.ROOT, "ROOT-" + vm.getId(), rootDiskOffering.first(),
rootDiskOffering.second(), vm, template, owner);
         } else if (template.getFormat() == ImageFormat.BAREMETAL) {
             // Do nothing
         } else {
@@ -396,7 +396,7 @@ public class VirtualMachineManagerImpl extends ManagerBase implements
VirtualMac
         }
 
         for (Pair<DiskOfferingVO, Long> offering : dataDiskOfferings) {
-            volumeMgr.allocateRawVolume(Type.DATADISK, "DATA-" + vm.getId(), offering.first(),
offering.second(), vm, owner);
+            volumeMgr.allocateRawVolume(Type.DATADISK, "DATA-" + vm.getId(), offering.first(),
offering.second(), vm, template, owner);
         }
 
         txn.commit();

http://git-wip-us.apache.org/repos/asf/cloudstack/blob/60585b51/setup/db/db/schema-307to410.sql
----------------------------------------------------------------------
diff --git a/setup/db/db/schema-307to410.sql b/setup/db/db/schema-307to410.sql
index be6c17d..af296ab 100644
--- a/setup/db/db/schema-307to410.sql
+++ b/setup/db/db/schema-307to410.sql
@@ -1572,3 +1572,4 @@ ALTER TABLE `cloud_usage`.`usage_storage` CHANGE COLUMN `virtual_size`
`virtual_
 ALTER TABLE `cloud_usage`.`cloud_usage` CHANGE COLUMN `virtual_size` `virtual_size1` bigint
unsigned;
 
 ALTER TABLE `cloud`.`network_offerings` CHANGE COLUMN `concurrent_connections` `concurrent_connections1`
int(10) unsigned COMMENT 'Load Balancer(haproxy) maximum number of concurrent connections(global
max)';
+ALTER TABLE `cloud`.`volumes` DROP COLUMN `iso_id`;
\ No newline at end of file

http://git-wip-us.apache.org/repos/asf/cloudstack/blob/60585b51/setup/db/db/schema-410to420.sql
----------------------------------------------------------------------
diff --git a/setup/db/db/schema-410to420.sql b/setup/db/db/schema-410to420.sql
index 6fdf3fe..aeacff3 100644
--- a/setup/db/db/schema-410to420.sql
+++ b/setup/db/db/schema-410to420.sql
@@ -1791,7 +1791,7 @@ CREATE VIEW `cloud`.`volume_view` AS
             left join
         `cloud`.`cluster` ON storage_pool.cluster_id = cluster.id
             left join
-        `cloud`.`vm_template` ON volumes.template_id = vm_template.id
+        `cloud`.`vm_template` ON volumes.template_id = vm_template.id OR volumes.iso_id =
vm_template.id
             left join
         `cloud`.`resource_tags` ON resource_tags.resource_id = volumes.id
             and resource_tags.resource_type = 'Volume'
@@ -2209,6 +2209,7 @@ CREATE TABLE `cloud_usage`.`usage_vmsnapshot` (
 ) ENGINE=InnoDB CHARSET=utf8;
 
 ALTER TABLE volumes ADD COLUMN vm_snapshot_chain_size bigint(20) unsigned;
+ALTER TABLE volumes ADD COLUMN iso_id bigint(20)  unsigned;
 
 INSERT IGNORE INTO `cloud`.`configuration` VALUES ('Advanced', 'DEFAULT', 'management-server',
'kvm.ssh.to.agent', 'true', 'Specify whether or not the management server is allowed to SSH
into KVM Agents');
 


Mime
View raw message