@@ -1518,7 +1518,7 @@ private boolean upgradeRunningVirtualMachine(Long vmId, Long newServiceOfferingI
15181518 // Check that the specified service offering ID is valid
15191519 _itMgr .checkIfCanUpgrade (vmInstance , newServiceOffering );
15201520
1521- ServiceOffering currentServiceOffering = _offeringDao .findByIdIncludingRemoved (vmInstance .getId (), vmInstance .getServiceOfferingId ());
1521+ ServiceOfferingVO currentServiceOffering = _offeringDao .findByIdIncludingRemoved (vmInstance .getId (), vmInstance .getServiceOfferingId ());
15221522 int newCpu = newServiceOffering .getCpu ();
15231523 int newMemory = newServiceOffering .getRamSize ();
15241524 int newSpeed = newServiceOffering .getSpeed ();
@@ -1535,6 +1535,19 @@ private boolean upgradeRunningVirtualMachine(Long vmId, Long newServiceOfferingI
15351535 + ",memory=," + currentMemory + ")" );
15361536 }
15371537
1538+ _offeringDao .loadDetails (currentServiceOffering );
1539+ _offeringDao .loadDetails (newServiceOffering );
1540+
1541+ Map <String , String > currentDetails = currentServiceOffering .getDetails ();
1542+ Map <String , String > newDetails = newServiceOffering .getDetails ();
1543+ String currentVgpuType = currentDetails .get ("vgpuType" );
1544+ String newVgpuType = newDetails .get ("vgpuType" );
1545+ if (currentVgpuType != null ) {
1546+ if (newVgpuType == null || !newVgpuType .equalsIgnoreCase (currentVgpuType )) {
1547+ throw new InvalidParameterValueException ("Dynamic scaling of vGPU type is not supported. VM has vGPU Type: " + currentVgpuType );
1548+ }
1549+ }
1550+
15381551 // Check resource limits
15391552 if (newCpu > currentCpu ) {
15401553 _resourceLimitMgr .checkResourceLimit (caller , ResourceType .cpu , newCpu - currentCpu );
@@ -1738,54 +1751,54 @@ public UserVm recoverVirtualMachine(RecoverVMCmd cmd) throws ResourceAllocationE
17381751 }
17391752
17401753 Transaction .execute (new TransactionCallbackWithExceptionNoReturn <ResourceAllocationException >() {
1741- @ Override
1742- public void doInTransactionWithoutResult (TransactionStatus status ) throws ResourceAllocationException {
1754+ @ Override public void doInTransactionWithoutResult (TransactionStatus status ) throws ResourceAllocationException {
17431755
17441756 Account account = _accountDao .lockRow (vm .getAccountId (), true );
17451757
1746- // if the account is deleted, throw error
1747- if (account .getRemoved () != null ) {
1758+ // if the account is deleted, throw error
1759+ if (account .getRemoved () != null ) {
17481760 throw new CloudRuntimeException ("Unable to recover VM as the account is deleted" );
1749- }
1761+ }
17501762
1751- // Get serviceOffering for Virtual Machine
1763+ // Get serviceOffering for Virtual Machine
17521764 ServiceOfferingVO serviceOffering = _serviceOfferingDao .findById (vm .getId (), vm .getServiceOfferingId ());
17531765
1754- // First check that the maximum number of UserVMs, CPU and Memory limit for the given
1755- // accountId will not be exceeded
1766+ // First check that the maximum number of UserVMs, CPU and Memory limit for the given
1767+ // accountId will not be exceeded
17561768 resourceLimitCheck (account , vm .isDisplayVm (), new Long (serviceOffering .getCpu ()), new Long (serviceOffering .getRamSize ()));
17571769
1758- _haMgr .cancelDestroy (vm , vm .getHostId ());
1770+ _haMgr .cancelDestroy (vm , vm .getHostId ());
17591771
1760- try {
1772+ try {
17611773 if (!_itMgr .stateTransitTo (vm , VirtualMachine .Event .RecoveryRequested , null )) {
17621774 s_logger .debug ("Unable to recover the vm because it is not in the correct state: " + vmId );
17631775 throw new InvalidParameterValueException ("Unable to recover the vm because it is not in the correct state: " + vmId );
1764- }
1765- } catch (NoTransitionException e ) {
1776+ }
1777+ } catch (NoTransitionException e ) {
17661778 throw new InvalidParameterValueException ("Unable to recover the vm because it is not in the correct state: " + vmId );
1767- }
1779+ }
17681780
1769- // Recover the VM's disks
1770- List <VolumeVO > volumes = _volsDao .findByInstance (vmId );
1771- for (VolumeVO volume : volumes ) {
1772- if (volume .getVolumeType ().equals (Volume .Type .ROOT )) {
1773- // Create an event
1774- Long templateId = volume .getTemplateId ();
1775- Long diskOfferingId = volume .getDiskOfferingId ();
1776- Long offeringId = null ;
1777- if (diskOfferingId != null ) {
1781+ // Recover the VM's disks
1782+ List <VolumeVO > volumes = _volsDao .findByInstance (vmId );
1783+ for (VolumeVO volume : volumes ) {
1784+ if (volume .getVolumeType ().equals (Volume .Type .ROOT )) {
1785+ // Create an event
1786+ Long templateId = volume .getTemplateId ();
1787+ Long diskOfferingId = volume .getDiskOfferingId ();
1788+ Long offeringId = null ;
1789+ if (diskOfferingId != null ) {
17781790 DiskOfferingVO offering = _diskOfferingDao .findById (diskOfferingId );
17791791 if (offering != null && (offering .getType () == DiskOfferingVO .Type .Disk )) {
1780- offeringId = offering .getId ();
1792+ offeringId = offering .getId ();
1793+ }
1794+ }
1795+ UsageEventUtils
1796+ .publishUsageEvent (EventTypes .EVENT_VOLUME_CREATE , volume .getAccountId (), volume .getDataCenterId (), volume .getId (), volume .getName (), offeringId ,
1797+ templateId , volume .getSize (), Volume .class .getName (), volume .getUuid (), volume .isDisplayVolume ());
17811798 }
17821799 }
1783- UsageEventUtils .publishUsageEvent (EventTypes .EVENT_VOLUME_CREATE , volume .getAccountId (), volume .getDataCenterId (), volume .getId (), volume .getName (),
1784- offeringId , templateId , volume .getSize (), Volume .class .getName (), volume .getUuid (), volume .isDisplayVolume ());
1785- }
1786- }
17871800
1788- //Update Resource Count for the given account
1801+ //Update Resource Count for the given account
17891802 resourceCountIncrement (account .getId (), vm .isDisplayVm (), new Long (serviceOffering .getCpu ()), new Long (serviceOffering .getRamSize ()));
17901803 }
17911804 });
0 commit comments