@@ -8860,36 +8860,21 @@ public UserVm allocateVMFromBackup(CreateVMFromBackupCmd cmd) throws Insufficien
88608860 throw new InvalidParameterValueException ("Deploy as is template not supported" );
88618861 }
88628862
8863- Long diskOfferingId = cmd .getDiskOfferingId ();
8864- DiskOffering diskOffering = null ;
8865- if (diskOfferingId != null ) {
8866- diskOffering = _entityMgr .findById (DiskOffering .class , diskOfferingId );
8867- if (diskOffering == null ) {
8868- throw new InvalidParameterValueException ("Unable to find disk offering " + diskOfferingId );
8869- }
8870- if (diskOffering .isComputeOnly ()) {
8871- throw new InvalidParameterValueException (String .format ("The disk offering id %d provided is directly mapped to a service offering, please provide an individual disk offering" , diskOfferingId ));
8872- }
8863+ if (cmd .getDiskOfferingId () != null ) {
8864+ throw new InvalidParameterValueException (ApiConstants .DISK_OFFERING_ID + " parameter is not supported for creating instance from backup. Please use the parameter " + ApiConstants .DATADISKS_DETAILS );
88738865 }
88748866
88758867 List <DiskOfferingInfo > dataDiskOfferingsInfo = cmd .getDataDiskOfferingsInfo ();
88768868 if (dataDiskOfferingsInfo != null ) {
88778869 backupManager .updateDiskOfferingSizeFromBackup (dataDiskOfferingsInfo , backup );
8878- }
8879- if (dataDiskOfferingsInfo != null && diskOfferingId != null ) {
8880- new InvalidParameterValueException ("Cannot specify both disk offering id and data disk offering details" );
8881- }
8882- if (dataDiskOfferingsInfo == null && diskOfferingId == null ) {
8870+ } else {
88838871 dataDiskOfferingsInfo = backupManager .getDataDiskOfferingListFromBackup (backup );
88848872 }
88858873
88868874 DiskOffering diskOfferingMappedInServiceOffering = _entityMgr .findById (DiskOffering .class , serviceOffering .getDiskOfferingId ());
88878875 if (diskOfferingMappedInServiceOffering .isUseLocalStorage ()) {
88888876 throw new InvalidParameterValueException ("Local storage disk offering not supported for instance created from backup" );
88898877 }
8890- if (diskOffering != null && diskOffering .isUseLocalStorage ()) {
8891- throw new InvalidParameterValueException ("Local storage disk offering not supported for instance created from backup" );
8892- }
88938878
88948879 List <Long > networkIds = cmd .getNetworkIds ();
88958880 LinkedHashMap <Integer , Long > userVmNetworkMap = getVmOvfNetworkMapping (zone , owner , template , cmd .getVmNetworkMap ());
@@ -8933,7 +8918,7 @@ public UserVm allocateVMFromBackup(CreateVMFromBackupCmd cmd) throws Insufficien
89338918 if (networkIds != null ) {
89348919 throw new InvalidParameterValueException ("Can't specify network Ids in Basic zone" );
89358920 } else {
8936- vm = createBasicSecurityGroupVirtualMachine (zone , serviceOffering , template , getSecurityGroupIdList (cmd , zone , template , owner ), owner , name , displayName , diskOfferingId ,
8921+ vm = createBasicSecurityGroupVirtualMachine (zone , serviceOffering , template , getSecurityGroupIdList (cmd , zone , template , owner ), owner , name , displayName , null ,
89378922 size , dataDiskOfferingsInfo , null , cmd .getHypervisor (), cmd .getHttpMethod (), null , null , null , sshKeyPairs , ipToNetworkMap , addrs , null , null , cmd .getAffinityGroupIdList (),
89388923 cmd .getDetails (), cmd .getCustomId (), cmd .getDhcpOptionsMap (),
89398924 dataDiskTemplateToDiskOfferingMap , userVmOVFProperties , false , overrideDiskOfferingId );
@@ -8942,15 +8927,15 @@ public UserVm allocateVMFromBackup(CreateVMFromBackupCmd cmd) throws Insufficien
89428927 if (_networkModel .checkSecurityGroupSupportForNetwork (owner , zone , networkIds ,
89438928 cmd .getSecurityGroupIdList ())) {
89448929 vm = createAdvancedSecurityGroupVirtualMachine (zone , serviceOffering , template , networkIds , getSecurityGroupIdList (cmd , zone , template , owner ), owner , name ,
8945- displayName , diskOfferingId , size , dataDiskOfferingsInfo , null , cmd .getHypervisor (), cmd .getHttpMethod (), null , null , null , sshKeyPairs , ipToNetworkMap , addrs , null , null ,
8930+ displayName , null , size , dataDiskOfferingsInfo , null , cmd .getHypervisor (), cmd .getHttpMethod (), null , null , null , sshKeyPairs , ipToNetworkMap , addrs , null , null ,
89468931 cmd .getAffinityGroupIdList (), cmd .getDetails (), cmd .getCustomId (), cmd .getDhcpOptionsMap (),
89478932 dataDiskTemplateToDiskOfferingMap , userVmOVFProperties , false , overrideDiskOfferingId , null );
89488933
89498934 } else {
89508935 if (cmd .getSecurityGroupIdList () != null && !cmd .getSecurityGroupIdList ().isEmpty ()) {
89518936 throw new InvalidParameterValueException ("Can't create vm with security groups; security group feature is not enabled per zone" );
89528937 }
8953- vm = createAdvancedVirtualMachine (zone , serviceOffering , template , networkIds , owner , name , displayName , diskOfferingId , size , dataDiskOfferingsInfo , null ,
8938+ vm = createAdvancedVirtualMachine (zone , serviceOffering , template , networkIds , owner , name , displayName , null , size , dataDiskOfferingsInfo , null ,
89548939 cmd .getHypervisor (), cmd .getHttpMethod (), null , null , null , sshKeyPairs , ipToNetworkMap , addrs , null , null , cmd .getAffinityGroupIdList (), cmd .getDetails (),
89558940 cmd .getCustomId (), cmd .getDhcpOptionsMap (), dataDiskTemplateToDiskOfferingMap , userVmOVFProperties , false , null , overrideDiskOfferingId );
89568941 }
0 commit comments