Search in sources :

Example 21 with Group

use of com.sequenceiq.cloudbreak.cloud.model.Group in project cloudbreak by hortonworks.

the class AzureTemplateBuilderTest method buildWithInstanceGroupTypeGatewayAndCore.

@Test
public void buildWithInstanceGroupTypeGatewayAndCore() throws Exception {
    // GIVEN
    Network network = new Network(new Subnet("testSubnet"));
    Map<String, String> parameters = new HashMap<>();
    parameters.put("persistentStorage", "persistentStorageTest");
    parameters.put("attachedStorageOption", "attachedStorageOptionTest");
    InstanceAuthentication instanceAuthentication = new InstanceAuthentication("sshkey", "", "cloudbreak");
    groups.add(new Group(name, InstanceGroupType.GATEWAY, Collections.singletonList(instance), security, null, instanceAuthentication, instanceAuthentication.getLoginUserName(), instanceAuthentication.getPublicKey()));
    groups.add(new Group(name, InstanceGroupType.CORE, Collections.singletonList(instance), security, null, instanceAuthentication, instanceAuthentication.getLoginUserName(), instanceAuthentication.getPublicKey()));
    cloudStack = new CloudStack(groups, network, image, parameters, tags, azureTemplateBuilder.getTemplateString(), instanceAuthentication, instanceAuthentication.getLoginUserName(), instanceAuthentication.getPublicKey());
    azureStackView = new AzureStackView("mystack", 3, groups, azureStorageView, azureSubnetStrategy);
    // WHEN
    when(defaultCostTaggingService.prepareAllTagsForTemplate()).thenReturn(defaultTags);
    when(azureStorage.getImageStorageName(any(AzureCredentialView.class), any(CloudContext.class), any(CloudStack.class))).thenReturn("test");
    when(azureStorage.getDiskContainerName(any(CloudContext.class))).thenReturn("testStorageContainer");
    String templateString = azureTemplateBuilder.build(stackName, CUSTOM_IMAGE_NAME, azureCredentialView, azureStackView, cloudContext, cloudStack);
    // THEN
    gson.fromJson(templateString, Map.class);
    assertThat(templateString, containsString("\"customData\": \"" + base64EncodedUserData(CORE_CUSTOM_DATA) + '"'));
    assertThat(templateString, containsString("\"customData\": \"" + base64EncodedUserData(GATEWAY_CUSTOM_DATA) + '"'));
}
Also used : Group(com.sequenceiq.cloudbreak.cloud.model.Group) AzureCredentialView(com.sequenceiq.cloudbreak.cloud.azure.view.AzureCredentialView) InstanceAuthentication(com.sequenceiq.cloudbreak.cloud.model.InstanceAuthentication) HashMap(java.util.HashMap) Network(com.sequenceiq.cloudbreak.cloud.model.Network) CloudContext(com.sequenceiq.cloudbreak.cloud.context.CloudContext) AzureStackView(com.sequenceiq.cloudbreak.cloud.azure.view.AzureStackView) Matchers.containsString(org.hamcrest.Matchers.containsString) Subnet(com.sequenceiq.cloudbreak.cloud.model.Subnet) CloudStack(com.sequenceiq.cloudbreak.cloud.model.CloudStack) Test(org.junit.Test)

Example 22 with Group

use of com.sequenceiq.cloudbreak.cloud.model.Group in project cloudbreak by hortonworks.

the class AzureTemplateBuilderTest method buildTestExistingSubnetNameNotInTemplate.

@Test
public void buildTestExistingSubnetNameNotInTemplate() {
    // GIVEN
    Network network = new Network(new Subnet("testSubnet"));
    Map<String, String> parameters = new HashMap<>();
    parameters.put("persistentStorage", "persistentStorageTest");
    parameters.put("attachedStorageOption", "attachedStorageOptionTest");
    InstanceAuthentication instanceAuthentication = new InstanceAuthentication("sshkey", "", "cloudbreak");
    groups.add(new Group(name, InstanceGroupType.GATEWAY, Collections.singletonList(instance), security, null, instanceAuthentication, instanceAuthentication.getLoginUserName(), instanceAuthentication.getPublicKey()));
    groups.add(new Group(name, InstanceGroupType.CORE, Collections.singletonList(instance), security, null, instanceAuthentication, instanceAuthentication.getLoginUserName(), instanceAuthentication.getPublicKey()));
    cloudStack = new CloudStack(groups, network, image, parameters, tags, azureTemplateBuilder.getTemplateString(), instanceAuthentication, instanceAuthentication.getLoginUserName(), instanceAuthentication.getPublicKey());
    azureStackView = new AzureStackView("mystack", 3, groups, azureStorageView, azureSubnetStrategy);
    // WHEN
    when(defaultCostTaggingService.prepareAllTagsForTemplate()).thenReturn(defaultTags);
    when(azureStorage.getImageStorageName(any(AzureCredentialView.class), any(CloudContext.class), any(CloudStack.class))).thenReturn("test");
    when(azureStorage.getDiskContainerName(any(CloudContext.class))).thenReturn("testStorageContainer");
    String templateString = azureTemplateBuilder.build(stackName, CUSTOM_IMAGE_NAME, azureCredentialView, azureStackView, cloudContext, cloudStack);
    // THEN
    gson.fromJson(templateString, Map.class);
    assertThat(templateString, not(containsString("existingSubnetName")));
}
Also used : Group(com.sequenceiq.cloudbreak.cloud.model.Group) AzureCredentialView(com.sequenceiq.cloudbreak.cloud.azure.view.AzureCredentialView) InstanceAuthentication(com.sequenceiq.cloudbreak.cloud.model.InstanceAuthentication) HashMap(java.util.HashMap) Network(com.sequenceiq.cloudbreak.cloud.model.Network) CloudContext(com.sequenceiq.cloudbreak.cloud.context.CloudContext) AzureStackView(com.sequenceiq.cloudbreak.cloud.azure.view.AzureStackView) Matchers.containsString(org.hamcrest.Matchers.containsString) Subnet(com.sequenceiq.cloudbreak.cloud.model.Subnet) CloudStack(com.sequenceiq.cloudbreak.cloud.model.CloudStack) Test(org.junit.Test)

Example 23 with Group

use of com.sequenceiq.cloudbreak.cloud.model.Group in project cloudbreak by hortonworks.

the class AzureTemplateBuilderTest method buildTestDataDisks.

@Test
public void buildTestDataDisks() {
    // GIVEN
    Network network = new Network(new Subnet("testSubnet"));
    Map<String, String> parameters = new HashMap<>();
    parameters.put("persistentStorage", "persistentStorageTest");
    parameters.put("attachedStorageOption", "attachedStorageOptionTest");
    InstanceAuthentication instanceAuthentication = new InstanceAuthentication("sshkey", "", "cloudbreak");
    groups.add(new Group(name, InstanceGroupType.GATEWAY, Collections.singletonList(instance), security, null, instanceAuthentication, instanceAuthentication.getLoginUserName(), instanceAuthentication.getPublicKey()));
    groups.add(new Group(name, InstanceGroupType.CORE, Collections.singletonList(instance), security, null, instanceAuthentication, instanceAuthentication.getLoginUserName(), instanceAuthentication.getPublicKey()));
    cloudStack = new CloudStack(groups, network, image, parameters, tags, azureTemplateBuilder.getTemplateString(), instanceAuthentication, instanceAuthentication.getLoginUserName(), instanceAuthentication.getPublicKey());
    azureStackView = new AzureStackView("mystack", 3, groups, azureStorageView, azureSubnetStrategy);
    // WHEN
    when(defaultCostTaggingService.prepareAllTagsForTemplate()).thenReturn(defaultTags);
    when(azureStorage.getImageStorageName(any(AzureCredentialView.class), any(CloudContext.class), any(CloudStack.class))).thenReturn("test");
    when(azureStorage.getDiskContainerName(any(CloudContext.class))).thenReturn("testStorageContainer");
    String templateString = azureTemplateBuilder.build(stackName, CUSTOM_IMAGE_NAME, azureCredentialView, azureStackView, cloudContext, cloudStack);
    // THEN
    gson.fromJson(templateString, Map.class);
    assertThat(templateString, containsString("[concat('datadisk', 'm0', '0')]"));
    assertThat(templateString, containsString("[concat('datadisk', 'm0', '1')]"));
}
Also used : Group(com.sequenceiq.cloudbreak.cloud.model.Group) AzureCredentialView(com.sequenceiq.cloudbreak.cloud.azure.view.AzureCredentialView) InstanceAuthentication(com.sequenceiq.cloudbreak.cloud.model.InstanceAuthentication) HashMap(java.util.HashMap) Network(com.sequenceiq.cloudbreak.cloud.model.Network) CloudContext(com.sequenceiq.cloudbreak.cloud.context.CloudContext) AzureStackView(com.sequenceiq.cloudbreak.cloud.azure.view.AzureStackView) Matchers.containsString(org.hamcrest.Matchers.containsString) Subnet(com.sequenceiq.cloudbreak.cloud.model.Subnet) CloudStack(com.sequenceiq.cloudbreak.cloud.model.CloudStack) Test(org.junit.Test)

Example 24 with Group

use of com.sequenceiq.cloudbreak.cloud.model.Group in project cloudbreak by hortonworks.

the class AzureTemplateBuilderTest method buildWithPublicIpAndFirewall.

@Test
public void buildWithPublicIpAndFirewall() {
    // GIVEN
    Network network = new Network(new Subnet("testSubnet"));
    when(azureUtils.isPrivateIp(any())).then(invocation -> false);
    when(azureUtils.isNoSecurityGroups(any())).then(invocation -> false);
    when(defaultCostTaggingService.prepareAllTagsForTemplate()).thenReturn(defaultTags);
    Map<String, String> parameters = new HashMap<>();
    parameters.put("persistentStorage", "persistentStorageTest");
    parameters.put("attachedStorageOption", "attachedStorageOptionTest");
    InstanceAuthentication instanceAuthentication = new InstanceAuthentication("sshkey", "", "cloudbreak");
    groups.add(new Group(name, InstanceGroupType.CORE, Collections.singletonList(instance), security, null, instanceAuthentication, instanceAuthentication.getLoginUserName(), instanceAuthentication.getPublicKey()));
    cloudStack = new CloudStack(groups, network, image, parameters, tags, azureTemplateBuilder.getTemplateString(), instanceAuthentication, instanceAuthentication.getLoginUserName(), instanceAuthentication.getPublicKey());
    azureStackView = new AzureStackView("mystack", 3, groups, azureStorageView, azureSubnetStrategy);
    // WHEN
    when(azureStorage.getImageStorageName(any(AzureCredentialView.class), any(CloudContext.class), any(CloudStack.class))).thenReturn("test");
    when(azureStorage.getDiskContainerName(any(CloudContext.class))).thenReturn("testStorageContainer");
    String templateString = azureTemplateBuilder.build(stackName, CUSTOM_IMAGE_NAME, azureCredentialView, azureStackView, cloudContext, cloudStack);
    // THEN
    gson.fromJson(templateString, Map.class);
    assertThat(templateString, containsString("publicIPAddress"));
    assertThat(templateString, containsString("networkSecurityGroups"));
}
Also used : Group(com.sequenceiq.cloudbreak.cloud.model.Group) AzureCredentialView(com.sequenceiq.cloudbreak.cloud.azure.view.AzureCredentialView) InstanceAuthentication(com.sequenceiq.cloudbreak.cloud.model.InstanceAuthentication) HashMap(java.util.HashMap) Network(com.sequenceiq.cloudbreak.cloud.model.Network) CloudContext(com.sequenceiq.cloudbreak.cloud.context.CloudContext) AzureStackView(com.sequenceiq.cloudbreak.cloud.azure.view.AzureStackView) Matchers.containsString(org.hamcrest.Matchers.containsString) Subnet(com.sequenceiq.cloudbreak.cloud.model.Subnet) CloudStack(com.sequenceiq.cloudbreak.cloud.model.CloudStack) Test(org.junit.Test)

Example 25 with Group

use of com.sequenceiq.cloudbreak.cloud.model.Group in project cloudbreak by hortonworks.

the class GcpInstanceResourceBuilderTest method newGroupWithParams.

public Group newGroupWithParams(Map<String, Object> params) {
    InstanceTemplate instanceTemplate = new InstanceTemplate(flavor, name, privateId, volumes, InstanceStatus.CREATE_REQUESTED, params, 0L);
    InstanceAuthentication instanceAuthentication = new InstanceAuthentication("sshkey", "", "cloudbreak");
    CloudInstance cloudInstance = new CloudInstance(instanceId, instanceTemplate, instanceAuthentication);
    return new Group(name, InstanceGroupType.CORE, Collections.singletonList(cloudInstance), security, null, instanceAuthentication, instanceAuthentication.getLoginUserName(), instanceAuthentication.getPublicKey());
}
Also used : Group(com.sequenceiq.cloudbreak.cloud.model.Group) InstanceAuthentication(com.sequenceiq.cloudbreak.cloud.model.InstanceAuthentication) CloudInstance(com.sequenceiq.cloudbreak.cloud.model.CloudInstance) InstanceTemplate(com.sequenceiq.cloudbreak.cloud.model.InstanceTemplate)

Aggregations

Group (com.sequenceiq.cloudbreak.cloud.model.Group)62 InstanceAuthentication (com.sequenceiq.cloudbreak.cloud.model.InstanceAuthentication)37 CloudStack (com.sequenceiq.cloudbreak.cloud.model.CloudStack)36 Test (org.junit.Test)36 Network (com.sequenceiq.cloudbreak.cloud.model.Network)35 HashMap (java.util.HashMap)35 CloudContext (com.sequenceiq.cloudbreak.cloud.context.CloudContext)33 Subnet (com.sequenceiq.cloudbreak.cloud.model.Subnet)33 Matchers.containsString (org.hamcrest.Matchers.containsString)20 AzureCredentialView (com.sequenceiq.cloudbreak.cloud.azure.view.AzureCredentialView)17 AzureStackView (com.sequenceiq.cloudbreak.cloud.azure.view.AzureStackView)17 AmazonEC2Client (com.amazonaws.services.ec2.AmazonEC2Client)15 DescribeSubnetsResult (com.amazonaws.services.ec2.model.DescribeSubnetsResult)15 Vpc (com.amazonaws.services.ec2.model.Vpc)15 AuthenticatedContext (com.sequenceiq.cloudbreak.cloud.context.AuthenticatedContext)15 DescribeVpcsResult (com.amazonaws.services.ec2.model.DescribeVpcsResult)14 Location (com.sequenceiq.cloudbreak.cloud.model.Location)14 ArrayList (java.util.ArrayList)14 CloudInstance (com.sequenceiq.cloudbreak.cloud.model.CloudInstance)11 InstanceTemplate (com.sequenceiq.cloudbreak.cloud.model.InstanceTemplate)9