use of com.sequenceiq.cloudbreak.cloud.azure.view.AzureSecurityView in project cloudbreak by hortonworks.
the class AzureTemplateBuilder method build.
public String build(String stackName, String customImageId, AzureCredentialView armCredentialView, AzureStackView armStack, CloudContext cloudContext, CloudStack cloudStack) {
try {
String imageUrl = cloudStack.getImage().getImageName();
String imageName = imageUrl.substring(imageUrl.lastIndexOf('/') + 1);
Network network = cloudStack.getNetwork();
Map<String, Object> model = new HashMap<>();
AzureInstanceCredentialView azureInstanceCredentialView = new AzureInstanceCredentialView(cloudStack);
model.put("credential", azureInstanceCredentialView);
String rootDiskStorage = azureStorage.getImageStorageName(armCredentialView, cloudContext, cloudStack);
AzureSecurityView armSecurityView = new AzureSecurityView(cloudStack.getGroups());
// needed for pre 1.16.5 templates
model.put("existingSubnetName", azureUtils.getCustomSubnetIds(network).stream().findFirst().orElse(""));
model.put("customImageId", customImageId);
model.put("storage_account_name", rootDiskStorage);
model.put("image_storage_container_name", AzureStorage.IMAGES_CONTAINER);
model.put("storage_container_name", azureStorage.getDiskContainerName(cloudContext));
model.put("storage_vhd_name", imageName);
model.put("stackname", stackName);
model.put("region", cloudContext.getLocation().getRegion().value());
model.put("subnet1Prefix", network.getSubnet().getCidr());
model.put("groups", armStack.getGroups());
model.put("igs", armStack.getInstanceGroups());
model.put("securities", armSecurityView.getPorts());
model.put("securityGroups", armSecurityView.getSecurityGroupIds());
model.put("corecustomData", base64EncodedUserData(cloudStack.getImage().getUserDataByType(InstanceGroupType.CORE)));
model.put("gatewaycustomData", base64EncodedUserData(cloudStack.getImage().getUserDataByType(InstanceGroupType.GATEWAY)));
model.put("disablePasswordAuthentication", !azureInstanceCredentialView.passwordAuthenticationRequired());
model.put("existingVPC", azureUtils.isExistingNetwork(network));
model.put("resourceGroupName", azureUtils.getCustomResourceGroupName(network));
model.put("existingVNETName", azureUtils.getCustomNetworkId(network));
model.put("noPublicIp", azureUtils.isPrivateIp(network));
model.put("noFirewallRules", azureUtils.isNoSecurityGroups(network));
model.put("userDefinedTags", cloudStack.getTags());
model.putAll(defaultCostTaggingService.prepareAllTagsForTemplate());
String generatedTemplate = processTemplateIntoString(getTemplate(cloudStack), model);
LOGGER.debug("Generated Arm template: {}", generatedTemplate);
return generatedTemplate;
} catch (IOException | TemplateException e) {
throw new CloudConnectorException("Failed to process the Arm TemplateBuilder", e);
}
}
Aggregations