Statistics
| Branch: | Tag: | Revision:

root / db / DBController.py @ c99fe4c7

History | View | Annotate | Download (968 Bytes)

1
#
2
# Bill Allocator - Administration script
3
#
4
# Run all the time, and wait for messages from ganeti, then update the database
5
#
6
# Copyright 2010 Greek Research and Technology Network
7
#
8

    
9
import zmq
10

    
11
from db.models import *
12

    
13
#GANETI_ZMQ_PUBLISHER = "tcp://ganeti-master:5801"
14

    
15
def init_publisher(context):
16
    request = context.socket(zmq.REQ)
17
    request.connect('tcp://127.0.0.1:6666')
18
    request.send('hello')
19
    
20
    message = request.recv()
21

    
22
def main():
23
    context = zmq.Context()
24
    
25
    subscriber = context.socket(zmq.SUB)
26
    subscriber.connect('tcp://127.0.0.1:5801')
27
    
28
    # accept all messages
29
    subscriber.setsockopt(zmq.IDENTITY, "DBController")
30
    subscriber.setsockopt(zmq.SUBSCRIBE, '')
31
    
32
    init_publisher(context)
33
    
34
    while True:
35
        message = sock.recv()
36
        
37
        # do something
38
        if message == 'start':
39
            print "start"
40
        elif message == 'stop':
41
            print "stop"
42
    
43
    subscriber.close()