Package ZenHub :: Package services :: Module WmiConfig
[hide private]
[frames] | no frames]

Source Code for Module ZenHub.services.WmiConfig

  1  ########################################################################### 
  2  # 
  3  # This program is part of Zenoss Core, an open source monitoring platform. 
  4  # Copyright (C) 2007, Zenoss Inc. 
  5  # 
  6  # This program is free software; you can redistribute it and/or modify it 
  7  # under the terms of the GNU General Public License version 2 as published by 
  8  # the Free Software Foundation. 
  9  # 
 10  # For complete information please visit: http://www.zenoss.com/oss/ 
 11  # 
 12  ########################################################################### 
 13   
 14  __doc__='''WmiService 
 15   
 16  Provides Wmi config to zenwin clients. 
 17  ''' 
 18   
 19  from Products.ZenHub.HubService import HubService 
 20  from Products.DataCollector.ApplyDataMap import ApplyDataMap 
 21  from Products.ZenModel.Device import Device 
 22  from Products.ZenModel.DeviceClass import DeviceClass 
 23   
 24  from Procrastinator import Procrastinate 
 25   
26 -class WmiConfig(HubService):
27
28 - def __init__(self, dmd, instance):
29 HubService.__init__(self, dmd, instance) 30 self.config = self.dmd.Monitors.Performance._getOb(self.instance) 31 self.procrastinator = Procrastinate(self.push)
32
33 - def remote_getDeviceWinInfo(self):
34 """Return list of (devname,user,passwd,url) for each device. 35 user and passwd are used to connect via wmi. 36 """ 37 38 devinfo = [] 39 for dev in self.config.devices(): 40 dev = dev.primaryAq() 41 if not dev.monitorDevice(): continue 42 if getattr(dev, 'zWmiMonitorIgnore', False): continue 43 user = getattr(dev,'zWinUser','') 44 passwd = getattr(dev, 'zWinPassword', '') 45 sev = getattr(dev, 'zWinEventlogMinSeverity', '') 46 devinfo.append((dev._lastChange, 47 dev.id, 48 dev.getManageIp(), 49 str(user), 50 str(passwd), 51 sev, 52 dev.absolute_url())) 53 return devinfo
54 55
56 - def remote_getWinServices(self):
57 """Return a list of (devname, user, passwd, {'EvtSys':0,'Exchange':0}) 58 """ 59 svcinfo = [] 60 allsvcs = {} 61 for dev in self.config.devices(): 62 dev = dev.primaryAq() 63 if not dev.monitorDevice(): continue 64 if getattr(dev, 'zWmiMonitorIgnore', False): continue 65 svcs = {} 66 for s in dev.getMonitoredComponents(type='WinService'): 67 name = s.name() 68 if type(name) == type(u''): 69 name = name.encode(s.zCollectorDecoding) 70 svcs[name] = (s.getStatus(), s.getAqProperty('zFailSeverity')) 71 if not svcs and not dev.zWinEventlog: continue 72 user = getattr(dev,'zWinUser','') 73 passwd = getattr(dev, 'zWinPassword', '') 74 svcinfo.append((dev.id, dev.getManageIp(), str(user), str(passwd), svcs)) 75 return svcinfo
76 77
78 - def remote_getConfig(self):
79 return self.config.propertyItems()
80
81 - def remote_applyDataMap(self, 82 url, 83 datamap, 84 relname="", 85 compname="", 86 modname=""):
87 dev = self.dmd.getObjByPath(url) 88 adm = ApplyDataMap() 89 result = adm.applyDataMap(dev, 90 datamap, 91 relname=relname, 92 compname=compname, 93 modname=modname) 94 import transaction 95 transaction.commit() 96 return result
97
98 - def update(self, object):
99 if isinstance(object, DeviceClass): 100 objects = object.getSubDevices() 101 else: 102 objects = [object] 103 for object in objects: 104 if not isinstance(object, Device): 105 continue 106 self.procrastinator.doLater(object)
107
108 - def push(self, object):
109 if (not object.monitorDevice() or 110 getattr(object, 'zWmiMonitorIgnore', False)): 111 self.deleted(object) 112 else: 113 for listener in self.listeners: 114 listener.callRemote('notifyConfigChanged') 115 self.procrastinator.clear()
116
117 - def deleted(self, obj):
118 for listener in self.listeners: 119 if isinstance(obj, Device): 120 listener.callRemote('deleteDevice', obj.id)
121