use of com.sequenceiq.cloudbreak.domain.stack.cluster.ClusterTemplate in project cloudbreak by hortonworks.
the class ClusterTemplateService method deleteByName.
public ClusterTemplate deleteByName(String name, Long workspaceId) {
ClusterTemplate clusterTemplate = getByNameForWorkspaceId(name, workspaceId);
clusterTemplate = delete(clusterTemplate);
ownerAssignmentService.notifyResourceDeleted(clusterTemplate.getResourceCrn(), MDCUtils.getRequestId());
stackTemplateService.delete(clusterTemplate.getStackTemplate());
return clusterTemplate;
}
use of com.sequenceiq.cloudbreak.domain.stack.cluster.ClusterTemplate in project cloudbreak by hortonworks.
the class ClusterTemplateService method deleteByCrn.
public ClusterTemplate deleteByCrn(String crn, Long workspaceId, boolean internalTenant) {
ClusterTemplate clusterTemplate = getByCrn(crn, workspaceId, internalTenant);
clusterTemplate = delete(clusterTemplate);
stackTemplateService.delete(clusterTemplate.getStackTemplate());
return clusterTemplate;
}
use of com.sequenceiq.cloudbreak.domain.stack.cluster.ClusterTemplate in project cloudbreak by hortonworks.
the class ClusterTemplateV4Controller method post.
@Override
@CheckPermissionByAccount(action = AuthorizationResourceAction.CREATE_CLUSTER_DEFINITION)
public ClusterTemplateV4Response post(Long workspaceId, @Valid ClusterTemplateV4Request request) {
String accountId = ThreadBasedUserCrnProvider.getAccountId();
String creator = ThreadBasedUserCrnProvider.getUserCrn();
ClusterTemplate clusterTemplate = clusterTemplateService.createForLoggedInUser(clusterTemplateV4RequestToClusterTemplateConverter.convert(request), threadLocalService.getRequestedWorkspaceId(), accountId, creator);
return getByName(threadLocalService.getRequestedWorkspaceId(), clusterTemplate.getName());
}
use of com.sequenceiq.cloudbreak.domain.stack.cluster.ClusterTemplate in project cloudbreak by hortonworks.
the class ClusterTemplateV4Controller method deleteByCrn.
@Override
@CheckPermissionByResourceCrn(action = AuthorizationResourceAction.DELETE_CLUSTER_DEFINITION)
public ClusterTemplateV4Response deleteByCrn(Long workspaceId, @TenantAwareParam @ResourceCrn String crn) {
boolean internalTenant = isInternalTenant();
ClusterTemplate clusterTemplate = clusterTemplateService.deleteByCrn(crn, threadLocalService.getRequestedWorkspaceId(), internalTenant);
return clusterTemplateToClusterTemplateV4ResponseConverter.convert(clusterTemplate);
}
use of com.sequenceiq.cloudbreak.domain.stack.cluster.ClusterTemplate in project cloudbreak by hortonworks.
the class BlueprintLoaderServiceTest method testForTheSpecifiedUserWhenNewDefaultsExistAndNONeedsToRetireOldBlueprintsThenRepositoryShouldUpdateAddTwoNewAndReturnWithFive.
@Test
public void testForTheSpecifiedUserWhenNewDefaultsExistAndNONeedsToRetireOldBlueprintsThenRepositoryShouldUpdateAddTwoNewAndReturnWithFive() {
Set<ClusterTemplate> notEmptyClusterTemplateList = Sets.newHashSet(new ClusterTemplate());
// We have a0, a1, a2 in the DB
Set<Blueprint> blueprints = generateBlueprintData(3, BlueprintUpgradeOption.ENABLED);
// We have a2, a3, a4 as defaults
Map<String, BlueprintFile> defaultBlueprints = generateCacheData(3, 2, BlueprintUpgradeOption.ENABLED);
setupMock(defaultBlueprints);
when(clusterTemplateService.getTemplatesByBlueprint(any(Blueprint.class))).thenReturn(notEmptyClusterTemplateList);
Collection<Blueprint> resultSet = ThreadBasedUserCrnProvider.doAs(USER_CRN, () -> underTest.loadBlueprintsForTheWorkspace(blueprints, workspace, this::mockSave));
ArgumentCaptor<Iterable<Blueprint>> argument = ArgumentCaptor.forClass(Iterable.class);
verify(blueprintService).pureSaveAll(argument.capture());
verify(blueprintService, times(1)).pureSaveAll(any(Iterable.class));
Assert.assertEquals(0, Iterators.size(argument.getValue().iterator()));
Assert.assertEquals(5L, resultSet.size());
Assert.assertTrue(CollectionUtils.isEqualCollection(Sets.newHashSet("multi-node-hdfs-yarn0", "multi-node-hdfs-yarn1", "multi-node-hdfs-yarn2"), collectBpNames(blueprints)));
Assert.assertTrue(CollectionUtils.isEqualCollection(Sets.newHashSet("multi-node-hdfs-yarn2", "multi-node-hdfs-yarn3", "multi-node-hdfs-yarn4"), defaultBlueprints.keySet()));
Assert.assertTrue(CollectionUtils.isEqualCollection(Sets.newHashSet("multi-node-hdfs-yarn0", "multi-node-hdfs-yarn1", "multi-node-hdfs-yarn2", "multi-node-hdfs-yarn3", "multi-node-hdfs-yarn4"), collectBpNames(resultSet)));
}
Aggregations