@@ -898,6 +898,7 @@ private UserVm migrateImportedVM(HostVO sourceHost, VirtualMachineTemplate templ
898898 if (!hostSupportsServiceOfferingAndTemplate (sourceHost , serviceOffering , template )) {
899899 logger .debug (String .format ("VM %s needs to be migrated" , vm .getUuid ()));
900900 final VirtualMachineProfile profile = new VirtualMachineProfileImpl (vm , template , serviceOffering , owner , null );
901+ profile .setServiceOffering (serviceOfferingDao .findById (vm .getId (), serviceOffering .getId ()));
901902 DeploymentPlanner .ExcludeList excludeList = new DeploymentPlanner .ExcludeList ();
902903 excludeList .addHost (sourceHost .getId ());
903904 final DataCenterDeployment plan = new DataCenterDeployment (sourceHost .getDataCenterId (), sourceHost .getPodId (), sourceHost .getClusterId (), null , null , null );
@@ -2164,11 +2165,6 @@ private UserVm importExternalKvmVirtualMachine(final UnmanagedInstanceTO unmanag
21642165 UserVm userVm = null ;
21652166
21662167 Map <String , String > allDetails = new HashMap <>(details );
2167- if (serviceOffering .isDynamic ()) {
2168- allDetails .put (VmDetailConstants .CPU_NUMBER , String .valueOf (serviceOffering .getCpu ()));
2169- allDetails .put (VmDetailConstants .MEMORY , String .valueOf (serviceOffering .getRamSize ()));
2170- allDetails .put (VmDetailConstants .CPU_SPEED , String .valueOf (serviceOffering .getSpeed ()));
2171- }
21722168 // Check disks and supplied disk offerings
21732169 List <UnmanagedInstanceTO .Disk > unmanagedInstanceDisks = unmanagedInstance .getDisks ();
21742170
@@ -2222,6 +2218,8 @@ private UserVm importExternalKvmVirtualMachine(final UnmanagedInstanceTO unmanag
22222218 }
22232219
22242220 final VirtualMachineProfile profile = new VirtualMachineProfileImpl (userVm , template , serviceOffering , owner , null );
2221+ ServiceOfferingVO dummyOffering = serviceOfferingDao .findById (userVm .getId (), serviceOffering .getId ());
2222+ profile .setServiceOffering (dummyOffering );
22252223 DeploymentPlanner .ExcludeList excludeList = new DeploymentPlanner .ExcludeList ();
22262224 final DataCenterDeployment plan = new DataCenterDeployment (zone .getId (), null , null , null , null , null );
22272225 DeployDestination dest = null ;
@@ -2273,7 +2271,7 @@ private UserVm importExternalKvmVirtualMachine(final UnmanagedInstanceTO unmanag
22732271 cleanupFailedImportVM (userVm );
22742272 throw new ServerApiException (ApiErrorCode .INTERNAL_ERROR , String .format ("Failed to import NICs while importing vm: %s. %s" , instanceName , StringUtils .defaultString (e .getMessage ())));
22752273 }
2276- publishVMUsageUpdateResourceCount (userVm , serviceOffering , template );
2274+ publishVMUsageUpdateResourceCount (userVm , dummyOffering , template );
22772275 return userVm ;
22782276 }
22792277
@@ -2285,11 +2283,6 @@ private UserVm importKvmVirtualMachineFromDisk(final ImportSource importSource,
22852283 UserVm userVm = null ;
22862284
22872285 Map <String , String > allDetails = new HashMap <>(details );
2288- if (serviceOffering .isDynamic ()) {
2289- allDetails .put (VmDetailConstants .CPU_NUMBER , String .valueOf (serviceOffering .getCpu ()));
2290- allDetails .put (VmDetailConstants .MEMORY , String .valueOf (serviceOffering .getRamSize ()));
2291- allDetails .put (VmDetailConstants .CPU_SPEED , String .valueOf (serviceOffering .getSpeed ()));
2292- }
22932286
22942287 VirtualMachine .PowerState powerState = VirtualMachine .PowerState .PowerOff ;
22952288
@@ -2356,6 +2349,8 @@ private UserVm importKvmVirtualMachineFromDisk(final ImportSource importSource,
23562349 DiskProfile diskProfile = volumeManager .allocateRawVolume (Volume .Type .ROOT , rootVolumeName , diskOffering , null , null , null , userVm , template , owner , null );
23572350
23582351 final VirtualMachineProfile profile = new VirtualMachineProfileImpl (userVm , template , serviceOffering , owner , null );
2352+ ServiceOfferingVO dummyOffering = serviceOfferingDao .findById (userVm .getId (), serviceOffering .getId ());
2353+ profile .setServiceOffering (dummyOffering );
23592354 DeploymentPlanner .ExcludeList excludeList = new DeploymentPlanner .ExcludeList ();
23602355 final DataCenterDeployment plan = new DataCenterDeployment (zone .getId (), null , null , hostId , poolId , null );
23612356 DeployDestination dest = null ;
@@ -2407,7 +2402,7 @@ private UserVm importKvmVirtualMachineFromDisk(final ImportSource importSource,
24072402 throw new ServerApiException (ApiErrorCode .INTERNAL_ERROR , String .format ("Failed to import volumes while importing vm: %s. %s" , instanceName , StringUtils .defaultString (e .getMessage ())));
24082403 }
24092404 networkOrchestrationService .importNic (macAddress , 0 , network , true , userVm , requestedIpPair , zone , true );
2410- publishVMUsageUpdateResourceCount (userVm , serviceOffering , template );
2405+ publishVMUsageUpdateResourceCount (userVm , dummyOffering , template );
24112406 return userVm ;
24122407 }
24132408
0 commit comments