use of com.sequenceiq.environment.platformresource.PlatformResourceRequest in project cloudbreak by hortonworks.
the class AzureEnvironmentSecurityGroupValidator method validateSecurityGroup.
private void validateSecurityGroup(EnvironmentDto environmentDto, ValidationResult.ValidationResultBuilder resultBuilder, String securityGroupIds) {
Region region = environmentDto.getRegions().iterator().next();
PlatformResourceRequest request = platformParameterService.getPlatformResourceRequest(environmentDto.getAccountId(), environmentDto.getCredential().getName(), null, region.getName(), getCloudPlatform().name(), null);
CloudSecurityGroups securityGroups = platformParameterService.getSecurityGroups(request);
boolean securityGroupFoundInRegion = false;
Map<String, Set<CloudSecurityGroup>> cloudSecurityGroupsResponses = securityGroups.getCloudSecurityGroupsResponses();
if (Objects.nonNull(cloudSecurityGroupsResponses)) {
Set<CloudSecurityGroup> cloudSecurityGroups = cloudSecurityGroupsResponses.get(region.getName());
for (String securityGroupId : getSecurityGroupIds(securityGroupIds)) {
securityGroupFoundInRegion = false;
if (Objects.nonNull(cloudSecurityGroups)) {
for (CloudSecurityGroup cloudSecurityGroup : cloudSecurityGroups) {
String groupId = cloudSecurityGroup.getGroupId();
if (!Strings.isNullOrEmpty(groupId) && groupId.equalsIgnoreCase(securityGroupId)) {
securityGroupFoundInRegion = true;
break;
}
}
}
if (!securityGroupFoundInRegion) {
break;
}
}
}
if (!securityGroupFoundInRegion) {
LOGGER.info("The security groups {} are not presented in the region {}", securityGroupIds, region.getName());
resultBuilder.error(securityGroupNotInTheSameRegion(securityGroupIds, region.getName()));
}
}
Aggregations