1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
|
#coding=utf-8
import os
import sys
import syslog
import subprocess
import time
import re
import logging
import logging.handlers
from common_system_cmd import *
from common_logger import *
from common_json import *
from common_modules_deploy import *
# coding: utf-8
#此文件定义四块计算板分别运行什么模块
#先根据tsg_chassis_ip.json, 根据当前设备的ip地址, 知道当前设备的sled名称
#然后根据设备类型名称, 找到当前运行的所有模块(应用)名称
#然后根据模块名称, 到common_modules_operator.json查找每个模块的操作方法
#{
# "modules_deploy": {
# "mcn0": ["kni", "a.out"],
# "mcn1": ["tfe", "a1.out"],
# "mcn2": ["tfe", "a2.out"],
# "mcn3": ["tfe", "a3.out"]
# }
#}
G_MODULE_DEPLOY_JSON = "/opt/tsg/etc/tsg_module_deploy.json"
#返回当前板卡运行的所有模块, 数组形式
def tsg_get_local_sled_modules(sled_name):
ret, err_msg, json_dict = tsg_json_parse(G_MODULE_DEPLOY_JSON)
if ret != 0:
return {}
module_list = json_dict['modules_deploy']
if len(module_list) <= 0:
return {}
return module_list[sled_name]
if __name__ == '__main__':
global logger
logger = logger_init(10)
module_list = tsg_get_local_sled_modules("mcn0")
print(module_list)
|