use of org.nhind.config.DnsRecord in project nhin-d by DirectProject.
the class DNSRecordCommands method ensureANAME.
/**
* Adds an A records to the configuration service only if the record does not exist.
* @param args Contains the A record attributes.
*
* @since 1.0
*/
@Command(name = "Dns_ANAME_Ensure", usage = ENSURE_ANAME_USAGE)
public void ensureANAME(String[] args) {
DnsRecord record = fromRecord(parser.parseANAME(args));
if (!verifyIsUnique(record, false)) {
return;
}
addDNS(record);
}
use of org.nhind.config.DnsRecord in project nhin-d by DirectProject.
the class DNSRecordCommands method verifyIsUnique.
/*
* ensures that a record is unique in the configuration service
*/
private boolean verifyIsUnique(DnsRecord record, boolean details) {
DnsRecord existing = find(record);
if (existing != null) {
System.out.println("Record already exists");
print(existing);
return false;
}
return true;
}
use of org.nhind.config.DnsRecord in project nhin-d by DirectProject.
the class DNSRecordCommands method print.
/*
* prints the contents of an array of records
*/
private void print(DnsRecord[] records) {
if (records != null) {
for (DnsRecord record : records) {
print(record);
System.out.println("\r\n-------------------------------------------");
}
}
}
use of org.nhind.config.DnsRecord in project nhin-d by DirectProject.
the class DNSRecordCommands method fromRecord.
/*
* Convert a dnsjava record to a DnsRecord for use with the proxy.
*/
private DnsRecord fromRecord(Record rec) {
DnsRecord retVal = new DnsRecord();
retVal.setData(rec.rdataToWireCanonical());
retVal.setDclass(rec.getDClass());
retVal.setName(rec.getName().toString());
retVal.setTtl(rec.getTTL());
retVal.setType(rec.getType());
return retVal;
}
use of org.nhind.config.DnsRecord in project nhin-d by DirectProject.
the class ClientProxyDNSTest method addDNSRecord.
@Test
public void addDNSRecord() throws Exception {
cleanDNSRecords();
DNSRecord rec = DNSRecordUtils.createARecord("example.domain.com", 86400L, "127.0.0.1");
DnsRecord recToAdd = new DnsRecord();
recToAdd.setData(rec.getData());
recToAdd.setDclass(rec.getDclass());
recToAdd.setName(rec.getName());
recToAdd.setTtl(rec.getTtl());
recToAdd.setType(rec.getType());
proxy.addDNS(new DnsRecord[] { recToAdd });
assertEquals(1, proxy.getDNSCount());
DnsRecord[] recs = proxy.getDNSByNameAndType(recToAdd.getName(), recToAdd.getType());
assertNotNull(recs);
assertEquals(1, recs.length);
assertEquals(rec.getName(), recs[0].getName());
}
Aggregations