Search in sources :

Example 6 with DnsRecord

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);
}
Also used : DnsRecord(org.nhind.config.DnsRecord) Command(org.nhindirect.dns.tools.utils.Command)

Example 7 with DnsRecord

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);
}
Also used : DnsRecord(org.nhind.config.DnsRecord) Command(org.nhindirect.dns.tools.utils.Command)

Example 8 with DnsRecord

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();
}
Also used : BaseTestPlan(org.nhindirect.dns.util.BaseTestPlan) ArrayList(java.util.ArrayList) SOARecord(org.xbill.DNS.SOARecord) ARecord(org.xbill.DNS.ARecord) MXRecord(org.xbill.DNS.MXRecord) DnsRecord(org.nhind.config.DnsRecord) SOARecord(org.xbill.DNS.SOARecord) ARecord(org.xbill.DNS.ARecord) MXRecord(org.xbill.DNS.MXRecord) Record(org.xbill.DNS.Record) ArrayList(java.util.ArrayList) List(java.util.List) SOARecord(org.xbill.DNS.SOARecord) DnsRecord(org.nhind.config.DnsRecord)

Example 9 with DnsRecord

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;
}
Also used : DnsRecord(org.nhind.config.DnsRecord)

Example 10 with DnsRecord

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);
}
Also used : DnsRecord(org.nhind.config.DnsRecord) Command(org.nhindirect.dns.tools.utils.Command)

Aggregations

DnsRecord (org.nhind.config.DnsRecord)32 Command (org.nhindirect.dns.tools.utils.Command)14 Record (org.xbill.DNS.Record)7 ArrayList (java.util.ArrayList)6 RemoteException (java.rmi.RemoteException)4 CertificateConversionException (org.nhindirect.config.model.exceptions.CertificateConversionException)3 CERTRecord (org.xbill.DNS.CERTRecord)3 SOARecord (org.xbill.DNS.SOARecord)3 File (java.io.File)2 List (java.util.List)2 Matcher (java.util.regex.Matcher)2 Pattern (java.util.regex.Pattern)2 BaseTestPlan (org.nhindirect.dns.util.BaseTestPlan)2 ARecord (org.xbill.DNS.ARecord)2 MXRecord (org.xbill.DNS.MXRecord)2 Test (org.junit.Test)1 ConfigurationServiceProxy (org.nhind.config.ConfigurationServiceProxy)1 DNSRecord (org.nhindirect.config.store.DNSRecord)1 RRset (org.xbill.DNS.RRset)1