Search in sources :

Example 1 with ClouderaManagerInfoV4Response

use of com.sequenceiq.cloudbreak.api.endpoint.v4.util.responses.ClouderaManagerInfoV4Response in project cloudbreak by hortonworks.

the class RepositoryInfoToClouderaManagerInfoV4ResponseConverter method convert.

public ClouderaManagerInfoV4Response convert(RepositoryInfo source) {
    ClouderaManagerInfoV4Response cmInfoJson = new ClouderaManagerInfoV4Response();
    cmInfoJson.setVersion(source.getVersion());
    cmInfoJson.setRepository(stringCMRepoDetailsMapToStringCMRepoDetailsJsonMap(source.getRepo()));
    return cmInfoJson;
}
Also used : ClouderaManagerInfoV4Response(com.sequenceiq.cloudbreak.api.endpoint.v4.util.responses.ClouderaManagerInfoV4Response)

Example 2 with ClouderaManagerInfoV4Response

use of com.sequenceiq.cloudbreak.api.endpoint.v4.util.responses.ClouderaManagerInfoV4Response in project cloudbreak by hortonworks.

the class DefaultClouderaManagerRepoService method getDefault.

public ClouderaManagerRepo getDefault(String osType, String clusterType, String clusterVersion, ImageCatalogPlatform platform) throws CloudbreakImageCatalogException {
    if (StackType.CDH.name().equals(clusterType)) {
        StackMatrixV4Response stackMatrixV4Response = stackMatrixService.getStackMatrix(platform);
        Map<String, ClouderaManagerStackDescriptorV4Response> stackDescriptorMap = stackMatrixV4Response.getCdh();
        if (stackDescriptorMap != null) {
            Optional<Entry<String, ClouderaManagerStackDescriptorV4Response>> descriptorEntry = stackDescriptorMap.entrySet().stream().filter(stackDescriptorEntry -> clusterVersion == null || clusterVersion.equals(stackDescriptorEntry.getKey())).max(Comparator.comparing(Entry::getKey));
            if (descriptorEntry.isPresent()) {
                Entry<String, ClouderaManagerStackDescriptorV4Response> stackDescriptorEntry = descriptorEntry.get();
                ClouderaManagerInfoV4Response clouderaManagerInfoJson = stackDescriptorEntry.getValue().getClouderaManager();
                if (clouderaManagerInfoJson.getRepository().get(osType) != null) {
                    ClouderaManagerRepo clouderaManagerRepo = new ClouderaManagerRepo();
                    clouderaManagerRepo.setPredefined(false);
                    clouderaManagerRepo.setVersion(clouderaManagerInfoJson.getVersion());
                    clouderaManagerRepo.setBaseUrl(clouderaManagerInfoJson.getRepository().get(osType).getBaseUrl());
                    clouderaManagerRepo.setGpgKeyUrl(clouderaManagerInfoJson.getRepository().get(osType).getGpgKeyUrl());
                    return clouderaManagerRepo;
                }
            }
        }
    }
    LOGGER.info("Missing Cloudera Manager Repo information for os: {} clusterType: {} clusterVersion: {}", osType, clusterType, clusterVersion);
    return null;
}
Also used : Logger(org.slf4j.Logger) LoggerFactory(org.slf4j.LoggerFactory) RepositoryInfo(com.sequenceiq.cloudbreak.cloud.model.component.RepositoryInfo) StackMatrixV4Response(com.sequenceiq.cloudbreak.api.endpoint.v4.util.responses.StackMatrixV4Response) ImageCatalogPlatform(com.sequenceiq.cloudbreak.service.image.catalog.model.ImageCatalogPlatform) HashMap(java.util.HashMap) ClouderaManagerInfoV4Response(com.sequenceiq.cloudbreak.api.endpoint.v4.util.responses.ClouderaManagerInfoV4Response) ClouderaManagerStackDescriptorV4Response(com.sequenceiq.cloudbreak.api.endpoint.v4.util.responses.ClouderaManagerStackDescriptorV4Response) StackType(com.sequenceiq.cloudbreak.cloud.model.component.StackType) ClouderaManagerRepo(com.sequenceiq.cloudbreak.cloud.model.ClouderaManagerRepo) Inject(javax.inject.Inject) Service(org.springframework.stereotype.Service) Map(java.util.Map) Entry(java.util.Map.Entry) Optional(java.util.Optional) CloudbreakImageCatalogException(com.sequenceiq.cloudbreak.core.CloudbreakImageCatalogException) Comparator(java.util.Comparator) ClouderaManagerInfoV4Response(com.sequenceiq.cloudbreak.api.endpoint.v4.util.responses.ClouderaManagerInfoV4Response) Entry(java.util.Map.Entry) ClouderaManagerRepo(com.sequenceiq.cloudbreak.cloud.model.ClouderaManagerRepo) ClouderaManagerStackDescriptorV4Response(com.sequenceiq.cloudbreak.api.endpoint.v4.util.responses.ClouderaManagerStackDescriptorV4Response) StackMatrixV4Response(com.sequenceiq.cloudbreak.api.endpoint.v4.util.responses.StackMatrixV4Response)

Example 3 with ClouderaManagerInfoV4Response

use of com.sequenceiq.cloudbreak.api.endpoint.v4.util.responses.ClouderaManagerInfoV4Response in project cloudbreak by hortonworks.

the class StackMatrixService method getImageBasedCMStackDescriptor.

private ClouderaManagerStackDescriptorV4Response getImageBasedCMStackDescriptor(DefaultCDHInfo stackInfo, Image image) {
    ClouderaManagerStackDescriptorV4Response stackDescriptorV4 = stackInfoToClouderaManagerStackDescriptorV4ResponseConverter.convert(stackInfo);
    RepositoryInfo cmInfo = new RepositoryInfo();
    cmInfo.setVersion(image.getPackageVersion(ImagePackageVersion.CM));
    cmInfo.setRepo(image.getRepo().entrySet().stream().collect(Collectors.toMap(Entry::getKey, e -> {
        RepositoryDetails repo = new RepositoryDetails();
        repo.setBaseurl(e.getValue());
        return repo;
    })));
    ClouderaManagerInfoV4Response cmInfoJson = repositoryInfoToClouderaManagerInfoV4ResponseConverter.convert(cmInfo);
    stackDescriptorV4.setClouderaManager(cmInfoJson);
    for (ClouderaManagerProduct parcel : stackInfo.getParcels()) {
        stackDescriptorV4.getProducts().add(ClouderaManagerProductToClouderaManagerProductV4Response.convert(parcel));
    }
    stackDescriptorV4.setProductDefinitions(stackInfo.getCsd());
    return stackDescriptorV4;
}
Also used : RepositoryDetails(com.sequenceiq.cloudbreak.cloud.model.component.RepositoryDetails) ClouderaManagerInfoV4Response(com.sequenceiq.cloudbreak.api.endpoint.v4.util.responses.ClouderaManagerInfoV4Response) Entry(java.util.Map.Entry) RepositoryInfo(com.sequenceiq.cloudbreak.cloud.model.component.RepositoryInfo) ClouderaManagerStackDescriptorV4Response(com.sequenceiq.cloudbreak.api.endpoint.v4.util.responses.ClouderaManagerStackDescriptorV4Response) ClouderaManagerProduct(com.sequenceiq.cloudbreak.cloud.model.ClouderaManagerProduct)

Example 4 with ClouderaManagerInfoV4Response

use of com.sequenceiq.cloudbreak.api.endpoint.v4.util.responses.ClouderaManagerInfoV4Response in project cloudbreak by hortonworks.

the class DefaultClouderaManagerRepoServiceTest method init.

@Before
public void init() throws Exception {
    StackMatrixV4Response stackMatrixV4Response = new StackMatrixV4Response();
    Map<String, ClouderaManagerStackDescriptorV4Response> cdhMap = new HashMap<>();
    ClouderaManagerInfoV4Response clouderaManagerInfoJson610 = new ClouderaManagerInfoV4Response();
    clouderaManagerInfoJson610.setVersion("6.1.0");
    clouderaManagerInfoJson610.setRepository(RepoTestUtil.getClouderaManagerRepositoryResponse("6.1.0"));
    ClouderaManagerInfoV4Response clouderaManagerInfoJson620 = new ClouderaManagerInfoV4Response();
    clouderaManagerInfoJson620.setVersion("6.2.0");
    clouderaManagerInfoJson620.setRepository(RepoTestUtil.getClouderaManagerRepositoryResponse("6.2.0"));
    ClouderaManagerStackDescriptorV4Response cdhDescriptor610 = new ClouderaManagerStackDescriptorV4Response();
    cdhDescriptor610.setClouderaManager(clouderaManagerInfoJson610);
    cdhMap.put("6.1.0", cdhDescriptor610);
    ClouderaManagerStackDescriptorV4Response cdhDescriptor620 = new ClouderaManagerStackDescriptorV4Response();
    cdhDescriptor620.setClouderaManager(clouderaManagerInfoJson620);
    cdhMap.put("6.2.0", cdhDescriptor620);
    stackMatrixV4Response.setCdh(cdhMap);
    when(stackMatrixService.getStackMatrix(null)).thenReturn(stackMatrixV4Response);
}
Also used : ClouderaManagerInfoV4Response(com.sequenceiq.cloudbreak.api.endpoint.v4.util.responses.ClouderaManagerInfoV4Response) HashMap(java.util.HashMap) ClouderaManagerStackDescriptorV4Response(com.sequenceiq.cloudbreak.api.endpoint.v4.util.responses.ClouderaManagerStackDescriptorV4Response) StackMatrixV4Response(com.sequenceiq.cloudbreak.api.endpoint.v4.util.responses.StackMatrixV4Response) Before(org.junit.Before)

Example 5 with ClouderaManagerInfoV4Response

use of com.sequenceiq.cloudbreak.api.endpoint.v4.util.responses.ClouderaManagerInfoV4Response in project cloudbreak by hortonworks.

the class StackMatrixServiceTest method getStackMatrixWithoutAmbari.

@Test
public void getStackMatrixWithoutAmbari() throws Exception {
    setupStackEntries();
    when(repositoryInfoToClouderaManagerInfoV4ResponseConverter.convert(any(RepositoryInfo.class))).thenReturn(new ClouderaManagerInfoV4Response());
    StackMatrixV4Response stackMatrixV4Response = stackMatrixService.getStackMatrix(WORKSPACE_ID, IMAGECATALOGPLATFORM, IMAGE_CATALOG_NAME);
    assertEquals(1L, stackMatrixV4Response.getCdh().size());
    assertEquals("6.1.0-1.cdh6.1.0.p0.770702", stackMatrixV4Response.getCdh().get("6.1.0").getVersion());
    assertNull(stackMatrixV4Response.getCdh().get("6.1.0").getClouderaManager().getRepository());
    assertNull(stackMatrixV4Response.getCdh().get("6.1.0").getClouderaManager().getVersion());
}
Also used : ClouderaManagerInfoV4Response(com.sequenceiq.cloudbreak.api.endpoint.v4.util.responses.ClouderaManagerInfoV4Response) RepositoryInfo(com.sequenceiq.cloudbreak.cloud.model.component.RepositoryInfo) StackMatrixV4Response(com.sequenceiq.cloudbreak.api.endpoint.v4.util.responses.StackMatrixV4Response) Test(org.junit.Test)

Aggregations

ClouderaManagerInfoV4Response (com.sequenceiq.cloudbreak.api.endpoint.v4.util.responses.ClouderaManagerInfoV4Response)7 ClouderaManagerStackDescriptorV4Response (com.sequenceiq.cloudbreak.api.endpoint.v4.util.responses.ClouderaManagerStackDescriptorV4Response)4 StackMatrixV4Response (com.sequenceiq.cloudbreak.api.endpoint.v4.util.responses.StackMatrixV4Response)4 RepositoryInfo (com.sequenceiq.cloudbreak.cloud.model.component.RepositoryInfo)4 HashMap (java.util.HashMap)3 Entry (java.util.Map.Entry)3 ClouderaManagerRepo (com.sequenceiq.cloudbreak.cloud.model.ClouderaManagerRepo)2 StackType (com.sequenceiq.cloudbreak.cloud.model.component.StackType)2 CloudbreakImageCatalogException (com.sequenceiq.cloudbreak.core.CloudbreakImageCatalogException)2 Comparator (java.util.Comparator)2 Map (java.util.Map)2 Optional (java.util.Optional)2 Inject (javax.inject.Inject)2 Logger (org.slf4j.Logger)2 LoggerFactory (org.slf4j.LoggerFactory)2 Service (org.springframework.stereotype.Service)2 ClouderaManagerProduct (com.sequenceiq.cloudbreak.cloud.model.ClouderaManagerProduct)1 RepositoryDetails (com.sequenceiq.cloudbreak.cloud.model.component.RepositoryDetails)1 ImageCatalogPlatform (com.sequenceiq.cloudbreak.service.image.catalog.model.ImageCatalogPlatform)1 Before (org.junit.Before)1