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) + '"'));
}
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")));
}
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')]"));
}
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"));
}
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());
}
Aggregations