in cli/src/pcluster/templates/cluster_stack.py [0:0]
def _add_fsx_storage(self, id: str, shared_fsx: SharedFsx):
"""Add specific Cfn Resources to map the FSX storage."""
fsx_id = shared_fsx.file_system_id
# Initialize DNSName and MountName for existing filesystem, if any
self.shared_storage_attributes[shared_fsx.shared_storage_type]["MountName"] = shared_fsx.existing_mount_name
self.shared_storage_attributes[shared_fsx.shared_storage_type]["DNSName"] = shared_fsx.existing_dns_name
if not fsx_id and shared_fsx.mount_dir:
# Drive cache type must be set for HDD (Either "NONE" or "READ"), and must not be set for SDD (None).
drive_cache_type = None
if shared_fsx.fsx_storage_type == "HDD":
if shared_fsx.drive_cache_type:
drive_cache_type = shared_fsx.drive_cache_type
else:
drive_cache_type = "NONE"
fsx_resource = fsx.CfnFileSystem(
self,
id,
storage_capacity=shared_fsx.storage_capacity,
lustre_configuration=fsx.CfnFileSystem.LustreConfigurationProperty(
deployment_type=shared_fsx.deployment_type,
data_compression_type=shared_fsx.data_compression_type,
imported_file_chunk_size=shared_fsx.imported_file_chunk_size,
export_path=shared_fsx.export_path,
import_path=shared_fsx.import_path,
weekly_maintenance_start_time=shared_fsx.weekly_maintenance_start_time,
automatic_backup_retention_days=shared_fsx.automatic_backup_retention_days,
copy_tags_to_backups=shared_fsx.copy_tags_to_backups,
daily_automatic_backup_start_time=shared_fsx.daily_automatic_backup_start_time,
per_unit_storage_throughput=shared_fsx.per_unit_storage_throughput,
auto_import_policy=shared_fsx.auto_import_policy,
drive_cache_type=drive_cache_type,
),
backup_id=shared_fsx.backup_id,
kms_key_id=shared_fsx.kms_key_id,
file_system_type="LUSTRE",
storage_type=shared_fsx.fsx_storage_type,
subnet_ids=self.config.compute_subnet_ids,
security_group_ids=self._get_compute_security_groups(),
tags=[CfnTag(key="Name", value=shared_fsx.name)],
)
fsx_id = fsx_resource.ref
# Get MountName for new filesystem
# DNSName cannot be retrieved from CFN and will be generated in cookbook
self.shared_storage_attributes[shared_fsx.shared_storage_type][
"MountName"
] = fsx_resource.attr_lustre_mount_name
# [shared_dir,fsx_fs_id,storage_capacity,fsx_kms_key_id,imported_file_chunk_size,
# export_path,import_path,weekly_maintenance_start_time,deployment_type,
# per_unit_storage_throughput,daily_automatic_backup_start_time,
# automatic_backup_retention_days,copy_tags_to_backups,fsx_backup_id,
# auto_import_policy,storage_type,drive_cache_type,existing_mount_name,existing_dns_name]",
self.shared_storage_options[shared_fsx.shared_storage_type] = ",".join(
str(item)
for item in [
shared_fsx.mount_dir,
fsx_id,
shared_fsx.storage_capacity or "NONE",
shared_fsx.kms_key_id or "NONE",
shared_fsx.imported_file_chunk_size or "NONE",
shared_fsx.export_path or "NONE",
shared_fsx.import_path or "NONE",
shared_fsx.weekly_maintenance_start_time or "NONE",
shared_fsx.deployment_type or "NONE",
shared_fsx.per_unit_storage_throughput or "NONE",
shared_fsx.daily_automatic_backup_start_time or "NONE",
shared_fsx.automatic_backup_retention_days or "NONE",
shared_fsx.copy_tags_to_backups if shared_fsx.copy_tags_to_backups is not None else "NONE",
shared_fsx.backup_id or "NONE",
shared_fsx.auto_import_policy or "NONE",
shared_fsx.fsx_storage_type or "NONE",
shared_fsx.drive_cache_type or "NONE",
shared_fsx.existing_mount_name,
shared_fsx.existing_dns_name,
]
)
return fsx_id