def haproxy(fs_root, config): """Run Treadmill HAProxy""" # keep sleeping until zksync ready zksync_utils.wait_for_ready(fs_root) # TODO: implment config creation by iterating over fs-root/app-groups. # We would get all app-groups, then add a frontend and backend for # each lbendpoint for this cell's region. Of course this would be # abstracted into treamdill.haproxy. subproc.safe_exec(['haproxy', '-f', config])
def gmsa_sync(fs_root, partition, group_ou, group_pattern, no_lock): """Sync placements GMSA groups.""" # keep sleeping until zksync ready zksync_utils.wait_for_ready(fs_root) watch = gmsa.HostGroupWatch(fs_root, partition, group_ou, group_pattern) if not no_lock: lock = zkutils.make_lock(context.GLOBAL.zk.conn, z.path.election(__name__)) _LOGGER.info('Waiting for leader lock.') with lock: watch.run() else: _LOGGER.info('Running without lock.') watch.run()
def websocket(fs_root, modules, port): """Treadmill Websocket""" _LOGGER.debug('port: %s', port) # keep sleeping until zksync ready zksync_utils.wait_for_ready(fs_root) impl, watches = {}, [] for topic, topic_impl, topic_watches in api.init(modules): impl[topic] = topic_impl watches.extend(topic_watches) pubsub = ws.DirWatchPubSub(fs_root, impl, watches) pubsub.run_detached() application = tornado.web.Application([(r'/', pubsub.ws)]) http_server = tornado.httpserver.HTTPServer(application) http_server.listen(port) tornado.ioloop.IOLoop.instance().start()
def test_wait_for_ready(self): """Test wait for ready """ modified = os.path.join(self.root, '.modified') utils.touch(modified) self.assertEqual(zksync_utils.wait_for_ready(self.root), modified)