use of com.sequenceiq.common.api.type.InstanceGroupType in project cloudbreak by hortonworks.
the class StackDecorator method setupDatabaseAttachedVolume.
private void setupDatabaseAttachedVolume(Stack subject, InstanceGroup instanceGroup, Template template) {
InstanceGroupType instanceGroupType = instanceGroup.getInstanceGroupType();
if (instanceGroupType == InstanceGroupType.GATEWAY && embeddedDatabaseService.isEmbeddedDatabaseOnAttachedDiskEnabled(subject, subject.getCluster())) {
String databaseVolumeType = embeddedDatabaseConfig.getPlatformVolumeType(subject.cloudPlatform()).orElseThrow(() -> new BadRequestException(String.format("If embedded db is enabled on attached disk, database volumetype" + " have to be defined for cloudprovider in app config! Missing database volumetype on %s provider", subject.cloudPlatform())));
VolumeTemplate databaseVolumeTemplate = new VolumeTemplate();
databaseVolumeTemplate.setUsageType(VolumeUsageType.DATABASE);
databaseVolumeTemplate.setVolumeSize(embeddedDatabaseConfig.getSize());
databaseVolumeTemplate.setVolumeCount(1);
databaseVolumeTemplate.setVolumeType(databaseVolumeType);
databaseVolumeTemplate.setTemplate(template);
template.getVolumeTemplates().add(databaseVolumeTemplate);
LOGGER.debug("Extra disk is attached with {} type and {}GB size for the embedded database.", databaseVolumeTemplate.getVolumeType(), databaseVolumeTemplate.getVolumeSize());
} else {
if (instanceGroupType == InstanceGroupType.GATEWAY) {
LOGGER.debug("No extra disk will be attached to the gateway instance as db volume because it is disabled or external database is used.");
} else {
LOGGER.debug("No extra disk will be attached to the instance as db volume because it is CORE instance.");
}
}
}
use of com.sequenceiq.common.api.type.InstanceGroupType in project cloudbreak by hortonworks.
the class UserDataBuilder method buildUserData.
public Map<InstanceGroupType, String> buildUserData(Platform cloudPlatform, byte[] cbSshKeyDer, String sshUser, PlatformParameters parameters, String saltBootPassword, String cbCert, CcmConnectivityParameters ccmParameters, ProxyConfig proxyConfig) {
Map<InstanceGroupType, String> result = new EnumMap<>(InstanceGroupType.class);
for (InstanceGroupType type : InstanceGroupType.values()) {
String userData = build(type, cloudPlatform, cbSshKeyDer, sshUser, parameters, saltBootPassword, cbCert, ccmParameters, proxyConfig);
result.put(type, userData);
LOGGER.debug("User data for {}, content; {}", type, anonymize(userData));
}
return result;
}
use of com.sequenceiq.common.api.type.InstanceGroupType in project cloudbreak by hortonworks.
the class GcpDiskResourceBuilderTest method setUp.
@BeforeEach
void setUp() throws Exception {
privateCrn = "crn";
CloudContext cloudContext = CloudContext.Builder.builder().withId(privateId).withName("testname").withCrn("crn").withPlatform("GCP").withWorkspaceId(WORKSPACE_ID).build();
CloudCredential cloudCredential = new CloudCredential(privateCrn, "credentialname", "account");
cloudCredential.putParameter("projectId", "projectId");
Location location = Location.location(Region.region("region"), AvailabilityZone.availabilityZone("az"));
String projectId = "projectId";
String serviceAccountId = "serviceAccountId";
context = new GcpContext(cloudContext.getName(), location, projectId, serviceAccountId, compute, false, 30, false);
List<CloudResource> networkResources = Collections.singletonList(new Builder().type(ResourceType.GCP_NETWORK).name("network-test").build());
context.addNetworkResources(networkResources);
privateId = 1L;
name = "master";
String flavor = "m1.medium";
instanceId = "SOME_ID";
cloudInstance = new CloudInstance(instanceId, new InstanceTemplate("flavor", "group", 1L, new ArrayList<>(), InstanceStatus.CREATE_REQUESTED, new HashMap<>(), 1L, "img", TemporaryStorage.ATTACHED_VOLUMES, 0L), new InstanceAuthentication("pub", "pub", "cb"), "subnet1", "az1");
auth = new AuthenticatedContext(cloudContext, cloudCredential);
Map<String, Object> params = Map.of();
List<Volume> volumes = Arrays.asList(new Volume("/hadoop/fs1", "HDD", 1, CloudVolumeUsageType.GENERAL), new Volume("/hadoop/fs2", "HDD", 1, CloudVolumeUsageType.GENERAL));
List<SecurityRule> rules = Collections.singletonList(new SecurityRule("0.0.0.0/0", new PortDefinition[] { new PortDefinition("22", "22"), new PortDefinition("443", "443") }, "tcp"));
security = new Security(rules, emptyList());
instanceAuthentication = new InstanceAuthentication("sshkey", "", "cloudbreak");
instanceTemplate = new InstanceTemplate(flavor, name, privateId, volumes, InstanceStatus.CREATE_REQUESTED, params, 0L, "cb-centos66-amb200-2015-05-25", TemporaryStorage.ATTACHED_VOLUMES, 0L);
group = createGroup(50);
buildableResource = List.of(CloudResource.builder().type(ResourceType.GCP_DISK).status(CommonStatus.REQUESTED).name("disk").params(Map.of()).build());
Map<InstanceGroupType, String> userData = ImmutableMap.of(InstanceGroupType.CORE, "CORE", InstanceGroupType.GATEWAY, "GATEWAY");
Image image = new Image("cb-centos66-amb200-2015-05-25", userData, "redhat6", "redhat6", "", "default", "default-id", new HashMap<>());
cloudStack = new CloudStack(Collections.emptyList(), null, image, emptyMap(), emptyMap(), null, null, null, null, null);
Operation operation = new Operation();
operation.setName("operation");
operation.setHttpErrorStatusCode(null);
when(compute.disks()).thenReturn(disks);
when(disks.insert(anyString(), anyString(), any(Disk.class))).thenReturn(insert);
when(insert.execute()).thenReturn(operation);
}
use of com.sequenceiq.common.api.type.InstanceGroupType in project cloudbreak by hortonworks.
the class GcpInstanceResourceBuilderTest method setUp.
@Before
public void setUp() {
privateId = 0L;
privateCrn = "crn";
name = "master";
flavor = "m1.medium";
instanceId = "SOME_ID";
volumes = Arrays.asList(new Volume("/hadoop/fs1", "HDD", 1, CloudVolumeUsageType.GENERAL), new Volume("/hadoop/fs2", "HDD", 1, CloudVolumeUsageType.GENERAL));
List<SecurityRule> rules = Collections.singletonList(new SecurityRule("0.0.0.0/0", new PortDefinition[] { new PortDefinition("22", "22"), new PortDefinition("443", "443") }, "tcp"));
security = new Security(rules, emptyList());
Location location = Location.location(Region.region("region"), AvailabilityZone.availabilityZone("az"));
Map<InstanceGroupType, String> userData = ImmutableMap.of(InstanceGroupType.CORE, "CORE", InstanceGroupType.GATEWAY, "GATEWAY");
image = new Image("cb-centos66-amb200-2015-05-25", userData, "redhat6", "redhat6", "", "default", "default-id", new HashMap<>());
CloudContext cloudContext = CloudContext.Builder.builder().withId(privateId).withName("testname").withCrn("crn").withPlatform("GCP").withWorkspaceId(WORKSPACE_ID).build();
CloudCredential cloudCredential = new CloudCredential(privateCrn, "credentialname", "account");
cloudCredential.putParameter("projectId", "projectId");
String projectId = "projectId";
String serviceAccountId = "serviceAccountId";
when(gcpStackUtil.getProjectId(cloudCredential)).thenReturn(projectId);
authenticatedContext = new AuthenticatedContext(cloudContext, cloudCredential);
context = new GcpContext(cloudContext.getName(), location, projectId, serviceAccountId, compute, false, 30, false);
List<CloudResource> networkResources = Collections.singletonList(new Builder().type(ResourceType.GCP_NETWORK).name("network-test").build());
context.addNetworkResources(networkResources);
operation = new Operation();
operation.setName("operation");
operation.setHttpErrorStatusCode(null);
operation.setError(new Operation.Error());
GcpResourceNameService resourceNameService = new GcpResourceNameService();
ReflectionTestUtils.setField(resourceNameService, "maxResourceNameLength", 50);
ReflectionTestUtils.setField(builder, "resourceNameService", resourceNameService);
Network network = new Network(null);
cloudStack = new CloudStack(Collections.emptyList(), network, image, emptyMap(), emptyMap(), null, null, null, null, null);
}
use of com.sequenceiq.common.api.type.InstanceGroupType in project cloudbreak by hortonworks.
the class ClusterCreationSetupServiceTest method init.
@Before
public void init() throws CloudbreakImageNotFoundException, CloudbreakImageCatalogException, IOException {
MockitoAnnotations.initMocks(this);
workspace = new Workspace();
clusterRequest = new ClusterV4Request();
stack = new Stack();
stack.setId(1L);
stack.setWorkspace(workspace);
stack.setEnvironmentCrn("env");
stack.setName("name");
blueprint = new Blueprint();
blueprint.setBlueprintText("{}");
user = new User();
Map<InstanceGroupType, String> userData = new HashMap<>();
userData.put(InstanceGroupType.CORE, "userdata");
Image image = new Image("imagename", userData, "centos7", REDHAT_7, "url", "imgcatname", "id", Collections.emptyMap());
Component imageComponent = new Component(ComponentType.IMAGE, ComponentType.IMAGE.name(), new Json(image), stack);
cluster = new Cluster();
stack.setCluster(cluster);
when(clusterDecorator.decorate(any(), any(), any(), any(), any(), any())).thenReturn(cluster);
when(componentConfigProviderService.getAllComponentsByStackIdAndType(any(), any())).thenReturn(Sets.newHashSet(imageComponent));
when(blueprintUtils.getBlueprintStackVersion(any())).thenReturn(HDP_VERSION);
when(blueprintUtils.getBlueprintStackName(any())).thenReturn("HDP");
DefaultCDHInfo defaultCDHInfo = getDefaultCDHInfo(CDH_VERSION);
when(imageBasedDefaultCDHEntries.getEntries(workspace.getId(), imageCatalogPlatform(PLATFORM), IMAGE_CATALOG_NAME)).thenReturn(Collections.singletonMap(CDH_VERSION, new ImageBasedDefaultCDHInfo(defaultCDHInfo, Mockito.mock(com.sequenceiq.cloudbreak.cloud.model.catalog.Image.class))));
when(componentConfigProviderService.getImage(anyLong())).thenReturn(image);
StackMatrixV4Response stackMatrixV4Response = new StackMatrixV4Response();
stackMatrixV4Response.setCdh(Collections.singletonMap(CDH_VERSION, null));
when(stackMatrixService.getStackMatrix(workspace.getId(), imageCatalogPlatform(PLATFORM), IMAGE_CATALOG_NAME)).thenReturn(stackMatrixV4Response);
when(clouderaManagerClusterCreationSetupService.prepareClouderaManagerCluster(any(), any(), any(), any(), any())).thenReturn(new ArrayList<>());
}
Aggregations