use of com.sequenceiq.cloudbreak.cloud.model.ExtendedCloudCredential in project cloudbreak by hortonworks.
the class ExtendedCloudCredentialToCredentialConverter method convert.
public Credential convert(ExtendedCloudCredential extendedCloudCredential) {
Credential credential = new Credential();
credential.setId(extendedCloudCredential.getId());
credential.setName(extendedCloudCredential.getName());
credential.setDescription(extendedCloudCredential.getDescription());
credential.setAccount(extendedCloudCredential.getAccount());
credential.setOwner(extendedCloudCredential.getOwner());
credential.setCloudPlatform(extendedCloudCredential.getCloudPlatform());
try {
Json json = new Json(extendedCloudCredential.getParameters());
credential.setAttributes(json);
} catch (JsonProcessingException e) {
throw new IllegalStateException(e);
}
return credential;
}
use of com.sequenceiq.cloudbreak.cloud.model.ExtendedCloudCredential in project cloudbreak by hortonworks.
the class ServiceProviderCredentialAdapter method interactiveLogin.
public Map<String, String> interactiveLogin(Credential credential) {
CloudContext cloudContext = new CloudContext(credential.getId(), credential.getName(), credential.cloudPlatform(), credential.getOwner());
ExtendedCloudCredential cloudCredential = extendedCloudCredentialConverter.convert(credential);
InteractiveLoginRequest request = new InteractiveLoginRequest(cloudContext, cloudCredential);
LOGGER.info("Triggering event: {}", request);
eventBus.notify(request.selector(), eventFactory.createEvent(request));
try {
InteractiveLoginResult res = request.await();
String message = "Interactive login Failed: ";
LOGGER.info("Result: {}", res);
if (res.getStatus() != EventStatus.OK) {
LOGGER.error(message, res.getErrorDetails());
throw new BadRequestException(message + res.getErrorDetails(), res.getErrorDetails());
}
return res.getParameters();
} catch (InterruptedException e) {
LOGGER.error("Error while executing credential verification", e);
throw new OperationException(e);
}
}
use of com.sequenceiq.cloudbreak.cloud.model.ExtendedCloudCredential in project cloudbreak by hortonworks.
the class CloudParameterService method getCloudAccessConfigs.
public CloudAccessConfigs getCloudAccessConfigs(Credential credential, String region, String variant, Map<String, String> filters) {
LOGGER.debug("Get platform accessConfigs");
ExtendedCloudCredential cloudCredential = credentialToExtendedCloudCredentialConverter.convert(credential);
GetPlatformCloudAccessConfigsRequest getPlatformCloudAccessConfigsRequest = new GetPlatformCloudAccessConfigsRequest(cloudCredential, cloudCredential, variant, region, filters);
eventBus.notify(getPlatformCloudAccessConfigsRequest.selector(), Event.wrap(getPlatformCloudAccessConfigsRequest));
try {
GetPlatformCloudAccessConfigsResult res = getPlatformCloudAccessConfigsRequest.await();
LOGGER.info("Platform accessConfigs result: {}", res);
if (res.getStatus().equals(EventStatus.FAILED)) {
LOGGER.error("Failed to get platform accessConfigs", res.getErrorDetails());
throw new GetCloudParameterException("Failed to get access configs for the cloud provider", res.getErrorDetails());
}
return res.getCloudAccessConfigs();
} catch (InterruptedException e) {
LOGGER.error("Error while getting the platform accessConfigs", e);
throw new OperationException(e);
}
}
use of com.sequenceiq.cloudbreak.cloud.model.ExtendedCloudCredential in project cloudbreak by hortonworks.
the class CloudParameterService method getInstanceGroupParameters.
public Map<String, InstanceGroupParameterResponse> getInstanceGroupParameters(Credential credential, Set<InstanceGroupParameterRequest> instanceGroups) {
LOGGER.debug("Get platform getInstanceGroupParameters");
ExtendedCloudCredential cloudCredential = credentialToExtendedCloudCredentialConverter.convert(credential);
GetPlatformInstanceGroupParameterRequest getPlatformInstanceGroupParameterRequest = new GetPlatformInstanceGroupParameterRequest(cloudCredential, cloudCredential, instanceGroups, null);
eventBus.notify(getPlatformInstanceGroupParameterRequest.selector(), Event.wrap(getPlatformInstanceGroupParameterRequest));
try {
GetPlatformInstanceGroupParameterResult res = getPlatformInstanceGroupParameterRequest.await();
LOGGER.info("Platform instanceGroupParameterResult result: {}", res);
if (res.getStatus().equals(EventStatus.FAILED)) {
LOGGER.error("Failed to get platform instanceGroupParameterResult", res.getErrorDetails());
throw new GetCloudParameterException("Failed to instance group parameters for the cloud provider", res.getErrorDetails());
}
return res.getInstanceGroupParameterResponses();
} catch (InterruptedException e) {
LOGGER.error("Error while getting the platform publicIpPools", e);
throw new OperationException(e);
}
}
use of com.sequenceiq.cloudbreak.cloud.model.ExtendedCloudCredential in project cloudbreak by hortonworks.
the class CloudParameterService method getRegionsV2.
public CloudRegions getRegionsV2(Credential credential, String region, String variant, Map<String, String> filters) {
LOGGER.debug("Get platform regions");
ExtendedCloudCredential cloudCredential = credentialToExtendedCloudCredentialConverter.convert(credential);
GetPlatformRegionsRequestV2 getPlatformRegionsRequest = new GetPlatformRegionsRequestV2(cloudCredential, cloudCredential, variant, region, filters);
eventBus.notify(getPlatformRegionsRequest.selector(), Event.wrap(getPlatformRegionsRequest));
try {
GetPlatformRegionsResultV2 res = getPlatformRegionsRequest.await();
LOGGER.info("Platform regions result: {}", res);
if (res.getStatus().equals(EventStatus.FAILED)) {
throw new GetCloudParameterException("Failed to get regions from the cloud provider due to network issues or invalid credential", res.getErrorDetails());
}
return res.getCloudRegions();
} catch (InterruptedException e) {
LOGGER.error("Error while getting the platform regions", e);
throw new OperationException(e);
}
}
Aggregations