-
Notifications
You must be signed in to change notification settings - Fork 7
/
Copy pathsalt_out.py
22 lines (18 loc) · 5.38 KB
/
salt_out.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
#!/usr/bin/env python
# -*- coding: utf-8 -*-
# =============================================================================
# FileName: salt_out.py
# Desc: 2015-15/4/8:下午2:16
# Author: 苦咖啡
# Email: [email protected]
# HomePage: http://blog.kukafei520.net
# History:
# =============================================================================
s = {'fun_args': ['test'], 'jid': '20150408141422052250', 'return': {'file_|-/home/jm/logs_|-/home/jm/logs_|-directory': {'comment': 'No directory to create /home/jm/logs in', 'name': '/home/jm/logs', 'start_time': '14:12:12.475051', 'result': False, 'duration': 0.978, '__run_num__': 2, 'changes': {}}, 'pkg_|-jm-diamond_|-jm-diamond-client_|-installed': {'comment': 'An exception occurred in this state: Traceback (most recent call last):\n File "/usr/lib/python2.6/site-packages/salt/state.py", line 1554, in call\n **cdata[\'kwargs\'])\n File "/usr/lib/python2.6/site-packages/salt/states/pkg.py", line 833, in installed\n **kwargs)\n File "/usr/lib/python2.6/site-packages/salt/states/pkg.py", line 309, in _find_install_targets\n problems = _preflight_check(desired, **kwargs)\n File "/usr/lib/python2.6/site-packages/salt/states/pkg.py", line 455, in _preflight_check\n *list(desired.keys()), fromrepo=fromrepo, **kwargs\n File "/usr/lib/python2.6/site-packages/salt/modules/yumpkg.py", line 584, in check_db\n query_format=\'%{NAME}_|-%{ARCH}\'\n File "/usr/lib/python2.6/site-packages/salt/modules/yumpkg.py", line 154, in _repoquery\n \'{0}\'.format(comment)\nCommandExecutionError: Traceback (most recent call last):\n File "/usr/bin/repoquery", line 1241, in <module>\n main(sys.argv)\n File "/usr/bin/repoquery", line 1235, in main\n repoq.runQuery(regexs)\n File "/usr/bin/repoquery", line 805, in runQuery\n pkgs = self.matchPkgs(items, plain_pkgs=plain_pkgs)\n File "/usr/bin/repoquery", line 742, in matchPkgs\n pkgs = self.returnPkgList(patterns=items)\n File "/usr/bin/repoquery", line 700, in returnPkgList\n ygh = self.doPackageLists(what, **kwargs)\n File "/usr/lib/python2.6/site-packages/yum/__init__.py", line 2276, in doPackageLists\n avail = self.pkgSack.returnNewestByNameArch(patterns=patterns,\n File "/usr/lib/python2.6/site-packages/yum/__init__.py", line 883, in <lambda>\n pkgSack = property(fget=lambda self: self._getSacks(),\n File "/usr/lib/python2.6/site-packages/yum/__init__.py", line 668, in _getSacks\n self.repos.populateSack(which=repos)\n File "/usr/lib/python2.6/site-packages/yum/repos.py", line 294, in populateSack\n sack.populate(repo, mdtype, callback, cacheonly)\n File "/usr/lib/python2.6/site-packages/yum/yumRepo.py", line 164, in populate\n if self._check_db_version(repo, mydbtype):\n File "/usr/lib/python2.6/site-packages/yum/yumRepo.py", line 222, in _check_db_version\n return repo._check_db_version(mdtype)\n File "/usr/lib/python2.6/site-packages/yum/yumRepo.py", line 1263, in _check_db_version\n repoXML = self.repoXML\n File "/usr/lib/python2.6/site-packages/yum/yumRepo.py", line 1462, in <lambda>\n repoXML = property(fget=lambda self: self._getRepoXML(),\n File "/usr/lib/python2.6/site-packages/yum/yumRepo.py", line 1454, in _getRepoXML\n self._loadRepoXML(text=self)\n File "/usr/lib/python2.6/site-packages/yum/yumRepo.py", line 1444, in _loadRepoXML\n return self._groupLoadRepoXML(text, self._mdpolicy2mdtypes())\n File "/usr/lib/python2.6/site-packages/yum/yumRepo.py", line 1419, in _groupLoadRepoXML\n if self._commonLoadRepoXML(text):\n File "/usr/lib/python2.6/site-packages/yum/yumRepo.py", line 1240, in _commonLoadRepoXML\n self._revertOldRepoXML()\n File "/usr/lib/python2.6/site-packages/yum/yumRepo.py", line 1090, in _revertOldRepoXML\n os.rename(old_data[\'old_local\'], old_data[\'local\'])\nOSError: [Errno 2] No such file or directory\n', 'name': 'jm-diamond-client', 'start_time': '14:12:12.481598', 'result': False, 'duration': 31944.605, '__run_num__': 6, 'changes': {}}, 'file_|-/home/jm/www_|-/home/jm/www_|-directory': {'comment': 'No directory to create /home/jm/www in', 'name': '/home/jm/www', 'start_time': '14:12:12.480473', 'result': False, 'duration': 0.893, '__run_num__': 5, 'changes': {}}, 'file_|-/home/jm/data_|-/home/jm/data_|-directory': {'comment': 'No directory to create /home/jm/data in', 'name': '/home/jm/data', 'start_time': '14:12:12.476208', 'result': False, 'duration': 0.875, '__run_num__': 3, 'changes': {}}, 'file_|-/etc/pam.d/su_|-/etc/pam.d/su_|-managed': {'comment': 'Source file salt://file/su.sls not found', 'name': '/etc/pam.d/su', 'start_time': '14:12:12.477256', 'result': False, 'duration': 3.018, '__run_num__': 4, 'changes': {}}, 'user_|-www-user_|-www_|-present': {'comment': 'User www is present and up to date', 'name': 'www', 'start_time': '14:12:12.472100', 'result': True, 'duration': 2.78, '__run_num__': 1, 'changes': {}}, 'group_|-www-user_|-www_|-present': {'comment': 'Group www is present and up to date', 'name': 'www', 'start_time': '14:12:12.471103', 'result': True, 'duration': 0.807, '__run_num__': 0, 'changes': {}}}, 'retcode': 2, 'success': True, 'cmd': '_return', '_stamp': '2015-04-08T14:15:06.217887', 'fun': 'state.sls', 'id': 'salt_test', 'out': 'highstate'}
from salt.output import display_output
opts={'extension_modules': '',
'color': True,
'state_verbose': True,
}
data = display_output(s["return"], "highstate", opts=opts)
print data