in cli/src/pcluster/config/cluster_config.py [0:0]
def _register_storage_validators(self): # noqa: C901 FIXME: function too complex
if self.shared_storage:
ebs_count = 0
new_storage_count = defaultdict(int)
existing_storage_count = defaultdict(int)
self._cache_describe_volume()
self._register_validator(
DuplicateNameValidator,
name_list=[storage.name for storage in self.shared_storage],
resource_name="Shared Storage",
)
self._register_validator(
DuplicateNameValidator,
name_list=self.existing_storage_id_list,
resource_name="Shared Storage IDs",
)
existing_fsx = set()
for storage in self.shared_storage:
self._register_validator(SharedStorageNameValidator, name=storage.name)
self._register_validator(SharedStorageMountDirValidator, mount_dir=storage.mount_dir)
if isinstance(storage, SharedFsxLustre):
if storage.file_system_id:
existing_storage_count["fsx"] += 1
existing_fsx.add(storage.file_system_id)
else:
new_storage_count["fsx"] += 1
self._register_validator(FeatureRegionValidator, feature=Feature.FSX_LUSTRE, region=self.region)
self._register_validator(
FsxArchitectureOsValidator, architecture=self.head_node.architecture, os=self.image.os
)
elif isinstance(storage, ExistingFsxOpenZfs):
existing_storage_count["fsx"] += 1
existing_fsx.add(storage.file_system_id)
self._register_validator(FeatureRegionValidator, feature=Feature.FSX_OPENZFS, region=self.region)
elif isinstance(storage, ExistingFsxOntap):
existing_storage_count["fsx"] += 1
existing_fsx.add(storage.file_system_id)
self._register_validator(FeatureRegionValidator, feature=Feature.FSX_ONTAP, region=self.region)
elif isinstance(storage, ExistingFileCache):
existing_storage_count["fsx"] += 1
existing_fsx.add(storage.file_cache_id)
self._register_validator(FeatureRegionValidator, feature=Feature.FILE_CACHE, region=self.region)
elif isinstance(storage, SharedEbs):
if storage.raid:
new_storage_count["raid"] += 1
else:
ebs_count += 1
elif isinstance(storage, SharedEfs):
if storage.file_system_id:
existing_storage_count["efs"] += 1
self._register_validator(
EfsIdValidator,
efs_id=storage.file_system_id,
avail_zones_mapping=self.availability_zones_subnets_mapping,
security_groups_by_nodes=self.security_groups_by_nodes,
)
else:
new_storage_count["efs"] += 1
self._register_validator(
ExistingFsxNetworkingValidator,
file_storage_ids=list(existing_fsx),
subnet_ids=[self.head_node.networking.subnet_id] + self.compute_subnet_ids,
security_groups_by_nodes=self.security_groups_by_nodes,
)
self._validate_max_storage_count(ebs_count, existing_storage_count, new_storage_count)
self._validate_new_storage_multiple_subnets(
self.scheduling.queues, self.compute_subnet_ids, new_storage_count
)
self._validate_mount_dirs()