List of usage examples for com.amazonaws.services.route53.model ListHostedZonesResult getHostedZones
public java.util.List<HostedZone> getHostedZones()
A complex type that contains general information about the hosted zone.
From source file:com.carrotgarden.maven.aws.dns.CarrotRoute53.java
License:BSD License
public HostedZone findZone(final String source) { final ListHostedZonesResult zoneResult = amazonClient.listHostedZones(); final List<HostedZone> zoneList = zoneResult.getHostedZones(); for (final HostedZone zone : zoneList) { final String name = zone.getName(); if (source.endsWith(name)) { return zone; }//from ww w .j ava 2s. c o m } return null; }
From source file:com.deploymentio.ec2namer.helpers.DnsRegistrar.java
License:Apache License
@Override public boolean validate(NamerRequest req, LambdaContext context) { if (StringUtils.isEmpty(req.getBaseDomain())) { context.log("BaseDomain is missing"); return false; }//from ww w. j av a 2 s . c o m if (StringUtils.isEmpty(req.getEnvironment())) { context.log("Environment is missing"); return false; } if (StringUtils.isEmpty(req.getGroup())) { context.log("Group is missing"); return false; } if (StringUtils.isEmpty(req.getInstanceId())) { context.log("InstanceId is missing"); return false; } ListHostedZonesResult result = route53.listHostedZones(); String lookingFor = req.getBaseDomain() + "."; for (HostedZone zone : result.getHostedZones()) { if (lookingFor.equals(zone.getName())) { context.put("hosted-zone", zone.getId()); context.log("Found hosted-zone: Id=" + zone.getId() + " Name=" + zone.getName()); return true; } } context.log("HostedZone is not found: BaseDomain=" + req.getBaseDomain()); return false; }
From source file:com.github.blacklocus.rdsecho.utl.Route53Find.java
License:Open Source License
public Iterable<HostedZone> hostedZones(final Predicate<HostedZone> predicate) { return new PagingIterable<HostedZone>(new Supplier<Iterable<HostedZone>>() { String nextMarker = null; boolean isTruncated = true; @Override/*from w ww . j av a 2 s. co m*/ public Iterable<HostedZone> get() { if (isTruncated) { ListHostedZonesRequest request = new ListHostedZonesRequest().withMarker(nextMarker); ListHostedZonesResult result = route53.listHostedZones(); nextMarker = result.getNextMarker(); isTruncated = result.isTruncated(); return Iterables.filter(result.getHostedZones(), predicate); } else { return Collections.emptyList(); } } }); }
From source file:com.msi.dns53.client.DNS53MetadataUtil.java
License:Apache License
public void populateServiceMetadata(final ServletConfig config, String serviceName) { logger.debug("init(): TXT record will be created for this service regarding its port and context path."); String contextPath = config.getServletContext().getContextPath(); String port = Appctx.getBean("TOMCAT_PORT"); String master_passwd = Appctx.getBean("DB_PASSWORD"); final String fqdn = (String) ConfigurationUtil.getConfiguration(Arrays.asList(new String[] { "FQDN" })); final String domain = (String) ConfigurationUtil .getConfiguration(Arrays.asList(new String[] { "FQDN_DOMAIN" })); String txtRecordValue = ":" + port + contextPath; String baseDNSServerURL = "http://localhost:" + port + "/DNS53Server/2012-02-29/"; logger.debug("Tomcat port = " + port + "; FQDN = " + fqdn + "; domain = " + domain + "; TXT Record Value = " + txtRecordValue + "; BaseDNSServerUrl = " + baseDNSServerURL); DNS53Client client = new DNS53Client(baseDNSServerURL + "hostedzone", baseDNSServerURL + "change", "admin", master_passwd);/*from ww w. j a va 2 s. co m*/ logger.debug("Service name = " + serviceName); String recordName = serviceName + "-" + fqdn; logger.debug("TXT Record Name: " + recordName); logger.debug("init(): Calling ListHostedZones to find the target zone!"); ListHostedZonesRequest lhzReq = new ListHostedZonesRequest(); lhzReq.setMaxItems("1"); ListHostedZonesResult lhzResult = client.listHostedZones(lhzReq); HostedZone zone = null; List<HostedZone> zones = lhzResult.getHostedZones(); if (zones != null && zones.size() > 0) { for (HostedZone hz : zones) { if (hz.getName().equals(domain + ".") || hz.getName().equals(domain)) { zone = hz; } } } else { logger.error( "BaseAsyncServlet encountered an error while it was trying to find the target hosted zone."); throw ErrorResponse.InternalFailure(); } if (zone == null) { logger.error("BaseAsyncServlet could not find any zone for this TopStackWeb instance."); throw ErrorResponse.InternalFailure(); } // TODO (optional) check for the CNAME record for this service before proceeding logger.debug("init(): Creating a new TXT record for " + recordName + " with \"" + txtRecordValue + "\" as its value!"); String zoneId = zone.getId(); ChangeResourceRecordSetsRequest crrsReq = new ChangeResourceRecordSetsRequest(); crrsReq.setHostedZoneId(zoneId); ChangeBatch cb = new ChangeBatch(); cb.setComment( "BaseAsyncServlet => init(): Registering " + serviceName + " service for Transcend TopStack."); Collection<Change> changes = new LinkedList<Change>(); Change change = new Change(); change.setAction(ChangeAction.CREATE); ResourceRecordSet rrSet = new ResourceRecordSet(); rrSet.setName(recordName); rrSet.setTTL(900L); rrSet.setType(RRType.TXT); Collection<ResourceRecord> rr = new LinkedList<ResourceRecord>(); ResourceRecord record = new ResourceRecord(); record.setValue(txtRecordValue); rr.add(record); rrSet.setResourceRecords(rr); change.setResourceRecordSet(rrSet); changes.add(change); cb.setChanges(changes); crrsReq.setChangeBatch(cb); ChangeResourceRecordSetsResult result = client.changeResourceRecordSets(crrsReq); logger.debug("Result for the last ChangeResourceRecordSets request: " + result.toString()); }
From source file:com.msi.dns53.server.query.ListHostedZones.java
License:Apache License
@Override public String marshall(MarshallStruct<ListHostedZonesResult> input, HttpServletResponse resp) throws Exception { logger.debug("Marshalling the result into xml."); ListHostedZonesResult result = input.getMainObject(); XMLNode response = new XMLNode(DNS53Constants.LISTHOSTEDZONESRESPONSE); response.addAttr(DNS53Constants.XMLNS, DNS53Constants.XMLNS_VALUE); if (result.getHostedZones() != null && result.getHostedZones().size() > 0) { XMLNode hzs = QueryUtil.addNode(response, DNS53Constants.HOSTEDZONES); for (HostedZone hostedZone : result.getHostedZones()) { DNS53QueryUtil.marshallHostedZone(hostedZone, hzs); }/*from w ww . j a v a2 s. c om*/ } QueryUtil.addNode(response, DNS53Constants.MARKER, result.getMarker()); QueryUtil.addNode(response, DNS53Constants.ISTRUNCATED, result.getIsTruncated()); QueryUtil.addNode(response, DNS53Constants.NEXTMARKER, result.getNextMarker()); QueryUtil.addNode(response, DNS53Constants.MAXITEMS, result.getMaxItems()); logger.debug("Returning the response xml to AbstractHeaderAction."); return response.toString(); }
From source file:com.oneops.inductor.AbstractOrderExecutor.java
License:Apache License
/** * Gets dns servers// w w w .j a va 2 s . c om * * @param awsCredentials AWSCredentials * @param zoneDomainName zoneDomainName * @return dns servers */ private List<String> getAuthoritativeServersWithAwsCreds(AWSCredentials awsCredentials, String zoneDomainName) { if (!zoneDomainName.endsWith(".")) { zoneDomainName += "."; } AmazonRoute53 route53 = new AmazonRoute53Client(awsCredentials); ListHostedZonesResult result = route53.listHostedZones(); List<HostedZone> zones = result.getHostedZones(); List<String> dnsServers = new ArrayList<String>(); for (int i = 0; i < zones.size(); i++) { HostedZone hostedZone = zones.get(i); logger.info("zone: " + hostedZone.getName()); if (hostedZone.getName().equalsIgnoreCase(zoneDomainName)) { logger.info("matched zone"); GetHostedZoneResult zone = route53.getHostedZone( new GetHostedZoneRequest().withId(hostedZone.getId().replace("/hostedzone/", ""))); DelegationSet delegationSet = zone.getDelegationSet(); dnsServers = delegationSet.getNameServers(); break; } } logger.info("dnsServer: " + dnsServers.toString()); return dnsServers; }
From source file:org.lendingclub.mercator.aws.Route53Scanner.java
License:Apache License
@Override protected void doScan() { ListHostedZonesRequest request = new ListHostedZonesRequest(); ListHostedZonesResult result = new ListHostedZonesResult(); do {/*from w w w . j a v a2 s . com*/ result = getClient().listHostedZones(request); for (HostedZone zone : result.getHostedZones()) { scanHostedZoneById(zone.getId()); } request.setMarker(result.getMarker()); } while (result.isTruncated()); }
From source file:org.ofbiz.tenant.amazonaws.AwsServices.java
License:Apache License
/** * get Amazon Rout53 hosted zones/*from w ww . ja v a 2 s .c o m*/ * @param ctx * @param context * @return */ public static Map<String, Object> getAmazonRoute53HostedZones(DispatchContext ctx, Map<String, Object> context) { AmazonRoute53 route53 = AwsFactory.getAmazonRoute53(); ListHostedZonesResult hostedZonesResult = route53.listHostedZones(); List<HostedZone> hostedZones = hostedZonesResult.getHostedZones(); Map<String, Object> results = ServiceUtil.returnSuccess(); results.put("hostedZones", hostedZones); return results; }