private boolean hasValue(ResourceRecordSetWithHostedZone resourceRecordSetWithHostedZone, String ip) { if (resourceRecordSetWithHostedZone != null && resourceRecordSetWithHostedZone.getResourceRecordSet() != null) { for (ResourceRecord rr : resourceRecordSetWithHostedZone.getResourceRecordSet().getResourceRecords()) { if (ip.equals(rr.getValue())) { return true; } } } return false; }
private boolean createResourceRecordSet(ResourceRecordSetWithHostedZone rrs) throws InterruptedException { rrs.getResourceRecordSet().setResourceRecords(Arrays.asList(new ResourceRecord(registrationHostname))); Change change = new Change(ChangeAction.UPSERT, rrs.getResourceRecordSet()); if (executeChangeWithRetry(change, rrs.getHostedZone())) { Thread.sleep(1000); // check change not overwritten ResourceRecordSet resourceRecordSet = getResourceRecordSet(rrs.getResourceRecordSet().getName(), rrs.getHostedZone()); return resourceRecordSet.getResourceRecords().equals(rrs.getResourceRecordSet().getResourceRecords()); } return false; }
if (getTTL() != null) sb.append("TTL: ").append(getTTL()).append(","); if (getResourceRecords() != null) sb.append("ResourceRecords: ").append(getResourceRecords()).append(","); if (getAliasTarget() != null) sb.append("AliasTarget: ").append(getAliasTarget()).append(",");
private void unbindFromDomain(String domain) throws InterruptedException { ResourceRecordSetWithHostedZone resourceRecordSetWithHostedZone = getResourceRecordSetWithHostedZone(domain); if (hasValue(resourceRecordSetWithHostedZone, registrationHostname)) { resourceRecordSetWithHostedZone.getResourceRecordSet().getResourceRecords().get(0).setValue(NULL_DOMAIN); executeChangeWithRetry(new Change(ChangeAction.UPSERT, resourceRecordSetWithHostedZone.getResourceRecordSet()), resourceRecordSetWithHostedZone.getHostedZone()); } }
@Override public int hashCode() { final int prime = 31; int hashCode = 1; hashCode = prime * hashCode + ((getName() == null) ? 0 : getName().hashCode()); hashCode = prime * hashCode + ((getType() == null) ? 0 : getType().hashCode()); hashCode = prime * hashCode + ((getSetIdentifier() == null) ? 0 : getSetIdentifier().hashCode()); hashCode = prime * hashCode + ((getWeight() == null) ? 0 : getWeight().hashCode()); hashCode = prime * hashCode + ((getRegion() == null) ? 0 : getRegion().hashCode()); hashCode = prime * hashCode + ((getGeoLocation() == null) ? 0 : getGeoLocation().hashCode()); hashCode = prime * hashCode + ((getFailover() == null) ? 0 : getFailover().hashCode()); hashCode = prime * hashCode + ((getMultiValueAnswer() == null) ? 0 : getMultiValueAnswer().hashCode()); hashCode = prime * hashCode + ((getTTL() == null) ? 0 : getTTL().hashCode()); hashCode = prime * hashCode + ((getResourceRecords() == null) ? 0 : getResourceRecords().hashCode()); hashCode = prime * hashCode + ((getAliasTarget() == null) ? 0 : getAliasTarget().hashCode()); hashCode = prime * hashCode + ((getHealthCheckId() == null) ? 0 : getHealthCheckId().hashCode()); hashCode = prime * hashCode + ((getTrafficPolicyInstanceId() == null) ? 0 : getTrafficPolicyInstanceId().hashCode()); return hashCode; }
private void doBind() throws InterruptedException { List<ResourceRecordSetWithHostedZone> freeDomains = new ArrayList<>(); List<String> domains = getDeclaredDomains(); for(String domain : domains) { ResourceRecordSetWithHostedZone rrs = getResourceRecordSetWithHostedZone(domain); if (rrs != null) { if (rrs.getResourceRecordSet() == null) { ResourceRecordSet resourceRecordSet = new ResourceRecordSet(); resourceRecordSet.setName(domain); resourceRecordSet.setType(RRType.CNAME); resourceRecordSet.setTTL(serverConfig.getRoute53DomainTTL()); freeDomains.add(new ResourceRecordSetWithHostedZone(rrs.getHostedZone(), resourceRecordSet)); } else if (NULL_DOMAIN.equals(rrs.getResourceRecordSet().getResourceRecords().get(0).getValue())) { freeDomains.add(rrs); } // already registered if (hasValue(rrs, registrationHostname)) { return; } } } for(ResourceRecordSetWithHostedZone rrs : freeDomains) { if (createResourceRecordSet(rrs)) { logger.info("Bind {} to {}" , registrationHostname, rrs.getResourceRecordSet().getName()); return; } } logger.warn("Unable to find free domain in {}", domains); }
if (other.getTTL() != null && other.getTTL().equals(this.getTTL()) == false) return false; if (other.getResourceRecords() == null ^ this.getResourceRecords() == null) return false; if (other.getResourceRecords() != null && other.getResourceRecords().equals(this.getResourceRecords()) == false) return false; if (other.getAliasTarget() == null ^ this.getAliasTarget() == null)
.getResourceRecords(); if (!resourceRecordSetResourceRecordsList.isEmpty() || !resourceRecordSetResourceRecordsList.isAutoConstruct()) { xmlWriter.startElement("ResourceRecords");
private boolean hasValue(ResourceRecordSetWithHostedZone resourceRecordSetWithHostedZone, String ip) { if (resourceRecordSetWithHostedZone != null && resourceRecordSetWithHostedZone.getResourceRecordSet() != null) { for (ResourceRecord rr : resourceRecordSetWithHostedZone.getResourceRecordSet().getResourceRecords()) { if (ip.equals(rr.getValue())) { return true; } } } return false; }
ObjectNode toJson(ResourceRecordSet rs) { ObjectNode n = mapper.createObjectNode(); n.put("aws_ttl", rs.getTTL()); n.put("aws_type", rs.getType()); n.put("aws_name", rs.getName()); n.put("id", rs.getType() + "_" + rs.getName()); ArrayNode an = mapper.createArrayNode(); n.set("aws_resourceRecords", an); for (ResourceRecord rr : rs.getResourceRecords()) { an.add(rr.getValue()); } return n; }
digest.update(rr.getAliasTarget().getEvaluateTargetHealth().toString().getBytes("UTF-8")); } else { digest.update(rr.getResourceRecords().toString().getBytes("UTF-8")); digest.update(rr.getTTL().toString().getBytes("UTF-8"));
private boolean createResourceRecordSet(ResourceRecordSetWithHostedZone rrs) throws InterruptedException { rrs.getResourceRecordSet().setResourceRecords(Arrays.asList(new ResourceRecord(registrationHostname))); Change change = new Change(ChangeAction.UPSERT, rrs.getResourceRecordSet()); if (executeChangeWithRetry(change, rrs.getHostedZone())) { Thread.sleep(1000); // check change not overwritten ResourceRecordSet resourceRecordSet = getResourceRecordSet(rrs.getResourceRecordSet().getName(), rrs.getHostedZone()); return resourceRecordSet.getResourceRecords().equals(rrs.getResourceRecordSet().getResourceRecords()); } return false; }
private void unbindFromDomain(String domain) throws InterruptedException { ResourceRecordSetWithHostedZone resourceRecordSetWithHostedZone = getResourceRecordSetWithHostedZone(domain); if (hasValue(resourceRecordSetWithHostedZone, registrationHostname)) { resourceRecordSetWithHostedZone.getResourceRecordSet().getResourceRecords().get(0).setValue(NULL_DOMAIN); executeChangeWithRetry(new Change(ChangeAction.UPSERT, resourceRecordSetWithHostedZone.getResourceRecordSet()), resourceRecordSetWithHostedZone.getHostedZone()); } }
private void doBind() throws InterruptedException { List<ResourceRecordSetWithHostedZone> freeDomains = new ArrayList<>(); List<String> domains = getDeclaredDomains(); for(String domain : domains) { ResourceRecordSetWithHostedZone rrs = getResourceRecordSetWithHostedZone(domain); if (rrs != null) { if (rrs.getResourceRecordSet() == null) { ResourceRecordSet resourceRecordSet = new ResourceRecordSet(); resourceRecordSet.setName(domain); resourceRecordSet.setType(RRType.CNAME); resourceRecordSet.setTTL(serverConfig.getRoute53DomainTTL()); freeDomains.add(new ResourceRecordSetWithHostedZone(rrs.getHostedZone(), resourceRecordSet)); } else if (NULL_DOMAIN.equals(rrs.getResourceRecordSet().getResourceRecords().get(0).getValue())) { freeDomains.add(rrs); } // already registered if (hasValue(rrs, registrationHostname)) { return; } } } for(ResourceRecordSetWithHostedZone rrs : freeDomains) { if (createResourceRecordSet(rrs)) { logger.info("Bind {} to {}" , registrationHostname, rrs.getResourceRecordSet().getName()); return; } } logger.warn("Unable to find free domain in {}", domains); }
exists = true; for(ResourceRecord record : recordSet.getResourceRecords())