use of com.sequenceiq.cloudbreak.domain.Component in project cloudbreak by hortonworks.
the class StackService method addTemplateForStack.
private void addTemplateForStack(Stack stack, String template) {
StackTemplate stackTemplate = new StackTemplate(template, cbVersion);
try {
Component stackTemplateComponent = new Component(ComponentType.STACK_TEMPLATE, ComponentType.STACK_TEMPLATE.name(), new Json(stackTemplate), stack);
componentConfigProvider.store(stackTemplateComponent);
} catch (JsonProcessingException e) {
LOGGER.error("Could not create Cloudbreak details component.", e);
}
}
use of com.sequenceiq.cloudbreak.domain.Component in project cloudbreak by hortonworks.
the class ImageService method getComponents.
private List<Component> getComponents(Stack stack, Map<InstanceGroupType, String> userData, com.sequenceiq.cloudbreak.cloud.model.catalog.Image imgFromCatalog, String imageName, String imageCatalogUrl, String imageCatalogName, String imageId) throws JsonProcessingException, CloudbreakImageCatalogException {
List<Component> components = new ArrayList<>();
Image image = new Image(imageName, userData, imgFromCatalog.getOsType(), imageCatalogUrl, imageCatalogName, imageId);
Component imageComponent = new Component(ComponentType.IMAGE, ComponentType.IMAGE.name(), new Json(image), stack);
components.add(imageComponent);
if (imgFromCatalog.getStackDetails() != null) {
components.add(getAmbariComponent(stack, imgFromCatalog));
StackDetails stackDetails = imgFromCatalog.getStackDetails();
Component stackRepoComponent;
if (!imgFromCatalog.getStackDetails().getRepo().getKnox().isEmpty()) {
StackRepoDetails hdfRepo = createHDFRepo(stackDetails);
stackRepoComponent = new Component(ComponentType.HDF_REPO_DETAILS, ComponentType.HDF_REPO_DETAILS.name(), new Json(hdfRepo), stack);
} else {
StackRepoDetails repo = createHDPRepo(stackDetails);
stackRepoComponent = new Component(ComponentType.HDP_REPO_DETAILS, ComponentType.HDP_REPO_DETAILS.name(), new Json(repo), stack);
}
components.add(stackRepoComponent);
}
return components;
}
use of com.sequenceiq.cloudbreak.domain.Component in project cloudbreak by hortonworks.
the class ImageService method create.
@Transactional(TxType.NEVER)
public void create(Stack stack, PlatformParameters params, String imageCatalog, Optional<String> imageId, Optional<Blueprint> blueprint) throws CloudbreakImageNotFoundException, CloudbreakImageCatalogException {
try {
Platform platform = platform(stack.cloudPlatform());
String platformString = platform(stack.cloudPlatform()).value().toLowerCase();
String region = stack.getRegion();
SecurityConfig securityConfig = stack.getSecurityConfig();
String cbPrivKey = securityConfig.getCloudbreakSshPrivateKeyDecoded();
byte[] cbSshKeyDer = PkiUtil.getPublicKeyDer(cbPrivKey);
String sshUser = stack.getStackAuthentication().getLoginUserName();
String cbCert = securityConfig.getClientCertRaw();
Map<InstanceGroupType, String> userData = userDataBuilder.buildUserData(platform, cbSshKeyDer, sshUser, params, securityConfig.getSaltBootPassword(), cbCert);
StatedImage imgFromCatalog = determineImageFromCatalog(imageId, platformString, imageCatalog, blueprint);
LOGGER.info("Determined image from catalog: {}", imgFromCatalog);
String imageName = determineImageName(platformString, region, imgFromCatalog.getImage());
LOGGER.info("Selected VM image for CloudPlatform '{}' and region '{}' is: {} from: {} image catalog", platformString, region, imageName, imgFromCatalog.getImageCatalogUrl());
List<Component> components = getComponents(stack, userData, imgFromCatalog.getImage(), imageName, imgFromCatalog.getImageCatalogUrl(), imgFromCatalog.getImageCatalogName(), imgFromCatalog.getImage().getUuid());
componentConfigProvider.store(components);
} catch (JsonProcessingException e) {
throw new CloudbreakServiceException("Failed to create json", e);
}
}
use of com.sequenceiq.cloudbreak.domain.Component in project cloudbreak by hortonworks.
the class ComponentConfigProvider method store.
public Component store(Component component) {
LOGGER.debug("Component is going to be saved: {}", component);
Component ret = componentRepository.save(component);
LOGGER.debug("Component saved: stackId: {}, component: {}", ret.getStack().getId(), ret);
return ret;
}
Aggregations