use of com.sequenceiq.cloudbreak.domain.stack.Component in project cloudbreak by hortonworks.
the class ImageService method create.
@Measure(ImageService.class)
public Set<Component> create(Stack stack, StatedImage imgFromCatalog) throws CloudbreakImageNotFoundException, CloudbreakImageCatalogException {
String region = stack.getRegion();
String cloudPlatform = stack.getCloudPlatform();
ImageCatalogPlatform platformString = platformStringTransformer.getPlatformStringForImageCatalog(cloudPlatform, stack.getPlatformVariant());
LOGGER.debug("Determined image from catalog: {}", imgFromCatalog);
String imageName = determineImageName(cloudPlatform, platformString, region, imgFromCatalog.getImage());
LOGGER.debug("Selected VM image for CloudPlatform '{}' and region '{}' is: {} from: {} image catalog", platformString, region, imageName, imgFromCatalog.getImageCatalogUrl());
Set<Component> components = getComponents(stack, Map.of(), imgFromCatalog, EnumSet.of(IMAGE, CDH_PRODUCT_DETAILS, CM_REPO_DETAILS));
componentConfigProviderService.store(components);
return components;
}
use of com.sequenceiq.cloudbreak.domain.stack.Component 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"));
}
use of com.sequenceiq.cloudbreak.domain.stack.Component in project cloudbreak by hortonworks.
the class ImageComponentUpdaterService method updateForUpgrade.
public UpgradeImageInfo updateForUpgrade(String targetImageId, Long stackId) {
Stack stack = stackService.getById(stackId);
try {
restRequestThreadLocalService.setWorkspace(stack.getWorkspace());
UpgradeImageInfo upgradeImageInfo = upgradeImageInfoFactory.create(targetImageId, stackId);
Set<Component> targetComponents = imageService.getComponents(stack, upgradeImageInfo.getCurrentImage().getUserdata(), upgradeImageInfo.getTargetStatedImage(), EnumSet.of(CDH_PRODUCT_DETAILS, CM_REPO_DETAILS));
stackComponentUpdater.updateComponentsByStackId(stack, targetComponents, true);
clusterComponentUpdater.updateClusterComponentsByStackId(stack, targetComponents, true);
return upgradeImageInfo;
} catch (CloudbreakImageNotFoundException | CloudbreakImageCatalogException e) {
LOGGER.warn(String.format("Image was not found for stack %s", stack.getName()), e);
throw notFoundException("Image", targetImageId);
}
}
use of com.sequenceiq.cloudbreak.domain.stack.Component in project cloudbreak by hortonworks.
the class ClouderaManagerClusterCreationSetupService method getCmRepoConfiguration.
private ClusterComponent getCmRepoConfiguration(Cluster cluster, Optional<Component> stackClouderaManagerRepoConfig, List<ClusterComponent> components, String blueprintCdhVersion, Optional<ClouderaManagerRepositoryV4Request> cmRepoRequest, String osType) throws CloudbreakImageCatalogException {
ClusterComponent cmRepoConfig;
if (cmRepoRequest.isEmpty()) {
cmRepoConfig = determineCmRepoConfig(stackClouderaManagerRepoConfig, osType, cluster, blueprintCdhVersion);
components.add(cmRepoConfig);
} else {
cmRepoConfig = cluster.getComponents().stream().filter(component -> ComponentType.CM_REPO_DETAILS.equals(component.getComponentType())).findFirst().orElse(null);
}
return cmRepoConfig;
}
use of com.sequenceiq.cloudbreak.domain.stack.Component in project cloudbreak by hortonworks.
the class CmSyncResultMergerServiceTest method testMergeWhenNoClouderaManagerProductFound.
@Test
void testMergeWhenNoClouderaManagerProductFound() {
Stack stack = new Stack();
ClouderaManagerRepo clouderaManagerRepo = new ClouderaManagerRepo();
CmRepoSyncOperationResult cmRepoSyncOperationResult = new CmRepoSyncOperationResult("", clouderaManagerRepo);
when(componentConverter.fromClouderaManagerRepo(clouderaManagerRepo, stack)).thenReturn(componentWithName(CM_REPO_COMPONENT_NAME));
CmParcelSyncOperationResult cmParcelSyncOperationResult = new CmParcelSyncOperationResult(Set.of(), Set.of());
CmSyncOperationResult cmSyncOperationResult = new CmSyncOperationResult(cmRepoSyncOperationResult, cmParcelSyncOperationResult);
Set<Component> mergedComponents = underTest.merge(stack, cmSyncOperationResult);
assertThat(mergedComponents, hasSize(1));
assertThat(mergedComponents, contains(hasProperty("name", is(CM_REPO_COMPONENT_NAME))));
verify(componentConverter).fromClouderaManagerRepo(clouderaManagerRepo, stack);
verify(componentConverter).fromClouderaManagerProductList(Set.of(), stack);
}
Aggregations