Search in sources :

Example 1 with GetPlatformSecurityGroupsResult

use of com.sequenceiq.cloudbreak.cloud.event.platform.GetPlatformSecurityGroupsResult 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));
    }
}
Also used : GetPlatformSecurityGroupsRequest(com.sequenceiq.cloudbreak.cloud.event.platform.GetPlatformSecurityGroupsRequest) GetPlatformSecurityGroupsResult(com.sequenceiq.cloudbreak.cloud.event.platform.GetPlatformSecurityGroupsResult) CloudSecurityGroups(com.sequenceiq.cloudbreak.cloud.model.CloudSecurityGroups) CloudPlatformVariant(com.sequenceiq.cloudbreak.cloud.model.CloudPlatformVariant)

Example 2 with GetPlatformSecurityGroupsResult

use of com.sequenceiq.cloudbreak.cloud.event.platform.GetPlatformSecurityGroupsResult 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);
    }
}
Also used : ExtendedCloudCredential(com.sequenceiq.cloudbreak.cloud.model.ExtendedCloudCredential) GetPlatformSecurityGroupsRequest(com.sequenceiq.cloudbreak.cloud.event.platform.GetPlatformSecurityGroupsRequest) GetPlatformSecurityGroupsResult(com.sequenceiq.cloudbreak.cloud.event.platform.GetPlatformSecurityGroupsResult) OperationException(com.sequenceiq.cloudbreak.service.stack.connector.OperationException)

Aggregations

GetPlatformSecurityGroupsRequest (com.sequenceiq.cloudbreak.cloud.event.platform.GetPlatformSecurityGroupsRequest)2 GetPlatformSecurityGroupsResult (com.sequenceiq.cloudbreak.cloud.event.platform.GetPlatformSecurityGroupsResult)2 CloudPlatformVariant (com.sequenceiq.cloudbreak.cloud.model.CloudPlatformVariant)1 CloudSecurityGroups (com.sequenceiq.cloudbreak.cloud.model.CloudSecurityGroups)1 ExtendedCloudCredential (com.sequenceiq.cloudbreak.cloud.model.ExtendedCloudCredential)1 OperationException (com.sequenceiq.cloudbreak.service.stack.connector.OperationException)1