in cookbooks/aws-parallelcluster-environment/files/cfn_hup_configuration/share_compute_fleet_dna.py [0:0]
def write_dna_files(write_files_section, shared_storage_loc):
"""
After extracting dna.json from write_files section of UserData, write it in shared location.
:param write_files_section: Entire write_files section from UserData
:param shared_storage_loc: Shared Storage Location of where to write dna.json
:return: None
"""
try:
file_path = shared_storage_loc + "-dna.json"
for data in write_files_section:
if data["path"] in ["/tmp/dna.json"]: # nosec B108
with open(file_path, "w", encoding="utf-8") as file:
logger.info("Writing %s", file_path)
file.write(json.dumps(json.loads(data["content"]), indent=4))
except Exception as err:
if hasattr(err, "message"):
err = err.message
logger.error("Unable to write %s due to %s", file_path, err)