/usr/lib/python2.7/dist-packages/txwinrm/winrm.py is in python-txwinrm 1.3.3-1.
This file is owned by root:root, with mode 0o644.
The actual contents of the file can be viewed below.
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 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 | ##############################################################################
#
# Copyright (C) Zenoss, Inc. 2013, all rights reserved.
#
# This content is made available according to terms specified in the LICENSE
# file at the top-level directory of this package.
#
##############################################################################
"""
Use twisted web client to enumerate/pull WQL query.
"""
import sys
from twisted.internet import defer
from . import app
from .WinRMClient import EnumerateClient
class WinrmStrategy(object):
def __init__(self):
self._item_count = 0
@property
def count_summary(self):
return '{0} items'.format(self._item_count)
def _print_items(self, items, hostname, wql, include_header):
if include_header:
print '\n', hostname, "==>", wql
indent = ' '
else:
indent = ''
is_first_item = True
for item in items:
if is_first_item:
is_first_item = False
else:
print '{0}{1}'.format(indent, '-' * 4)
for name, value in vars(item).iteritems():
self._item_count += 1
text = value
if isinstance(value, list):
text = ', '.join(value)
print '{0}{1} = {2}'.format(indent, name, text)
def act(self, good_conn_infos, args, config):
include_header = len(config.conn_infos) > 1
ds = []
for conn_info in good_conn_infos:
client = EnumerateClient(conn_info)
for wql in config.wqls:
d = client.enumerate(wql)
d.addCallback(
self._print_items, conn_info.hostname, wql, include_header)
ds.append(d)
return defer.DeferredList(ds, consumeErrors=True)
class WinrmUtility(app.ConfigDrivenUtility):
def add_args(self, parser):
parser.add_argument("--filter", "-f")
def check_args(self, args):
legit = args.config or args.filter
if not legit:
print >>sys.stderr, "ERROR: You must specify a config file with " \
"-c or specify a WQL filter with -f"
return legit
def add_config(self, parser, config):
config.wqls = parser.options('wqls')
def adapt_args_to_config(self, args, config):
config.wqls = [args.filter]
if __name__ == '__main__':
app.main(WinrmUtility(WinrmStrategy()))
|