@@ -1374,12 +1374,20 @@ public VMTemplateVO createPrivateTemplateRecord(CreateTemplateCmd cmd) throws Re
13741374 Long nextTemplateId = _templateDao .getNextInSequence (Long .class , "id" );
13751375 String description = cmd .getDisplayText ();
13761376 boolean isExtractable = false ;
1377+ Long sourceTemplateId = null ;
13771378 if (volume != null ) {
13781379 VMTemplateVO template = ApiDBUtils .findTemplateById (volume .getTemplateId ());
13791380 isExtractable = template != null && template .isExtractable () && template .getTemplateType () != Storage .TemplateType .SYSTEM ;
1381+ sourceTemplateId = template .getId ();
13801382 }
13811383 privateTemplate = new VMTemplateVO (nextTemplateId , uniqueName , name , ImageFormat .RAW , isPublic , featured , isExtractable , TemplateType .USER , null , null , requiresHvmValue , bitsValue , accountId ,
13821384 null , description , passwordEnabledValue , guestOS .getId (), true , hyperType );
1385+ if (sourceTemplateId != null ){
1386+ if (s_logger .isDebugEnabled ()){
1387+ s_logger .debug ("This template is getting created from other template, setting source template Id to: " +sourceTemplateId );
1388+ }
1389+ }
1390+ privateTemplate .setSourceTemplateId (sourceTemplateId );
13831391
13841392 VMTemplateVO template = _templateDao .persist (privateTemplate );
13851393 // Increment the number of templates
@@ -1954,7 +1962,7 @@ protected boolean validPassword(String password) {
19541962 @ Override
19551963 public UserVm createBasicSecurityGroupVirtualMachine (DataCenter zone , ServiceOffering serviceOffering , VirtualMachineTemplate template , List <Long > securityGroupIdList , Account owner ,
19561964 String hostName , String displayName , Long diskOfferingId , Long diskSize , String group , HypervisorType hypervisor , String userData , String sshKeyPair , Host destinationHost )
1957- throws InsufficientCapacityException , ConcurrentOperationException , ResourceUnavailableException , StorageUnavailableException , ResourceAllocationException {
1965+ throws InsufficientCapacityException , ConcurrentOperationException , ResourceUnavailableException , StorageUnavailableException , ResourceAllocationException {
19581966
19591967 Account caller = UserContext .current ().getCaller ();
19601968 List <NetworkVO > networkList = new ArrayList <NetworkVO >();
@@ -2052,7 +2060,7 @@ public UserVm createAdvancedSecurityGroupVirtualMachine(DataCenter zone, Service
20522060 @ Override
20532061 public UserVm createAdvancedVirtualMachine (DataCenter zone , ServiceOffering serviceOffering , VirtualMachineTemplate template , List <Long > networkIdList , Account owner , String hostName ,
20542062 String displayName , Long diskOfferingId , Long diskSize , String group , HypervisorType hypervisor , String userData , String sshKeyPair , Host destinationHost )
2055- throws InsufficientCapacityException , ConcurrentOperationException , ResourceUnavailableException , StorageUnavailableException , ResourceAllocationException {
2063+ throws InsufficientCapacityException , ConcurrentOperationException , ResourceUnavailableException , StorageUnavailableException , ResourceAllocationException {
20562064
20572065 Account caller = UserContext .current ().getCaller ();
20582066 List <NetworkVO > networkList = new ArrayList <NetworkVO >();
@@ -2397,7 +2405,7 @@ public UserVm startVirtualMachine(DeployVMCmd cmd) throws ResourceUnavailableExc
23972405 }
23982406
23992407 protected UserVm startVirtualMachine (DeployVMCmd cmd , Map <VirtualMachineProfile .Param , Object > additonalParams ) throws ResourceUnavailableException , InsufficientCapacityException ,
2400- ConcurrentOperationException {
2408+ ConcurrentOperationException {
24012409 long vmId = cmd .getEntityId ();
24022410 UserVmVO vm = _vmDao .findById (vmId );
24032411 _vmDao .loadDetails (vm );
@@ -2955,7 +2963,7 @@ public HypervisorType getHypervisorTypeOfUserVM(long vmid) {
29552963
29562964 @ Override
29572965 public UserVm createVirtualMachine (DeployVMCmd cmd ) throws InsufficientCapacityException , ResourceUnavailableException , ConcurrentOperationException , StorageUnavailableException ,
2958- ResourceAllocationException {
2966+ ResourceAllocationException {
29592967 // TODO Auto-generated method stub
29602968 return null ;
29612969 }
0 commit comments