dashboard.py 1.2 KB

123456789101112131415161718192021222324252627282930313233343536
  1. #!/usr/bin/env python
  2. # -*- coding: utf-8 -*-
  3. import json
  4. from flask import Blueprint, render_template, url_for, request
  5. import requests
  6. __author__ = 'James Iter'
  7. __date__ = '2017/8/17'
  8. __contact__ = 'james.iter.cn@gmail.com'
  9. __copyright__ = '(c) 2017 by James Iter.'
  10. blueprint = Blueprint(
  11. 'v_dashboard',
  12. __name__,
  13. url_prefix='/'
  14. )
  15. def show():
  16. url = url_for('api_dashboard.r_show', _external=True)
  17. ret = requests.get(url=url, cookies=request.cookies)
  18. ret = json.loads(ret.content)
  19. return render_template('dashboard.html', hosts_sum=ret['data']['hosts_sum'],
  20. guests_distribute_count_ret=ret['data']['guests_distribute_count_ret'],
  21. disks_distribute_count_ret=ret['data']['disks_distribute_count_ret'],
  22. guests_current_top_10_ret=ret['data']['guests_current_top_10_ret'],
  23. guests_mapping_by_uuid=ret['data']['guests_mapping_by_uuid'],
  24. disks_mapping_by_uuid=ret['data']['disks_mapping_by_uuid'],
  25. hosts_current_top_10_ret=ret['data']['hosts_current_top_10_ret'],
  26. hosts_mapping_by_node_id=ret['data']['hosts_mapping_by_node_id'])