Просмотр исходного кода

计算节点主机展现列表实现按启动时间进行排序

James Iter 8 лет назад
Родитель
Сommit
09b2c0983f
4 измененных файлов с 12 добавлено и 2 удалено
  1. 1 1
      README.md
  2. 9 0
      api/host.py
  3. 1 0
      models/event_processor.py
  4. 1 1
      views/guest.py

+ 1 - 1
README.md

@@ -23,7 +23,7 @@
     - [[过滤器操作符原语](docs/filter_primitive.md)](#过滤器操作符原语)
     - [[状态列表](docs/enum.md)](#状态列表)
     - [[配置](docs/config.md)](#配置)
-    - [[实例初始化操作簇](docs/os_init.md)](#实例初始化操作簇)
+    - [[实例初始化操作簇](docs/boot_job.md)](#实例初始化操作簇)
     - [[系统模板](docs/os_template.md)](#系统模板)
     - [[Guest](docs/guest.md)](#guest)
     - [[磁盘](docs/disk.md)](#磁盘)

+ 9 - 0
api/host.py

@@ -60,6 +60,9 @@ def r_get(nodes_id):
                     v['node_id'] = node_id
                     ret['data'].append(v)
 
+            if ret['data'].__len__() > 1:
+                ret['data'].sort(key=lambda _k: _k['boot_time'])
+
         return ret
 
     except ji.PreviewingError, e:
@@ -79,6 +82,9 @@ def r_get_by_filter():
             v['node_id'] = k
             ret['data'].append(v)
 
+        if ret['data'].__len__() > 1:
+            ret['data'].sort(key=lambda _k: _k['boot_time'])
+
         return ret
 
     except ji.PreviewingError, e:
@@ -107,6 +113,9 @@ def r_content_search():
                 v['node_id'] = k
                 ret['data'].append(v)
 
+        if ret['data'].__len__() > 1:
+            ret['data'].sort(key=lambda _k: _k['boot_time'])
+
         return ret
 
     except ji.PreviewingError, e:

+ 1 - 0
models/event_processor.py

@@ -119,6 +119,7 @@ class EventProcessor(object):
             'memory_available': cls.message['message']['memory_available'],
             'interfaces': cls.message['message']['interfaces'],
             'disks': cls.message['message']['disks'],
+            'boot_time': cls.message['message']['boot_time'],
             'timestamp': ji.Common.ts()
         }
 

+ 1 - 1
views/guest.py

@@ -125,7 +125,7 @@ def create():
         if not isinstance(ability, basestring):
             pass
 
-        m = re.search('^(\d)c(\d)g$', ability.lower())
+        m = re.search('^(\d+)c(\d+)g$', ability.lower())
         if m is None:
             pass