@Override public String getEventDescription() { return "reconnecting host: " + getId(); }
@Override public Long getInstanceId() { return getId(); }
@Override public String getEventDescription() { return "releasing reservation for host: " + getId(); }
@Override public void execute() { boolean result = _resourceService.deleteHost(getId(), isForced(), isForceDestoryLocalStorage()); if (result) { SuccessResponse response = new SuccessResponse(getCommandName()); this.setResponseObject(response); } else { throw new ServerApiException(ApiErrorCode.INTERNAL_ERROR, "Failed to delete host"); } } }
@Override public List<? extends Host> discoverHosts(final AddSecondaryStorageCmd cmd) throws IllegalArgumentException, DiscoveryException, InvalidParameterValueException { final Long dcId = cmd.getZoneId(); final String url = cmd.getUrl(); return discoverHostsFull(dcId, null, null, null, url, null, null, "SecondaryStorage", null, null, false); }
@Override public void execute() { if (getClusterId() == null) { _mgr.updateHostPassword(this); _resourceService.updateHostPassword(this); } else { _mgr.updateClusterPassword(this); _resourceService.updateClusterPassword(this); } setResponseObject(new SuccessResponse(getCommandName())); } }
@Override public void execute() { ListResponse<HostResponse> response = getHostResponses(); response.setResponseName(getCommandName()); this.setResponseObject(response); } }
@Override public boolean updateHostPassword(final UpdateHostPasswordCmd command) { // update agent attache password try { final Boolean result = propagateResourceEvent(command.getHostId(), ResourceState.Event.UpdatePassword); if (result != null) { return result; } } catch (final AgentUnavailableException e) { s_logger.error("Agent is not availbale!", e); } final boolean shouldUpdateHostPasswd = command.getUpdatePasswdOnHost(); // If shouldUpdateHostPasswd has been set to false, the method doUpdateHostPassword() won't be called. return shouldUpdateHostPasswd && doUpdateHostPassword(command.getHostId()); }
@Override public void execute() { boolean result = _resourceService.releaseHostReservation(getId()); if (result) { SuccessResponse response = new SuccessResponse(getCommandName()); this.setResponseObject(response); } else { throw new ServerApiException(ApiErrorCode.INTERNAL_ERROR, "Failed to release host reservation"); } } }
@Override public Long getInstanceId() { return getId(); }
@Override public void execute() { this.getFullUrlParams().put(ApiConstants.BAREMETAL_DISCOVER_NAME, BareMetalDiscoverer.class.getName()); super.execute(); }
@Override public void execute() { ListResponse<HostTagResponse> response = _queryService.searchForHostTags(this); response.setResponseName(getCommandName()); setResponseObject(response); } }
@Override public void execute() { Host result = _resourceService.cancelMaintenance(this); if (result != null) { HostResponse response = _responseGenerator.createHostResponse(result); response.setResponseName(getCommandName()); this.setResponseObject(response); } else { throw new ServerApiException(ApiErrorCode.INTERNAL_ERROR, "Failed to cancel host maintenance"); } } }
@Override @Before public void setUp() { responseGenerator = Mockito.mock(ResponseGenerator.class); managementServer = Mockito.mock(ManagementService.class); resourceService = Mockito.mock(ResourceService.class); updateHostPasswordCmd = new UpdateHostPasswordCmd(); }
@Override public void execute() { Host result = _resourceService.maintain(this); if (result != null) { HostResponse response = _responseGenerator.createHostResponse(result); response.setResponseName("host"); this.setResponseObject(response); } else { throw new ServerApiException(ApiErrorCode.INTERNAL_ERROR, "Failed to prepare host for maintenance"); } } }
@Override public Long getInstanceId() { return getId(); }
@Override public String getEventDescription() { return "canceling maintenance for host: " + getId(); }
@Override public String getEventDescription() { return "preparing host: " + getId() + " for maintenance"; }
@Test public void testExecuteForEmptyResult() { addHostCmd._resourceService = resourceService; try { addHostCmd.execute(); } catch (ServerApiException exception) { Assert.assertEquals("Failed to add host", exception.getDescription()); } }
@Override public Long getInstanceId() { return getId(); }