public Map<String, String> updateVM(HttpInputs httpInputs, VmInputs vmInputs) throws Exception {
        ConnectionResources connectionResources = new ConnectionResources(httpInputs, vmInputs);
        try {
            ManagedObjectReference vmMor = new MorObjectHandler().getMor(connectionResources,
                    ManagedObjectType.VIRTUAL_MACHINE.getValue(), vmInputs.getVirtualMachineName());
            if (vmMor != null) {
                VirtualMachineConfigSpec vmConfigSpec = new VirtualMachineConfigSpec();
                String device = Device.getValue(vmInputs.getDevice()).toLowerCase();
                if (Constants.CPU.equalsIgnoreCase(device) || Constants.MEMORY.equalsIgnoreCase(device)) {
                    vmConfigSpec = new VmUtils().getUpdateConfigSpec(vmInputs, vmConfigSpec, device);
                } else {
                    vmConfigSpec = new VmUtils().getAddOrRemoveSpecs(connectionResources, vmMor, vmInputs, vmConfigSpec, device);
                }

                ManagedObjectReference task = connectionResources.getVimPortType().reconfigVMTask(vmMor, vmConfigSpec);

                return new ResponseHelper(connectionResources, task).getResultsMap("Success: The [" +
                        vmInputs.getVirtualMachineName() + "] VM was successfully reconfigured. The taskId is: " +
                        task.getValue(), "Failure: The [" + vmInputs.getVirtualMachineName() + "] VM could not be reconfigured.");
            } else {
                return ResponseUtils.getVmNotFoundResultsMap(vmInputs);
            }
        } catch (Exception ex) {
            return ResponseUtils.getResultsMap(ex.toString(), Outputs.RETURN_CODE_FAILURE);
        } finally {
            if (httpInputs.isCloseSession()) {
                connectionResources.getConnection().disconnect();
                clearConnectionFromContext(httpInputs.getGlobalSessionObject());
            }
        }
    }
public Map < String , String > updateVM ( HttpInputs httpInputs , VmInputs vmInputs ) throws Exception { ConnectionResources connectionResources = new ConnectionResources ( httpInputs , vmInputs ) ; try { ManagedObjectReference vmMor = new MorObjectHandler ( ) . getMor ( connectionResources , ManagedObjectType . VIRTUAL_MACHINE . getValue ( ) , vmInputs . getVirtualMachineName ( ) ) ; if ( vmMor != null ) { VirtualMachineConfigSpec vmConfigSpec = new VirtualMachineConfigSpec ( ) ; String device = Device . getValue ( vmInputs . getDevice ( ) ) . toLowerCase ( ) ; if ( Constants . CPU . equalsIgnoreCase ( device ) || Constants . MEMORY . equalsIgnoreCase ( device ) ) { vmConfigSpec = new VmUtils ( ) . getUpdateConfigSpec ( vmInputs , vmConfigSpec , device ) ; } else { vmConfigSpec = new VmUtils ( ) . getAddOrRemoveSpecs ( connectionResources , vmMor , vmInputs , vmConfigSpec , device ) ; } ManagedObjectReference task = connectionResources . getVimPortType ( ) . reconfigVMTask ( vmMor , vmConfigSpec ) ; return new ResponseHelper ( connectionResources , task ) . getResultsMap ( "Success: The [" + vmInputs . getVirtualMachineName ( ) + "] VM was successfully reconfigured. The taskId is: " + task . getValue ( ) , "Failure: The [" + vmInputs . getVirtualMachineName ( ) + "] VM could not be reconfigured." ) ; } else { return ResponseUtils . getVmNotFoundResultsMap ( vmInputs ) ; } } catch ( Exception ex ) { return ResponseUtils . getResultsMap ( ex . toString ( ) , Outputs . RETURN_CODE_FAILURE ) ; } finally { if ( httpInputs . isCloseSession ( ) ) { connectionResources . getConnection ( ) . disconnect ( ) ; clearConnectionFromContext ( httpInputs . getGlobalSessionObject ( ) ) ; } } }
Method used to connect to data center to update existing devices of a virtual machine identified by the inputs
provided.

@param httpInputs Object that has all the inputs necessary to made a connection to data center
@param vmInputs   Object that has all the specific inputs necessary to identify the targeted device
@return Map with String as key and value that contains returnCode of the operation, success message with task id
of the execution or failure message and the exception if there is one
@throws Exception