Merge pull request #148 from CGenie/cgenie/connections-graph-fix

fix hosts_file run action + color_repr
This commit is contained in:
Jędrzej Nowak 2015-09-15 16:09:44 +02:00
commit 3bb6cafe2b
3 changed files with 20 additions and 5 deletions

View File

@ -1,11 +1,11 @@
- hosts: [{{host}}] - hosts: [{{host}}]
sudo: yes sudo: yes
tasks: tasks:
{% for ip, host in zip(hosts_ips.value, hosts_names.value) %} {% for ip, host in zip(hosts_ips, hosts_names) %}
- name: Create hosts entries for {{host['value']}} => {{ip['value']}} - name: Create hosts entries for {{host}} => {{ip}}
lineinfile: lineinfile:
dest: /etc/hosts dest: /etc/hosts
regexp: '.*{{host["value"]}}$' regexp: '.*{{host}}$'
line: '{{ip["value"]}} {{host["value"]}}' line: '{{ip}} {{host}}'
state: present state: present
{% endfor %} {% endfor %}

View File

@ -262,7 +262,7 @@ def init_cli_resource():
def show(**kwargs): def show(**kwargs):
resources = [] resources = []
for name, res in sresource.load_all().items(): for res in sresource.load_all():
show = True show = True
if kwargs['tag']: if kwargs['tag']:
if kwargs['tag'] not in res.tags: if kwargs['tag'] not in res.tags:

View File

@ -124,6 +124,21 @@ class Resource(object):
return ret return ret
def color_repr(self):
import click
arg_color = 'yellow'
return ("{resource_s}({name_s}='{id}', {base_path_s}={base_path} "
"{args_s}={input}, {tags_s}={tags})").format(
resource_s=click.style('Resource', fg='white', bold=True),
name_s=click.style('name', fg=arg_color, bold=True),
base_path_s=click.style('base_path', fg=arg_color, bold=True),
args_s=click.style('args', fg=arg_color, bold=True),
tags_s=click.style('tags', fg=arg_color, bold=True),
**self.to_dict()
)
def load(name): def load(name):
r = orm.DBResource.load(name) r = orm.DBResource.load(name)