use of org.nhind.config.DnsRecord in project nhin-d by DirectProject.
the class DNSRecordCommands method ensureSOA.
/**
* Adds an SOA records to the configuration service only if the record does not exist.
* @param args Contains the SOA record attributes.
*
* @since 1.0
*/
@Command(name = "Dns_SOA_Ensure", usage = ENSURE_SOA_USAGE)
public void ensureSOA(String[] args) {
DnsRecord record = fromRecord(parser.parseSOA(args));
if (!verifyIsUnique(record, false)) {
return;
}
addDNS(record);
}
use of org.nhind.config.DnsRecord in project nhin-d by DirectProject.
the class DNSRecordCommands method addMX.
/**
* Adds an MX records to the configuration service.
* @param args Contains the MX record attributes.
*
* @since 1.0
*/
@Command(name = "Dns_MX_Add", usage = ADD_MX_USAGE)
public void addMX(String[] args) {
DnsRecord record = fromRecord(parser.parseMX(args));
addDNS(record);
}
use of org.nhind.config.DnsRecord in project nhin-d by DirectProject.
the class DNSRecordCommands_removeRecords_Test method testRemoveOnlyARecords_AssertOnlyARecordRemoved.
public void testRemoveOnlyARecords_AssertOnlyARecordRemoved() throws Exception {
new TestPlan() {
private List<Record> recordsToAdd;
private List<Record> expectedRemainingRecords;
@Override
protected List<Record> getRecordsToAdd() throws Exception {
recordsToAdd = new ArrayList<Record>();
recordsToAdd.add(new ARecord(Name.fromString("example.domain.com."), DClass.IN, 3600, InetAddress.getByName("127.0.0.1")));
recordsToAdd.add(new ARecord(Name.fromString("example.domain.com."), DClass.IN, 3600, InetAddress.getByName("127.0.0.2")));
recordsToAdd.add(new MXRecord(Name.fromString("example.domain.com."), DClass.IN, 3600, 1, Name.fromString("mail1.example.domain.com.")));
recordsToAdd.add(new MXRecord(Name.fromString("example2.domain.com."), DClass.IN, 3600, 1, Name.fromString("mail2.exampl2.domain.com.")));
recordsToAdd.add(new SOARecord(Name.fromString("example.domain.com."), DClass.IN, 3600, Name.fromString("ns1.example.domain.com."), Name.fromString("gm2552.example.domain.com."), 1, 3600, 60, 60, 3600));
return recordsToAdd;
}
@Override
protected List<DnsRecord> getRecordsToRemove(List<DnsRecord> addedRecords) throws Exception {
List<DnsRecord> retVal = new ArrayList<DnsRecord>();
expectedRemainingRecords = new ArrayList<Record>();
for (DnsRecord addedRecord : addedRecords) {
if (addedRecord.getType() == Type.A)
retVal.add(addedRecord);
else
expectedRemainingRecords.add(toRecord(addedRecord));
}
return retVal;
}
@Override
protected void doAssertions(List<Record> remainingRecords) throws Exception {
assertNotNull(remainingRecords);
assertEquals(3, remainingRecords.size());
for (Record expectedRemaining : expectedRemainingRecords) {
int index = remainingRecords.indexOf(expectedRemaining);
assertTrue(index >= 0);
Record checkRecord = remainingRecords.get(index);
assertTrue(checkRecord.getType() != Type.A);
assertEquals(checkRecord, expectedRemaining);
}
}
}.perform();
}
use of org.nhind.config.DnsRecord in project nhin-d by DirectProject.
the class DNSRecordUtil method toDnsRecord.
private static DnsRecord toDnsRecord(DNSRecord rec) {
DnsRecord retVal = new DnsRecord();
retVal.setData(rec.getData());
retVal.setDclass(rec.getDclass());
retVal.setName(rec.getName());
retVal.setTtl(rec.getTtl());
retVal.setType(rec.getType());
return retVal;
}
use of org.nhind.config.DnsRecord in project nhin-d by DirectProject.
the class DNSRecordCommands method addMX.
/**
* Adds an MX records to the configuration service.
* @param args Contains the MX record attributes.
*
* @since 1.0
*/
@Command(name = "Dns_MX_Add", usage = ADD_MX_USAGE)
public void addMX(String[] args) {
DnsRecord record = fromRecord(parser.parseMX(args));
addDNS(record);
}
Aggregations