Package ZenHub :: Module pbClient
[hide private]
[frames] | no frames]

Source Code for Module ZenHub.pbClient

 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  #! /usr/bin/python 
15   
16  from twisted.spread import pb 
17  from twisted.internet import reactor 
18  from twisted.cred import credentials 
19  from socket import getfqdn 
20   
21  import Globals 
22  from Products.ZenUtils.Driver import drive 
23  from Products.ZenEvents.Event import Event 
24   
25  from zenhub import PB_PORT 
26   
27 -def main():
28 def go(driver): 29 factory = pb.PBClientFactory() 30 reactor.connectTCP("localhost", PB_PORT, factory) 31 32 yield factory.login(credentials.UsernamePassword("zenoss", "zenoss")) 33 perspective = driver.next() 34 35 yield perspective.callRemote('getService', 'EventService', 'client1') 36 service = driver.next() 37 38 service.sendEvent(Event(device=getfqdn(), 39 summary="This is a test", 40 severity=5))
41 42 drive(go).addBoth(lambda x: reactor.stop()) 43 reactor.run() 44 45 if __name__ == '__main__': 46 main() 47