def get_sshserver_hostinfo_byhost( sshhost ): # There Should get hostinfo from db hostinfo = switch_db.get_hostinfo_byhost(sshhost) if hostinfo != []: h_host = hostinfo[0].ip_address h_port = hostinfo[0].port_id h_retry = hostinfo[0].retry_times h_recont = hostinfo[0].reconnect_time hostinfo_t = (h_host, h_port, h_retry, h_recont) return hostinfo_t
def set_sshserver_hostinfo(index, sshhost, sshport, retry, reconnect): # parameter check # save host info into db ret = switch_db.get_hostinfo_byhost(sshhost) if ret == [] : # not find host info ,Create new one switch_db.add_hostinfo(index, sshhost, sshport, retry, reconnect) else: # find old hostinfo ,Update it switch_db.update_hostinfo(index, sshhost, sshport, retry, reconnect) return 0