Search in sources :

Example 6 with FreeMarkerConfigurationFactoryBean

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());
}
Also used : Group(com.sequenceiq.cloudbreak.cloud.model.Group) InstanceAuthentication(com.sequenceiq.cloudbreak.cloud.model.InstanceAuthentication) FreeMarkerConfigurationFactoryBean(org.springframework.ui.freemarker.FreeMarkerConfigurationFactoryBean) CloudEfsConfiguration(com.sequenceiq.cloudbreak.cloud.model.filesystem.efs.CloudEfsConfiguration) Configuration(freemarker.template.Configuration) InstanceGroupType(com.sequenceiq.common.api.type.InstanceGroupType) HashMap(java.util.HashMap) CloudInstance(com.sequenceiq.cloudbreak.cloud.model.CloudInstance) Matchers.containsString(org.hamcrest.Matchers.containsString) Security(com.sequenceiq.cloudbreak.cloud.model.Security) Image(com.sequenceiq.cloudbreak.cloud.model.Image) AwsInstanceTemplate(com.sequenceiq.cloudbreak.cloud.model.instance.AwsInstanceTemplate) InstanceTemplate(com.sequenceiq.cloudbreak.cloud.model.InstanceTemplate) BeforeEach(org.junit.jupiter.api.BeforeEach)

Example 7 with FreeMarkerConfigurationFactoryBean

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");
}
Also used : FreeMarkerConfigurationFactoryBean(org.springframework.ui.freemarker.FreeMarkerConfigurationFactoryBean) Before(org.junit.Before)

Example 8 with FreeMarkerConfigurationFactoryBean

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();
}
Also used : FreeMarkerConfigurationFactoryBean(org.springframework.ui.freemarker.FreeMarkerConfigurationFactoryBean) BeforeEach(org.junit.jupiter.api.BeforeEach)

Example 9 with FreeMarkerConfigurationFactoryBean

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();
}
Also used : InstanceAuthentication(com.sequenceiq.cloudbreak.cloud.model.InstanceAuthentication) PortDefinition(com.sequenceiq.cloudbreak.cloud.model.PortDefinition) FreeMarkerConfigurationFactoryBean(org.springframework.ui.freemarker.FreeMarkerConfigurationFactoryBean) Configuration(freemarker.template.Configuration) InstanceGroupType(com.sequenceiq.common.api.type.InstanceGroupType) HashMap(java.util.HashMap) CloudInstance(com.sequenceiq.cloudbreak.cloud.model.CloudInstance) AvailabilityZone(com.sequenceiq.cloudbreak.cloud.model.AvailabilityZone) ArgumentMatchers.anyString(org.mockito.ArgumentMatchers.anyString) SecurityRule(com.sequenceiq.cloudbreak.cloud.model.SecurityRule) Security(com.sequenceiq.cloudbreak.cloud.model.Security) Image(com.sequenceiq.cloudbreak.cloud.model.Image) AzureMarketplaceImage(com.sequenceiq.cloudbreak.cloud.azure.image.marketplace.AzureMarketplaceImage) AzureStorageView(com.sequenceiq.cloudbreak.cloud.azure.view.AzureStorageView) AzureCredentialView(com.sequenceiq.cloudbreak.cloud.azure.view.AzureCredentialView) Volume(com.sequenceiq.cloudbreak.cloud.model.Volume) InstanceTemplate(com.sequenceiq.cloudbreak.cloud.model.InstanceTemplate) AzureInstanceTemplate(com.sequenceiq.cloudbreak.cloud.model.instance.AzureInstanceTemplate) BeforeEach(org.junit.jupiter.api.BeforeEach)

Example 10 with FreeMarkerConfigurationFactoryBean

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);
}
Also used : FreeMarkerConfigurationFactoryBean(org.springframework.ui.freemarker.FreeMarkerConfigurationFactoryBean) Configuration(freemarker.template.Configuration) Before(org.junit.Before)

Aggregations

FreeMarkerConfigurationFactoryBean (org.springframework.ui.freemarker.FreeMarkerConfigurationFactoryBean)21 Configuration (freemarker.template.Configuration)8 BeforeEach (org.junit.jupiter.api.BeforeEach)6 Bean (org.springframework.context.annotation.Bean)6 Before (org.junit.Before)5 HashMap (java.util.HashMap)4 CloudInstance (com.sequenceiq.cloudbreak.cloud.model.CloudInstance)3 Image (com.sequenceiq.cloudbreak.cloud.model.Image)3 InstanceAuthentication (com.sequenceiq.cloudbreak.cloud.model.InstanceAuthentication)3 InstanceTemplate (com.sequenceiq.cloudbreak.cloud.model.InstanceTemplate)3 Security (com.sequenceiq.cloudbreak.cloud.model.Security)3 Properties (java.util.Properties)3 Test (org.junit.Test)3 Group (com.sequenceiq.cloudbreak.cloud.model.Group)2 PortDefinition (com.sequenceiq.cloudbreak.cloud.model.PortDefinition)2 SecurityRule (com.sequenceiq.cloudbreak.cloud.model.SecurityRule)2 Volume (com.sequenceiq.cloudbreak.cloud.model.Volume)2 InstanceGroupType (com.sequenceiq.common.api.type.InstanceGroupType)2 Matchers.containsString (org.hamcrest.Matchers.containsString)2 FileSystemResource (org.springframework.core.io.FileSystemResource)2