diff --git a/networkapi/api_equipment/exceptions.py b/networkapi/api_equipment/exceptions.py index 47b0eb3ff..223806b60 100644 --- a/networkapi/api_equipment/exceptions.py +++ b/networkapi/api_equipment/exceptions.py @@ -7,8 +7,8 @@ class AllEquipmentsAreInMaintenanceException(APIException): status_code = status.HTTP_400_BAD_REQUEST default_detail = 'All equipments to be configured are in maintenance mode.' - def __init__(self, param=default_detail): - self.detail = param + def __init__(self, param=default_detail, equips=None): + self.detail = param if not equips else "{} Equipments: {}".format(param, equips) class EquipmentInvalidValueException(APIException): diff --git a/networkapi/api_vip_request/facade/v3.py b/networkapi/api_vip_request/facade/v3.py index 7d2780e03..5af635b9e 100644 --- a/networkapi/api_vip_request/facade/v3.py +++ b/networkapi/api_vip_request/facade/v3.py @@ -156,6 +156,8 @@ def get_vip_request_by_search(search=dict()): def prepare_apply(load_balance, vip, created=True, user=None): + log.debug("Preparing to aplly. load_balance:%s vip:%s, created:%s", load_balance, vip, created) + vip_request = copy.deepcopy(vip) id_vip = str(vip_request.get('id')) @@ -617,6 +619,9 @@ def patch_real_vip_request(vip_requests, user): @commit_on_success def delete_real_vip_request(vip_requests, user, cleanup='0'): + + log.debug("Deleting real VIP request. vip_requests:%s cleanup:%s", vip_requests, cleanup) + load_balance = dict() cleanup = True if cleanup == '1' else False @@ -656,6 +661,8 @@ def delete_real_vip_request(vip_requests, user, cleanup='0'): def _validate_vip_to_apply(vip_request, update=False, user=None): + log.debug("Validating VIP to aplly. vip_request:%s update:%s", vip_request, update) + vip = get_vip_request_by_id(vip_request.get('id')) # validate vip with same ipv4 ou ipv6 @@ -676,11 +683,12 @@ def _validate_vip_to_apply(vip_request, update=False, user=None): raise exceptions.VipRequestAlreadyCreated(vip.id) equips = facade_eqpt.get_eqpt_by_envvip(vip_request['environmentvip']) + log.debug("equips:%s", equips) conf = EnvironmentVip.objects.get(id=vip_request['environmentvip']).conf - if facade_eqpt.all_equipments_are_in_maintenance(equips): - raise exceptions_eqpt.AllEquipmentsAreInMaintenanceException() + if equips and facade_eqpt.all_equipments_are_in_maintenance(equips): + raise exceptions_eqpt.AllEquipmentsAreInMaintenanceException(equips=equips) if user: if not facade_eqpt.all_equipments_can_update_config(equips, user): diff --git a/networkapi/api_vip_request/views/v3.py b/networkapi/api_vip_request/views/v3.py index bb54b1148..3536eb2fd 100644 --- a/networkapi/api_vip_request/views/v3.py +++ b/networkapi/api_vip_request/views/v3.py @@ -74,6 +74,8 @@ def delete(self, request, *args, **kwargs): """ + log.debug("Undeploying vip request. kwargs: %s", kwargs) + vip_request_ids = kwargs['obj_ids'].split(';') cleanup = request.GET.get('cleanup', '0')