Liron Aravot has posted comments on this change.

Change subject: core:WIP: introducing OvfAutoUpdate
......................................................................


Patch Set 10: (20 inline comments)

....................................................
File backend/manager/dbscripts/create_views.sql
Line 373: vds_groups ON vm_templates.vds_group_id = vds_groups.vds_group_id
Line 374: left outer JOIN
Line 375: storage_pool ON storage_pool.id = vds_groups.storage_pool_id
Line 376: left outer JOIN
Line 377: quota ON vm_templates.quota_id = quota.id 
Done
Line 378: WHERE entity_type = 'TEMPLATE';
Line 379: 
Line 380: 
Line 381: 


....................................................
File backend/manager/dbscripts/upgrade/03_01_1530_add_vm_generation_columns.sql
Line 1: select fn_db_add_column('vm_static', 'db_generation', 'BIGINT default 
1');
Line 2: 
Line 3: -- not added as foreign key so that when vm is removed, it record in 
vm_ovf_generations record will stay
Done
Line 4: CREATE TABLE vm_ovf_generations
Line 5: (
Line 6:    vm_guid UUID PRIMARY KEY,
Line 7:    storage_pool_id UUID references storage_pool(id) ON DELETE CASCADE,


Line 9: );
Line 10: 
Line 11: INSERT into vm_ovf_generations (select vm.vm_guid, sp.id  from 
vm_static vm ,storage_pool sp, vds_groups vg where vg.storage_pool_id = sp.id 
AND vm.vds_group_id = vg.vds_group_id);
Line 12: 
Line 13: -- ovf_generation of 1 should be set only the pre existing vms, so 
after we added
Done
Line 14: -- the pre existing vms, the default should be 0.
Line 15: ALTER TABLE vm_ovf_generations ALTER COLUMN ovf_generation set default 
0;


....................................................
File backend/manager/dbscripts/vms_sp.sql
Line 18:     FETCH curs_vmids INTO id;
Line 19:     FETCH curs_newovfgen INTO new_ovf_gen;
Line 20:     IF NOT FOUND THEN
Line 21:      EXIT;
Line 22:     END IF;    
Done
Line 23:     UPDATE vm_ovf_generations
Line 24:     SET ovf_generation = new_ovf_gen WHERE vm_guid = id;
Line 25: END LOOP;
Line 26: CLOSE curs_vmids;


....................................................
File 
backend/manager/modules/bll/src/main/java/org/ovirt/engine/core/bll/OvfDataUpdater.java
Line 43: import org.ovirt.engine.core.utils.timer.SchedulerUtilQuartzImpl;
Line 44: 
Line 45: public final class OvfDataUpdater {
Line 46:     private static final Log log = 
LogFactory.getLog(OvfDataUpdater.class);
Line 47:     private static final OvfDataUpdater INSTANCE = new 
OvfDataUpdater();
Done
Line 48:     private static final int ITEMS_COUNT_PER_UPDATE = Config.<Integer> 
GetValue(ConfigValues.OvfItemsCountPerUpdate);
Line 49: 
Line 50: 
Line 51:     private final Map<Guid, KeyValuePairCompat<String, List<Guid>>> 
vmsAndTemplateMetadata;


Line 47:     private static final OvfDataUpdater INSTANCE = new 
OvfDataUpdater();
Line 48:     private static final int ITEMS_COUNT_PER_UPDATE = Config.<Integer> 
GetValue(ConfigValues.OvfItemsCountPerUpdate);
Line 49: 
Line 50: 
Line 51:     private final Map<Guid, KeyValuePairCompat<String, List<Guid>>> 
vmsAndTemplateMetadata;
Done
Line 52:     private final List<Guid> proccessedIdsInfo;
Line 53:     private final List<Long> proccessedOvfGenerationsInfo;
Line 54:     OvfManager ovfManager;
Line 55: 


Line 107:         }
Line 108:     }
Line 109: 
Line 110:     /**
Line 111:      * update ovfs for updated/added vms since last for the given 
storage pool
Done
Line 112:      * @param poolId
Line 113:      */
Line 114:     protected void updateOvfForVmsOfStoragePool(Guid poolId) {
Line 115:         // get vm ids that needs to be updated.


Line 111:      * update ovfs for updated/added vms since last for the given 
storage pool
Line 112:      * @param poolId
Line 113:      */
Line 114:     protected void updateOvfForVmsOfStoragePool(Guid poolId) {
Line 115:         // get vm ids that needs to be updated.
Done
Line 116:         List<Guid> vmsIdsForUpdate = 
getVmAndTemplatesGenerationsDao().getVmsIdsForOvfUpdate(poolId);
Line 117:         int i = 0;
Line 118:         while (i < vmsIdsForUpdate.size()) {
Line 119:             int delta = vmsIdsForUpdate.size() - i;


Line 116:         List<Guid> vmsIdsForUpdate = 
getVmAndTemplatesGenerationsDao().getVmsIdsForOvfUpdate(poolId);
Line 117:         int i = 0;
Line 118:         while (i < vmsIdsForUpdate.size()) {
Line 119:             int delta = vmsIdsForUpdate.size() - i;
Line 120:             int size = delta  >= ITEMS_COUNT_PER_UPDATE ? 
ITEMS_COUNT_PER_UPDATE : delta;
Done
Line 121:             List<Guid> idsToProcess = vmsIdsForUpdate.subList(i, 
i+size);
Line 122:             i+= size;
Line 123: 
Line 124:             populateVmsMetadataForOvfUpdate(idsToProcess);


Line 152:     }
Line 153: 
Line 154:     /**
Line 155:      * returns a list of templates that are valid for update from the 
given templates list.
Line 156:      * valid template is a template which is not locked and none of 
it's disks is locked.
Done
Line 157:      * @param templates
Line 158:      * @return
Line 159:      */
Line 160:     protected void populateTemplatesMetadataForOvfUpdate(List<Guid> 
idsToProcess) {


Line 186:         List<Guid> templateIdsForUpdate = 
getVmAndTemplatesGenerationsDao().
Line 187:                 getVmTemplatesIdsForOvfUpdate(poolId);
Line 188:         int i = 0;
Line 189:         while (i < templateIdsForUpdate.size()) {
Line 190:             int delta = templateIdsForUpdate.size() - i;
Done
Line 191:             int size = delta  >= ITEMS_COUNT_PER_UPDATE ? 
ITEMS_COUNT_PER_UPDATE : delta;
Line 192:             List<Guid> idsToProcess = templateIdsForUpdate.subList(i, 
i+size);
Line 193:             i+= size;
Line 194: 


Line 208:         for (VM vm : vms) {
Line 209:             if (VMStatus.ImageLocked != vm.getstatus()) {
Line 210:                 VmHandler.updateDisksFromDb(vm);
Line 211:                 boolean verifyDisksNotLocked = 
verifyDisksNotLocked(vm.getDiskList());
Line 212:                 if (verifyDisksNotLocked) {
Done
Line 213:                     loadVmData(vm);
Line 214:                     Long currentDbGeneration = 
getVmStaticDao().getDbGeneration(vm.getId());
Line 215:                     if (vm.getStaticData().getDb_generation() == 
currentDbGeneration.longValue()) {
Line 216:                         buildMetadataDictionaryForVm(vm, 
vmsAndTemplateMetadata);


Line 241:         String templateMeta = ovfManager.ExportTemplate(template, 
allTemplateImages);
Line 242:         metaDictionary.put(template.getId(), new 
KeyValuePairCompat<String, List<Guid>>(
Line 243:                 templateMeta, LinqUtils.foreach(allTemplateImages, 
new Function<DiskImage, Guid>() {
Line 244:                     @Override
Line 245:                     public Guid eval(DiskImage diskImage) {
Done
Line 246:                         return 
diskImage.getimage_group_id().getValue();
Line 247:                     }
Line 248:                 })));
Line 249:     }


Line 249:     }
Line 250: 
Line 251:     protected void loadTemplateData(VmTemplate template) {
Line 252:         if (template.getInterfaces() == null || 
template.getInterfaces().isEmpty()) {
Line 253:             
template.setInterfaces(DbFacade.getInstance().getVmNetworkInterfaceDao()
Done
Line 254:                     .getAllForTemplate(template.getId()));
Line 255:         }
Line 256:     }
Line 257: 


Line 257: 
Line 258:     protected void loadVmData(VM vm) {
Line 259:         if (vm.getInterfaces().isEmpty()) {
Line 260:             
vm.setInterfaces(DbFacade.getInstance().getVmNetworkInterfaceDao().getAllForVm(vm.getId()));
Line 261:         }
Done
Line 262:         if (StringUtils.isEmpty(vm.getvmt_name())) {
Line 263:             VmTemplate t = 
DbFacade.getInstance().getVmTemplateDao().get(vm.getvmt_guid());
Line 264:             vm.setvmt_name(t.getname());
Line 265:         }


Line 265:         }
Line 266:     }
Line 267: 
Line 268:     protected void buildMetadataDictionaryForVm(VM vm , Map<Guid, 
KeyValuePairCompat<String, List<Guid>>> metaDictionary){
Line 269:         ArrayList<DiskImage> AllVmImages = new ArrayList<DiskImage>();
1. it's pre existing code :-) just moved here
2. ovfManager.ExportVm gets an ArrayList as a parameter and pass it to further 
methods, this change isn't related to this patch.
Line 270:         for (Disk disk : vm.getDiskMap().values()) {
Line 271:             if (disk.isAllowSnapshot()) {
Line 272:                 DiskImage diskImage = (DiskImage) disk;
Line 273:                 
AllVmImages.addAll(ImagesHandler.getAllImageSnapshots(diskImage.getImageId(),


....................................................
File 
backend/manager/modules/dal/src/main/java/org/ovirt/engine/core/dao/VmDAO.java
Line 159:      */
Line 160:     public List<VM> getAllVmsRelatedToQuotaId(Guid quotaId);
Line 161: 
Line 162:     /**
Line 163:      * Get all vms which were updated in db since last ovf update in 
storage by ids.
Done
Line 164:      *
Line 165:      * @param quotaId
Line 166:      * @param vmCount
Line 167:      * @return


....................................................
File 
backend/manager/modules/dal/src/main/java/org/ovirt/engine/core/dao/VmStaticDAO.java
Line 76:      */
Line 77:     public void incrementDbGenerationForAllInStoragePool(Guid 
storagePoolId);
Line 78: 
Line 79:     /**
Line 80:      * increment the generation for the vm/template with the given 
guid by 1
Done
Line 81:      *
Line 82:      * @param id - vm/template id
Line 83:      * @return
Line 84:      */


....................................................
File 
backend/manager/modules/dal/src/main/java/org/ovirt/engine/core/dao/VmTemplateDAO.java
Line 77:      */
Line 78:     List<VmTemplate> getAllTemplatesRelatedToQuotaId(Guid quotaId);
Line 79: 
Line 80:     /**
Line 81:      * Get all templates which were updated in db since last ovf 
update in storage by ids.
Done
Line 82:      *
Line 83:      * @param quotaId
Line 84:      * @param teamplatesCount
Line 85:      * @return


....................................................
File 
backend/manager/modules/vdsbroker/src/main/java/org/ovirt/engine/core/vdsbroker/irsbroker/UpdateVMVDSCommand.java
Line 53:         VdcBllErrors returnStatus = 
GetReturnValueFromStatus(getReturnStatus());
Line 54:         if (returnStatus != VdcBllErrors.Done) {
Line 55:             getVDSReturnValue().setSucceeded(false);
Line 56:             InitializeVdsError(returnStatus);
Line 57:         }
Done
Line 58:     }
Line 59: 
Line 60:     @Override
Line 61:     protected VDSExceptionBase createDefaultConcreteException(String 
errorMessage) {


--
To view, visit http://gerrit.ovirt.org/9328
To unsubscribe, visit http://gerrit.ovirt.org/settings

Gerrit-MessageType: comment
Gerrit-Change-Id: I9b5132300fb1f1fd94f771cab15efe5246dbeca8
Gerrit-PatchSet: 10
Gerrit-Project: ovirt-engine
Gerrit-Branch: master
Gerrit-Owner: Liron Aravot <[email protected]>
Gerrit-Reviewer: Allon Mureinik <[email protected]>
Gerrit-Reviewer: Arik Hadas <[email protected]>
Gerrit-Reviewer: Ayal Baron <[email protected]>
Gerrit-Reviewer: Liron Aravot <[email protected]>
Gerrit-Reviewer: Maor Lipchuk <[email protected]>
Gerrit-Reviewer: Michael Kublin <[email protected]>
Gerrit-Reviewer: Tal Nisan <[email protected]>
Gerrit-Reviewer: Vered Volansky <[email protected]>
Gerrit-Reviewer: Yair Zaslavsky <[email protected]>
Gerrit-Reviewer: liron aravot <[email protected]>
_______________________________________________
Engine-patches mailing list
[email protected]
http://lists.ovirt.org/mailman/listinfo/engine-patches

Reply via email to