/usr/lib/python2.7/dist-packages/txwinrm/associate.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 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 | ##############################################################################
#
# 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.
#
##############################################################################
import logging
from twisted.internet import defer
from WinRMClient import AssociatorClient
from .util import (
ConnectionInfo,
)
log = logging.getLogger('winrm')
# for use with seed_class of Win32_NetworkAdapter
interface_map = [{'return_class': 'Win32_PnPEntity',
'search_class': 'win32_NetworkAdapter',
'search_property': 'DeviceID',
'where_type': 'ResultClass'
}]
# for use with seed_class of Win32_DiskDrive
disk_map = [{'return_class': 'Win32_DiskDriveToDiskPartition',
'search_class': 'Win32_DiskDrive',
'search_property': 'DeviceID',
'where_type': 'AssocClass'},
{'return_class': 'Win32_LogicalDiskToPartition',
'search_class': 'Win32_DiskPartition',
'search_property': 'DeviceID',
'where_type': 'AssocClass'
}]
class WinrmAssociatorClient(object):
@defer.inlineCallbacks
def do_associate(self, conn_info):
"""
"""
client = AssociatorClient(conn_info)
items = {}
items = yield client.associate(
'Win32_DiskDrive',
disk_map
)
defer.returnValue(items)
# ----- An example of usage...
if __name__ == '__main__':
from pprint import pprint
import logging
from twisted.internet import reactor
logging.basicConfig()
winrm = WinrmAssociatorClient()
# Enter your params here before running
params = {
'hostname': "", # name of host
'authtype': "", # kerberos or basic
'user': "", # username
'password': "", # password
'kdc': "", # kdc address
'ipaddress': "" # ip address
}
''' Remove this line and line at the end to run test
@defer.inlineCallbacks
def do_example_collect():
connectiontype = 'Keep-Alive'
conn_info = ConnectionInfo(
params['hostname'],
params['authtype'],
params['user'],
params['password'],
"http",
5985,
connectiontype,
"",
params['kdc'],
ipaddress=params['ipaddress'])
items = yield winrm.do_associate(conn_info)
pprint(items)
pprint(items.keys())
reactor.stop()
reactor.callWhenRunning(do_example_collect)
reactor.run()
Remove this line to execute above code'''
|