Showing correctly errors from API
-showing errors that API throw in stack-create action, there are lot of possible errors that needs to be exposed to the user -fixed worklow actions contributions to correct ones Change-Id: I0a352d0aac814864da1f40de05d1f91dc5ed9630
This commit is contained in:
parent
fb56f8e030
commit
31adbe7561
@ -210,10 +210,7 @@ class Overcloud(base.APIResourceWrapper):
|
||||
# state of all inner entities and operations correctly.
|
||||
# Then also delete the try/except, it should not be caught on this
|
||||
# level.
|
||||
try:
|
||||
return heat.stack_get(self._request, 'overcloud')
|
||||
except heatclient.exc.HTTPNotFound:
|
||||
return None
|
||||
return heat.stack_get(self._request, 'overcloud')
|
||||
|
||||
@cached_property
|
||||
def stack_events(self):
|
||||
|
@ -11,9 +11,9 @@
|
||||
# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
|
||||
# License for the specific language governing permissions and limitations
|
||||
# under the License.
|
||||
|
||||
from django.core import exceptions as django_exceptions
|
||||
from django.utils.translation import ugettext_lazy as _
|
||||
from horizon import exceptions
|
||||
|
||||
import horizon.workflows
|
||||
|
||||
from tuskar_ui import api
|
||||
@ -33,11 +33,14 @@ class Workflow(horizon.workflows.Workflow):
|
||||
success_url = 'horizon:infrastructure:overcloud:index'
|
||||
|
||||
def handle(self, request, context):
|
||||
success = True
|
||||
try:
|
||||
api.Overcloud.create(self.request, context['role_counts'],
|
||||
context['configuration'])
|
||||
except Exception:
|
||||
success = False
|
||||
exceptions.handle(request, _('Unable to start deployment.'))
|
||||
return success
|
||||
except Exception as e:
|
||||
# Showing error in both workflow tabs, because from the exception
|
||||
# type we can't recognize where it should show
|
||||
self.add_error_to_step(unicode(e), 'undeployed_overview')
|
||||
self.add_error_to_step(unicode(e), 'deployed_configuration')
|
||||
raise django_exceptions.ValidationError(unicode(e))
|
||||
|
||||
return True
|
||||
|
@ -260,12 +260,12 @@ class Action(horizon.workflows.Action):
|
||||
for name, data in parameters:
|
||||
self.fields[name] = make_field(name, **data)
|
||||
|
||||
def handle(self, request, context):
|
||||
context['configuration'] = self.cleaned_data
|
||||
return context
|
||||
|
||||
|
||||
class Step(horizon.workflows.Step):
|
||||
action_class = Action
|
||||
contributes = ('configuration',)
|
||||
template_name = 'infrastructure/overcloud/undeployed_configuration.html'
|
||||
|
||||
def contribute(self, data, context):
|
||||
context['configuration'] = data
|
||||
return context
|
||||
|
@ -90,16 +90,6 @@ class Action(horizon.workflows.Action):
|
||||
_("Can't deploy nodes without a node profile assigned."))
|
||||
return self.cleaned_data
|
||||
|
||||
def handle(self, request, context):
|
||||
counts = {}
|
||||
for key, value in self.cleaned_data.iteritems():
|
||||
if not key.startswith('count_'):
|
||||
continue
|
||||
count, role_id, profile = key.split('__', 2)
|
||||
counts[role_id, profile] = int(value)
|
||||
context['role_counts'] = counts
|
||||
return context
|
||||
|
||||
|
||||
class Step(horizon.workflows.Step):
|
||||
action_class = Action
|
||||
@ -110,3 +100,13 @@ class Step(horizon.workflows.Step):
|
||||
def get_free_nodes(self):
|
||||
"""Get the count of nodes that are not assigned yet."""
|
||||
return len(api.Node.list(self.workflow.request, False))
|
||||
|
||||
def contribute(self, data, context):
|
||||
counts = {}
|
||||
for key, value in data.iteritems():
|
||||
if not key.startswith('count_'):
|
||||
continue
|
||||
count, role_id, profile = key.split('__', 2)
|
||||
counts[role_id, profile] = int(value)
|
||||
context['role_counts'] = counts
|
||||
return context
|
||||
|
Loading…
x
Reference in New Issue
Block a user