def db_add_IPv4Network(ip_domain_id, name, address, comment): result=0 ip , mask = address.split("/") print ip, mask if (is_valid_ipv4_address(ip) == False): return str(ip + " is not a valid IPv4 address.") result = db_add_entry(IPv4Network,ip_domain_id=ip_domain_id, name=name, ip=ip2long(ip), mask=int(mask), comment=comment) if type(result) is int: result = db_add_entry(DomainIPv4,ip_domain_id=ip_domain_id, ip4_network_id=result) return result
def api_ip_domain_post(): data = json.loads(request.data) result = db_add_entry(IPDomain,name=data['name'], comment=data['comment']) if type(result) is str: return response('error',result) else: return response('success', 'IP Domain ' + data['name'] + ' succesfully created.')
def api_ip_address_post(): data = json.loads(request.data) result = db_add_entry(IPv4Address,ip=data['ip'], ip_domain_id=data['ip_domain_id'], fqdn=data['fqdn'], description=data['description'], reserved=data['reserved']) if type(result) is str: return response('error',result) else: return response('success', 'IP Address entry ' + data['fqdn'] + ' succesfully created.')