![]() ![]() exit ( 1 ) try : fh = open ( path ) except IOError as e : sys. write ( " USAGE: dot_find_cycles.py /path/to/file.dot \n " ) def main (): path = "" if ( len ( sys. write ( " finds cycles in dot file graphs, such as those from Puppet \n\n " ) sys. write ( "dot_find_cycles.py by Jason Antman \n " ) sys. ![]() REQUIREMENTS: Python python-networkx - graphviz-python - pydot - (all of these are available as native packages at least on CentOS) USAGE: dot_find_cycles.py /path/to/file.dot The canonical source of this script can always be found from: $HeadURL: $ $LastChangedRevision: 33 $ CHANGELOG: Wednesday Jason Antman : - initial script creation """ import sys from os import path, access, R_OK import networkx as nx def usage (): sys. ![]() Free for all use, provided that you send any changes you make back to me, update the changelog, and keep this comment intact. #!/usr/bin/env python """ dot_find_cycles.py - uses Pydot and NetworkX to find cycles in a dot file directed graph. For Puppet purposes, I’d recommend running this onĮxpanded_relationships.dot to get the full information. Which are available as packages in the default repos of Fedora andĬentOS at least). On the python-networkx, graphviz-python, and pydot packages (all of The script is written in Python, and depends ![]() Source URL notice intact, update the changelog, and send anyįeatures/fixes back to me. You can always obtain the latest version of this script fromĪnd distribution, provided that you leave my copyright/attribution and I sincerely hope that this script will save someone else at leastĪs much time as it took me to write (I know it will for me…). To track down an extraneous “require puppet” that this all originatedįrom. With that little tidbit of information, I managed It probably would have taken me hours to come up with that by hand, letĪlone realize that Service is the common item in all of them,Īnd hence the problem. ', 'File', 'Service', 'Package', 'Service', 'Package'] (nodes on the graph, not puppet clients), and got the following output: On the expanded_relationships.dot file from Puppet, which had 99 nodes Will output all of the cycles found within the graph. Given a dot file (of the type generated, for example, by Puppet), this In about 20 minutes, I hacked together the dead-simple Their site, “NetworkX is a Python language software package for theĬreation, manipulation, and study of the structure, dynamics, andįunctions of complex networks.” Among its features are the ability to With a little research, I managed to find the Generated the png as described in the Puppet FAQs, but even scrollingīack and forth on this for 20 minutes didn’t help: (note: link is to Not exactly easy to follow, or to pull much meaning out of, even if Iĭid some slight reformatting by putting in some newlines. Could not apply complete catalog: Found dependency cycles in the following relationships: Service => File, File => File, Service => File, File => Service, File => Service, File => Service, File => Service, Service => File, File => Package, Service => Package, File => Package, Package => Package, User => Package, File => Package, File => Package, File => Package, File => Exec, Service => Exec, File => Exec, Package => Exec, User => Exec, File => Exec, File => Exec, File => Exec, File => File, Service => File, File => File, Package => File, User => File, File => File, File => File, File => File, File => Service, Package => Service, Service ![]()
0 Comments
Leave a Reply. |