ServerRestService { @GET @Path( "/{host_id}/bootoptions" ) @Produces( "application/json" ) public SystemBootOptions getSystemBootOptions( @PathParam( "host_id" ) String host_id ) throws HMSRestException { if ( !serverConnector.getNodeMap().containsKey( host_id ) ) throw new HMSRestException( Status.NOT_FOUND.getStatusCode(), "Invalid Request", "Can't find host with id " + host_id ); else { ServerNode node = (ServerNode) serverConnector.getNodeMap().get( host_id ); try { executeTask( node, TaskType.GetSystemBootOptions ); } catch ( HmsResourceBusyException e ) { throw new HMSRestException( Status.INTERNAL_SERVER_ERROR.getStatusCode(), Constants.RESOURCE_BUSY, e.getMessage() ); } catch ( HmsException e ) { if ( e instanceof HMSRestException ) { throw e; } else { throw new HMSRestException( Status.INTERNAL_SERVER_ERROR.getStatusCode(), "Server Error", e.getMessage() ); } } catch ( Exception e ) { throw new HMSRestException( Status.INTERNAL_SERVER_ERROR.getStatusCode(), "Server Error", e.getMessage() ); } return node.getSytemBootOptions(); } }  @GET @Path( "/" ) @Produces( "application/json" ) Map<String, HmsNode> getHosts(); @GET @Path( "/{host_id}" ) @Produces( "application/json" ) ServerNode getHostNode( @PathParam( "host_id" ) String host_id ); @GET @Path( "/jnlpRemoteConsoleSupportFiles/{host_id}/{path : .*}" ) @Produces( MediaType.APPLICATION_OCTET_STREAM ) Response getJnlpSupportFiles( @PathParam( "host_id" ) String host_id, @PathParam( "path" ) String path ); @GET @Path( "/{host_id}/startremoteconsole" ) @Produces( "application/json" ) RemoteConsoleConnectionInfo startRemoteConsoleConnection( @PathParam( "host_id" ) String host_id ); @GET @Path( "/{host_id}/remoteconsoledetails" ) @Produces( "application/json" ) RemoteConsoleCapabilities getHostRemoteConsoleCapabilities( @PathParam( "host_id" ) String host_id ); @GET @Path( "/{host_id}/powerstatus" ) @Produces( "application/json" ) ServerNodePowerStatus getHostPowerStatus( @PathParam( "host_id" ) String host_id ); @GET @Path( "/{host_id}/selftest" ) @Produces( "application/json" ) SelfTestResults getHostSelfTestResults( @PathParam( "host_id" ) String host_id ); @GET @Path( "/{host_id}/bmcusers" ) @Produces( "application/json" ) List<BmcUser> getBmcUsers( @PathParam( "host_id" ) String host_id ); @GET @Path( "/{host_id}/cpuinfo" ) @Produces( "application/json" ) List<CPUInfo> getCpuInfo( @PathParam( "host_id" ) String host_id ); @GET @Path( "/{host_id}/storageinfo" ) @Produces( "application/json" ) List<HddInfo> getHddInfo( @PathParam( "host_id" ) String host_id ); @GET @Path( "/{host_id}/storagecontrollerinfo" ) @Produces( "application/json" ) List<StorageControllerInfo> getStorageControllerInfo( @PathParam( "host_id" ) String host_id ); @GET @Path( "/{host_id}/memoryinfo" ) @Produces( "application/json" ) List<PhysicalMemory> getMemoryInfo( @PathParam( "host_id" ) String host_id ); @GET @Path( "/{host_id}/acpipowerstate" ) @Produces( "application/json" ) AcpiPowerState getHostAcpiPowerState( @PathParam( "host_id" ) String host_id ); @GET @Path( "/{host_id}/nicinfo" ) @Produces( "application/json" ) List<EthernetController> getNicInfo( @PathParam( "host_id" ) String host_id ); @PUT @Path( "/update" ) @Consumes( MediaType.APPLICATION_FORM_URLENCODED ) @Produces( "application/json" ) BaseResponse updateNodes( @Form HMSRestServerActionsForm actions ); @PUT @Path( "/{host_id}" ) @Produces( "application/json" ) BaseResponse updateNodes( @PathParam( "host_id" ) String host_id, @QueryParam( "action" ) String action ); @GET @Path( "/{host_id}/bootoptions" ) @Produces( "application/json" ) SystemBootOptions getSystemBootOptions( @PathParam( "host_id" ) String host_id ); @PUT @Path( "/{host_id}/bootoptions" ) @Consumes( MediaType.APPLICATION_JSON ) @Produces( "application/json" ) BaseResponse getSystemBootOptions( @PathParam( "host_id" ) String host_id,
                                              SystemBootOptions systemBootOptions ); @PUT @Path( "/{host_id}/chassisidentify" ) @Consumes( MediaType.APPLICATION_JSON ) @Produces( "application/json" ) BaseResponse chassisIdentify( @PathParam( "host_id" ) String host_id,
                                         ChassisIdentifyOptions chassisIdentifyOptions ); @PUT @Path( "/{host_id}/selinfo" ) @Consumes( MediaType.APPLICATION_JSON ) @Produces( "application/json" ) SelInfo selInfo( @PathParam( "host_id" ) String host_id, SelOption selOption ); @PUT @Path( "/{host_id}/setpassword" ) @Consumes( MediaType.APPLICATION_JSON ) @Produces( "application/json" ) BaseResponse setBmcPassword( @PathParam( "host_id" ) String host_id, SetNodePassword nodePassword ); @GET @Path( "/{host_id}/supportedAPI" ) @Produces( "application/json" ) List<HmsApi> getAvailableNodeOperations( @PathParam( "host_id" ) String host_id ); @DELETE @Path( "/{hostId}" ) @Produces( "application/json" ) Response removeServer( @PathParam( "hostId" ) String hostId );  }
@Test public void getSystemBootOptions_nodeInNodeMap_BoardServiceFound() throws Exception { insertNodeInNodeMap( getServerNode() ); addBoardServiceForNode(); ServerRestService restService = new ServerRestService(); SystemBootOptions bootOptions = restService.getSystemBootOptions( "N1" ); assertNotNull( bootOptions ); assertEquals( BootOptionsValidity.Persistent, bootOptions.getBootOptionsValidity() ); assertEquals( BootDeviceSelector.PXE, bootOptions.getBootDeviceSelector() ); assertEquals( BootDeviceType.Internal, bootOptions.getBootDeviceType() ); assertEquals( BiosBootType.Legacy, bootOptions.getBiosBootType() ); }
@Test( expected = HMSRestException.class ) public void setSystemBootOptions_validNode_noBoardServiceFound() throws Exception { insertNodeInNodeMap( getServerNode() ); addBoardServiceForNode(); ServerRestService restService = new ServerRestService(); SystemBootOptions systemBootOptions = new SystemBootOptions(); systemBootOptions.setBiosBootType( BiosBootType.Legacy ); systemBootOptions.setBootDeviceInstanceNumber( 0 ); systemBootOptions.setBootDeviceSelector( BootDeviceSelector.PXE ); systemBootOptions.setBootDeviceType( BootDeviceType.Internal ); systemBootOptions.setBootOptionsValidity( BootOptionsValidity.Persistent ); BaseResponse response = restService.getSystemBootOptions( "N2", systemBootOptions ); assertNotNull( response ); assertTrue( 200 == response.getStatusCode() ); }
@Test public void setSystemBootOptions_nodeInNodeMap_BoardServiceFound() throws Exception { insertNodeInNodeMap( getServerNode() ); addBoardServiceForNode(); ServerRestService restService = new ServerRestService(); SystemBootOptions systemBootOptions = new SystemBootOptions(); systemBootOptions.setBiosBootType( BiosBootType.Legacy ); systemBootOptions.setBootDeviceInstanceNumber( 0 ); systemBootOptions.setBootDeviceSelector( BootDeviceSelector.PXE ); systemBootOptions.setBootDeviceType( BootDeviceType.Internal ); systemBootOptions.setBootOptionsValidity( BootOptionsValidity.Persistent ); BaseResponse response = restService.getSystemBootOptions( "N1", systemBootOptions ); assertNotNull( response ); assertTrue( 202 == response.getStatusCode() ); }