예제 #1
0
파일: fields.py 프로젝트: shinn1982/vista
 def constraint(obj, attr, value):
     try:
         return generate_password_hash(value)
     except Exception:
         raise ValueError(
             _("a password is required in field %(attr)s.") %
             {'attr': attr})
예제 #2
0
class ObjectNotFound(NotFound):
    """A not found exception indicating an identifiable object isn't found.
    A specialization of the NotFound exception indicating an object with a said
    ID doesn't exist.
    :param id: The ID of the (not found) object.
    """
    message = _("%(objtype)s object %(id)s not found.")
예제 #3
0
파일: fields.py 프로젝트: shinn1982/vista
 def constraint(obj, attr, value):
     try:
         if not value:
             return uuid.uuid4().hex
         return uuid.UUID(str(value)).hex
     except Exception:
         raise ValueError(
             _("a UUID is required in field %(attr)s.") % {'attr': attr})
예제 #4
0
파일: fields.py 프로젝트: shinn1982/vista
 def constraint(obj, attr, value):
     result = IPAddress.constraint(obj, attr, value)
     if result.version != 4:
         raise ValueError(
             _("%(val)s is not valid for the field %(attr)s") % {
                 'val': value,
                 'attr': attr
             })
     return result
예제 #5
0
파일: fields.py 프로젝트: shinn1982/vista
 def constraint(obj, attr, value):
     try:
         return netaddr.IPAddress(value).__str__()
     except netaddr.AddrFormatError:
         raise ValueError(
             _("%(val)s is not valid IP Address for the field %(attr)s") % {
                 'val': value,
                 'attr': attr
             })
예제 #6
0
파일: fields.py 프로젝트: shinn1982/vista
 def _null(self, obj, attr):
     """process field value is None
     """
     if self.nullable:
         return None
     else:
         raise ValueError(
             _("field '%(attr)s' of object '%(obj)s' cannot be None.") % {
                 'attr': attr,
                 'obj': obj
             })
예제 #7
0
파일: fields.py 프로젝트: shinn1982/vista
    def constraint(obj, attr, value):
        """make sure the field value is string or converted to string
        """
        accepted_types = (str, int)

        if isinstance(value, accepted_types):
            return str(value)
        else:
            raise ValueError(
                _("a string is required in field %(attr)s, not a %(type)s.") %
                {
                    'attr': attr,
                    'type': type(value).__name__
                })
예제 #8
0
    "reopt_mode": "loose",
    "flow_factor": 1.0,
    "real_traffic": False,
    "traffic_ratio": 1.0,
    "congest_threshold": 0.8,
    "target_threshold": 0.7,
    "prioriry_prefer": "HIGH",
    "traffic_prefer": "HIGH",
    "priority_weight": 0.5,
    "bandwidth_weight": 0.5
}

################################################
# General Constants
################################################
DEFAULT_USER_ERR_MES = _('Invalid input arguments.')


################################################
# Unused Constants Below
################################################

ACTION_DICT_1 = {
    'creator': {"bgp": 0, "netconf": 1},
    'create_backup': {False: 0, True: 1},
    'tlv_encoding': {"old": 0, "new": 1},
    'origin': {"IGP": 0, "BGP": 1, "INCOMPLETE": 2},
    'valid_check': {False: 0, True: 1},
    'target_type': {"PE": 0, "RR": 1},
    'generator': {"manual": 0, "topo": 1, "auto": 2, "local": 3},
    'append_type': {"ANY": 0, "EPE": 1},
예제 #9
0
class SqlExecuteError(BaseException):
    """Database operation error."""
    message = _("database general function execution error, %(info)s.")
예제 #10
0
class ObjectFieldInvalid(BaseException):
    """the field value of object is invalid
    """
    message = _("Field %(field)s of %(objname)s is not an instance of Field")
예제 #11
0
class StatusError(BaseException):
    """Target object status error."""
    message = _("%(obj_type)s object of %(status)s status can't do the %(action)s operation.")
예제 #12
0
class NoAccessAuthority(BaseException):
    """No authority to do some operation"""
    message = _("current user no access to do %(obj_type)s %(oper_type)s operation.")
예제 #13
0
class ServiceUnavailable(BaseException):
    """A generic service unavailable exception."""
    message = _("The service is unavailable.")
예제 #14
0
class NotAuthorized(BaseException):
    """A generic not authorized exception."""
    message = _("Not authorized.")
예제 #15
0
class ObjectFieldUpdateError(BaseException):
    """the field value of object do not allow to update
    """
    message = _("Field %(field)s of %(objname)s no update allowed")
예제 #16
0
class AssociationError(BaseException):
    """operation failed for association exitsting."""
    message = _("operation error because target %(obj)s object still has associations with %(ass_obj)s.")
예제 #17
0
class BadRequest(BaseException):
    """An exception indicating a generic bad request for a said resource.
    A generic exception indicating a bad request for a specified resource.
    """
    message = _('Bad %(resource)s request: %(msg)s.')