Merge "Fix handling solar resource action run errors"

This commit is contained in:
Jenkins 2016-02-11 15:50:19 +00:00 committed by Gerrit Code Review
commit 0ecbf945ae

View File

@ -14,21 +14,35 @@
import json
import os
import sys
import click
from functools import wraps
import tabulate
import yaml
from solar.cli.base import EGroup
from solar.cli import executors
from solar.core import actions
from solar.core.log import log
from solar.core import resource as sresource
from solar.core.resource import composer as cr
from solar import errors
@click.group()
class ResourceGroup(EGroup):
def error_wrapper(self, f):
@wraps(f)
def _in(*args, **kwargs):
try:
return f(*args, **kwargs)
except errors.SolarError as e:
if self.error_wrapper_enabled:
raise click.ClickException(str(e))
raise
return _in
@click.group(cls=ResourceGroup)
def resource():
pass
@ -48,11 +62,7 @@ def action(dry_run_mapping, dry_run, action, resource):
)
r = sresource.load(resource)
try:
actions.resource_action(r, action)
except errors.SolarError as e:
log.debug(e)
sys.exit(1)
actions.resource_action(r, action)
if dry_run:
click.echo('EXECUTED:')