def allocate_domains(): # Create drones drones.build_all_drones() # Setup initial allocation if start: import allocate_domains allocate_domains.allocate_domains(True, controller) # Add host for i in xrange(0, 18): hosts.add_host('target%i' % i, 'target') hosts.add_host('target%i' % i, 'database') hosts.add_host('load0', 'load') hosts.add_host('load1', 'load') # Connect with all drone relays hosts_map = hosts.get_hosts_list() dlist = base.connect(hosts_map) # Wait for all connections wait = defer.DeferredList(dlist) wait.addErrback(errback) # Decide what to do after connection setup if start: print 'starting system ...' wait.addCallback(start_phase) else: print 'stopping system ...' wait.addCallback(stop_phase) # Start the Twisted reactor reactor.run()
def action(self): # Create drones drones.build_all_drones() # Add host for i in xrange(0, 18): hosts.add_host('target%i' % i, 'target') hosts.add_host('target%i' % i, 'database') hosts.add_host('load0', 'load') hosts.add_host('load1', 'load') # Connect with all drone relays hosts_map = hosts.get_hosts_list() dlist = base.connect(hosts_map) # Wait for all connections wait = defer.DeferredList(dlist) d = defer.Deferred() wait.addCallback(self.start_phase, d) return d