Search in sources :

Example 1 with Topology

use of com.sequenceiq.cloudbreak.domain.Topology in project cloudbreak by hortonworks.

the class HostGroupAssociationBuilder method getTopologyMapping.

private Map<String, String> getTopologyMapping(HostGroup hg) {
    Map<String, String> result = new HashMap<>();
    LOGGER.info("Computing hypervisor - rack mapping based on topology");
    Topology topology = hg.getCluster().getStack().getCredential().getTopology();
    if (topology == null) {
        return result;
    }
    List<TopologyRecord> records = topology.getRecords();
    if (records != null) {
        for (TopologyRecord t : records) {
            result.put(t.getHypervisor(), t.getRack());
        }
    }
    return result;
}
Also used : HashMap(java.util.HashMap) TopologyRecord(com.sequenceiq.cloudbreak.domain.TopologyRecord) Topology(com.sequenceiq.cloudbreak.domain.Topology)

Example 2 with Topology

use of com.sequenceiq.cloudbreak.domain.Topology in project cloudbreak by hortonworks.

the class TopologyService method delete.

public void delete(Long topologyId, IdentityUser user) {
    Topology topology = topologyRepository.findByIdInAccount(topologyId, user.getAccount());
    if (topology == null) {
        throw new NotFoundException(String.format(TOPOLOGY_NOT_FOUND_MSG, topologyId));
    }
    delete(topology);
}
Also used : NotFoundException(com.sequenceiq.cloudbreak.controller.NotFoundException) Topology(com.sequenceiq.cloudbreak.domain.Topology)

Example 3 with Topology

use of com.sequenceiq.cloudbreak.domain.Topology in project cloudbreak by hortonworks.

the class CredentialServiceTest method testModifyMapAllField.

@Test
public void testModifyMapAllField() throws Exception {
    Credential credential = new Credential();
    credential.setCloudPlatform(PLATFORM);
    credential.setTopology(new Topology());
    credential.setAttributes(new Json("other"));
    credential.setDescription("mod-desc");
    Credential modify = credentialService.modify(user, credential);
    assertEquals(credential.getTopology(), modify.getTopology());
    assertEquals(credential.getAttributes(), modify.getAttributes());
    assertEquals(credential.getDescription(), modify.getDescription());
    assertNotEquals(originalTopology, modify.getTopology());
    assertNotEquals(originalAttributes, modify.getAttributes());
    assertNotEquals(originalAttributes, modify.getDescription());
    assertEquals(credential.cloudPlatform(), modify.cloudPlatform());
}
Also used : Credential(com.sequenceiq.cloudbreak.domain.Credential) Topology(com.sequenceiq.cloudbreak.domain.Topology) Json(com.sequenceiq.cloudbreak.domain.json.Json) Test(org.junit.Test)

Example 4 with Topology

use of com.sequenceiq.cloudbreak.domain.Topology in project cloudbreak by hortonworks.

the class TopologyController method postPublic.

@Override
public TopologyResponse postPublic(TopologyRequest topologyRequest) {
    IdentityUser user = authenticatedUserService.getCbUser();
    Topology topology = conversionService.convert(topologyRequest, Topology.class);
    topology = topologyService.create(user, topology);
    notify(user, ResourceEvent.TOPOLOGY_CREATED);
    return conversionService.convert(topology, TopologyResponse.class);
}
Also used : IdentityUser(com.sequenceiq.cloudbreak.common.model.user.IdentityUser) Topology(com.sequenceiq.cloudbreak.domain.Topology)

Example 5 with Topology

use of com.sequenceiq.cloudbreak.domain.Topology in project cloudbreak by hortonworks.

the class TopologyController method getPublics.

@Override
public Set<TopologyResponse> getPublics() {
    IdentityUser user = authenticatedUserService.getCbUser();
    Set<Topology> stacks = topologyRepository.findAllInAccount(user.getAccount());
    return convert(stacks);
}
Also used : IdentityUser(com.sequenceiq.cloudbreak.common.model.user.IdentityUser) Topology(com.sequenceiq.cloudbreak.domain.Topology)

Aggregations

Topology (com.sequenceiq.cloudbreak.domain.Topology)9 IdentityUser (com.sequenceiq.cloudbreak.common.model.user.IdentityUser)3 Credential (com.sequenceiq.cloudbreak.domain.Credential)2 Json (com.sequenceiq.cloudbreak.domain.json.Json)2 BadRequestException (com.sequenceiq.cloudbreak.controller.BadRequestException)1 NotFoundException (com.sequenceiq.cloudbreak.controller.NotFoundException)1 TopologyRecord (com.sequenceiq.cloudbreak.domain.TopologyRecord)1 Date (java.util.Date)1 HashMap (java.util.HashMap)1 Transactional (javax.transaction.Transactional)1 Before (org.junit.Before)1 Test (org.junit.Test)1 DataIntegrityViolationException (org.springframework.dao.DataIntegrityViolationException)1