use of com.scaleset.cfbuilder.ec2.instance.ec2blockdevicemapping.EC2EBSBlockDevice in project TOSCAna by StuPro-TOSCAna.
the class CapabilityMapper method mapDiskSize.
/**
* Maps the disk_size property of a ComputeCapability to an EC2 Instance.
*
* @param computeCapability Capability containing the disk_size property
* @param cfnModule Module containing the Instance
* @param nodeName name of the Instance
*/
public void mapDiskSize(ComputeCapability computeCapability, CloudFormationModule cfnModule, String nodeName) {
// If disk_size is not set, default to 8000 Mb
Integer diskSizeInMb = computeCapability.getDiskSizeInMb().orElse(8000);
// Convert disk_size to Gb
Integer diskSizeInGb = diskSizeInMb / 1000;
logger.debug("Check diskSize: '{}' Gb", diskSizeInGb);
if (diskSizeInGb < 8) {
logger.warn("Disk size of '{}' smaller than the minimum value required by EC2 Instances. Setting the disk size of '{}' to the minimum allowed value of 8 Gb.", nodeName, nodeName);
diskSizeInGb = 8;
}
// Add BlockDeviceMapping if needed
if (diskSizeInGb > 8) {
logger.debug("Disk size of '{}' bigger than the default value of EC2 Instances. Adding a BlockDeviceMapping to '{}'.", nodeName, nodeName);
Instance computeAsInstance = (Instance) cfnModule.getResource(nodeName);
computeAsInstance.blockDeviceMappings(new EC2BlockDeviceMapping().deviceName("/dev/sda1").ebs(new EC2EBSBlockDevice().volumeSize(diskSizeInGb.toString())));
}
}
Aggregations