use of com.globo.globodns.cloudstack.commands.RemoveRecordCommand in project cloudstack by apache.
the class GloboDnsElement method release.
@Override
@DB
public boolean release(final Network network, NicProfile nic, final VirtualMachineProfile vm, ReservationContext context) throws ConcurrentOperationException, ResourceUnavailableException {
if (!isTypeSupported(vm.getType())) {
s_logger.info("GloboDNS only manages records for VMs of type User, ConsoleProxy and DomainRouter. VM " + vm + " is " + vm.getType());
return false;
}
Long zoneId = network.getDataCenterId();
final DataCenter zone = _dcDao.findById(zoneId);
if (zone == null) {
throw new CloudRuntimeException("Could not find zone associated to this network");
}
RemoveRecordCommand cmd = new RemoveRecordCommand(hostNameOfVirtualMachine(vm), nic.getIPv4Address(), network.getNetworkDomain(), GloboDNSOverride.value());
callCommand(cmd, zoneId);
return true;
}
use of com.globo.globodns.cloudstack.commands.RemoveRecordCommand in project cloudstack by apache.
the class GloboDnsResourceTest method testRemoveReverseRecordButNotRemoveRecordWhenRecordExistsWithDifferentValueAndOverrideIsFalse.
@Test
public void testRemoveReverseRecordButNotRemoveRecordWhenRecordExistsWithDifferentValueAndOverrideIsFalse() throws Exception {
String recordName = "recordname";
String recordIp = "40.30.20.10";
String domainName = "domain.name.com";
String reverseDomainName = "20.30.40.in-addr.arpa";
String reverseRecordName = "10";
String reverseRecordContent = recordName + "." + domainName;
Domain domain = generateFakeDomain(domainName, false);
Record record = generateFakeRecord(domain, recordName, "X", false);
Domain reverseDomain = generateFakeDomain(reverseDomainName, true);
Record reverseRecord = generateFakeRecord(reverseDomain, reverseRecordName, reverseRecordContent, true);
Answer answer = _globoDnsResource.execute(new RemoveRecordCommand(recordName, recordIp, domainName, false));
assertEquals(true, answer.getResult());
verify(_recordApi, never()).removeRecord(eq(record.getId()));
verify(_recordApi, times(1)).removeRecord(eq(reverseRecord.getId()));
verify(_exportApi, times(1)).scheduleExport();
}
use of com.globo.globodns.cloudstack.commands.RemoveRecordCommand in project cloudstack by apache.
the class GloboDnsResourceTest method testRemoveDomainWithSuccessButDomainKeptWhenDomainExistsAndThereAreRecordsAndOverrideIsFalse.
// ///////////////////////
// Remove Domain tests //
// ///////////////////////
@Test
public void testRemoveDomainWithSuccessButDomainKeptWhenDomainExistsAndThereAreRecordsAndOverrideIsFalse() throws Exception {
String recordName = "recordname";
String recordIp = "40.30.20.10";
String domainName = "domain.name.com";
Domain domain = generateFakeDomain(domainName, false);
Record record = generateFakeRecord(domain, recordName, "X", false);
when(_recordApi.listAll(domain.getId())).thenReturn(Arrays.asList(record));
Answer answer = _globoDnsResource.execute(new RemoveRecordCommand(recordName, recordIp, domainName, false));
assertEquals(true, answer.getResult());
verify(_domainApi, never()).removeDomain(any(Long.class));
verify(_exportApi, never()).scheduleExport();
}
use of com.globo.globodns.cloudstack.commands.RemoveRecordCommand in project cloudstack by apache.
the class GloboDnsResourceTest method testRemoveRecordWithSuccessAndReverseRecordNotRemovedWhenReverseRecordExistsWithDifferentValueAndOverrideIsFalse.
@Test
public void testRemoveRecordWithSuccessAndReverseRecordNotRemovedWhenReverseRecordExistsWithDifferentValueAndOverrideIsFalse() throws Exception {
String recordName = "recordname";
String recordIp = "40.30.20.10";
String domainName = "domain.name.com";
String reverseDomainName = "20.30.40.in-addr.arpa";
String reverseRecordName = "10";
Domain domain = generateFakeDomain(domainName, false);
Record record = generateFakeRecord(domain, recordName, recordIp, false);
Domain reverseDomain = generateFakeDomain(reverseDomainName, true);
Record reverseRecord = generateFakeRecord(reverseDomain, reverseRecordName, "X", true);
Answer answer = _globoDnsResource.execute(new RemoveRecordCommand(recordName, recordIp, domainName, false));
assertEquals(true, answer.getResult());
verify(_recordApi, times(1)).removeRecord(eq(record.getId()));
verify(_recordApi, never()).removeRecord(eq(reverseRecord.getId()));
verify(_exportApi, times(1)).scheduleExport();
}
use of com.globo.globodns.cloudstack.commands.RemoveRecordCommand in project cloudstack by apache.
the class GloboDnsResourceTest method testRemoveRecordWhenRecordExists.
// ///////////////////////
// Remove Record tests //
// ///////////////////////
@Test
public void testRemoveRecordWhenRecordExists() throws Exception {
String recordName = "recordname";
String recordIp = "40.30.20.10";
String domainName = "domain.name.com";
String reverseDomainName = "20.30.40.in-addr.arpa";
String reverseRecordName = "10";
String reverseRecordContent = recordName + "." + domainName;
Domain domain = generateFakeDomain(domainName, false);
Record record = generateFakeRecord(domain, recordName, recordIp, false);
Domain reverseDomain = generateFakeDomain(reverseDomainName, true);
Record reverseRecord = generateFakeRecord(reverseDomain, reverseRecordName, reverseRecordContent, true);
Answer answer = _globoDnsResource.execute(new RemoveRecordCommand(recordName, recordIp, domainName, true));
assertNotNull(answer);
assertEquals(true, answer.getResult());
verify(_recordApi, times(1)).removeRecord(eq(record.getId()));
verify(_recordApi, times(1)).removeRecord(eq(reverseRecord.getId()));
verify(_exportApi, times(1)).scheduleExport();
}
Aggregations