Esempio n. 1
0
    def __init__(self, config):
        self.state = 'unconfigured'
        config.set_var({'identity' : Identity().id})
        config.save()

        self.vmadapter = vmadapter.VmKVM()
        config.set_var({'vmhostdefinitions': self.vmadapter.ls()})
        config.save()
        #mlog(" [%s] Loaded config:\n"% (self.logkey,) , simplejson.dumps(config.config, indent=4, sort_keys=True))
        AmqpBase.__init__(self, config)
Esempio n. 2
0
    def __init__(self, config):
        StateEngine.__init__(self, {
            'ev_amqpready': {
                '*': {},
                'unconfigured': {'nextstate':'ready'},
            },
            'ev_request_uuid': {
                '*': {},
                'ready': {
                    'nextstate':'request_uuid',
                    'cmd': [
                        (0, self.send_message, [], {'routing_key':'worker_request_uuid.metal'})
                    ],
                    'timeout': 6
                },
            },
            'request_uuid_timeout': {
                '*':{ 'nextstate':'ready' }
            },
            'ev_configured': {
                '*': {
                    'nextstate':'configured',
                    'cmd': [
                        (0, self.cmd_send_alive),
                        (2, self.event, ['ev_request_job'])
                    ]
                },
            },
            'ev_request_job': {
                '*': {'cmd':lambda :warning("ev_request_job while", self.state)},
                'configured': {
                    'nextstate':'request_job', 
                    'cmd': (0, self.send_message, [], {'routing_key':'worker_requests_job.hub'}),
                    'timeout': self.request_job_timeout
                }
            },
            'request_job_timeout': {
                '*': {},
                'request_job': {
                    'nextstate':'configured',
                    'cmd': (0.1, self.event, ['ev_request_job'])
                }
            },
            'ev_got_job': {
                'request_job': {
                    'nextstate':'got_job'
                }
            }
        }, 'unconfigured')

        self.uuid = None
        self.identity = Identity()

        config.set_var({'identity' : self.identity.id})
        config.save()

        for hwaddr in self.identity.id['hwaddrlist']:
            self.routing_key.append("*.%s"%hwaddr)

        try:
            self.uuid = config.config['var']['uuid']
            self.routing_key.append("*.%s"%self.uuid)
        except KeyError:
            self.uuid = None

        AmqpBase.__init__(self, config)
Esempio n. 3
0
 def on_connected(self, connection):
     self.heartbeat = IntervalScheduler(connection, callback=self.tick, interval=60)
     AmqpBase.on_connected(self, connection)