@@ -896,6 +896,7 @@ private UserVm migrateImportedVM(HostVO sourceHost, VirtualMachineTemplate templ
896896 if (!hostSupportsServiceOffering (sourceHost , serviceOffering )) {
897897 LOGGER .debug (String .format ("VM %s needs to be migrated" , vm .getUuid ()));
898898 final VirtualMachineProfile profile = new VirtualMachineProfileImpl (vm , template , serviceOffering , owner , null );
899+ profile .setServiceOffering (serviceOfferingDao .findById (vm .getId (), serviceOffering .getId ()));
899900 DeploymentPlanner .ExcludeList excludeList = new DeploymentPlanner .ExcludeList ();
900901 excludeList .addHost (sourceHost .getId ());
901902 final DataCenterDeployment plan = new DataCenterDeployment (sourceHost .getDataCenterId (), sourceHost .getPodId (), sourceHost .getClusterId (), null , null , null );
@@ -2131,11 +2132,6 @@ private UserVm importExternalKvmVirtualMachine(final UnmanagedInstanceTO unmanag
21312132 UserVm userVm = null ;
21322133
21332134 Map <String , String > allDetails = new HashMap <>(details );
2134- if (serviceOffering .isDynamic ()) {
2135- allDetails .put (VmDetailConstants .CPU_NUMBER , String .valueOf (serviceOffering .getCpu ()));
2136- allDetails .put (VmDetailConstants .MEMORY , String .valueOf (serviceOffering .getRamSize ()));
2137- allDetails .put (VmDetailConstants .CPU_SPEED , String .valueOf (serviceOffering .getSpeed ()));
2138- }
21392135 // Check disks and supplied disk offerings
21402136 List <UnmanagedInstanceTO .Disk > unmanagedInstanceDisks = unmanagedInstance .getDisks ();
21412137
@@ -2189,6 +2185,8 @@ private UserVm importExternalKvmVirtualMachine(final UnmanagedInstanceTO unmanag
21892185 }
21902186
21912187 final VirtualMachineProfile profile = new VirtualMachineProfileImpl (userVm , template , serviceOffering , owner , null );
2188+ ServiceOfferingVO dummyOffering = serviceOfferingDao .findById (userVm .getId (), serviceOffering .getId ());
2189+ profile .setServiceOffering (dummyOffering );
21922190 DeploymentPlanner .ExcludeList excludeList = new DeploymentPlanner .ExcludeList ();
21932191 final DataCenterDeployment plan = new DataCenterDeployment (zone .getId (), null , null , null , null , null );
21942192 DeployDestination dest = null ;
@@ -2240,7 +2238,7 @@ private UserVm importExternalKvmVirtualMachine(final UnmanagedInstanceTO unmanag
22402238 cleanupFailedImportVM (userVm );
22412239 throw new ServerApiException (ApiErrorCode .INTERNAL_ERROR , String .format ("Failed to import NICs while importing vm: %s. %s" , instanceName , StringUtils .defaultString (e .getMessage ())));
22422240 }
2243- publishVMUsageUpdateResourceCount (userVm , serviceOffering );
2241+ publishVMUsageUpdateResourceCount (userVm , dummyOffering );
22442242 return userVm ;
22452243 }
22462244
@@ -2252,11 +2250,6 @@ private UserVm importKvmVirtualMachineFromDisk(final ImportSource importSource,
22522250 UserVm userVm = null ;
22532251
22542252 Map <String , String > allDetails = new HashMap <>(details );
2255- if (serviceOffering .isDynamic ()) {
2256- allDetails .put (VmDetailConstants .CPU_NUMBER , String .valueOf (serviceOffering .getCpu ()));
2257- allDetails .put (VmDetailConstants .MEMORY , String .valueOf (serviceOffering .getRamSize ()));
2258- allDetails .put (VmDetailConstants .CPU_SPEED , String .valueOf (serviceOffering .getSpeed ()));
2259- }
22602253
22612254 VirtualMachine .PowerState powerState = VirtualMachine .PowerState .PowerOff ;
22622255
@@ -2323,6 +2316,8 @@ private UserVm importKvmVirtualMachineFromDisk(final ImportSource importSource,
23232316 DiskProfile diskProfile = volumeManager .allocateRawVolume (Volume .Type .ROOT , rootVolumeName , diskOffering , null , null , null , userVm , template , owner , null );
23242317
23252318 final VirtualMachineProfile profile = new VirtualMachineProfileImpl (userVm , template , serviceOffering , owner , null );
2319+ ServiceOfferingVO dummyOffering = serviceOfferingDao .findById (userVm .getId (), serviceOffering .getId ());
2320+ profile .setServiceOffering (dummyOffering );
23262321 DeploymentPlanner .ExcludeList excludeList = new DeploymentPlanner .ExcludeList ();
23272322 final DataCenterDeployment plan = new DataCenterDeployment (zone .getId (), null , null , hostId , poolId , null );
23282323 DeployDestination dest = null ;
@@ -2374,7 +2369,7 @@ private UserVm importKvmVirtualMachineFromDisk(final ImportSource importSource,
23742369 throw new ServerApiException (ApiErrorCode .INTERNAL_ERROR , String .format ("Failed to import volumes while importing vm: %s. %s" , instanceName , StringUtils .defaultString (e .getMessage ())));
23752370 }
23762371 networkOrchestrationService .importNic (macAddress ,0 ,network , true , userVm , requestedIpPair , zone , true );
2377- publishVMUsageUpdateResourceCount (userVm , serviceOffering );
2372+ publishVMUsageUpdateResourceCount (userVm , dummyOffering );
23782373 return userVm ;
23792374 }
23802375
0 commit comments