Search in sources :

Example 1 with InstanceGroupType

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.");
        }
    }
}
Also used : InstanceGroupType(com.sequenceiq.common.api.type.InstanceGroupType) VolumeTemplate(com.sequenceiq.cloudbreak.domain.VolumeTemplate) BadRequestException(com.sequenceiq.cloudbreak.common.exception.BadRequestException)

Example 2 with InstanceGroupType

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;
}
Also used : InstanceGroupType(com.sequenceiq.common.api.type.InstanceGroupType) EnumMap(java.util.EnumMap)

Example 3 with InstanceGroupType

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);
}
Also used : InstanceGroupType(com.sequenceiq.common.api.type.InstanceGroupType) Builder(com.sequenceiq.cloudbreak.cloud.model.CloudResource.Builder) ArgumentMatchers.anyString(org.mockito.ArgumentMatchers.anyString) AuthenticatedContext(com.sequenceiq.cloudbreak.cloud.context.AuthenticatedContext) SecurityRule(com.sequenceiq.cloudbreak.cloud.model.SecurityRule) Operation(com.google.api.services.compute.model.Operation) Security(com.sequenceiq.cloudbreak.cloud.model.Security) Image(com.sequenceiq.cloudbreak.cloud.model.Image) GcpContext(com.sequenceiq.cloudbreak.cloud.gcp.context.GcpContext) Disk(com.google.api.services.compute.model.Disk) InstanceAuthentication(com.sequenceiq.cloudbreak.cloud.model.InstanceAuthentication) PortDefinition(com.sequenceiq.cloudbreak.cloud.model.PortDefinition) CloudCredential(com.sequenceiq.cloudbreak.cloud.model.CloudCredential) CloudContext(com.sequenceiq.cloudbreak.cloud.context.CloudContext) CloudInstance(com.sequenceiq.cloudbreak.cloud.model.CloudInstance) CloudStack(com.sequenceiq.cloudbreak.cloud.model.CloudStack) Volume(com.sequenceiq.cloudbreak.cloud.model.Volume) CloudResource(com.sequenceiq.cloudbreak.cloud.model.CloudResource) Location(com.sequenceiq.cloudbreak.cloud.model.Location) InstanceTemplate(com.sequenceiq.cloudbreak.cloud.model.InstanceTemplate) BeforeEach(org.junit.jupiter.api.BeforeEach)

Example 4 with InstanceGroupType

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);
}
Also used : PortDefinition(com.sequenceiq.cloudbreak.cloud.model.PortDefinition) InstanceGroupType(com.sequenceiq.common.api.type.InstanceGroupType) HashMap(java.util.HashMap) CloudCredential(com.sequenceiq.cloudbreak.cloud.model.CloudCredential) CloudContext(com.sequenceiq.cloudbreak.cloud.context.CloudContext) Builder(com.sequenceiq.cloudbreak.cloud.model.CloudResource.Builder) GcpResourceNameService(com.sequenceiq.cloudbreak.cloud.gcp.service.GcpResourceNameService) SecurityRule(com.sequenceiq.cloudbreak.cloud.model.SecurityRule) ArgumentMatchers.anyString(org.mockito.ArgumentMatchers.anyString) AuthenticatedContext(com.sequenceiq.cloudbreak.cloud.context.AuthenticatedContext) Operation(com.google.api.services.compute.model.Operation) Security(com.sequenceiq.cloudbreak.cloud.model.Security) Image(com.sequenceiq.cloudbreak.cloud.model.Image) CloudStack(com.sequenceiq.cloudbreak.cloud.model.CloudStack) GcpContext(com.sequenceiq.cloudbreak.cloud.gcp.context.GcpContext) Volume(com.sequenceiq.cloudbreak.cloud.model.Volume) GroupNetwork(com.sequenceiq.cloudbreak.cloud.model.GroupNetwork) Network(com.sequenceiq.cloudbreak.cloud.model.Network) CloudResource(com.sequenceiq.cloudbreak.cloud.model.CloudResource) Location(com.sequenceiq.cloudbreak.cloud.model.Location) Before(org.junit.Before)

Example 5 with InstanceGroupType

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<>());
}
Also used : User(com.sequenceiq.cloudbreak.workspace.model.User) 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) ImageBasedDefaultCDHInfo(com.sequenceiq.cloudbreak.cloud.model.component.ImageBasedDefaultCDHInfo) DefaultCDHInfo(com.sequenceiq.cloudbreak.cloud.model.component.DefaultCDHInfo) RepoTestUtil.getDefaultCDHInfo(com.sequenceiq.cloudbreak.RepoTestUtil.getDefaultCDHInfo) Component(com.sequenceiq.cloudbreak.domain.stack.Component) StackMatrixV4Response(com.sequenceiq.cloudbreak.api.endpoint.v4.util.responses.StackMatrixV4Response) Workspace(com.sequenceiq.cloudbreak.workspace.model.Workspace) Before(org.junit.Before)

Aggregations

InstanceGroupType (com.sequenceiq.common.api.type.InstanceGroupType)31 Image (com.sequenceiq.cloudbreak.cloud.model.Image)17 CloudStack (com.sequenceiq.cloudbreak.cloud.model.CloudStack)10 HashMap (java.util.HashMap)10 Test (org.junit.Test)9 ArgumentMatchers.anyString (org.mockito.ArgumentMatchers.anyString)9 CloudInstance (com.sequenceiq.cloudbreak.cloud.model.CloudInstance)8 Network (com.sequenceiq.cloudbreak.cloud.model.Network)8 Security (com.sequenceiq.cloudbreak.cloud.model.Security)8 BeforeEach (org.junit.jupiter.api.BeforeEach)8 CcmConnectivityParameters (com.sequenceiq.cloudbreak.ccm.cloudinit.CcmConnectivityParameters)7 InstanceAuthentication (com.sequenceiq.cloudbreak.cloud.model.InstanceAuthentication)7 Group (com.sequenceiq.cloudbreak.cloud.model.Group)6 CloudResource (com.sequenceiq.cloudbreak.cloud.model.CloudResource)5 Json (com.sequenceiq.cloudbreak.common.json.Json)5 GroupNetwork (com.sequenceiq.cloudbreak.cloud.model.GroupNetwork)4 InstanceTemplate (com.sequenceiq.cloudbreak.cloud.model.InstanceTemplate)4 PortDefinition (com.sequenceiq.cloudbreak.cloud.model.PortDefinition)4 SecurityRule (com.sequenceiq.cloudbreak.cloud.model.SecurityRule)4 Volume (com.sequenceiq.cloudbreak.cloud.model.Volume)4