config.py 1.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657
  1. #!/usr/bin/env python
  2. # -*- coding: utf-8 -*-
  3. from jimvc.models import app_config
  4. from jimvc.models import Database as db
  5. from jimvc.models import ORM
  6. from jimvc.models import status
  7. __author__ = 'James Iter'
  8. __date__ = '2017/3/21'
  9. __contact__ = 'james.iter.cn@gmail.com'
  10. __copyright__ = '(c) 2017 by James Iter.'
  11. class Config(ORM):
  12. _table_name = 'config'
  13. _primary_key = 'id'
  14. def __init__(self):
  15. super(Config, self).__init__()
  16. # 配置条目的 id 只会是 1
  17. self.id = 1
  18. self.jimv_edition = status.JimVEdition.standalone.value
  19. self.storage_mode = status.StorageMode.local.value
  20. self.dfs_volume = ''
  21. self.storage_path = ''
  22. self.vm_network = ''
  23. self.vm_manage_network = ''
  24. self.iops_base = 0
  25. self.iops_pre_unit = 0
  26. self.iops_cap = 0
  27. self.iops_max = 0
  28. self.iops_max_length = 0
  29. self.bps_base = 0
  30. self.bps_pre_unit = 0
  31. self.bps_cap = 0
  32. self.bps_max = 0
  33. self.bps_max_length = 0
  34. @staticmethod
  35. def get_filter_keywords():
  36. return {}
  37. @staticmethod
  38. def get_allow_update_keywords():
  39. return []
  40. @staticmethod
  41. def get_allow_content_search_keywords():
  42. return []
  43. def update_global_config(self):
  44. db.r.hmset(app_config['global_config'], self.__dict__)