private void postEventlogError(ComputeState hostState, String message) { EventLogState eventLog = new EventLogState(); eventLog.description = message == null ? "Unexpected error" : message; eventLog.eventLogType = EventLogType.ERROR; eventLog.resourceType = getClass().getName(); eventLog.tenantLinks = hostState.tenantLinks; sendRequest(Operation.createPost(this, EventLogService.FACTORY_LINK) .setBody(eventLog) .setCompletion((o, e) -> { if (e != null) { logWarning("Failed to create event log: %s", Utils.toString(e)); } })); }
private void updateContainerHostInfo(String documentSelfLink) { URI uri = UriUtils.buildUri(getHost(), ContainerHostDataCollectionService.HOST_INFO_DATA_COLLECTION_LINK); ContainerHostDataCollectionState state = new ContainerHostDataCollectionState(); state.createOrUpdateHost = true; state.computeContainerHostLinks = Collections.singleton(documentSelfLink); sendRequest(Operation.createPatch(uri) .setBody(state) .setCompletion((o, ex) -> { if (ex != null) { logWarning("Failed to update host data collection: %s", ex.getMessage()); } })); }
sendRequest(store .setBody(cs) .setCompletion((o, e) -> {
desc.documentSelfLink = descriptionId; desc.id = descriptionId; sendRequest(Operation .createPost(this, ComputeDescriptionService.FACTORY_LINK) .setBody(desc)
private void updateHost(ContainerHostSpec hostSpec, Operation op) { fetchSslTrustAliasProperty(hostSpec, () -> { ComputeState cs = hostSpec.hostState; sendRequest(Operation.createPut(this, cs.documentSelfLink) .setBody(cs) .setCompletion((o, e) -> { if (e != null) { op.fail(e); return; } createHostPortProfile(cs, op); // when host is updated and ssl property cannot be fetch (power state is // UNKNOWN) do not run data collection (DC) to avoid endless loop. DC will // check for the ssl property and send new update for the host, and so on. if (ComputeService.PowerState.UNKNOWN != hostSpec.hostState.powerState) { // run data collection only if there's no error getting its certificate updateContainerHostInfo(cs.documentSelfLink); triggerEpzEnumeration(); } })); }); }
private void createHostPortProfile(ComputeState computeState, Operation operation) { HostPortProfileService.HostPortProfileState hostPortProfileState = new HostPortProfileService.HostPortProfileState(); hostPortProfileState.hostLink = computeState.documentSelfLink; // Make sure there is only one HostPortProfile per Host by generating profile id based on // host id hostPortProfileState.id = computeState.id; hostPortProfileState.documentSelfLink = HostPortProfileService.getHostPortProfileLink( computeState.documentSelfLink); // POST will be converted to PUT if profile with this id already exists sendRequest(OperationUtil .createForcedPost(this, HostPortProfileService.FACTORY_LINK) .setBody(hostPortProfileState) .setCompletion((o, ex) -> { if (ex != null) { operation.fail(ex); return; } HostPortProfileService.HostPortProfileState result = o.getBody( HostPortProfileService.HostPortProfileState.class); logInfo("Created HostPortProfile for host %s with port range %s-%s.", result.hostLink, result.startPort, result.endPort); completeOperationSuccess(operation); })); }
patchOp.addRequestHeader(Operation.ACCEPT_LANGUAGE_HEADER, languageHeader); sendRequest(patchOp);