def main(): print """Available commands: bgstress on/off \tRuns allocations (and frees them) in the background. allocate nrHosts [pool=default] \tAllocates the given number of hosts from the given pool. free \tFrees the current allocation (which was created with the 'allocate' command, if such allocation exists.""" useFakeGeneralConfiguration() import pdb pdb.set_trace() global backgroundStressTestClient, profilingTestClient, profilingAllocation backgroundStressTestClient = RackattackTestClients("background-stress") profilingTestClient = RackattackTestClients("profiling") client = clientfactory.factory() profilingAllocation = False commands = dict(bgstress=bgStress, allocate=allocate, free=free) while True: cmdline = raw_input() cmdline = cmdline.strip() if not cmdline: continue cmdline = cmdline.split(" ") cmdline = [item.strip() for item in cmdline] commandName = cmdline[0] args = cmdline[1:] if commandName not in commands: print "Invalid command: %(commandName)s" % dict(commandName=commandName) continue command = commands[commandName] try: command(*args) except Exception as e: print "An error has occurred while executing command: %(message)s" % dict(message=e.message) continue
import logging import threading from rackattack.physical import pikapatch, config from rackattack.physical.tests.integration import fakehosts from rackattack.physical.tests.integration.main import (useFakeRackConf, useFakeIPMITool, useFakeGeneralConfiguration) def configureLogging(): for loggerName in ("fakeConsumersServer", "pipeListener"): _logger = logging.getLogger(loggerName) handler = logging.StreamHandler() handler.setLevel(logging.DEBUG) formatter = logging.Formatter('%(name)s: %(message)s') handler.setFormatter(formatter) _logger.addHandler(handler) _logger.setLevel(logging.DEBUG) _logger.propagate = False if __name__ == "__main__": useFakeRackConf() useFakeIPMITool() useFakeGeneralConfiguration() configureLogging() fakeHostsServer = fakehosts.FakeHosts() fakeHostsServer.run()