mirror of https://github.com/apache/cloudstack.git
upgrade to ASF 4.2 "cloud" Database Schema Inconsistencies on the Upgraded Setup - Table "volumes"
Signed-off-by: Abhinandan Prateek <aprateek@apache.org>
This commit is contained in:
parent
80cfc81bc9
commit
65370f31bc
|
|
@ -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;
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -77,7 +77,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);
|
||||
|
||||
|
|
|
|||
|
|
@ -31,6 +31,13 @@ import java.util.concurrent.ExecutionException;
|
|||
import javax.inject.Inject;
|
||||
import javax.naming.ConfigurationException;
|
||||
|
||||
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 +1387,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 +1406,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);
|
||||
|
|
|
|||
|
|
@ -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());
|
||||
|
|
|
|||
|
|
@ -372,7 +372,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 {
|
||||
|
|
@ -380,7 +380,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();
|
||||
|
|
|
|||
|
|
@ -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`;
|
||||
|
|
@ -1788,7 +1788,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'
|
||||
|
|
@ -2220,6 +2220,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', 'healthcheck.update.interval', '600', 'Time Interval to fetch the LB health check states (in sec)');
|
||||
INSERT IGNORE INTO `cloud`.`configuration` VALUES ('Snapshots', 'DEFAULT', 'SnapshotManager', 'KVM.snapshot.enabled', 'false', 'whether snapshot is enabled for KVM hosts');
|
||||
|
|
|
|||
Loading…
Reference in New Issue