Using status information to populate "Available minions" instead of using grains list.
This fixes the occurences where servers disappear because they are down on the grains call and up on the status call as calls are not transactional.
This commit is contained in:
parent
6d443d362a
commit
74b3534388
2 changed files with 22 additions and 4 deletions
|
@ -49,15 +49,15 @@ class Inventorizer:
|
|||
|
||||
def collectHostData(self):
|
||||
self.keys_list = self.saltwhe.cmd('key.list_all', [], {}, {})
|
||||
self.host_list = self.saltcmd.cmd('*', 'grains.items')
|
||||
self.stat_list = self.saltrun.cmd('manage.status')
|
||||
self.grains_list = self.saltcmd.cmd('*', 'grains.items')
|
||||
self.jobs_list = self.saltrun.cmd('jobs.list_jobs')
|
||||
|
||||
def createHostList(self):
|
||||
fo = open(self.config['base_path'] + "index.html", "wb")
|
||||
env = Environment(loader = FileSystemLoader(config['template_path']))
|
||||
template = env.get_template('hostlist_template.html')
|
||||
fo.write(template.render({'hostlist': self.host_list, 'statlist': self.stat_list, 'keylist': self.keys_list, 'joblist': self.jobs_list, 'now' : time.strftime('%Y-%m-%d %H:%M:%S')}))
|
||||
fo.write(template.render({'grainlist': self.grains_list, 'statlist': self.stat_list, 'keylist': self.keys_list, 'joblist': self.jobs_list, 'now' : time.strftime('%Y-%m-%d %H:%M:%S')}))
|
||||
fo.close
|
||||
|
||||
def lenFilter(self, list):
|
||||
|
|
|
@ -43,7 +43,9 @@
|
|||
</tr>
|
||||
</thead>
|
||||
<tbody>
|
||||
{% for name, data in hostlist.iteritems() %}
|
||||
{% for name in statlist['up'] %}
|
||||
{% if name in grainlist %}
|
||||
{% set data = grainlist[name] %}
|
||||
<tr>
|
||||
<td>
|
||||
<button type="button" class="btn btn-info" data-toggle="modal" data-target="#{{ name.translate(None, '.') }}">
|
||||
|
@ -58,6 +60,22 @@
|
|||
<td class="right number hidden-xs hidden-sm">{{ data.mem_total }}</td>
|
||||
<td>{{ data.saltversion }}</td>
|
||||
</tr>
|
||||
{% else %}
|
||||
<tr>
|
||||
<td>
|
||||
<button class="btn btn-danger" class="btn btn-info">
|
||||
<span class="glyphicon glyphicon-ban-circle" aria-hidden="true"></span>
|
||||
</button>
|
||||
<span class="glyphicon glyphicon-ban-circle" aria-hidden="true"></span>
|
||||
{{ name }}
|
||||
</td>
|
||||
<td class="hidden-xs hidden-sm" style="white-space: nowrap"></td>
|
||||
<td></td>
|
||||
<td></td>
|
||||
<td class="right number hidden-xs hidden-sm"></td>
|
||||
<td></td>
|
||||
</tr>
|
||||
{% endif %}
|
||||
{% endfor %}
|
||||
</tbody>
|
||||
<tfoot>
|
||||
|
@ -148,7 +166,7 @@
|
|||
</div>
|
||||
</div>
|
||||
|
||||
{% for name, data in hostlist.iteritems() %}
|
||||
{% for name, data in grainlist.iteritems() %}
|
||||
<div class="modal" id="{{ name.translate(None, '.') }}" tabindex="-1" role="dialog" aria-labelledby="myModalLabel">
|
||||
<div class="modal-dialog modal-lg" role="document">
|
||||
<div class="modal-content">
|
||||
|
|
Reference in a new issue