use of com.sequenceiq.cloudbreak.cloud.event.platform.GetPlatformSecurityGroupsRequest in project cloudbreak by hortonworks.
the class GetPlatformSecurityGroupsHandler method accept.
@Override
public void accept(Event<GetPlatformSecurityGroupsRequest> getPlatformSecurityGroupsRequest) {
LOGGER.info("Received event: {}", getPlatformSecurityGroupsRequest);
GetPlatformSecurityGroupsRequest request = getPlatformSecurityGroupsRequest.getData();
try {
CloudPlatformVariant cloudPlatformVariant = new CloudPlatformVariant(Platform.platform(request.getExtendedCloudCredential().getCloudPlatform()), Variant.variant(request.getVariant()));
CloudSecurityGroups securityGroups = cloudPlatformConnectors.get(cloudPlatformVariant).platformResources().securityGroups(request.getCloudCredential(), Region.region(request.getRegion()), request.getFilters());
GetPlatformSecurityGroupsResult getPlatformSecurityGroupsResult = new GetPlatformSecurityGroupsResult(request, securityGroups);
request.getResult().onNext(getPlatformSecurityGroupsResult);
LOGGER.info("Query platform networks types finished.");
} catch (Exception e) {
request.getResult().onNext(new GetPlatformSecurityGroupsResult(e.getMessage(), e, request));
}
}
use of com.sequenceiq.cloudbreak.cloud.event.platform.GetPlatformSecurityGroupsRequest in project cloudbreak by hortonworks.
the class CloudParameterService method getSecurityGroups.
public CloudSecurityGroups getSecurityGroups(Credential credential, String region, String variant, Map<String, String> filters) {
LOGGER.debug("Get platform securitygroups");
ExtendedCloudCredential cloudCredential = credentialToExtendedCloudCredentialConverter.convert(credential);
GetPlatformSecurityGroupsRequest getPlatformSecurityGroupsRequest = new GetPlatformSecurityGroupsRequest(cloudCredential, cloudCredential, variant, region, filters);
eventBus.notify(getPlatformSecurityGroupsRequest.selector(), eventFactory.createEvent(getPlatformSecurityGroupsRequest));
try {
GetPlatformSecurityGroupsResult res = getPlatformSecurityGroupsRequest.await();
LOGGER.info("Platform securitygroups types result: {}", res);
if (res.getStatus().equals(EventStatus.FAILED)) {
LOGGER.error("Failed to get platform securitygroups", res.getErrorDetails());
throw new GetCloudParameterException("Failed to get security groups for the cloud provider", res.getErrorDetails());
}
return res.getCloudSecurityGroups();
} catch (InterruptedException e) {
LOGGER.error("Error while getting the platform securitygroups", e);
throw new OperationException(e);
}
}
Aggregations