Fix handling solar resource action run errors
Change-Id: I60975a50a370de0de408c1581dcd18b33bf325e0 Closes-bug: #1544544 Related-bug: #1544506
This commit is contained in:
parent
06e3069d2b
commit
3f75defff1
@ -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:')
|
||||
|
Loading…
x
Reference in New Issue
Block a user