use of org.springframework.ui.freemarker.FreeMarkerConfigurationFactoryBean in project cloudbreak by hortonworks.
the class CloudFormationTemplateBuilderTest method setUp.
@BeforeEach
public void setUp() throws Exception {
FreeMarkerConfigurationFactoryBean factoryBean = new FreeMarkerConfigurationFactoryBean();
factoryBean.setPreferFileSystemAccess(false);
factoryBean.setTemplateLoaderPath("classpath:/");
factoryBean.afterPropertiesSet();
Configuration configuration = factoryBean.getObject();
ReflectionTestUtils.setField(cloudFormationTemplateBuilder, "freemarkerConfiguration", configuration);
when(freeMarkerTemplateUtils.processTemplateIntoString(any(), any())).thenCallRealMethod();
awsCloudFormationTemplate = configuration.getTemplate(LATEST_AWS_CLOUD_FORMATION_TEMPLATE_PATH, "UTF-8").toString();
authenticatedContext = authenticatedContext();
existingSubnetCidr = "testSubnet";
InstanceTemplate instanceTemplate = createDefaultInstanceTemplate();
instanceAuthentication = new InstanceAuthentication("sshkey", "", "cloudbreak");
instance = new CloudInstance("SOME_ID", instanceTemplate, instanceAuthentication, "subnet-1", "az1");
Security security = getDefaultCloudStackSecurity();
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<>());
List<Group> groups = List.of(createDefaultGroup("master", InstanceGroupType.CORE, ROOT_VOLUME_SIZE, security, Optional.empty()), createDefaultGroup("gateway", InstanceGroupType.GATEWAY, ROOT_VOLUME_SIZE, security, Optional.empty()));
cloudStack = createDefaultCloudStack(groups, getDefaultCloudStackParameters(), getDefaultCloudStackTags());
}
use of org.springframework.ui.freemarker.FreeMarkerConfigurationFactoryBean in project cloudbreak by hortonworks.
the class AzureNetworkDnsZoneTemplateBuilderTest method before.
@Before
public void before() throws IOException, TemplateException {
FreeMarkerConfigurationFactoryBean factoryBean = new FreeMarkerConfigurationFactoryBean();
factoryBean.setPreferFileSystemAccess(false);
factoryBean.setTemplateLoaderPath("classpath:/");
factoryBean.afterPropertiesSet();
ReflectionTestUtils.setField(underTest, "freemarkerConfiguration", factoryBean.getObject());
ReflectionTestUtils.setField(underTest, "armTemplatePath", "templates/arm-network-dnszone.ftl");
}
use of org.springframework.ui.freemarker.FreeMarkerConfigurationFactoryBean in project cloudbreak by hortonworks.
the class AzureTemplateBuilderDbTest method setUp.
@BeforeEach
void setUp() throws Exception {
factoryBean = new FreeMarkerConfigurationFactoryBean();
factoryBean.setPreferFileSystemAccess(false);
factoryBean.setTemplateLoaderPath("classpath:/");
factoryBean.afterPropertiesSet();
cloudContext = CloudContext.Builder.builder().withId(STACK_ID).withName(STACK_NAME).withCrn(STACK_CRN).withPlatform(PLATFORM).withVariant(VARIANT).withLocation(Location.location(Region.region(REGION))).withAccountId(ACCOUNT_ID).build();
}
use of org.springframework.ui.freemarker.FreeMarkerConfigurationFactoryBean in project cloudbreak by hortonworks.
the class AzureTemplateBuilderTest method setUp.
@BeforeEach
public void setUp() throws Exception {
FreeMarkerConfigurationFactoryBean factoryBean = new FreeMarkerConfigurationFactoryBean();
factoryBean.setPreferFileSystemAccess(false);
factoryBean.setTemplateLoaderPath("classpath:/");
factoryBean.afterPropertiesSet();
Configuration configuration = factoryBean.getObject();
ReflectionTestUtils.setField(azureTemplateBuilder, "freemarkerConfiguration", configuration);
ReflectionTestUtils.setField(azureTemplateBuilder, "armTemplateParametersPath", "templates/parameters.ftl");
Map<InstanceGroupType, String> userData = ImmutableMap.of(InstanceGroupType.CORE, CORE_CUSTOM_DATA, InstanceGroupType.GATEWAY, GATEWAY_CUSTOM_DATA);
groups = new ArrayList<>();
stackName = "testStack";
name = "master";
List<Volume> volumes = Arrays.asList(new Volume("/hadoop/fs1", "HDD", 1, CloudVolumeUsageType.GENERAL), new Volume("/hadoop/fs2", "HDD", 1, CloudVolumeUsageType.GENERAL));
InstanceTemplate instanceTemplate = new InstanceTemplate("m1.medium", name, 0L, volumes, InstanceStatus.CREATE_REQUESTED, new HashMap<>(), 0L, "cb-centos66-amb200-2015-05-25", TemporaryStorage.ATTACHED_VOLUMES, 0L);
Map<String, Object> params = new HashMap<>();
params.put(NetworkConstants.SUBNET_ID, "existingSubnet");
InstanceAuthentication instanceAuthentication = new InstanceAuthentication("sshkey", "", "cloudbreak");
instance = new CloudInstance("SOME_ID", instanceTemplate, instanceAuthentication, "existingSubnet", "az1", params);
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());
image = new Image("cb-centos66-amb200-2015-05-25", userData, "redhat6", "redhat6", "", "default", "default-id", new HashMap<>());
cloudContext = CloudContext.Builder.builder().withId(7899L).withName("thisisaverylongazureresourcenamewhichneedstobeshortened").withCrn("crn").withPlatform("dummy1").withLocation(Location.location(Region.region("westus2"), new AvailabilityZone("availabilityZone"))).withWorkspaceId(WORKSPACE_ID).build();
azureCredentialView = new AzureCredentialView(cloudCredential());
azureStorageView = new AzureStorageView(azureCredentialView, cloudContext, azureStorage, null);
azureSubnetStrategy = AzureSubnetStrategy.getAzureSubnetStrategy(FILL, Collections.singletonList("existingSubnet"), ImmutableMap.of("existingSubnet", 100L));
when(customVMImageNameProvider.getImageNameFromConnectionString(anyString())).thenCallRealMethod();
}
use of org.springframework.ui.freemarker.FreeMarkerConfigurationFactoryBean in project cloudbreak by hortonworks.
the class UserDataBuilderTest method setup.
@Before
public void setup() throws IOException, TemplateException {
FreeMarkerConfigurationFactoryBean factoryBean = new FreeMarkerConfigurationFactoryBean();
factoryBean.setPreferFileSystemAccess(false);
factoryBean.setTemplateLoaderPath("classpath:/");
factoryBean.afterPropertiesSet();
Configuration configuration = factoryBean.getObject();
underTest.setFreemarkerConfiguration(configuration);
UserDataBuilderParams params = new UserDataBuilderParams();
params.setCustomData("date >> /tmp/time.txt");
ReflectionTestUtils.setField(underTest, "userDataBuilderParams", params);
}
Aggregations