use of com.sequenceiq.cloudbreak.cloud.CloudConnector in project cloudbreak by hortonworks.
the class CloudPlatformConnectorsTest method getDefaultForOpenstack.
@Test
public void getDefaultForOpenstack() {
CloudConnector conn = c.getDefault(platform("MULTIWITHDEFAULT"));
assertEquals("ONE", conn.variant().value());
}
use of com.sequenceiq.cloudbreak.cloud.CloudConnector in project cloudbreak by hortonworks.
the class InstanceStateQuery method getCloudVmInstanceStatuses.
public List<CloudVmInstanceStatus> getCloudVmInstanceStatuses(CloudCredential cloudCredential, CloudContext cloudContext, List<CloudInstance> instances) {
CloudConnector connector = cloudPlatformConnectors.get(cloudContext.getPlatformVariant());
AuthenticatedContext auth = connector.authentication().authenticate(cloudContext, cloudCredential);
return connector.instances().check(auth, instances);
}
use of com.sequenceiq.cloudbreak.cloud.CloudConnector in project cloudbreak by hortonworks.
the class GetSSHFingerprintsHandler method accept.
@Override
public void accept(Event<GetSSHFingerprintsRequest> getSSHFingerprintsRequestEvent) {
LOGGER.info("Received event: {}", getSSHFingerprintsRequestEvent);
GetSSHFingerprintsRequest fingerprintsRequest = getSSHFingerprintsRequestEvent.getData();
try {
CloudContext cloudContext = fingerprintsRequest.getCloudContext();
CloudInstance cloudInstance = fingerprintsRequest.getCloudInstance();
CloudConnector connector = cloudPlatformConnectors.get(cloudContext.getPlatformVariant());
AuthenticatedContext ac = connector.authentication().authenticate(cloudContext, fingerprintsRequest.getCloudCredential());
GetSSHFingerprintsResult fingerprintsResult;
try {
String initialConsoleOutput = connector.instances().getConsoleOutput(ac, cloudInstance);
InstanceConsoleOutputResult consoleOutputResult = new InstanceConsoleOutputResult(cloudContext, cloudInstance, initialConsoleOutput);
PollTask<InstanceConsoleOutputResult> outputPollerTask = statusCheckFactory.newPollConsoleOutputTask(connector.instances(), ac, cloudInstance);
if (!outputPollerTask.completed(consoleOutputResult)) {
consoleOutputResult = syncPollingScheduler.schedule(outputPollerTask);
}
Set<String> sshFingerprints = FingerprintParserUtil.parseFingerprints(consoleOutputResult.getConsoleOutput());
if (sshFingerprints.isEmpty()) {
throw new RuntimeException("Failed to get SSH fingerprints from the specified VM instance.");
} else {
fingerprintsResult = new GetSSHFingerprintsResult(fingerprintsRequest, sshFingerprints);
}
} catch (CloudOperationNotSupportedException ignored) {
fingerprintsResult = new GetSSHFingerprintsResult(fingerprintsRequest, new HashSet<>());
}
fingerprintsRequest.getResult().onNext(fingerprintsResult);
eventBus.notify(fingerprintsResult.selector(), new Event<>(getSSHFingerprintsRequestEvent.getHeaders(), fingerprintsResult));
LOGGER.info("GetSSHFingerprintsHandler finished");
} catch (Exception e) {
GetSSHFingerprintsResult failure = new GetSSHFingerprintsResult("Failed to get ssh fingerprints!", e, fingerprintsRequest);
fingerprintsRequest.getResult().onNext(failure);
eventBus.notify(failure.selector(), new Event<>(getSSHFingerprintsRequestEvent.getHeaders(), failure));
}
}
use of com.sequenceiq.cloudbreak.cloud.CloudConnector in project cloudbreak by hortonworks.
the class GetStackParamValidationHandler method accept.
@Override
public void accept(Event<GetStackParamValidationRequest> getStackParametersRequestEvent) {
LOGGER.info("Received event: {}", getStackParametersRequestEvent);
GetStackParamValidationRequest request = getStackParametersRequestEvent.getData();
try {
CloudConnector aDefault = cloudPlatformConnectors.getDefault(request.getCloudContext().getPlatform());
GetStackParamValidationResult getStackParamValidationResult = new GetStackParamValidationResult(request, aDefault.parameters().additionalStackParameters());
request.getResult().onNext(getStackParamValidationResult);
LOGGER.info("Query platform stack parameters finished.");
} catch (RuntimeException e) {
request.getResult().onNext(new GetStackParamValidationResult(e.getMessage(), e, request));
}
}
use of com.sequenceiq.cloudbreak.cloud.CloudConnector in project cloudbreak by hortonworks.
the class GetTlsInfoHandler method accept.
@Override
public void accept(Event<GetTlsInfoRequest> getTlsInfoRequestEvent) {
LOGGER.info("Received event: {}", getTlsInfoRequestEvent);
GetTlsInfoRequest<?> tlsInfoRequest = getTlsInfoRequestEvent.getData();
try {
CloudContext cloudContext = tlsInfoRequest.getCloudContext();
CloudCredential cloudCredential = tlsInfoRequest.getCloudCredential();
CloudConnector connector = cloudPlatformConnectors.get(cloudContext.getPlatformVariant());
CloudStack cloudStack = tlsInfoRequest.getCloudStack();
AuthenticatedContext ac = connector.authentication().authenticate(cloudContext, cloudCredential);
TlsInfo tlsInfo = connector.resources().getTlsInfo(ac, cloudStack);
GetTlsInfoResult getTlsInfoResult = new GetTlsInfoResult(tlsInfoRequest, tlsInfo);
tlsInfoRequest.getResult().onNext(getTlsInfoResult);
eventBus.notify(getTlsInfoResult.selector(), new Event<>(getTlsInfoRequestEvent.getHeaders(), getTlsInfoResult));
LOGGER.info("GetTlsInfoHandler finished.");
} catch (RuntimeException e) {
String errorMsg = "Failed to get Tls info from cloud connector!";
LOGGER.error(errorMsg, e);
GetTlsInfoResult failure = new GetTlsInfoResult(errorMsg, e, tlsInfoRequest);
tlsInfoRequest.getResult().onNext(failure);
eventBus.notify(failure.selector(), new Event<>(getTlsInfoRequestEvent.getHeaders(), failure));
}
}
Aggregations