mirror of
				https://github.com/apache/cloudstack.git
				synced 2025-11-04 00:02:37 +01:00 
			
		
		
		
	Fix size issue in copying template from S3 to cache storage to make
system vm up.
This commit is contained in:
		
							parent
							
								
									d5050d3157
								
							
						
					
					
						commit
						b66c484905
					
				@ -263,7 +263,7 @@ public class TemplateDataStoreVO implements StateObject<ObjectInDataStoreStateMa
 | 
				
			|||||||
		return tid.hashCode()+hid.hashCode();
 | 
							return tid.hashCode()+hid.hashCode();
 | 
				
			||||||
	}
 | 
						}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    public void setSize(long size) {
 | 
					    public void setSize(Long size) {
 | 
				
			||||||
        this.size = size;
 | 
					        this.size = size;
 | 
				
			||||||
    }
 | 
					    }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
				
			|||||||
@ -613,7 +613,7 @@ public class TemplateServiceImpl implements TemplateService {
 | 
				
			|||||||
            TemplateDataStoreVO tmpltStore = _vmTemplateStoreDao.findByStoreTemplate(storeId, tmplt.getId());
 | 
					            TemplateDataStoreVO tmpltStore = _vmTemplateStoreDao.findByStoreTemplate(storeId, tmplt.getId());
 | 
				
			||||||
            if ( tmpltStore == null ) {
 | 
					            if ( tmpltStore == null ) {
 | 
				
			||||||
                tmpltStore = new TemplateDataStoreVO(storeId, tmplt.getId(), new Date(), 100, Status.DOWNLOADED, null, null, null, TemplateConstants.DEFAULT_SYSTEM_VM_TEMPLATE_PATH + tmplt.getId() + File.separator, tmplt.getUrl());
 | 
					                tmpltStore = new TemplateDataStoreVO(storeId, tmplt.getId(), new Date(), 100, Status.DOWNLOADED, null, null, null, TemplateConstants.DEFAULT_SYSTEM_VM_TEMPLATE_PATH + tmplt.getId() + File.separator, tmplt.getUrl());
 | 
				
			||||||
                tmpltStore.setSize(0);
 | 
					                tmpltStore.setSize(0L);
 | 
				
			||||||
                tmpltStore.setPhysicalSize(0); // no size information for pre-seeded system vm templates
 | 
					                tmpltStore.setPhysicalSize(0); // no size information for pre-seeded system vm templates
 | 
				
			||||||
                tmpltStore.setDataStoreRole(store.getRole());
 | 
					                tmpltStore.setDataStoreRole(store.getRole());
 | 
				
			||||||
                _vmTemplateStoreDao.persist(tmpltStore);
 | 
					                _vmTemplateStoreDao.persist(tmpltStore);
 | 
				
			||||||
 | 
				
			|||||||
@ -359,6 +359,7 @@ public class VolumeServiceImpl implements VolumeService {
 | 
				
			|||||||
        try {
 | 
					        try {
 | 
				
			||||||
         	templateOnPrimaryStoreObj.processEvent(Event.CreateOnlyRequested);
 | 
					         	templateOnPrimaryStoreObj.processEvent(Event.CreateOnlyRequested);
 | 
				
			||||||
        } catch (Exception e) {
 | 
					        } catch (Exception e) {
 | 
				
			||||||
 | 
					            s_logger.info("Got exception in case of multi-thread");
 | 
				
			||||||
        	try {
 | 
					        	try {
 | 
				
			||||||
        	    templateOnPrimaryStoreObj = waitForTemplateDownloaded(dataStore, template);
 | 
					        	    templateOnPrimaryStoreObj = waitForTemplateDownloaded(dataStore, template);
 | 
				
			||||||
        	} catch(Exception e1) {
 | 
					        	} catch(Exception e1) {
 | 
				
			||||||
 | 
				
			|||||||
@ -50,6 +50,7 @@ import com.cloud.agent.api.StartupSecondaryStorageCommand;
 | 
				
			|||||||
import com.cloud.agent.api.StopAnswer;
 | 
					import com.cloud.agent.api.StopAnswer;
 | 
				
			||||||
import com.cloud.agent.api.check.CheckSshAnswer;
 | 
					import com.cloud.agent.api.check.CheckSshAnswer;
 | 
				
			||||||
import com.cloud.agent.api.check.CheckSshCommand;
 | 
					import com.cloud.agent.api.check.CheckSshCommand;
 | 
				
			||||||
 | 
					import com.cloud.agent.api.to.NfsTO;
 | 
				
			||||||
import com.cloud.agent.api.to.NicTO;
 | 
					import com.cloud.agent.api.to.NicTO;
 | 
				
			||||||
import com.cloud.agent.api.to.VirtualMachineTO;
 | 
					import com.cloud.agent.api.to.VirtualMachineTO;
 | 
				
			||||||
import com.cloud.agent.manager.Commands;
 | 
					import com.cloud.agent.manager.Commands;
 | 
				
			||||||
@ -293,6 +294,8 @@ public class SecondaryStorageManagerImpl extends ManagerBase implements Secondar
 | 
				
			|||||||
 | 
					
 | 
				
			||||||
            List<DataStore> ssStores = this._dataStoreMgr.getImageStoresByScope(new ZoneScope(zoneId));
 | 
					            List<DataStore> ssStores = this._dataStoreMgr.getImageStoresByScope(new ZoneScope(zoneId));
 | 
				
			||||||
             for( DataStore ssStore : ssStores ) {
 | 
					             for( DataStore ssStore : ssStores ) {
 | 
				
			||||||
 | 
					                 if (!(ssStore.getTO() instanceof NfsTO ))
 | 
				
			||||||
 | 
					                     continue; // only do this for Nfs
 | 
				
			||||||
                String secUrl = ssStore.getUri();
 | 
					                String secUrl = ssStore.getUri();
 | 
				
			||||||
                SecStorageSetupCommand setupCmd = null;
 | 
					                SecStorageSetupCommand setupCmd = null;
 | 
				
			||||||
                if (!_useSSlCopy) {
 | 
					                if (!_useSSlCopy) {
 | 
				
			||||||
 | 
				
			|||||||
@ -308,6 +308,8 @@ public class NfsSecondaryStorageResource extends ServerResourceBase implements S
 | 
				
			|||||||
 | 
					
 | 
				
			||||||
            String finalFileName = templateFilename;
 | 
					            String finalFileName = templateFilename;
 | 
				
			||||||
            String finalDownloadPath = destPath + File.separator + templateFilename;
 | 
					            String finalDownloadPath = destPath + File.separator + templateFilename;
 | 
				
			||||||
 | 
					            // compute the size of
 | 
				
			||||||
 | 
					            long size = this._storage.getSize(downloadPath + File.separator + templateFilename);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
            DataTO newDestTO = null;
 | 
					            DataTO newDestTO = null;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
@ -315,6 +317,7 @@ public class NfsSecondaryStorageResource extends ServerResourceBase implements S
 | 
				
			|||||||
                TemplateObjectTO newTemplTO = new TemplateObjectTO();
 | 
					                TemplateObjectTO newTemplTO = new TemplateObjectTO();
 | 
				
			||||||
                newTemplTO.setPath(finalDownloadPath);
 | 
					                newTemplTO.setPath(finalDownloadPath);
 | 
				
			||||||
                newTemplTO.setName(finalFileName);
 | 
					                newTemplTO.setName(finalFileName);
 | 
				
			||||||
 | 
					                newTemplTO.setSize(size);
 | 
				
			||||||
                newDestTO = newTemplTO;
 | 
					                newDestTO = newTemplTO;
 | 
				
			||||||
            } else {
 | 
					            } else {
 | 
				
			||||||
                return new CopyCmdAnswer("not implemented yet");
 | 
					                return new CopyCmdAnswer("not implemented yet");
 | 
				
			||||||
 | 
				
			|||||||
		Loading…
	
	
			
			x
			
			
		
	
		Reference in New Issue
	
	Block a user