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
#!/usr/bin/env python
#-*-coding:UTF-8-*-
"""
@Item   :  Soceet daemon
@Author :  william
@Group  :  DEV Group
@Date   :  2013-10-16
@Funtion:
"""
import  os,sys
import  socket,json
class  state( object ):
def  __init__ ( self ):
self .host  =  '172.16.15.112'
self .port  =  10086
self .addr  =  ( self .host, self .port)
self .buf  =  2048
def  Send( self ,mess):
try :
self .sock = socket.socket(socket.AF_INET,socket.SOCK_STREAM)
self .sock.setsockopt(socket.SOL_SOCKET,socket.SO_REUSEADDR, 1 )
self .sock.setblocking( True )
self .sock.connect( self .addr)
self .sock.send(mess)
data  =  self .sock.recv( self .buf)
print  data
self .sock.close()
except  socket.timeout,e:
print  e
if  __name__  = =  "__main__" :
st  =  state()
=  dict ()
import  libvirt
conn  =  libvirt. open ( None )
domainsID  =  conn.listDomainsID()
for  ids  in  domainsID:
uuid  =  conn.lookupByID(ids).UUIDString()
a[ "Node" =  { "IP" : "172.16.15.1" , "UUID" :uuid}
mes  =  json.dumps(a)
st.Send(mes)