Пример #1
0
def writeEvent(expfile, ret):
	localHA = None
	try:
		name = expfile.split("/")[2].rstrip(".exp")
		localHA = NASHAComm("127.0.0.1")
		setHistoryResult({'status' : ret['status'], 'expfile' : expfile})	
		cfg = localHA.getConfig("RRConfig", "rr_get_task", {'name' : name})['data']
		if ret['status'] == 0:
			eventAgent.writeEvent(localHA, {'op' : 'runRR', 'name' : name, 'ip' : cfg['ip'], 'ret' : ret})	
		else:
			if ret['status'] == QUOTA_EXCEED:
				eventAgent.writeEvent(localHA, {'op' : 'RRquota', 'name' : name, 'ret' : ret})	
			elif ret['status'] == IN_PROGRESS:
				eventAgent.writeEvent(localHA, {'op' : 'RRinprogress', 'name' : name, 'ret' : ret})	
			elif ret['status'] == PERM_DENY:
				eventAgent.writeEvent(localHA, {'op' : 'RRperm', 'name' : name, 'ret' : ret})	
			elif ret['status'] == LOCALBLOCKBYSHELL:
				eventAgent.writeEvent(localHA, {'op' : 'runRR', 'name' : name, 'ip' : cfg['ip'], 'ret' : ret})	
			elif ret['status'] == IP_ERROR:
				eventAgent.writeEvent(localHA, {'op' : 'RRip', 'name' : name, 'ip' : cfg['ip'], 'ret' : ret})	
			elif ret['status'] == PATHERROR:
				eventAgent.writeEvent(localHA, {'op' : 'RRpath', 'name' : name, 'ret' : ret, 'cfg' : cfg})	
			else:
				eventAgent.writeEvent(localHA, {'op' : 'runRR', 'name' : name, 'ip' : cfg['ip'], 'ret' : ret})	
	except:
		print traceback.format_exc()
		pass
	finally:
		localHA.closeSocket()
Пример #2
0
def stopNetService():
	try:
		localHA = NASHAComm("127.0.0.1")
		paraList = {}
		paraList['op'] = "stopNetService"
		localHA.callGetLocalFunc("RROperation", paraList)
	except:
		pass	
	finally:
		localHA.closeSocket()
Пример #3
0
def setHistoryResult(paraList):
	try:
		localHA = NASHAComm("127.0.0.1")
		name = paraList['expfile'].split("/")[2].rstrip(".exp")
		paras = {
			'op' : 'setHistoryResult',
			'sourceTask' : name,
			'controller' : localHA.getCurrentController(),
		}
		status = paraList.get('status')
		if status == None:
			paras['result'] = "In Progress"
		else:
			if status == 0:
				paras['result'] = "Success"
			else:
				paras['result'] = "Fail"
		print paras
		ret = localHA.callGetLocalFunc("schOperation", paras)
		print "setConfig:", ret
	except:
		log("set result:%s"%(traceback.format_exc()))
	finally:
		localHA.closeSocket()
Пример #4
0
		
	def close(self):
		self._timer.close()
		self._worker.close()
		self._info_updater.close()
		Actor.close(self)
		
	def join(self):
		self._timer.join()
		self._worker.join()
		self._info_updater.join()
		Actor.join(self)
	
	def test(self):
		for sch_config in self._schedule_list:
			self._worker.send(('run', sch_config))
			
def echo(msg):
	print '[echo] msg: %s' % (msg)
		
if __name__ == '__main__': 
	localHA = NASHAComm(LOCAL_HA_IP)
	schInfo = localHA.getConfig("ScheduleConfig", "schedule_statusAll")
	cdaemon = CronDaemon(localHA)
	cdaemon.start()
	cdaemon.join()
	localHA.closeSocket()
	

	
Пример #5
0
import sys
import traceback

def restore[module_name](HAServer, paraList = None):
    return {'status' : 0}

def main(HAServer):
    func = getattr(sys.modules[__name__], sys.argv[1])
    func(HAServer)
    
if __name__ == "__main__":
    try:
        sys.path.append("/usr/local/NAS/misc/HAAgent")
        from NASHAComm import *
        HA = NASHAComm("127.0.0.1")
        main(HA)
    except:
        print traceback.format_exc()
    finally:
        HA.closeSocket()


Пример #6
0
def restoreVpn(HAServer, paraList = None):
    if HAServer.isPrimaryController():
        paraList = {
            'op' : 'xl2tpd_restore',
            'proto' : "xl2tpd",
            'controller' : 'A',
            'serviceId' : '0'
        }
        ret = HAServer.callGetLocalFunc("vpnLib", paraList)
        return ret
    else:
        return {'status' : 0}

def main(HAServer):
    func = getattr(sys.modules[__name__], sys.argv[1])
    func(HAServer)
    
if __name__ == "__main__":
    try:
        sys.path.append("/usr/local/NAS/misc/HAAgent")
        from NASHAComm import *
        HA = NASHAComm("127.0.0.1")
        main(HA)
    except:
        print traceback.format_exc()
    finally:
        HA.closeSocket()