Skip to content

Commit d05ec0d

Browse files
committed
Fix problem when IP or AIC directory already exists when transferIP
1 parent c5782d1 commit d05ec0d

1 file changed

Lines changed: 14 additions & 6 deletions

File tree

ESSArch_TA/lib/app_tools.py

Lines changed: 14 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1003,7 +1003,7 @@ def transferIP( agent, contextdata ):
10031003
else:
10041004
status_code = 201
10051005
error_list.append('Package description file %s does not exist' % pspec_filepath)
1006-
return 1, status_code, error_list
1006+
return None, status_code, error_list
10071007

10081008
# get ip_uuid
10091009
if context["ip_uuid"][:5] == 'UUID:' or context["ip_uuid"][:5] == 'RAID:' :
@@ -1031,11 +1031,19 @@ def transferIP( agent, contextdata ):
10311031
aic_uuid = str(uuid.uuid4())
10321032

10331033
if not remote_flag:
1034-
# create AIC_UUID directory
1035-
aic_rootpath = createAICdirectory(path_gate_reception, aic_uuid)
1036-
1037-
# create IP_UUID directory
1038-
ip_rootpath = createIPdirectory(aic_rootpath, ip_uuid)
1034+
try:
1035+
# create AIC_UUID directory
1036+
aic_rootpath = createAICdirectory(path_gate_reception, aic_uuid)
1037+
1038+
# create IP_UUID directory
1039+
ip_rootpath = createIPdirectory(aic_rootpath, ip_uuid)
1040+
except OSError as e:
1041+
status_code = 99
1042+
if e.errno == 17:
1043+
error_list.append('AIC or IP directory %s already exists for ip_uuid: %s' % (e.filename, ip_uuid))
1044+
else:
1045+
error_list.append('Problem to create AIC or IP directory for ip_uuid: %s, error: %s' % (ip_uuid, repr(e)))
1046+
return None, status_code, error_list
10391047

10401048
# copy specfile from source to destination
10411049
dst_psspec_filepath = os.path.join(aic_rootpath, package_descriptionfile)

0 commit comments

Comments
 (0)