Choose an approppriate image upon stack failure

The get_app_image function was always choosing
'dashboard/img/stack-green.svg', regardless of the actual status of the
stack. Adding some logic to choose green, red or gray depending on the
status. Also, set as default the 'status' argument to None, since this
function is used on another completely different context

Change-Id: Ifab532ee4706038c85f76061eca85238d0d19be1
Closes-Bug: #1467246
This commit is contained in:
Juan Manuel Santos 2015-07-21 16:20:58 +02:00
parent 39bdff2354
commit 5e793fb0cd
1 changed files with 12 additions and 3 deletions

View File

@ -23,9 +23,17 @@ from muranodashboard.api import packages as pkg_cli
from muranodashboard.environments import consts
def get_app_image(request, app_fqdn):
def get_app_image(request, app_fqdn, status=None):
package = pkg_cli.app_by_fqn(request, app_fqdn)
url = static('dashboard/img/stack-green.svg')
if status in [
consts.STATUS_ID_DEPLOY_FAILURE,
consts.STATUS_ID_DELETE_FAILURE,
]:
url = static('dashboard/img/stack-red.svg')
elif status == consts.STATUS_ID_READY:
url = static('dashboard/img/stack-green.svg')
else:
url = static('dashboard/img/stack-gray.svg')
if package:
app_id = package.id
url = reverse("horizon:murano:catalog:images", args=(app_id,))
@ -256,7 +264,8 @@ def render_d3_data(request, environment):
required_by = ext_net_name
service_node = _create_empty_node()
service_image = get_app_image(request, service['?']['type'])
service_image = get_app_image(request, service['?']['type'],
service['?']['status'])
node_id = service['?']['id']
node_refs[node_id] = service_node
service_node.update({