def reset(offline=False): """ Reset the htm-it database; upon successful completion, the necessary schema are created, but the tables are not populated :param offline: False to execute SQL commands; True to just dump SQL commands to stdout for offline mode or debugging """ # Make sure we have the latest version of configuration config.loadConfig() dbName = config.get('repository', 'db') resetDatabaseSQL = ( "DROP DATABASE IF EXISTS %(database)s; " "CREATE DATABASE %(database)s;" % {"database": dbName}) statements = resetDatabaseSQL.split(";") engine = getUnaffiliatedEngine() with engine.connect() as connection: for s in statements: if s.strip(): connection.execute(s) migrate(offline=offline)
def handle(self): import cPickle from migrate import * print "Receving incoming agent, verification is in process ..." print "From client:", self.client_address f = self.request.makefile() career = cPickle.load(f) agent = career.unloadAgent() #Welcome! agent.localip = getCurrentIP(agent.masterip) try: agent.compute() agent.dispInfo() except: print "Agent execution on host failed." return -1 if (migrate(agent) == 0): print "\t Agent mission acomplished" return 0
masterip = cp.get("master", "masterip") print "Masterip:", masterip hops = cp.getint("itinerary", "hops") while hops > 0: attrname = "node" + str(i) groute.append(cp.get("itinerary", attrname)) hops = hops - 1 i = i + 1 else: print "Can not find required configuration file\n" sys.exit(1) #### main program starts mafinit("maf.conf") #### create new agent agentx = DiskAgent(masterip, groute) #### Sign the agent binstr = cPickle.dumps(agentx.compLocal, 1) _privkey = getPrivateKey(masterip) _pubkey = getPublicKey(masterip) agentx.serverSignature = _privkey.sign(binstr, b"")[0] #### display some information related to this agent agentx.dispInfo() #### migrate this agent migrate(agentx)