public Map < String , String > customizeVM ( HttpInputs httpInputs , VmInputs vmInputs , GuestInputs guestInputs , boolean isWin ) throws Exception { ConnectionResources connectionResources = new ConnectionResources ( httpInputs , vmInputs ) ; try { ManagedObjectReference vmMor = new MorObjectHandler ( ) . getMor ( connectionResources , ManagedObjectType . VIRTUAL_MACHINE . getValue ( ) , vmInputs . getVirtualMachineName ( ) ) ; if ( vmMor != null ) { CustomizationSpec customizationSpec = isWin ? new GuestConfigSpecs ( ) . getWinCustomizationSpec ( guestInputs ) : new GuestConfigSpecs ( ) . getLinuxCustomizationSpec ( guestInputs ) ; connectionResources . getVimPortType ( ) . checkCustomizationSpec ( vmMor , customizationSpec ) ; ManagedObjectReference task = connectionResources . getVimPortType ( ) . customizeVMTask ( vmMor , customizationSpec ) ; return new ResponseHelper ( connectionResources , task ) . getResultsMap ( "Success: The [" + vmInputs . getVirtualMachineName ( ) + "] VM was successfully customized. The taskId is: " + task . getValue ( ) , "Failure: The [" + vmInputs . getVirtualMachineName ( ) + "] VM could not be customized." ) ; } 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 specified data center and customize the windows OS based virtual machine identified by the inputs provided .