From dc0edfd0fc32fb663e0ae0c5a2f625b1543b404a Mon Sep 17 00:00:00 2001 From: Przemyslaw Kaminski Date: Tue, 15 Sep 2015 14:41:54 +0200 Subject: [PATCH] Fix hosts_file run action --- resources/hosts_file/actions/run.yaml | 8 ++++---- solar/solar/cli/main.py | 2 +- solar/solar/core/resource/resource.py | 15 +++++++++++++++ 3 files changed, 20 insertions(+), 5 deletions(-) diff --git a/resources/hosts_file/actions/run.yaml b/resources/hosts_file/actions/run.yaml index 61876e05..68959684 100644 --- a/resources/hosts_file/actions/run.yaml +++ b/resources/hosts_file/actions/run.yaml @@ -1,11 +1,11 @@ - hosts: [{{host}}] sudo: yes tasks: - {% for ip, host in zip(hosts_ips.value, hosts_names.value) %} - - name: Create hosts entries for {{host['value']}} => {{ip['value']}} + {% for ip, host in zip(hosts_ips, hosts_names) %} + - name: Create hosts entries for {{host}} => {{ip}} lineinfile: dest: /etc/hosts - regexp: '.*{{host["value"]}}$' - line: '{{ip["value"]}} {{host["value"]}}' + regexp: '.*{{host}}$' + line: '{{ip}} {{host}}' state: present {% endfor %} diff --git a/solar/solar/cli/main.py b/solar/solar/cli/main.py index 5be1529d..846eb34c 100644 --- a/solar/solar/cli/main.py +++ b/solar/solar/cli/main.py @@ -262,7 +262,7 @@ def init_cli_resource(): def show(**kwargs): resources = [] - for name, res in sresource.load_all().items(): + for res in sresource.load_all(): show = True if kwargs['tag']: if kwargs['tag'] not in res.tags: diff --git a/solar/solar/core/resource/resource.py b/solar/solar/core/resource/resource.py index 0bb6309e..0f182351 100644 --- a/solar/solar/core/resource/resource.py +++ b/solar/solar/core/resource/resource.py @@ -124,6 +124,21 @@ class Resource(object): 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): r = orm.DBResource.load(name)