Esempio n. 1
0
def ip_id_validator(value):
    if isinstance(value, list):
        for v in value:
            if not IpsModel.ip_exists_by_id(v):
                raise serializers.ValidationError(_(u"%s 不存在" % v))
    if not IpsModel.ip_exists_by_id(value):
        raise serializers.ValidationError(_(u"%s 不存在" % value))
Esempio n. 2
0
def make_ip_id():
    while True:
        ip_id = "%s-%s" % (settings.IP_PREFIX, randomname_maker())
        if not IpsModel.ip_exists_by_id(ip_id):
            return ip_id