Skip to content

Commit

Permalink
Merge pull request #443 from globocom/develop
Browse files Browse the repository at this point in the history
Develop
  • Loading branch information
renan-lopes-rodrigues authored Sep 26, 2024
2 parents e9c5eca + b4b7054 commit ee87d61
Show file tree
Hide file tree
Showing 3 changed files with 14 additions and 4 deletions.
4 changes: 2 additions & 2 deletions networkapi/api_equipment/exceptions.py
Original file line number Diff line number Diff line change
Expand Up @@ -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):
Expand Down
12 changes: 10 additions & 2 deletions networkapi/api_vip_request/facade/v3.py
Original file line number Diff line number Diff line change
Expand Up @@ -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'))
Expand Down Expand Up @@ -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

Expand Down Expand Up @@ -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
Expand All @@ -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):
Expand Down
2 changes: 2 additions & 0 deletions networkapi/api_vip_request/views/v3.py
Original file line number Diff line number Diff line change
Expand Up @@ -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')

Expand Down

0 comments on commit ee87d61

Please sign in to comment.