示例#1
0
文件: cpu.py 项目: Amos-x/Operation
    def process(self):
        result = utils.get_info(self.token, self.tgt, 'grains')
        cpu_physical = utils.shell_exec_command(
            self.token, self.tgt,
            "cat /proc/cpuinfo | grep 'physical id' | sort | uniq | wc -l")
        response = {}
        for key in self.tgt:
            grains_items = result['return'][0].get(key)
            cpu_physical_num = cpu_physical['return'][0].get(key)
            if not grains_items and not cpu_physical_num:
                cpu_info = {
                    'status': False,
                    'message': 'salt-minion数据返回错误,可能是salt-key错误或salt-minon无法连接'
                }
            else:
                cpu_info = {
                    'status': True,
                    'cpu_arch': grains_items.get('cpuarch'),
                    'cpu_model': grains_items.get('cpu_model'),
                    'cpu_flags': grains_items.get('cpu_flags'),
                    'cpu_core_count': grains_items.get('num_cpus'),
                    'cpu_physical_num': cpu_physical_num,
                }
            response[key] = cpu_info

        return response
示例#2
0
文件: board.py 项目: Amos-x/Operation
    def process(self):
        result = utils.shell_exec_command(self.token, self.tgt, 'dmidecode -t2')
        response = {}
        for key in self.tgt:
            content = result['return'][0].get(key)
            if not content:
                info = {'status':False,'message':'salt-minion数据返回错误,可能是salt-key错误或salt-minon无法连接'}
            else:
                info = self.parse(content)
                info['status'] = True
            response[key] = info

        return response
示例#3
0
文件: disk.py 项目: Amos-x/Operation
    def process(self):
        result = utils.shell_exec_command(self.token, self.tgt, "fdisk -l |sed -n '2p' |awk '{print$3}'")
        response = {}
        for key in self.tgt:
            content = result['return'][0].get(key)
            if not content:
                disk_info = {'status': False, 'message':'salt-minion数据返回错误,可能是salt-key错误或salt-minon无法连接'}
            else:
                disk_info = {
                    'status': True,
                    'iface_type': 'SCSI',
                    'capacity': content
                }
            response[key] = disk_info

        return response