@@ -1644,16 +1644,45 @@ private UserVm importUnmanagedInstanceFromHypervisor(DataCenter zone, Cluster cl
16441644 }
16451645
16461646 private Pair <UnmanagedInstanceTO , Boolean > getSourceVmwareUnmanagedInstance (String vcenter , String datacenterName , String username ,
1647- String password , String clusterName , String sourceHostName ,
1648- String sourceVM ) {
1647+ String password , String clusterName , String sourceHostName ,
1648+ String sourceVM , ServiceOfferingVO serviceOffering ) {
16491649 HypervisorGuru vmwareGuru = hypervisorGuruManager .getGuru (Hypervisor .HypervisorType .VMware );
16501650
16511651 Map <String , String > params = createParamsForTemplateFromVmwareVmMigration (vcenter , datacenterName ,
16521652 username , password , clusterName , sourceHostName , sourceVM );
1653+ addServiceOfferingDetailsToParams (params , serviceOffering );
16531654
16541655 return vmwareGuru .getHypervisorVMOutOfBandAndCloneIfRequired (sourceHostName , sourceVM , params );
16551656 }
16561657
1658+ /**
1659+ * Add the minimum resources to check on the hypervisor source VM before converting the instance against the selected offering resources
1660+ * @param params sets the minimum CPU number, CPU speed and memory to be checked against the source VM
1661+ * @param serviceOffering service offering for the converted VM
1662+ */
1663+ protected void addServiceOfferingDetailsToParams (Map <String , String > params , ServiceOfferingVO serviceOffering ) {
1664+ if (serviceOffering != null ) {
1665+ serviceOfferingDao .loadDetails (serviceOffering );
1666+ Map <String , String > serviceOfferingDetails = serviceOffering .getDetails ();
1667+
1668+ if (serviceOffering .getCpu () != null ) {
1669+ params .put (VmDetailConstants .CPU_NUMBER , String .valueOf (serviceOffering .getCpu ()));
1670+ } else if (MapUtils .isNotEmpty (serviceOfferingDetails ) && serviceOfferingDetails .containsKey (ApiConstants .MIN_CPU_NUMBER )) {
1671+ params .put (VmDetailConstants .CPU_NUMBER , serviceOfferingDetails .get (ApiConstants .MIN_CPU_NUMBER ));
1672+ }
1673+
1674+ if (serviceOffering .getSpeed () != null ) {
1675+ params .put (VmDetailConstants .CPU_SPEED , String .valueOf (serviceOffering .getSpeed ()));
1676+ }
1677+
1678+ if (serviceOffering .getRamSize () != null ) {
1679+ params .put (VmDetailConstants .MEMORY , String .valueOf (serviceOffering .getRamSize ()));
1680+ } else if (MapUtils .isNotEmpty (serviceOfferingDetails ) && serviceOfferingDetails .containsKey (ApiConstants .MIN_MEMORY )) {
1681+ params .put (VmDetailConstants .MEMORY , serviceOfferingDetails .get (ApiConstants .MIN_MEMORY ));
1682+ }
1683+ }
1684+ }
1685+
16571686 private String createOvfTemplateOfSourceVmwareUnmanagedInstance (String vcenter , String datacenterName , String username ,
16581687 String password , String clusterName , String sourceHostName ,
16591688 String sourceVMwareInstanceName , DataStoreTO convertLocation , int threadsCountToExportOvf ) {
@@ -1734,7 +1763,7 @@ protected UserVm importUnmanagedInstanceFromVmwareToKvm(DataCenter zone, Cluster
17341763 // sourceVMwareInstance could be a cloned instance from sourceVMName, of the sourceVMName itself if its powered off.
17351764 // isClonedInstance indicates if the VM is a clone of sourceVMName
17361765
1737- Pair <UnmanagedInstanceTO , Boolean > sourceInstanceDetails = getSourceVmwareUnmanagedInstance (vcenter , datacenterName , username , password , clusterName , sourceHostName , sourceVMName );
1766+ Pair <UnmanagedInstanceTO , Boolean > sourceInstanceDetails = getSourceVmwareUnmanagedInstance (vcenter , datacenterName , username , password , clusterName , sourceHostName , sourceVMName , serviceOffering );
17381767 sourceVMwareInstance = sourceInstanceDetails .first ();
17391768 isClonedInstance = sourceInstanceDetails .second ();
17401769
0 commit comments