From a4fe14aae919dbd02b65a4e0134cc612bb0d8bd6 Mon Sep 17 00:00:00 2001 From: Przemyslaw Kaminski Date: Fri, 17 Apr 2015 13:24:30 +0200 Subject: [PATCH] Added missing main.yml, docker.yml for Astute, fixed graph outputting --- README.md | 3 +++ cli.py | 17 +++++++++++++---- docker.yml | 8 ++++++++ main.yml | 19 +++++++++++++++++++ 4 files changed, 43 insertions(+), 4 deletions(-) create mode 100644 docker.yml create mode 100644 main.yml diff --git a/README.md b/README.md index 7c115a03..96ac7285 100644 --- a/README.md +++ b/README.md @@ -80,6 +80,9 @@ python cli.py resource show rs/mariadb_keystone_data # --> IP is 1.1.1.1 # View connections python cli.py connections show + +# Outputs graph to 'graph.png' file, please note that arrows don't have "normal" pointers, but just the line is thicker +# please see http://networkx.lanl.gov/_modules/networkx/drawing/nx_pylab.html python cli.py connections graph # Disconnect diff --git a/cli.py b/cli.py index 9e35dd9b..b3432f00 100644 --- a/cli.py +++ b/cli.py @@ -1,5 +1,8 @@ import click import json +import matplotlib +matplotlib.use('Agg') # don't show windows +import matplotlib.pyplot as plt import networkx as nx import os @@ -100,11 +103,17 @@ def init_cli_connections(): connections.add_command(show) # TODO: this requires graphing libraries - #@click.command() - #def graph(): - # nx.draw_graphviz(xs.connection_graph()) + @click.command() + def graph(): + g = xs.connection_graph() + pos = nx.spring_layout(g) + nx.draw_networkx_nodes(g, pos) + nx.draw_networkx_edges(g, pos, arrows=True) + nx.draw_networkx_labels(g, pos) + plt.axis('off') + plt.savefig('graph.png') - #connections.add_command(graph) + connections.add_command(graph) if __name__ == '__main__': diff --git a/docker.yml b/docker.yml new file mode 100644 index 00000000..f4c70229 --- /dev/null +++ b/docker.yml @@ -0,0 +1,8 @@ +- hosts: all + sudo: yes + tasks: + - shell: docker --version + ignore_errors: true + register: docker_version + - shell: curl -sSL https://get.docker.com/ | sudo sh + when: docker_version | failed diff --git a/main.yml b/main.yml new file mode 100644 index 00000000..17fc5b8d --- /dev/null +++ b/main.yml @@ -0,0 +1,19 @@ +--- + +- hosts: all + sudo: yes + tasks: + # Setup additional development tools + - apt: name=vim state=present + - apt: name=tmux state=present + - apt: name=htop state=present + - apt: name=python-virtualenv state=present + - apt: name=virtualenvwrapper state=present + - apt: name=ipython state=present + - apt: name=python-pudb state=present + + # Graph drawing + - apt: name=python-matplotlib state=present + + # Setup development env for solar + #- shell: python setup.py develop chdir=/vagrant/solar