Add a DisjunctionError exception and use it

in case there is no possible disjoint path with the added constraints
(most of the time due to an inconsistant user request)

Signed-off-by: EstherLerouzic <esther.lerouzic@orange.com>
This commit is contained in:
EstherLerouzic
2019-09-13 19:07:51 +01:00
parent 66bdeb0e4d
commit b15c8c60ab
3 changed files with 9 additions and 3 deletions

View File

@@ -436,7 +436,11 @@ def main(args):
print(rqs)
print('\x1b[1;34;40m' + f'Computing all paths with constraints' + '\x1b[0m')
pths = compute_path_dsjctn(network, equipment, rqs, dsjn)
try:
pths = compute_path_dsjctn(network, equipment, rqs, dsjn)
except DisjunctionError as this_e:
print(f'{ansi_escapes.red}Disjunction error:{ansi_escapes.reset} {this_e}')
exit(1)
print('\x1b[1;34;40m' + f'Propagating on selected path' + '\x1b[0m')
propagatedpths, reversed_pths, reversed_propagatedpths = \

View File

@@ -21,3 +21,5 @@ class NetworkTopologyError(ConfigurationError):
class ServiceError(Exception):
'''Service of user-provided request is wrong'''
class DisjunctionError(ServiceError):
'''Disjunction of user-provided request can not be satisfied'''

View File

@@ -24,7 +24,7 @@ from gnpy.core.service_sheet import convert_service_sheet, Request_element, Elem
from gnpy.core.elements import Transceiver, Roadm, Edfa, Fused
from gnpy.core.utils import db2lin, lin2db
from gnpy.core.info import create_input_spectral_information, SpectralInformation, Channel, Power
from gnpy.core.exceptions import ServiceError
from gnpy.core.exceptions import ServiceError, DisjunctionError
from copy import copy, deepcopy
from csv import writer
from math import ceil
@@ -878,7 +878,7 @@ def compute_path_dsjctn(network, equipment, pathreqlist, disjunctions_list):
LOGGER.critical(msg)
print(f'{msg}\nComputation stopped.')
# TODO in this case: replay step 5 with the candidate without constraints
exit()
raise DisjunctionError(msg)
# for i in disjunctions_list:
# print(i.disjunction_id)