# -*- coding: utf-8 -*-
from rest_framework import status
from rest_framework.exceptions import APIException
[docs]class VipRequestNotFoundError(APIException):
status_code = status.HTTP_404_NOT_FOUND
def __init__(self, msg):
self.detail = u'Vips Request %s do not exist.' % (msg)
[docs]class VipRequestError(APIException):
status_code = status.HTTP_500_INTERNAL_SERVER_ERROR
def __init__(self, msg):
self.detail = msg
[docs]class VipRequestPortNotFoundError(APIException):
status_code = status.HTTP_404_NOT_FOUND
def __init__(self, msg):
self.detail = u'Vips Request Port %s do not exist.' % (msg)
[docs]class VipRequestPortError(APIException):
status_code = status.HTTP_500_INTERNAL_SERVER_ERROR
def __init__(self, msg):
self.detail = msg
[docs]class VipRequestPortOptionVipNotFoundError(APIException):
status_code = status.HTTP_404_NOT_FOUND
def __init__(self, msg):
self.detail = u'Vips Request Port Option Vip %s do not exist.' % (msg)
[docs]class VipRequestPortOptionVipError(APIException):
status_code = status.HTTP_500_INTERNAL_SERVER_ERROR
def __init__(self, msg):
self.detail = msg
[docs]class VipRequestPortPoolNotFoundError(APIException):
status_code = status.HTTP_404_NOT_FOUND
def __init__(self, msg):
self.detail = u'Vips Request Port Pool %s do not exist.' % (msg)
[docs]class VipRequestPortPoolError(APIException):
status_code = status.HTTP_500_INTERNAL_SERVER_ERROR
def __init__(self, msg):
self.detail = msg
[docs]class VipRequestOptionVipNotFoundError(APIException):
status_code = status.HTTP_404_NOT_FOUND
def __init__(self, msg):
self.detail = u'Vips Request Port Option Vip %s do not exist.' % (msg)
[docs]class VipRequestOptionVipError(APIException):
status_code = status.HTTP_500_INTERNAL_SERVER_ERROR
def __init__(self, msg):
self.detail = msg
[docs]class VipRequestDSCPNotFoundError(APIException):
status_code = status.HTTP_404_NOT_FOUND
def __init__(self, msg):
self.detail = u'Vips Request Dscp %s do not exist.' % (msg)
[docs]class VipRequestDSCPError(APIException):
status_code = status.HTTP_500_INTERNAL_SERVER_ERROR
def __init__(self, msg):
self.detail = msg
[docs]class VipRequestDoesNotExistException(APIException):
status_code = status.HTTP_404_NOT_FOUND
default_detail = 'Vip Request Does Not Exist.'
def __init__(self, msg=None):
if msg:
self.detail = u'Vips Request %s do not exist.' % (
msg)
else:
self.detail = self.default_detail
[docs]class EnvironmentVipDoesNotExistException(APIException):
status_code = status.HTTP_404_NOT_FOUND
default_detail = 'Environment Vip Does Not Exist.'
[docs]class InvalidIdVipRequestException(APIException):
status_code = status.HTTP_400_BAD_REQUEST
default_detail = 'Invalid id for Vip Request.'
[docs]class AlreadyVipRequestException(APIException):
status_code = status.HTTP_400_BAD_REQUEST
default_detail = 'Vip with ipv4 or ipv6 already exists.'
[docs]class CreatedVipRequestValuesException(APIException):
status_code = status.HTTP_400_BAD_REQUEST
default_detail = 'Vip Request already created. Cannot change values.'
def __init__(self, msg=None):
self.detail = u'Not is possible to change some values in vip request when is created. Values prohibited:<<%s>>' % (
msg)
[docs]class ServerPoolMemberDiffEnvironmentVipException(APIException):
status_code = status.HTTP_400_BAD_REQUEST
default_detail = 'Server Pool Member is associated with different environment vip of vip request.'
def __init__(self, msg=None):
self.detail = u'Server Pool Member is associated with different environment vip of vip request. <<%s>>' % (
msg)
[docs]class IpNotFoundByEnvironment(APIException):
status_code = status.HTTP_400_BAD_REQUEST
default_detail = 'Environment of Ip is different of environment of vip' + \
' request. Look the association of network of IP with environment vip'
def __init__(self, msg=default_detail):
self.detail = msg
[docs]class VipRequestAlreadyCreated(APIException):
status_code = status.HTTP_400_BAD_REQUEST
default_detail = 'Vip Request already created.'
def __init__(self, msg=None):
self.detail = u'Vip Request <<%s>> already created.' % msg
[docs]class VipRequestNotCreated(APIException):
status_code = status.HTTP_400_BAD_REQUEST
default_detail = 'Vip Request not created.'
def __init__(self, msg=None):
self.detail = u'Vip Request <<%s>> not created.' % msg
[docs]class VipConstraintCreated(APIException):
status_code = status.HTTP_400_BAD_REQUEST
default_detail = 'Vip request can not be deleted because it is created in equipment.'
def __init__(self, msg=None):
if msg:
self.detail = u'Vip request %s can not be deleted because it is created in equipment' % msg
else:
self.detail = self.default_detail