def run(): params = ssh_ping_args.get_cmd_input(ssh_ping_args.get_parser(),sys.argv[1:]) if(params.__dict__['mode']== 'adhoc'): #connect host as adhoc pr= propertyReader('config.property'); db_connect_dict=pr.getSectionAsDict('db') #db_connect_dict={'host':'10.224.38.16','port':2702,'sid':'webdbb','username':'******','password':'******'} dbop = db_operator(db_connect_dict) conn = dbop.db_connect() serverlist = dbop.getServerList(conn) failedlist = [] failedinfo = [] for server in serverlist: ip = server[1] import sshbatch import copy copydict = copy.deepcopy(params.__dict__) copydict['host'] = ip copydict['user'] = copydict['username'] try: sshbatch.exec_batch(copydict,[]) except Exception, e: failedlist.append(ip) failedict = {} failedict['hostname'] = copydict['host'] failedict['error'] = e.__repr__() failedinfo.append(failedict) print e dbop.clearReportResult(conn) dbop.batch_insertServerErrorInfo(conn, failedinfo) dbop.destroy(conn)
#!/usr/bin/env python # -*- coding: UTF-8 -*- from head import * from db_operator import db_operator db_op = db_operator() db_op.db_connect() insert_sensor_state = t_insert_sensor_state() for i in range(6): for j in range(1, 6): insert_sensor_state.node_id = i insert_sensor_state.sensor_id = j if j == d_sensor_set["SOLENOIDVALVES"]: insert_sensor_state.switcher = d_default_data["DEFAULT_SWITCH"] elif j == d_sensor_set["YL69"]: insert_sensor_state.capture_frequency = d_default_data[ "DEFAULT_YL69_PERIOD"] insert_sensor_state.threshold = d_default_data[ "DEFAULT_YL69_THRESHOLD"] elif j == d_sensor_set["LIGHT"]: insert_sensor_state.capture_frequency = d_default_data[ "DEFAULT_LIGHT_PERIOD"] insert_sensor_state.threshold = d_default_data[ "DEFAULT_LIGHT_THRESHOLD"] elif j == d_sensor_set["THERMISTOR"]: insert_sensor_state.capture_frequency = d_default_data[ "DEFAULT_TEMP_PERIOD"] insert_sensor_state.threshold = d_default_data[ "DEFAULT_TEMP_THRESHOLD"]
#!/usr/bin/env python # -*- coding: UTF-8 -*- from head import * from db_operator import db_operator db_op = db_operator() db_op.db_connect() insert_sensor_state = t_insert_sensor_state() for i in range(6) : for j in range(1, 6) : insert_sensor_state.node_id = i insert_sensor_state.sensor_id = j if j == d_sensor_set["SOLENOIDVALVES"]: insert_sensor_state.switcher = d_default_data["DEFAULT_SWITCH"] elif j == d_sensor_set["YL69"]: insert_sensor_state.capture_frequency = d_default_data["DEFAULT_YL69_PERIOD"] insert_sensor_state.threshold = d_default_data["DEFAULT_YL69_THRESHOLD"] elif j == d_sensor_set["LIGHT"]: insert_sensor_state.capture_frequency = d_default_data["DEFAULT_LIGHT_PERIOD"] insert_sensor_state.threshold = d_default_data["DEFAULT_LIGHT_THRESHOLD"] elif j == d_sensor_set["THERMISTOR"]: insert_sensor_state.capture_frequency = d_default_data["DEFAULT_TEMP_PERIOD"] insert_sensor_state.threshold = d_default_data["DEFAULT_TEMP_THRESHOLD"] elif j == d_sensor_set["DS18B20"]: insert_sensor_state.capture_frequency = d_default_data["DEFAULT_DS18B20_PERIOD"] insert_sensor_state.threshold = d_default_data["DEFAULT_DS18B20_THRESHOLD"] try: db_op.db_insert_sensor_state(insert_sensor_state) except Exception, e: