use of org.platformlayer.service.dns.model.DnsZone in project platformlayer by platformlayer.
the class DnsHelpers method buildDnsFile.
public ZoneFile buildDnsFile(DnsRecord dnsRecord) throws OpsException {
List<DnsZone> matches = Lists.newArrayList();
for (DnsZone dnsZone : platformLayer.listItems(DnsZone.class)) {
if (isInZone(dnsRecord, dnsZone)) {
matches.add(dnsZone);
}
}
if (matches.size() == 0) {
throw new OpsException("Cannot find zone for record: " + dnsRecord.dnsName);
}
if (matches.size() != 1) {
throw new OpsException("Picking between multiple matching zones not yet implemented");
}
DnsZone dnsZone = matches.get(0);
return buildDnsFile(dnsZone);
}
use of org.platformlayer.service.dns.model.DnsZone in project platformlayer by platformlayer.
the class DnsServerBootstrap method handler.
@Handler
public void handler(OpsTarget target) throws OpsException {
for (DnsZone record : platformLayer.listItems(DnsZone.class)) {
ZoneFile dnsFile = dns.buildDnsFile(record);
dns.upload(target, dnsFile);
}
}
use of org.platformlayer.service.dns.model.DnsZone in project platformlayer by platformlayer.
the class DnsService method beforeCreateItem.
@Override
public void beforeCreateItem(ItemBase item) throws OpsException {
if (item instanceof DnsServer) {
DnsServer model = (DnsServer) item;
model.dnsName = normalize(model.dnsName);
if (Strings.isNullOrEmpty(model.dnsName)) {
throw new IllegalArgumentException("dnsName must be specified");
}
}
if (item instanceof DnsRecord) {
DnsRecord model = (DnsRecord) item;
model.dnsName = normalize(model.dnsName);
if (Strings.isNullOrEmpty(model.dnsName)) {
throw new IllegalArgumentException("dnsName must be specified");
}
if (Strings.isNullOrEmpty(model.recordType)) {
model.recordType = "A";
}
if (model.recordType.equals("A")) {
// OK
} else {
throw new IllegalArgumentException("Record type not supported: " + model.recordType);
}
}
if (item instanceof DnsZone) {
DnsZone model = (DnsZone) item;
model.dnsName = normalize(model.dnsName);
if (Strings.isNullOrEmpty(model.dnsName)) {
model.dnsName = normalize(model.getId());
}
}
super.beforeCreateItem(item);
}
Aggregations