Skip to content

Commit

Permalink
Merge branch 'dev' into v0.8.1
Browse files Browse the repository at this point in the history
- Added quickpath syntax [netgrph ip1 ip2]
- Added -allpaths and -singlepath options
- Most pathfinding bugs resolved
- Merged prod and dev test suite
- Improved debugging support
  • Loading branch information
yantisj committed Aug 23, 2016
2 parents 2142a1e + 65954fb commit 3b4d3fe
Show file tree
Hide file tree
Showing 11 changed files with 202 additions and 114 deletions.
3 changes: 2 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -457,7 +457,8 @@ tool that is reliable enough.
NetGrph was developed on Ubuntu 14.04 LTS, tested on 16.04, and should be
compatible with other versions of linux. I highly recommend using Ubuntu at this
early stage for better support. I also plan to create an ansible build script in
the next few months.
the next few months. It also works just find on MacOS but there are no Ansible or
install instructions for that OS.

## Installation

Expand Down
12 changes: 1 addition & 11 deletions docs/TODO
Original file line number Diff line number Diff line change
@@ -1,24 +1,14 @@


NetDB:
- Add CIDR scope usage reporting
- Add more extensive device reporting

Reporting:
- No name, no root, no router report

Other:
- Add VRF to -rpath
- Add master -path to netgrph
- Add tabular output option
- Add distance option for traversals
- built-in paging support
- Group report takes up entire console

Maintenance:
- Add switch skip on certain neighbors
- Rewrite nglib.net_update using Bolt as Pythonic
- Emulate dict with ngtree
- Rewrite py2neo cypher queries with py2neo v3.0
- Change py2neo to use bolt driver by default


19 changes: 10 additions & 9 deletions netgrph.py
Original file line number Diff line number Diff line change
Expand Up @@ -120,6 +120,7 @@ def check_path(singlepath):
singlepath = True
return singlepath


# Alternate Config File
if args.conf:
config_file = args.conf
Expand Down Expand Up @@ -155,37 +156,37 @@ def check_path(singlepath):

## Pathfinding
if args.fpath:
nglib.query.path.get_fw_path(args.fpath, args.search)
nglib.query.path.get_fw_path(args.fpath, args.search, dict())

# Quick Path
elif args.qpath:
rtype = "QTREE"
if args.output:
rtype = args.output
nglib.query.path.get_full_path(args.search, args.qpath, rtype=rtype, \
onepath=check_path(False))
nglib.query.path.get_full_path(args.search, args.qpath, \
{"onepath": check_path(False)}, rtype=rtype)

elif args.spath:
rtype = "TREE"

if args.output:
rtype = args.output
nglib.query.path.get_switched_path(args.spath, args.search, rtype=rtype, \
onepath=check_path(False))
nglib.query.path.get_switched_path(args.spath, args.search, \
{"onepath": check_path(False)}, rtype=rtype)

elif args.rpath:
rtype = "TREE"
if args.output:
rtype = args.output
nglib.query.path.get_routed_path(args.rpath, args.search, rtype=rtype, \
onepath=check_path(False))
nglib.query.path.get_routed_path(args.rpath, args.search, \
{"onepath":check_path(False)}, rtype=rtype)

elif args.path:
rtype = "TREE"
if args.output:
rtype = args.output
nglib.query.path.get_full_path(args.path, args.search, rtype=rtype, \
onepath=check_path(True))
nglib.query.path.get_full_path(args.path, args.search, \
{"onepath": check_path(False)}, rtype=rtype)

## Individual Queries
elif args.dev:
Expand Down
3 changes: 2 additions & 1 deletion nglib/ngtree/export.py
Original file line number Diff line number Diff line change
Expand Up @@ -124,4 +124,5 @@ def strip_ngtree(ngtree, top=True):
elif top:
newtree[en] = ngtree[en]

return newtree
return newtree

2 changes: 1 addition & 1 deletion nglib/query/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -177,7 +177,7 @@ def get_filter_dict(group=None, nFilter=None):
gFilter = nFilter
else:
raise Exception("Must pass in group or filter")

# Split all VRFs by spaces
vrfFilters = gFilter.rsplit()

Expand Down
9 changes: 5 additions & 4 deletions nglib/query/net.py
Original file line number Diff line number Diff line change
Expand Up @@ -41,12 +41,13 @@
logger = logging.getLogger(__name__)


def get_net(ip, rtype="TREE", days=7):
def get_net(ip, rtype="TREE", days=7, verbose=True):
"""Find a network and return text output"""

rtypes = ('TREE', 'JSON', 'YAML', 'NGTREE')

logger.info("Query: Looking up %s for %s", ip, nglib.user)
if verbose:
logger.info("Query: Looking up %s for %s", ip, nglib.user)

if rtype in rtypes:
net = nglib.query.net.find_cidr(ip)
Expand Down Expand Up @@ -294,8 +295,8 @@ def find_cidr(ip):
if len(networks) > 1:
for r in networks.records:
if ipaddress.ip_address(ip) in ipaddress.ip_network(r.cidr):
if nglib.verbose:
print(ip + " in " + r.cidr)
if nglib.verbose>1:
print("find_cidr", ip + " in " + r.cidr)
mostSpecific = compare_cidr(mostSpecific, r.cidr)


Expand Down
Loading

0 comments on commit 3b4d3fe

Please sign in to comment.