Merge "Do not let keystoneauth mask the errors"
This commit is contained in:
@@ -0,0 +1,8 @@
|
|||||||
|
---
|
||||||
|
fixes:
|
||||||
|
- |
|
||||||
|
Some cli mistral calls when failed would return unhelpful messages like
|
||||||
|
error(400) that is not what the mistral api is returning. This changes
|
||||||
|
those messages to the useful messages sent by the api.
|
||||||
|
The affected are the run-action, the crud for actions, workflows, and
|
||||||
|
workbooks.
|
@@ -38,16 +38,12 @@ class ActionExecutionManager(base.ResourceManager):
|
|||||||
if params:
|
if params:
|
||||||
data['params'] = json.dumps(params)
|
data['params'] = json.dumps(params)
|
||||||
|
|
||||||
resp = self.http_client.post(
|
return self._create(
|
||||||
'/action_executions',
|
'/action_executions',
|
||||||
json.dumps(data)
|
data,
|
||||||
|
dump_json=True
|
||||||
)
|
)
|
||||||
|
|
||||||
if resp.status_code != 201:
|
|
||||||
self._raise_api_exception(resp)
|
|
||||||
|
|
||||||
return self.resource_class(self, base.get_json(resp))
|
|
||||||
|
|
||||||
def update(self, id, state=None, output=None):
|
def update(self, id, state=None, output=None):
|
||||||
self._ensure_not_empty(id=id)
|
self._ensure_not_empty(id=id)
|
||||||
|
|
||||||
|
@@ -14,6 +14,7 @@
|
|||||||
|
|
||||||
import six
|
import six
|
||||||
|
|
||||||
|
from keystoneauth1 import exceptions
|
||||||
from mistralclient.api import base
|
from mistralclient.api import base
|
||||||
from mistralclient import utils
|
from mistralclient import utils
|
||||||
|
|
||||||
@@ -34,11 +35,14 @@ class ActionManager(base.ResourceManager):
|
|||||||
# definition file
|
# definition file
|
||||||
definition = utils.get_contents_if_file(definition)
|
definition = utils.get_contents_if_file(definition)
|
||||||
|
|
||||||
|
try:
|
||||||
resp = self.http_client.post(
|
resp = self.http_client.post(
|
||||||
'/actions?scope=%s' % scope,
|
'/actions?scope=%s' % scope,
|
||||||
definition,
|
definition,
|
||||||
headers={'content-type': 'text/plain'}
|
headers={'content-type': 'text/plain'}
|
||||||
)
|
)
|
||||||
|
except exceptions.HttpError as ex:
|
||||||
|
self._raise_api_exception(ex.response)
|
||||||
|
|
||||||
if resp.status_code != 201:
|
if resp.status_code != 201:
|
||||||
self._raise_api_exception(resp)
|
self._raise_api_exception(resp)
|
||||||
@@ -55,11 +59,14 @@ class ActionManager(base.ResourceManager):
|
|||||||
# definition file
|
# definition file
|
||||||
definition = utils.get_contents_if_file(definition)
|
definition = utils.get_contents_if_file(definition)
|
||||||
|
|
||||||
|
try:
|
||||||
resp = self.http_client.put(
|
resp = self.http_client.put(
|
||||||
'%s?scope=%s' % (url_pre, scope),
|
'%s?scope=%s' % (url_pre, scope),
|
||||||
definition,
|
definition,
|
||||||
headers={'content-type': 'text/plain'}
|
headers={'content-type': 'text/plain'}
|
||||||
)
|
)
|
||||||
|
except exceptions.HttpError as ex:
|
||||||
|
self._raise_api_exception(ex.response)
|
||||||
|
|
||||||
if resp.status_code != 200:
|
if resp.status_code != 200:
|
||||||
self._raise_api_exception(resp)
|
self._raise_api_exception(resp)
|
||||||
@@ -111,11 +118,14 @@ class ActionManager(base.ResourceManager):
|
|||||||
# definition file
|
# definition file
|
||||||
definition = utils.get_contents_if_file(definition)
|
definition = utils.get_contents_if_file(definition)
|
||||||
|
|
||||||
|
try:
|
||||||
resp = self.http_client.post(
|
resp = self.http_client.post(
|
||||||
'/actions/validate',
|
'/actions/validate',
|
||||||
definition,
|
definition,
|
||||||
headers={'content-type': 'text/plain'}
|
headers={'content-type': 'text/plain'}
|
||||||
)
|
)
|
||||||
|
except exceptions.HttpError as ex:
|
||||||
|
self._raise_api_exception(ex.response)
|
||||||
|
|
||||||
if resp.status_code != 200:
|
if resp.status_code != 200:
|
||||||
self._raise_api_exception(resp)
|
self._raise_api_exception(resp)
|
||||||
|
@@ -13,6 +13,7 @@
|
|||||||
# See the License for the specific language governing permissions and
|
# See the License for the specific language governing permissions and
|
||||||
# limitations under the License.
|
# limitations under the License.
|
||||||
|
|
||||||
|
from keystoneauth1 import exceptions
|
||||||
from mistralclient.api import base
|
from mistralclient.api import base
|
||||||
from mistralclient import utils
|
from mistralclient import utils
|
||||||
|
|
||||||
@@ -31,11 +32,14 @@ class WorkbookManager(base.ResourceManager):
|
|||||||
# definition file
|
# definition file
|
||||||
definition = utils.get_contents_if_file(definition)
|
definition = utils.get_contents_if_file(definition)
|
||||||
|
|
||||||
|
try:
|
||||||
resp = self.http_client.post(
|
resp = self.http_client.post(
|
||||||
'/workbooks',
|
'/workbooks',
|
||||||
definition,
|
definition,
|
||||||
headers={'content-type': 'text/plain'}
|
headers={'content-type': 'text/plain'}
|
||||||
)
|
)
|
||||||
|
except exceptions.HttpError as ex:
|
||||||
|
self._raise_api_exception(ex.response)
|
||||||
|
|
||||||
if resp.status_code != 201:
|
if resp.status_code != 201:
|
||||||
self._raise_api_exception(resp)
|
self._raise_api_exception(resp)
|
||||||
@@ -49,11 +53,14 @@ class WorkbookManager(base.ResourceManager):
|
|||||||
# definition file
|
# definition file
|
||||||
definition = utils.get_contents_if_file(definition)
|
definition = utils.get_contents_if_file(definition)
|
||||||
|
|
||||||
|
try:
|
||||||
resp = self.http_client.put(
|
resp = self.http_client.put(
|
||||||
'/workbooks',
|
'/workbooks',
|
||||||
definition,
|
definition,
|
||||||
headers={'content-type': 'text/plain'}
|
headers={'content-type': 'text/plain'}
|
||||||
)
|
)
|
||||||
|
except exceptions.HttpError as ex:
|
||||||
|
self._raise_api_exception(ex.response)
|
||||||
|
|
||||||
if resp.status_code != 200:
|
if resp.status_code != 200:
|
||||||
self._raise_api_exception(resp)
|
self._raise_api_exception(resp)
|
||||||
@@ -80,11 +87,14 @@ class WorkbookManager(base.ResourceManager):
|
|||||||
# definition file
|
# definition file
|
||||||
definition = utils.get_contents_if_file(definition)
|
definition = utils.get_contents_if_file(definition)
|
||||||
|
|
||||||
|
try:
|
||||||
resp = self.http_client.post(
|
resp = self.http_client.post(
|
||||||
'/workbooks/validate',
|
'/workbooks/validate',
|
||||||
definition,
|
definition,
|
||||||
headers={'content-type': 'text/plain'}
|
headers={'content-type': 'text/plain'}
|
||||||
)
|
)
|
||||||
|
except exceptions.HttpError as ex:
|
||||||
|
self._raise_api_exception(ex.response)
|
||||||
|
|
||||||
if resp.status_code != 200:
|
if resp.status_code != 200:
|
||||||
self._raise_api_exception(resp)
|
self._raise_api_exception(resp)
|
||||||
|
@@ -15,6 +15,7 @@
|
|||||||
|
|
||||||
import six
|
import six
|
||||||
|
|
||||||
|
from keystoneauth1 import exceptions
|
||||||
from mistralclient.api import base
|
from mistralclient.api import base
|
||||||
from mistralclient import utils
|
from mistralclient import utils
|
||||||
|
|
||||||
@@ -36,11 +37,14 @@ class WorkflowManager(base.ResourceManager):
|
|||||||
# definition file
|
# definition file
|
||||||
definition = utils.get_contents_if_file(definition)
|
definition = utils.get_contents_if_file(definition)
|
||||||
|
|
||||||
|
try:
|
||||||
resp = self.http_client.post(
|
resp = self.http_client.post(
|
||||||
'/workflows?scope=%s&namespace=%s' % (scope, namespace),
|
'/workflows?scope=%s&namespace=%s' % (scope, namespace),
|
||||||
definition,
|
definition,
|
||||||
headers={'content-type': 'text/plain'}
|
headers={'content-type': 'text/plain'}
|
||||||
)
|
)
|
||||||
|
except exceptions.HttpError as ex:
|
||||||
|
self._raise_api_exception(ex.response)
|
||||||
|
|
||||||
if resp.status_code != 201:
|
if resp.status_code != 201:
|
||||||
self._raise_api_exception(resp)
|
self._raise_api_exception(resp)
|
||||||
@@ -57,11 +61,14 @@ class WorkflowManager(base.ResourceManager):
|
|||||||
# definition file
|
# definition file
|
||||||
definition = utils.get_contents_if_file(definition)
|
definition = utils.get_contents_if_file(definition)
|
||||||
|
|
||||||
|
try:
|
||||||
resp = self.http_client.put(
|
resp = self.http_client.put(
|
||||||
'%s?namespace=%s&scope=%s' % (url_pre, namespace, scope),
|
'%s?namespace=%s&scope=%s' % (url_pre, namespace, scope),
|
||||||
definition,
|
definition,
|
||||||
headers={'content-type': 'text/plain'}
|
headers={'content-type': 'text/plain'}
|
||||||
)
|
)
|
||||||
|
except exceptions.HttpError as ex:
|
||||||
|
self._raise_api_exception(ex.response)
|
||||||
|
|
||||||
if resp.status_code != 200:
|
if resp.status_code != 200:
|
||||||
self._raise_api_exception(resp)
|
self._raise_api_exception(resp)
|
||||||
@@ -126,11 +133,14 @@ class WorkflowManager(base.ResourceManager):
|
|||||||
# definition file
|
# definition file
|
||||||
definition = utils.get_contents_if_file(definition)
|
definition = utils.get_contents_if_file(definition)
|
||||||
|
|
||||||
|
try:
|
||||||
resp = self.http_client.post(
|
resp = self.http_client.post(
|
||||||
'/workflows/validate',
|
'/workflows/validate',
|
||||||
definition,
|
definition,
|
||||||
headers={'content-type': 'text/plain'}
|
headers={'content-type': 'text/plain'}
|
||||||
)
|
)
|
||||||
|
except exceptions.HttpError as ex:
|
||||||
|
self._raise_api_exception(ex.response)
|
||||||
|
|
||||||
if resp.status_code != 200:
|
if resp.status_code != 200:
|
||||||
self._raise_api_exception(resp)
|
self._raise_api_exception(resp)
|
||||||
|
Reference in New Issue
Block a user