use of com.globo.globodns.cloudstack.commands.CreateOrUpdateDomainCommand in project cloudstack by apache.
the class GloboDnsElement method implement.
@Override
@DB
public boolean implement(final Network network, NetworkOffering offering, DeployDestination dest, ReservationContext context) throws ConcurrentOperationException, ResourceUnavailableException, InsufficientCapacityException {
Long zoneId = network.getDataCenterId();
DataCenter zone = _dcDao.findById(zoneId);
if (zone == null) {
throw new CloudRuntimeException("Could not find zone associated to this network");
}
CreateOrUpdateDomainCommand cmd = new CreateOrUpdateDomainCommand(network.getNetworkDomain(), GloboDNSTemplateId.value());
callCommand(cmd, zoneId);
return true;
}
use of com.globo.globodns.cloudstack.commands.CreateOrUpdateDomainCommand in project cloudstack by apache.
the class GloboDnsResourceTest method testCreateDomainWithSuccessWhenDomainDoesntExistAndOverrideIsTrue.
/////////////////////////
// Create Domain tests //
/////////////////////////
@Test
public void testCreateDomainWithSuccessWhenDomainDoesntExistAndOverrideIsTrue() throws Exception {
String domainName = "domain.name.com";
Domain domain = new Domain();
domain.getDomainAttributes().setId(sequenceId++);
domain.getDomainAttributes().setName(domainName);
when(_domainApi.createDomain(eq(domain.getName()), eq(TEMPLATE_ID), eq("M"))).thenReturn(domain);
Answer answer = _globoDnsResource.execute(new CreateOrUpdateDomainCommand(domainName, TEMPLATE_ID));
assertNotNull(answer);
assertEquals(true, answer.getResult());
verify(_exportApi, times(1)).scheduleExport();
}
use of com.globo.globodns.cloudstack.commands.CreateOrUpdateDomainCommand in project cloudstack by apache.
the class GloboDnsResourceTest method testCreateDomainWillSucceedWhenDomainAlreadyExistsAndOverrideIsFalse.
@Test
@SuppressWarnings("unused")
public void testCreateDomainWillSucceedWhenDomainAlreadyExistsAndOverrideIsFalse() throws Exception {
String domainName = "domain.name.com";
Domain domain = generateFakeDomain(domainName, false);
Answer answer = _globoDnsResource.execute(new CreateOrUpdateDomainCommand(domainName, TEMPLATE_ID));
assertNotNull(answer);
assertEquals(true, answer.getResult());
}
Aggregations