Skip to content
This repository has been archived by the owner on Apr 6, 2024. It is now read-only.

Commit

Permalink
Identify orchestration runs
Browse files Browse the repository at this point in the history
refs #3
  • Loading branch information
ipmb committed Jan 31, 2018
1 parent d75ad08 commit 1aea454
Show file tree
Hide file tree
Showing 3 changed files with 14 additions and 7 deletions.
16 changes: 11 additions & 5 deletions saltdash/dash/models.py
Original file line number Diff line number Diff line change
Expand Up @@ -137,16 +137,18 @@ def return_val_as_json(self) -> str:
@property
def result_type(self) -> str:
if isinstance(self.return_val, dict):
if self.return_val.get('fun') == 'runner.state.orchestrate':
return 'orchestrate'
try:
__ = list(self.return_val.values())[0]['__sls__']
list(self.return_val.values())[0]['__sls__']
return 'state'
except (TypeError, IndexError, KeyError):
return 'json'
return 'text'

@property
def is_state(self) -> bool:
return self.result_type == 'state'
def has_states(self) -> bool:
return self.result_type in ['state', 'orchestrate']

def states_with_status(self, status: str) -> int:
return len([s for s in self.states if s['status'] == status])
Expand All @@ -169,9 +171,13 @@ def states_unchanged(self) -> int:

@cached_property
def states(self) -> list:
if self.result_type != 'state':
if self.result_type == 'state':
state_dict = self.return_val
elif self.result_type == 'orchestrate':
state_dict = list(self.return_val['return']['data'].values())[0]
else:
raise TypeError("Return must be for a state")
sorted_run = sorted(self.return_val.items(),
sorted_run = sorted(state_dict.items(),
key=lambda s: s[1]['__run_num__'])
return [_convert_state(*args) for args in sorted_run]

Expand Down
4 changes: 2 additions & 2 deletions saltdash/templates/dash/_result_card.html
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
class="float-right ml-1 badge badge-{% if result.was_success %}success{% else %}danger{% endif %}">
{% if result.was_success %}√{% else %}x{% endif %}
</a>
{% if result.is_state %}
{% if result.has_states %}
<code class="float-right small text-muted">{{ result.duration|pretty_time }}</code>
{% endif %}

Expand All @@ -18,7 +18,7 @@ <h4 class="card-title">
{% include "dash/_job_summary.html" with job=result.job %}
{% endif %}

{% if result.is_state %}
{% if result.has_states %}
{% if result.states_failed > 0 %}
<a href="#"
data-toggle="collapse-optimized"
Expand Down
1 change: 1 addition & 0 deletions saltdash/templates/dash/_results/orchestrate.html
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
{% extends "dash/_results/state.html" %}

0 comments on commit 1aea454

Please sign in to comment.