use of com.globo.globodns.cloudstack.commands.CreateOrUpdateRecordAndReverseCommand in project cloudstack by apache.
the class GloboDnsResourceTest method testCreateRecordAndReverseWillFailWhenRecordAlreadyExistsAndOverrideIsFalse.
@Test
@SuppressWarnings("unused")
public void testCreateRecordAndReverseWillFailWhenRecordAlreadyExistsAndOverrideIsFalse() throws Exception {
String recordName = "recordname";
String newIp = "40.30.20.10";
String oldIp = "50.40.30.20";
String domainName = "domain.name.com";
Domain domain = generateFakeDomain(domainName, false);
Record record = generateFakeRecord(domain, recordName, oldIp, false);
Answer answer = _globoDnsResource.execute(new CreateOrUpdateRecordAndReverseCommand(recordName, newIp, domainName, TEMPLATE_ID, false));
assertNotNull(answer);
assertEquals(false, answer.getResult());
}
use of com.globo.globodns.cloudstack.commands.CreateOrUpdateRecordAndReverseCommand in project cloudstack by apache.
the class GloboDnsElement method prepare.
@Override
@DB
public boolean prepare(final Network network, final NicProfile nic, final VirtualMachineProfile vm, DeployDestination dest, ReservationContext context) throws ConcurrentOperationException, ResourceUnavailableException, InsufficientCapacityException {
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");
}
/* Create new A record in GloboDNS */
// We allow only lower case names in DNS, so force lower case names for VMs
String vmName = vm.getHostName();
String vmHostname = hostNameOfVirtualMachine(vm);
if (!vmName.equals(vmHostname) && vm.getType() == VirtualMachine.Type.User) {
throw new InvalidParameterValueException("VM name should contain only lower case letters and digits: " + vmName + " - " + vm);
}
CreateOrUpdateRecordAndReverseCommand cmd = new CreateOrUpdateRecordAndReverseCommand(vmHostname, nic.getIPv4Address(), network.getNetworkDomain(), GloboDNSTemplateId.value(), GloboDNSOverride.value());
callCommand(cmd, zoneId);
return true;
}
Aggregations