How to use show_server method in tempest

Best Python code snippet using tempest_python

monitor.py

Source:monitor.py Github

copy

Full Screen

...55 print()56 print("COORDINATOR ORPHANS")57 for coordinator_info in coordinator_orphans:58 print(coordinator_info)59 def show_server(number):60 if number > 0:61 print()62 print("Server %s" % (number + 1))63 option_parser = OptionParser()64 option_parser.add_option( "-e", "--list-experiments",65 action="store_true",66 dest="list_experiments",67 help="Lists all the available experiments" )68 69 option_parser.add_option( "-u", "--list-users",70 dest="list_users",71 nargs=1,72 default=None,73 metavar='EXPERIMENT_ID',74 help="Lists all users using a certain experiment (format: experiment@category)" )75 option_parser.add_option( "-a", "--list-experiment-users",76 action="store_true",77 dest="list_experiment_users",78 help="Lists all users using any experiment" )79 option_parser.add_option( "-l", "--list-all-users",80 action="store_true",81 dest="list_all_users",82 help="Lists all connected users" )83 option_parser.add_option( "-f", "--full-info",84 action="store_true",85 dest="full_info",86 help="Shows full information (full session ids instead of only the first characteres)" )87 88 option_parser.add_option( "-k", "--kick-session",89 dest="kick_session",90 nargs=1,91 default=None,92 metavar='SESSION_ID',93 help="Given the full UPS Session ID, it kicks out a user from the system" )94 option_parser.add_option( "-b", "--kick-user",95 dest="kick_user",96 nargs=1,97 default=None,98 metavar='USER_LOGIN',99 help="Given the user login, it kicks him out from the system" )100 options, _ = option_parser.parse_args()101 for num, server in enumerate(SERVERS):102 wl = WebLabMonitor(server)103 if options.list_experiments:104 print(wl.list_experiments(), end='')105 elif options.list_experiment_users:106 show_server(num)107 experiments = wl.list_experiments()108 if experiments != '':109 for experiment in experiments.split('\n')[:-1]:110 print()111 print("%s..." % experiment)112 print()113 list_users(experiment)114 115 elif options.list_users != None:116 show_server(num)117 list_users(options.list_users)118 119 elif options.list_all_users:120 show_server(num)121 all_users = wl.list_all_users()122 print("%15s\t%11s\t%17s\t%24s" % ("LOGIN","UPS_SESSID","FULL_NAME","LATEST TIMESTAMP"))123 for ups_session_id, user_information, latest_timestamp in all_users:124 latest = time.asctime(time.localtime(latest_timestamp))125 if options.full_info:126 print("%15s\t%11s\t%17s\t%24s" % (user_information.login, ups_session_id.id, user_information.full_name, latest))127 else:128 if len(user_information.full_name) <= 14:129 print("%15s\t%8s...\t%s\t%24s" % (user_information.login, ups_session_id.id[:8], user_information.full_name, latest))130 else:131 print("%15s\t%8s...\t%14s...\t%24s" % (user_information.login, ups_session_id.id[:8], user_information.full_name[:14], latest))132 133 elif options.kick_session != None:134 show_server(num)135 wl.kick_session(options.kick_session)136 elif options.kick_user != None:137 show_server(num)138 wl.kick_user(options.kick_user)139 140 else:141 option_parser.print_help()...

Full Screen

Full Screen

main.py

Source:main.py Github

copy

Full Screen

1# coding: utf-82import sys, getopt, os, traceback3import traceback4import settings5# import gui6def link():7 try:8 import pexpect9 except ImportError:10 print("""11 You must install pexpect module12 """)13 os.system("pip3 install pexpect")14 sys.exit(1)15 RED_COLOR = '\033[1;31m' # 红16 GREEN_COLOR = '\033[1;32m' # 绿17 YELOW_COLOR = '\033[1;33m' # 黄18 BLUE_COLOR = '\033[1;34m' # 蓝19 PINK = '\033[1;35m' # 粉红20 RES = '\033[0m'21 SHOW_SERVER = settings.SHOW_SERVER22 SERVER = settings.SERVER23 def auto_connect(host):24 SSH = "ssh -p %s %s@%s "% (host[0], host[1], host[2])25 if len(host)==4:26 print("采用ssh-copy-id方式连接")27 SSH = "ssh -p %s %s@%s " % (host[0], host[1], host[2])28 child = pexpect.spawn(SSH, echo=False)29 elif os.path.exists(host[4]):30 print("采用密钥文件方式连接")31 SSH = "ssh -p %s %s@%s -i %s " % (host[0], host[1], host[2], host[4])32 child = pexpect.spawn(SSH, echo=False)33 # index = child.expect(['continue connecting (yes/no)?', pexpect.EOF, pexpect.TIMEOUT])34 # if index == 0:35 # child.sendline('yes')36 # child.interact()37 # else:38 # child.interact()39 else:40 print("采用密码方式连接")41 try:42 child = pexpect.spawn(SSH, echo=False)43 index = child.expect(['password:', 'continue connecting (yes/no)?', pexpect.EOF, pexpect.TIMEOUT])44 if index == 0:45 child.sendline(host[4])46 child.interact()47 elif index == 1:48 child.sendline('yes')49 child.expect(['password:'])50 child.sendline(host[4])51 elif index == 2:52 print("子程序异常,退出!")53 child.close()54 elif index == 3:55 print("连接超时")56 child.close()57 except:58 traceback.print_exc()59 child.close()60 if host[3]:61 child.sendline("resize -cu >/dev/null 2>&1")62 child.interact()63 show = "其从如下的连接中选择一个:\n"64 i = 165 tmp = [""] * 10066 for sel in SHOW_SERVER:67 show = show + "\n" + sel + "\n"68 for server in SHOW_SERVER[sel]:69 if server != "" and server != None:70 show = show + " |--" + "[" + str(i) + "] " + RED_COLOR + " " + server + " " + RES + "\n"71 tmp[i - 1] = server72 i += 173 # selectFrame = gui.SelectFrame(SHOW_SERVER)74 print(show)75 iinput = "steven"76 while iinput.isdigit() is not True:77 if iinput != "steven":78 print("\n输入有误,请输入正确的编号数字!\n")79 iinput = input("请输入连接编号:")80 select = int(iinput)81 try:82 host = SERVER[tmp[select - 1]]83 except:84 print("""85 argv error, use it link86 jssh v3, v3 must defined in addr_map87 """)88 sys.exit(1)89 auto_connect(host)90def search(id):91 i = 192 tmp = [""] * 10093 SHOW_SERVER = settings.SHOW_SERVER94 SERVER = settings.SERVER95 for sel in SHOW_SERVER:96 for server in SHOW_SERVER[sel]:97 if server != "" and server != None:98 tmp[i - 1] = server99 i += 1100 print(SERVER[tmp[id]])101def main(argv):102 try:103 opts, args = getopt.getopt(argv, "l:s:", ["linkId"])104 except getopt.GetoptError:105 sys.exit(2)106 if len(opts) == 0:107 link()108 else:109 for opt, arg in opts:110 if opt == '-s':111 search(int(arg) - 1)112if __name__ == "__main__":...

Full Screen

Full Screen

utils.py

Source:utils.py Github

copy

Full Screen

1def filter_tags(server=None, tags=None):2 """3 >>> filter_tags(server={'name': 'frosty-mountain-6164', 'tags': ['58824ea91d41c8ed3761d8b0']}, tags='58824ea91d41c8ed3761d8b0')4 True5 >>> filter_tags(server={'name': 'frosty-mountain-6164', 'tags': ['58824761d8b0']}, tags='58824ea91d41c8ed3761d8b0')6 False7 """8 show_server = False9 10 if len(tags) > 0:11 tags_list = tags.split(',')12 server_tags = server.get('tags') # Convert <filter object to list>13 server_tag_ids = []14 for x in server_tags:15 if type(x)is dict:16 value = str(x.get("_id"))17 else:18 value = str(x)19 server_tag_ids.append(value)20 if list(tags_list) <= list(server_tag_ids):21 show_server = True22 else:23 show_server = True24 ...

Full Screen

Full Screen

Automation Testing Tutorials

Learn to execute automation testing from scratch with LambdaTest Learning Hub. Right from setting up the prerequisites to run your first automation test, to following best practices and diving deeper into advanced test scenarios. LambdaTest Learning Hubs compile a list of step-by-step guides to help you be proficient with different test automation frameworks i.e. Selenium, Cypress, TestNG etc.

LambdaTest Learning Hubs:

YouTube

You could also refer to video tutorials over LambdaTest YouTube channel to get step by step demonstration from industry experts.

Run tempest automation tests on LambdaTest cloud grid

Perform automation testing on 3000+ real desktop and mobile devices online.

Try LambdaTest Now !!

Get 100 minutes of automation test minutes FREE!!

Next-Gen App & Browser Testing Cloud

Was this article helpful?

Helpful

NotHelpful