this.novaApi = checkNotNull(novaApi, "novaApi");
}
public boolean apply(AtomicReference<ZoneAndName> securityGroupInZoneRef) {
checkNotNull(securityGroupInZoneRef, "securityGroupRef");
final ZoneAndName securityGroupInZone = checkNotNull(securityGroupInZoneRef.get(), "securityGroupInZone");
Optional<? extends SecurityGroupApi> api = novaApi.getSecurityGroupExtensionForZone(securityGroupInZone.getZone());
checkArgument(api.isPresent(), "Security groups are required, but the extension is not available!");
logger.trace("looking for security group %s", securityGroupInZone.slashEncode());
try {
SecurityGroup returnVal = Iterables.find(api.get().list(), new Predicate<SecurityGroup>() {
@Override
public boolean apply(SecurityGroup input) {
return input.getName().equals(securityGroupInZone.getName());
}
});
securityGroupInZoneRef.set(new SecurityGroupInZone(returnVal, securityGroupInZone.getZone()));
return true;
} catch (ResourceNotFoundException e) {
return false;
} catch (NoSuchElementException e) {
return false;