def get_sshserver_password( sshhost): # get server id from db by host index = switch_db.get_sshserver_id(sshhost) # get username from db by host id usercfg = switch_db.get_userinfo(index) passwd = usercfg[0].password LOG.debug("get_sshserver_password passwd = %s ",passwd) return passwd
def get_sshserver_username( sshhost ): # get server id from db by host index = switch_db.get_sshserver_id(sshhost) # get username from db by host id usercfg = switch_db.get_userinfo(index) LOG.debug("get_sshserver_username usercfg = %s ",usercfg) username = usercfg[0].username LOG.debug("get_sshserver_username username = %s",username) return username
def set_sshserver_userinfo(index, username, passwd): # parameter check #save user config info # should save into db userinfo_t = (index, username, passwd) ret = switch_db.get_userinfo(index) if ret == [] : # not find user info ,Create new one switch_db.add_userinfo(index, username, passwd) else: # find old user info ,Update it switch_db.update_userinfo(index, username, passwd) return 0