Skip to content

Commit 86a9416

Browse files
authored
Merge pull request #21 from openmsa/replace_process_content/ydu
Replace process_content by task_xxx
2 parents d0d5d9d + c08c6b8 commit 86a9416

File tree

77 files changed

+371
-779
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

77 files changed

+371
-779
lines changed

ASN_POOL_MGNT/Process_Check_ASN_Id_Availability/Tasks/Task_Check_ASN_id_availability.py

Lines changed: 10 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -10,14 +10,14 @@
1010
context = Variables.task_call(dev_var)
1111

1212
if "asnRangeList" not in context:
13-
MSA_API.task_error('No ASN Pool found',context, True)
13+
MSA_API.task_error('No ASN Pool found', context)
1414

1515
#if len(context['asnRangeList']) != len(context['asnRangeList_backup']):
1616
# context['asnRangeList']=context['asnRangeList_backup']
17-
# MSA_API.task_error('ASN Pool update cannot be done from this process',context, True)
17+
# MSA_API.task_error('ASN Pool update cannot be done from this process', context)
1818

1919
if not context['device_id'] or not context['name']:
20-
MSA_API.task_error('Mandatory parameters required, please edit the ASN pool',context, True)
20+
MSA_API.task_error('Mandatory parameters required, please edit the ASN pool', context)
2121

2222
if not context.get('asnRangeList'):
2323
context['asnRangeList'] = []
@@ -26,13 +26,13 @@
2626
context['asnsInUse'] = []
2727

2828
if not context.get('searchedAsnId'):
29-
MSA_API.task_error('Please enter an ASN Id to search', context, True)
29+
MSA_API.task_error('Please enter an ASN Id to search', context)
3030

3131
searchedAsnId=context['searchedAsnId']
3232

3333
# Check if given ASN Id is not starting with 0 (eg : 01)
3434
if searchedAsnId.startswith('0'):
35-
MSA_API.task_error('ASN Id '+searchedAsnId+" not valid, please retry", context, True)
35+
MSA_API.task_error('ASN Id '+searchedAsnId+" not valid, please retry", context)
3636

3737
SelectedAsnRangeStart=""
3838
SelectedAsnRangeEnd=""
@@ -48,17 +48,17 @@
4848
nbSelected+=1
4949

5050
if nbSelected == 0:
51-
MSA_API.task_error( 'You need to select one of the avaiable pool range ', context, True)
51+
MSA_API.task_error( 'You need to select one of the avaiable pool range ', context)
5252
if nbSelected > 1:
53-
MSA_API.task_error( 'You need to select only one pool range ', context, True)
53+
MSA_API.task_error( 'You need to select only one pool range ', context)
5454

5555
context['SelectedAsnRangeStart']=SelectedAsnRangeStart
5656
context['SelectedAsnRangeEnd']=SelectedAsnRangeEnd
5757

5858

5959
# Check if given ASN Id is include on the range
6060
if int(context['SelectedAsnRangeStart']) > int(searchedAsnId) or int(searchedAsnId) > int(context['SelectedAsnRangeEnd']):
61-
MSA_API.task_error('ASN Id '+searchedAsnId+" not on the available range ("+context['SelectedAsnRangeStart']+" - "+context['SelectedAsnRangeEnd']+")", context, True)
61+
MSA_API.task_error('ASN Id '+searchedAsnId+" not on the available range ("+context['SelectedAsnRangeStart']+" - "+context['SelectedAsnRangeEnd']+")", context)
6262

6363
#Check if the given ASN Id is already allocated
6464
freeAsnId=True
@@ -67,8 +67,6 @@
6767
freeAsnId=False
6868
break
6969
if not freeAsnId:
70-
MSA_API.task_error('ASN Id '+searchedAsnId+' is already in use in Pool range '+context['SelectedAsnRangeStart']+' - '+context['SelectedAsnRangeEnd']+'', context, True)
70+
MSA_API.task_error('ASN Id '+searchedAsnId+' is already in use in Pool range '+context['SelectedAsnRangeStart']+' - '+context['SelectedAsnRangeEnd']+'', context)
7171

72-
73-
ret = MSA_API.process_content('ENDED', 'The ASN Id '+searchedAsnId+' is available in Pool range '+context['SelectedAsnRangeStart']+' - '+context['SelectedAsnRangeEnd']+'', context, True)
74-
print(ret)
72+
MSA_API.task_success('The ASN Id '+searchedAsnId+' is available in Pool range '+context['SelectedAsnRangeStart']+' - '+context['SelectedAsnRangeEnd']+'', context);

ASN_POOL_MGNT/Process_Create_ASN_Pool/Tasks/Task_Create_ASN_Pool.py

Lines changed: 2 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -53,15 +53,6 @@
5353

5454
# check if the response is OK
5555
if order.response.ok:
56-
ret = MSA_API.process_content('ENDED',
57-
f'STATUS: {content["status"]}, \
58-
MESSAGE: successfull',
59-
context, True)
56+
MSA_API.task_success(f'STATUS: {content["status"]}, MESSAGE: successful', context)
6057
else:
61-
ret = MSA_API.process_content('FAILED',
62-
f'Import failed \
63-
- {order.content}',
64-
context, True)
65-
66-
67-
print(ret)
58+
MSA_API.task_error(f'Import failed - {order.content}', context)

ASN_POOL_MGNT/Process_Create_ASN_Pool/Tasks/Task_Get_existing_ASN_Pools.py

Lines changed: 3 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@
1717
context = Variables.task_call(dev_var)
1818

1919
if not context['device_id'] or not context['name'] :
20-
MSA_API.task_error('Mandatory parameters required',context, True)
20+
MSA_API.task_error('Mandatory parameters required', context)
2121

2222
# read the ID of the selected managed entity
2323
device_id = context['device_id']
@@ -49,14 +49,6 @@
4949

5050
# check if the response is OK
5151
if order.response.ok:
52-
ret = MSA_API.process_content('ENDED',
53-
f'STATUS: {content["status"]}, \
54-
MESSAGE: successfull',
55-
context, True)
52+
MSA_API.task_success(f'STATUS: {content["status"]}, MESSAGE: successful', context)
5653
else:
57-
ret = MSA_API.process_content('FAILED',
58-
f'Import failed \
59-
- {order.content}',
60-
context, True)
61-
62-
print(ret)
54+
MSA_API.task_error(f'Import failed - {order.content}', context)

ASN_POOL_MGNT/Process_Create_ASN_Pool/Tasks/Task_Perform_parameters_checks.py

Lines changed: 9 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66

77
#check that at least there is one ASN range pool defined
88
if not context.get('pool'):
9-
MSA_API.task_error('You need to enter at least one ASN range pool',context, True)
9+
MSA_API.task_error('You need to enter at least one ASN range pool', context)
1010

1111
#Get all Pool Ids
1212
extract_asn_pool=[]
@@ -16,27 +16,27 @@
1616

1717
for index in extract_asn_pool:
1818
if context['import_result_asn_pool'][index]['name'] == context['name']:
19-
MSA_API.task_error(''+context['name']+' already exist, please edit your Pool Name',context, True)
19+
MSA_API.task_error(''+context['name']+' already exist, please edit your Pool Name', context)
2020

2121
duplicateRangeCheck=[]
2222

2323
#check the range order
2424
for asnRange in context.get('pool'):
2525
if not asnRange['poolStart'] or not asnRange['poolEnd']:
26-
MSA_API.task_error('Invalid input in your pool list, please check',context, True)
26+
MSA_API.task_error('Invalid input in your pool list, please check', context)
2727
poolStart=int(asnRange['poolStart'])
2828
poolEnd=int(asnRange['poolEnd'])
2929
duplicateRangeCheck.append(''+str(poolStart)+'-'+str(poolEnd)+'')
3030

3131
if poolStart >= poolEnd:
32-
MSA_API.task_error('ASN ID start range value cannot be higher or equals to end range value',context, True)
32+
MSA_API.task_error('ASN ID start range value cannot be higher or equals to end range value', context)
3333
elif poolStart <= 0 or poolEnd <= 0:
34-
MSA_API.task_error('ASN ID range cannot have null or negative value',context, True)
34+
MSA_API.task_error('ASN ID range cannot have null or negative value', context)
3535
elif poolStart > 65535 or poolEnd > 65535:
36-
MSA_API.task_error('ASN ID range cannot exceed the value of 65535',context, True)
36+
MSA_API.task_error('ASN ID range cannot exceed the value of 65535', context)
3737

3838
if len(duplicateRangeCheck) != len(set(duplicateRangeCheck)):
39-
MSA_API.task_error('Duplicate of ASN range detected, please edit your ASN Pool',context, True)
39+
MSA_API.task_error('Duplicate of ASN range detected, please edit your ASN Pool', context)
4040

4141
for asnRange in context.get('pool'):
4242
poolStart=int(asnRange['poolStart'])
@@ -50,7 +50,6 @@
5050
#context['overlaps_check']=i1.overlaps(i2)
5151
if (i1.overlaps(i2) == True):
5252
if (poolStart != poolStart2) or (poolEnd != poolEnd2):
53-
MSA_API.task_error('Overlaps detected between range '+str(poolStart)+'-'+str(poolEnd)+' and range '+str(poolStart2)+'-'+str(poolEnd2)+'',context, True)
53+
MSA_API.task_error('Overlaps detected between range '+str(poolStart)+'-'+str(poolEnd)+' and range '+str(poolStart2)+'-'+str(poolEnd2)+'', context)
5454

55-
ret=MSA_API.process_content('ENDED','',context, True)
56-
print(ret)
55+
MSA_API.task_success('', context)

ASN_POOL_MGNT/Process_Delete_ASN_Pool/Tasks/Task_Delete_ASN_Pool.py

Lines changed: 5 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -12,12 +12,11 @@
1212
context['asnsInUse'] = []
1313

1414
if not context['Confirmation'] == "Delete me":
15-
ret=MSA_API.process_content('ERROR','You need to enter "Delete me" as a confirmation',context, True)
16-
print(ret)
15+
MSA_API.task_error('You need to enter "Delete me" as a confirmation', context)
1716

1817
if context.get('asnsInUse'):
19-
MSA_API.task_error('ASNs still in use, please release them before deleting',context, True)
20-
18+
MSA_API.task_error('ASNs still in use, please release them before deleting', context)
19+
2120
# read the ID of the selected managed entity
2221
device_id = context['device_id']
2322

@@ -44,16 +43,6 @@
4443

4544
# check if the response is OK
4645
if order.response.ok:
47-
ret = MSA_API.process_content('ENDED',
48-
f'STATUS: {content["status"]}, \
49-
MESSAGE: successfull',
50-
context, True)
46+
MSA_API.task_success(f'STATUS: {content["status"]}, MESSAGE: successful', context)
5147
else:
52-
ret = MSA_API.process_content('FAILED',
53-
f'Import failed \
54-
- {order.content}',
55-
context, True)
56-
57-
58-
print(ret)
59-
48+
MSA_API.task_error(f'Import failed - {order.content}', context)

ASN_POOL_MGNT/Process_Edit_ASN_Pool/Tasks/Task_Get_existing_ASN_Pools.py

Lines changed: 5 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@
1717

1818
#check that at least there is one ASN range pool defined
1919
if not context.get('pool'):
20-
MSA_API.task_error('You need to enter at least one ASN range pool',context, True)
20+
MSA_API.task_error('You need to enter at least one ASN range pool', context)
2121

2222
if not context.get('asnsInUse'):
2323
context['asnsInUse'] = []
@@ -46,10 +46,10 @@
4646

4747
if context['asnPoolToBeDeletedSum'] != 0:
4848
context['pool']=context['pool_backup']
49-
MSA_API.task_error('Some range pool cannot be deleted, resource still in use, please release them',context, True)
49+
MSA_API.task_error('Some range pool cannot be deleted, resource still in use, please release them', context)
5050

5151
if not context['device_id'] or not context['name'] :
52-
MSA_API.task_error('Mandatory parameters required',context, True)
52+
MSA_API.task_error('Mandatory parameters required', context)
5353

5454
# read the ID of the selected managed entity
5555
device_id = context['device_id']
@@ -81,14 +81,6 @@
8181

8282
# check if the response is OK
8383
if order.response.ok:
84-
ret = MSA_API.process_content('ENDED',
85-
f'STATUS: {content["status"]}, \
86-
MESSAGE: successfull',
87-
context, True)
84+
MSA_API.task_success(f'STATUS: {content["status"]}, MESSAGE: successful', context)
8885
else:
89-
ret = MSA_API.process_content('FAILED',
90-
f'Import failed \
91-
- {order.content}',
92-
context, True)
93-
94-
print(ret)
86+
MSA_API.task_error(f'Import failed - {order.content}', context)

ASN_POOL_MGNT/Process_Edit_ASN_Pool/Tasks/Task_Perform_parameters__checks.py

Lines changed: 10 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66

77
#check that at least there is one ASN range pool defined
88
if not context.get('pool'):
9-
MSA_API.task_error('You need to enter at least one ASN range pool',context, True)
9+
MSA_API.task_error('You need to enter at least one ASN range pool', context)
1010

1111
#Get all Pool Ids
1212
extract_asn_pool=[]
@@ -16,30 +16,30 @@
1616

1717
for index in extract_asn_pool:
1818
if context['import_result_asn_pool'][index]['name'] == context['name'] and context['import_result_asn_pool'][index]['object_id'] != context['object_id']:
19-
MSA_API.task_error(''+context['name']+' already exist, please edit your Pool Name',context, True)
19+
MSA_API.task_error(''+context['name']+' already exist, please edit your Pool Name', context)
2020

2121
duplicateRangeCheck=[]
2222

2323
#check the range order
2424
for asnRange in context.get('pool'):
2525
if not asnRange['poolStart'] or not asnRange['poolEnd']:
26-
MSA_API.task_error('Invalid input in your pool list, please check',context, True)
26+
MSA_API.task_error('Invalid input in your pool list, please check', context)
2727
poolStart=int(asnRange['poolStart'])
2828
poolEnd=int(asnRange['poolEnd'])
2929
duplicateRangeCheck.append(''+str(poolStart)+'-'+str(poolEnd)+'')
3030

3131
if poolStart >= poolEnd:
3232
context['pool']=context['pool_backup']
33-
MSA_API.task_error('ASN ID start range value cannot be higher or equals to end range value',context, True)
33+
MSA_API.task_error('ASN ID start range value cannot be higher or equals to end range value', context)
3434
elif poolStart <= 0 or poolEnd <= 0:
3535
context['pool']=context['pool_backup']
36-
MSA_API.task_error('ASN ID range cannot have null or negative value',context, True)
36+
MSA_API.task_error('ASN ID range cannot have null or negative value', context)
3737
elif poolStart > 65535 or poolEnd > 65535:
3838
context['pool']=context['pool_backup']
39-
MSA_API.task_error('ASN ID range cannot exceed the value of 65535',context, True)
39+
MSA_API.task_error('ASN ID range cannot exceed the value of 65535', context)
4040

4141
if len(duplicateRangeCheck) != len(set(duplicateRangeCheck)):
42-
MSA_API.task_error('Duplicate of ASN range detected, please edit your ASN Pool',context, True)
42+
MSA_API.task_error('Duplicate of ASN range detected, please edit your ASN Pool', context)
4343

4444
for asnRange in context.get('pool'):
4545
poolStart=int(asnRange['poolStart'])
@@ -54,7 +54,7 @@
5454
if (i1.overlaps(i2) == True):
5555
if (poolStart != poolStart2) or (poolEnd != poolEnd2):
5656
context['pool']=context['pool_backup']
57-
MSA_API.task_error('Overlaps detected between range '+str(poolStart)+'-'+str(poolEnd)+' and range '+str(poolStart2)+'-'+str(poolEnd2)+'',context, True)
57+
MSA_API.task_error('Overlaps detected between range '+str(poolStart)+'-'+str(poolEnd)+' and range '+str(poolStart2)+'-'+str(poolEnd2)+'', context)
5858

5959
## Check Range update and asnsInUse
6060

@@ -69,8 +69,7 @@
6969
else:
7070
context['pool']=context['pool_backup']
7171
context['asnsInUse']=context['asnsInUse_backup']
72-
MSA_API.task_error('ASN Id ' +asnsInUse['asnId']+ ' in use is out of the new range ' +asnPoolUpdate['poolStart']+'-'+ asnPoolUpdate['poolEnd']+'',context, True)
72+
MSA_API.task_error('ASN Id ' +asnsInUse['asnId']+ ' in use is out of the new range ' +asnPoolUpdate['poolStart']+'-'+ asnPoolUpdate['poolEnd']+'', context)
7373
i+=1
7474

75-
ret=MSA_API.process_content('ENDED','',context, True)
76-
print(ret)
75+
MSA_API.task_success('', context)

ASN_POOL_MGNT/Process_Edit_ASN_Pool/Tasks/Task_Update_ASN_Pools.py

Lines changed: 2 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -68,16 +68,6 @@
6868

6969
# check if the response is OK
7070
if order.response.ok:
71-
ret = MSA_API.process_content('ENDED',
72-
f'STATUS: {content["status"]}, \
73-
MESSAGE: successfull',
74-
context, True)
71+
MSA_API.task_success(f'STATUS: {content["status"]}, MESSAGE: successful', context)
7572
else:
76-
ret = MSA_API.process_content('FAILED',
77-
f'Import failed \
78-
- {order.content}',
79-
context, True)
80-
81-
82-
print(ret)
83-
73+
MSA_API.task_error(f'Import failed - {order.content}', context)

ASN_POOL_MGNT/Process_Get_ASN_Ids_Used_List/Tasks/Task_Show_used_ASN_Ids.py

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -11,5 +11,4 @@
1111
for asnId in context['asnsInUse']:
1212
usedList=usedList+"\n"+asnId['asnId']+' >> '+asnId['assignment_information']+''
1313
context['usedAsnIds']=usedList
14-
ret = MSA_API.process_content('ENDED', 'Used ASN Ids :'+usedList, context, True)
15-
print(ret)
14+
MSA_API.task_success('Used ASN Ids :'+usedList, context)

ASN_POOL_MGNT/Process_Get_New_ASN_Id/Tasks/Task_Final_Message_Status.py

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,5 +6,4 @@
66

77
context = Variables.task_call(dev_var)
88

9-
ret = MSA_API.process_content('ENDED', 'New ASN Id '+context['newAssignedASNId']+ ' has been allocated from ASN Pool '+ context['name']+'', context, True)
10-
print(ret)
9+
MSA_API.task_success('New ASN Id '+context['newAssignedASNId']+ ' has been allocated from ASN Pool '+ context['name']+'', context)

0 commit comments

Comments
 (0)