@@ -3670,7 +3670,7 @@ public boolean unplugNic(Network network, NicTO nic, VirtualMachineTO vm, Reserv
36703670 @ Override
36713671 public VMInstanceVO reConfigureVm (String vmUuid , ServiceOffering oldServiceOffering ,
36723672 boolean reconfiguringOnExistingHost )
3673- throws ResourceUnavailableException , ConcurrentOperationException {
3673+ throws ResourceUnavailableException , InsufficientServerCapacityException , ConcurrentOperationException {
36743674
36753675 AsyncJobExecutionContext jobContext = AsyncJobExecutionContext .getCurrentExecutionContext ();
36763676 if (!VmJobEnabled .value () || jobContext .isJobDispatchedBy (VmWorkConstants .VM_WORK_JOB_DISPATCHER )) {
@@ -3688,20 +3688,21 @@ public VMInstanceVO reConfigureVm(String vmUuid, ServiceOffering oldServiceOffer
36883688 throw new RuntimeException ("Execution excetion" , e );
36893689 }
36903690
3691- AsyncJobVO jobVo = _entityMgr .findById (AsyncJobVO .class , outcome .getJob ().getId ());
3692- if (jobVo .getResultCode () == JobInfo .Status .SUCCEEDED .ordinal ()) {
3693- return _entityMgr .findById (VMInstanceVO .class , vm .getId ());
3694- } else {
3695- Object jobResult = _jobMgr .unmarshallResultObject (outcome .getJob ());
3696- if (jobResult != null ) {
3697- if (jobResult instanceof ResourceUnavailableException )
3698- throw (ResourceUnavailableException )jobResult ;
3699- else if (jobResult instanceof ConcurrentOperationException )
3700- throw (ConcurrentOperationException )jobResult ;
3691+ Object jobResult = _jobMgr .unmarshallResultObject (outcome .getJob ());
3692+ if (jobResult != null ) {
3693+ if (jobResult instanceof ResourceUnavailableException )
3694+ throw (ResourceUnavailableException )jobResult ;
3695+ else if (jobResult instanceof ConcurrentOperationException )
3696+ throw (ConcurrentOperationException )jobResult ;
3697+ else if (jobResult instanceof InsufficientServerCapacityException )
3698+ throw (InsufficientServerCapacityException )jobResult ;
3699+ else if (jobResult instanceof Throwable ) {
3700+ s_logger .error ("Unhandled exception" , (Throwable )jobResult );
3701+ throw new RuntimeException ("Unhandled exception" , (Throwable )jobResult );
37013702 }
3702-
3703- throw new RuntimeException ("Failed with un-handled exception" );
37043703 }
3704+
3705+ return (VMInstanceVO )vm ;
37053706 }
37063707 }
37073708
@@ -4633,7 +4634,7 @@ public Object[] doInTransaction(TransactionStatus status) {
46334634 }
46344635
46354636 public Outcome <VirtualMachine > reconfigureVmThroughJobQueue (
4636- final String vmUuid , final ServiceOffering oldServiceOffering , final boolean reconfiguringOnExistingHost ) {
4637+ final String vmUuid , final ServiceOffering newServiceOffering , final boolean reconfiguringOnExistingHost ) {
46374638
46384639 final CallContext context = CallContext .current ();
46394640 final User user = context .getCallingUser ();
@@ -4668,7 +4669,7 @@ public Object[] doInTransaction(TransactionStatus status) {
46684669
46694670 // save work context info (there are some duplications)
46704671 VmWorkReconfigure workInfo = new VmWorkReconfigure (user .getId (), account .getId (), vm .getId (),
4671- VirtualMachineManagerImpl .VM_WORK_JOB_HANDLER , oldServiceOffering , reconfiguringOnExistingHost );
4672+ VirtualMachineManagerImpl .VM_WORK_JOB_HANDLER , newServiceOffering . getId () , reconfiguringOnExistingHost );
46724673 workJob .setCmdInfo (VmWorkSerializer .serialize (workInfo ));
46734674
46744675 _jobMgr .submitAsyncJob (workJob , VmWorkConstants .VM_WORK_QUEUE , vm .getId ());
@@ -4796,7 +4797,10 @@ private Pair<JobInfo.Status, String> orchestrateReconfigure(VmWorkReconfigure wo
47964797 s_logger .info ("Unable to find vm " + work .getVmId ());
47974798 }
47984799 assert (vm != null );
4799- reConfigureVm (vm .getUuid (), work .getNewServiceOffering (),
4800+
4801+ ServiceOffering newServiceOffering = _offeringDao .findById (vm .getId (), work .getNewServiceOfferingId ());
4802+
4803+ reConfigureVm (vm .getUuid (), newServiceOffering ,
48004804 work .isSameHost ());
48014805 return new Pair <JobInfo .Status , String >(JobInfo .Status .SUCCEEDED , null );
48024806 }
0 commit comments