Search in sources :

Example 1 with CreateOrUpdateDomainCommand

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;
}
Also used : DataCenter(com.cloud.dc.DataCenter) CloudRuntimeException(com.cloud.utils.exception.CloudRuntimeException) CreateOrUpdateDomainCommand(com.globo.globodns.cloudstack.commands.CreateOrUpdateDomainCommand) DB(com.cloud.utils.db.DB)

Example 2 with CreateOrUpdateDomainCommand

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();
}
Also used : Answer(com.cloud.agent.api.Answer) Domain(com.globo.globodns.client.model.Domain) CreateOrUpdateDomainCommand(com.globo.globodns.cloudstack.commands.CreateOrUpdateDomainCommand) Test(org.junit.Test)

Example 3 with CreateOrUpdateDomainCommand

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());
}
Also used : Answer(com.cloud.agent.api.Answer) Domain(com.globo.globodns.client.model.Domain) CreateOrUpdateDomainCommand(com.globo.globodns.cloudstack.commands.CreateOrUpdateDomainCommand) Test(org.junit.Test)

Aggregations

CreateOrUpdateDomainCommand (com.globo.globodns.cloudstack.commands.CreateOrUpdateDomainCommand)3 Answer (com.cloud.agent.api.Answer)2 Domain (com.globo.globodns.client.model.Domain)2 Test (org.junit.Test)2 DataCenter (com.cloud.dc.DataCenter)1 DB (com.cloud.utils.db.DB)1 CloudRuntimeException (com.cloud.utils.exception.CloudRuntimeException)1