Search in sources :

Example 6 with StackMatrixV4Response

use of com.sequenceiq.cloudbreak.api.endpoint.v4.util.responses.StackMatrixV4Response 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)

Example 7 with StackMatrixV4Response

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

the class ClouderaManagerClusterCreationSetupServiceTest method init.

@Before
public void init() throws CloudbreakImageCatalogException {
    MockitoAnnotations.initMocks(this);
    Workspace workspace = new Workspace();
    clusterRequest = new ClusterV4Request();
    stack = new Stack();
    stack.setId(STACK_ID);
    stack.setName("test-stack");
    stack.setWorkspace(workspace);
    Blueprint blueprint = new Blueprint();
    blueprint.setBlueprintText("{}");
    Map<InstanceGroupType, String> userData = new HashMap<>();
    userData.put(InstanceGroupType.CORE, "userdata");
    Image image = new Image("imagename", userData, "centos7", REDHAT_7, "url", IMAGE_CATALOG_NAME, "id", Collections.emptyMap());
    imageComponent = new Component(ComponentType.IMAGE, ComponentType.IMAGE.name(), new Json(image), stack);
    cluster = new Cluster();
    stack.setCluster(cluster);
    cluster.setStack(stack);
    cluster.setBlueprint(blueprint);
    cluster.setWorkspace(workspace);
    setupDefaultClouderaManagerEntries();
    Map<String, ImageBasedDefaultCDHInfo> defaultCDHInfoMap = Map.of(OLDER_CDH_VERSION, new ImageBasedDefaultCDHInfo(getDefaultCDHInfo(OLDER_CDH_VERSION), mock(com.sequenceiq.cloudbreak.cloud.model.catalog.Image.class)), SOME_CDH_VERSION, new ImageBasedDefaultCDHInfo(getDefaultCDHInfo(SOME_CDH_VERSION), mock(com.sequenceiq.cloudbreak.cloud.model.catalog.Image.class)), NEWER_CDH_VERSION, new ImageBasedDefaultCDHInfo(getDefaultCDHInfo(NEWER_CDH_VERSION), mock(com.sequenceiq.cloudbreak.cloud.model.catalog.Image.class)));
    when(imageBasedDefaultCDHEntries.getEntries(workspace.getId(), null, IMAGE_CATALOG_NAME)).thenReturn(defaultCDHInfoMap);
    StackMatrixV4Response stackMatrixV4Response = new StackMatrixV4Response();
    stackMatrixV4Response.setCdh(Collections.singletonMap(OLDER_CDH_VERSION, null));
    when(stackMatrixService.getStackMatrix(Mockito.eq(workspace.getId()), Mockito.eq(null), Mockito.anyString())).thenReturn(stackMatrixV4Response);
    when(platformStringTransformer.getPlatformStringForImageCatalog(anyString(), anyString())).thenReturn(imageCatalogPlatform("AWS"));
}
Also used : InstanceGroupType(com.sequenceiq.common.api.type.InstanceGroupType) HashMap(java.util.HashMap) Blueprint(com.sequenceiq.cloudbreak.domain.Blueprint) ImageBasedDefaultCDHInfo(com.sequenceiq.cloudbreak.cloud.model.component.ImageBasedDefaultCDHInfo) Cluster(com.sequenceiq.cloudbreak.domain.stack.cluster.Cluster) ArgumentMatchers.anyString(org.mockito.ArgumentMatchers.anyString) Json(com.sequenceiq.cloudbreak.common.json.Json) Image(com.sequenceiq.cloudbreak.cloud.model.Image) Stack(com.sequenceiq.cloudbreak.domain.stack.Stack) ClusterV4Request(com.sequenceiq.cloudbreak.api.endpoint.v4.stacks.request.cluster.ClusterV4Request) Component(com.sequenceiq.cloudbreak.domain.stack.Component) ClusterComponent(com.sequenceiq.cloudbreak.domain.stack.cluster.ClusterComponent) StackMatrixV4Response(com.sequenceiq.cloudbreak.api.endpoint.v4.util.responses.StackMatrixV4Response) Workspace(com.sequenceiq.cloudbreak.workspace.model.Workspace) Before(org.junit.Before)

Example 8 with StackMatrixV4Response

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

the class StackMatrixService method getImageBasedStackMatrix.

private StackMatrixV4Response getImageBasedStackMatrix(Long workspaceId, ImageCatalogPlatform platform, String imageCatalogName) throws CloudbreakImageCatalogException {
    Map<String, ImageBasedDefaultCDHInfo> cdhEntries = imageBasedDefaultCDHEntries.getEntries(workspaceId, platform, imageCatalogName);
    StackMatrixV4Response stackMatrixV4Response = new StackMatrixV4Response();
    Map<String, ClouderaManagerStackDescriptorV4Response> cdhStackDescriptors = new HashMap<>();
    for (Entry<String, ImageBasedDefaultCDHInfo> defaultCDHInfoEntry : cdhEntries.entrySet()) {
        DefaultCDHInfo defaultCDHInfo = defaultCDHInfoEntry.getValue().getDefaultCDHInfo();
        Image image = defaultCDHInfoEntry.getValue().getImage();
        ClouderaManagerStackDescriptorV4Response stackDescriptorV4 = getImageBasedCMStackDescriptor(defaultCDHInfo, image);
        cdhStackDescriptors.put(defaultCDHInfoEntry.getKey(), stackDescriptorV4);
    }
    stackMatrixV4Response.setCdh(cdhStackDescriptors);
    return stackMatrixV4Response;
}
Also used : ImageBasedDefaultCDHInfo(com.sequenceiq.cloudbreak.cloud.model.component.ImageBasedDefaultCDHInfo) DefaultCDHInfo(com.sequenceiq.cloudbreak.cloud.model.component.DefaultCDHInfo) HashMap(java.util.HashMap) ImageBasedDefaultCDHInfo(com.sequenceiq.cloudbreak.cloud.model.component.ImageBasedDefaultCDHInfo) ClouderaManagerStackDescriptorV4Response(com.sequenceiq.cloudbreak.api.endpoint.v4.util.responses.ClouderaManagerStackDescriptorV4Response) Image(com.sequenceiq.cloudbreak.cloud.model.catalog.Image) StackMatrixV4Response(com.sequenceiq.cloudbreak.api.endpoint.v4.util.responses.StackMatrixV4Response)

Example 9 with StackMatrixV4Response

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

the class ClouderaManagerClusterCreationSetupService method checkCmStackRepositories.

private void checkCmStackRepositories(ClusterComponent cmRepoConfig, Component imageComponent) throws IOException, CloudbreakImageCatalogException {
    if (Objects.nonNull(cmRepoConfig)) {
        ClouderaManagerRepo clouderaManagerRepo = cmRepoConfig.getAttributes().get(ClouderaManagerRepo.class);
        Image image = imageComponent.getAttributes().get(Image.class);
        StackMatrixV4Response stackMatrixV4Response = stackMatrixService.getStackMatrix(cmRepoConfig.getCluster().getWorkspace().getId(), platformStringTransformer.getPlatformStringForImageCatalog(cmRepoConfig.getCluster().getStack().getCloudPlatform(), cmRepoConfig.getCluster().getStack().getPlatformVariant()), image.getImageCatalogName());
        Map<String, ClouderaManagerStackDescriptorV4Response> stackDescriptorMap = stackMatrixV4Response.getCdh();
        ClouderaManagerStackDescriptorV4Response clouderaManagerStackDescriptor = stackDescriptorMap.get(clouderaManagerRepo.getVersion());
        if (clouderaManagerStackDescriptor != null) {
            boolean hasDefaultStackRepoUrlForOsType = clouderaManagerStackDescriptor.getRepository().getStack().containsKey(image.getOsType());
            boolean hasDefaultCmRepoUrlForOsType = clouderaManagerStackDescriptor.getClouderaManager().getRepository().containsKey(image.getOsType());
            if (!hasDefaultCmRepoUrlForOsType || !hasDefaultStackRepoUrlForOsType) {
                String message = String.format("The given repository information seems to be incompatible." + " CM version: %s, Image Id: %s, Os type: %s.", clouderaManagerRepo.getVersion(), image.getImageId(), image.getOsType());
                LOGGER.warn(message);
            }
        }
    }
}
Also used : ClouderaManagerRepo(com.sequenceiq.cloudbreak.cloud.model.ClouderaManagerRepo) ClouderaManagerStackDescriptorV4Response(com.sequenceiq.cloudbreak.api.endpoint.v4.util.responses.ClouderaManagerStackDescriptorV4Response) Image(com.sequenceiq.cloudbreak.cloud.model.Image) StackMatrixV4Response(com.sequenceiq.cloudbreak.api.endpoint.v4.util.responses.StackMatrixV4Response)

Example 10 with StackMatrixV4Response

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

the class StackMatrixService method getImageBasedStackMatrix.

private StackMatrixV4Response getImageBasedStackMatrix(Long workspaceId, String platform, String imageCatalogName) throws CloudbreakImageCatalogException {
    Map<String, ImageBasedDefaultCDHInfo> cdhEntries = imageBasedDefaultCDHEntries.getEntries(workspaceId, platform, imageCatalogName);
    StackMatrixV4Response stackMatrixV4Response = new StackMatrixV4Response();
    Map<String, ClouderaManagerStackDescriptorV4Response> cdhStackDescriptors = new HashMap<>();
    for (Entry<String, ImageBasedDefaultCDHInfo> defaultCDHInfoEntry : cdhEntries.entrySet()) {
        DefaultCDHInfo defaultCDHInfo = defaultCDHInfoEntry.getValue().getDefaultCDHInfo();
        Image image = defaultCDHInfoEntry.getValue().getImage();
        ClouderaManagerStackDescriptorV4Response stackDescriptorV4 = getImageBasedCMStackDescriptor(defaultCDHInfo, image);
        cdhStackDescriptors.put(defaultCDHInfoEntry.getKey(), stackDescriptorV4);
    }
    stackMatrixV4Response.setCdh(cdhStackDescriptors);
    return stackMatrixV4Response;
}
Also used : ImageBasedDefaultCDHInfo(com.sequenceiq.cloudbreak.cloud.model.component.ImageBasedDefaultCDHInfo) DefaultCDHInfo(com.sequenceiq.cloudbreak.cloud.model.component.DefaultCDHInfo) HashMap(java.util.HashMap) ImageBasedDefaultCDHInfo(com.sequenceiq.cloudbreak.cloud.model.component.ImageBasedDefaultCDHInfo) ClouderaManagerStackDescriptorV4Response(com.sequenceiq.cloudbreak.api.endpoint.v4.util.responses.ClouderaManagerStackDescriptorV4Response) Image(com.sequenceiq.cloudbreak.cloud.model.catalog.Image) StackMatrixV4Response(com.sequenceiq.cloudbreak.api.endpoint.v4.util.responses.StackMatrixV4Response)

Aggregations

StackMatrixV4Response (com.sequenceiq.cloudbreak.api.endpoint.v4.util.responses.StackMatrixV4Response)11 ClouderaManagerStackDescriptorV4Response (com.sequenceiq.cloudbreak.api.endpoint.v4.util.responses.ClouderaManagerStackDescriptorV4Response)8 HashMap (java.util.HashMap)7 ClouderaManagerInfoV4Response (com.sequenceiq.cloudbreak.api.endpoint.v4.util.responses.ClouderaManagerInfoV4Response)4 ImageBasedDefaultCDHInfo (com.sequenceiq.cloudbreak.cloud.model.component.ImageBasedDefaultCDHInfo)4 ClouderaManagerRepo (com.sequenceiq.cloudbreak.cloud.model.ClouderaManagerRepo)3 Image (com.sequenceiq.cloudbreak.cloud.model.Image)3 DefaultCDHInfo (com.sequenceiq.cloudbreak.cloud.model.component.DefaultCDHInfo)3 RepositoryInfo (com.sequenceiq.cloudbreak.cloud.model.component.RepositoryInfo)3 Before (org.junit.Before)3 ClusterV4Request (com.sequenceiq.cloudbreak.api.endpoint.v4.stacks.request.cluster.ClusterV4Request)2 Image (com.sequenceiq.cloudbreak.cloud.model.catalog.Image)2 StackType (com.sequenceiq.cloudbreak.cloud.model.component.StackType)2 Json (com.sequenceiq.cloudbreak.common.json.Json)2 CloudbreakImageCatalogException (com.sequenceiq.cloudbreak.core.CloudbreakImageCatalogException)2 Blueprint (com.sequenceiq.cloudbreak.domain.Blueprint)2 Component (com.sequenceiq.cloudbreak.domain.stack.Component)2 Stack (com.sequenceiq.cloudbreak.domain.stack.Stack)2 Cluster (com.sequenceiq.cloudbreak.domain.stack.cluster.Cluster)2 Workspace (com.sequenceiq.cloudbreak.workspace.model.Workspace)2