dashboard.py 1.2 KB

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