def cleanup(): """ :return: """ cleanupSettings = {} try: cleanupSettings = { 'ec2_server_id': ini_parser.returnVar('ec2_server_id', 'aws'), 'ec2_client_id': ini_parser.returnVar('ec2_client_id', 'aws'), 'vpc_id': ini_parser.returnVar('vpc_id', 'aws'), 'region': ini_parser.returnVar('region', 'aws'), } except: print( "can't cleanup. Looks like created AWS objects not defined in the list" ) return False r = ansible_runner.run(private_data_dir='./', playbook='playbooks/playbook_cleanup.yml', quiet=quietPlaybooks, extravars={ **cleanupSettings, **awsCreds, **sshCreds }) #print(f"r.rc={r.rc}") if r.rc == 0: ini_parser.deleteVar('ec2_server_id', 'aws') ini_parser.deleteVar('ec2_client_id', 'aws') ini_parser.deleteVar('vpc_id', 'aws') ini_parser.deleteVar('iperf3_server_host', 'connections') ini_parser.deleteVar('iperf3_client_host', 'connections') ini_parser.deleteVar('region', 'aws') ini_parser.deleteVar('iperf3_int_server', 'iperf3') ini_parser.deleteVar('iperf3_int_client', 'iperf3') ini_parser.deleteVar('vcpu_server', 'aws') ini_parser.deleteVar('vcpu_client', 'aws') ini_parser.deleteVar('instance_type_client', 'aws') ini_parser.deleteVar('instance_type_server', 'aws') ini_parser.writeVar('ready4test', 'False', 'connections') print("I've just done a clean up job") return True else: print("can't do clean up in the AWS side. Please do it manually") return False
def ready4Test(): iniOptions = [] iniOptions.append(ini_parser.returnVar('ready4test', 'connections')) iniOptions.append(ini_parser.returnVar('iperf3_server_host', 'connections')) iniOptions.append(ini_parser.returnVar('iperf3_client_host', 'connections')) iniOptions.append(ini_parser.returnVar('iperf3_int_server', 'iperf3')) iniOptions.append(ini_parser.returnVar('iperf3_int_client', 'iperf3')) if None in iniOptions: return None else: if strtobool(iniOptions[0]): return True else: return False
def checkVariables(): clientHost = ini_parser.returnVar('iperf3_client_host', 'connections') serverHost = ini_parser.returnVar('iperf3_server_host', 'connections') # iperf3_int_client = ini_parser.returnVar('iperf3_client_host','iperf3') iperf3_int_server = ini_parser.returnVar('iperf3_int_server', 'iperf3') commandPort = int(ini_parser.returnVar('command_port', 'connections')) durationSecs = int(ini_parser.returnVar('duration', 'iperf3')) numStreams = int(ini_parser.returnVar('num_streams', 'iperf3')) waitUntilCheck = int( ini_parser.returnVar('wait_until_check', 'connections')) iperf3ServerPort = int(ini_parser.returnVar('iperf3_server_port', 'iperf3')) iperf3BindAddress = ini_parser.returnVar('iperf3_bind_address', 'iperf3') iperf3ServerHost = ini_parser.returnVar('iperf3_server_host', 'connections') return clientHost, serverHost, iperf3_int_server, commandPort, durationSecs, numStreams, waitUntilCheck, iperf3ServerPort, iperf3BindAddress, iperf3ServerHost
def max_speed(): sender_bind_port = int(ini_parser.returnVar('data_port', 'connections')) sender_bind_address = ini_parser.returnVar('iperf3_client_host', 'connections') pickledResults = b'' with socket.socket(socket.AF_INET, socket.SOCK_STREAM) as s: s.connect((sender_bind_address, sender_bind_port)) s.settimeout(3) while True: netChunk = s.recv(1024) if not netChunk: break pickledResults += netChunk unPickledResults = pickle.loads(pickledResults) traverseDataStructure(unPickledResults) #print(unPickledResults) #print("===") #print(bitSecList) maxSpeed = bitSecList[0] maxSpeedHumanize = humanize.naturalsize(maxSpeed) return maxSpeed, maxSpeedHumanize
def reinstallReqChecker(): print( "hmm... Looks like we already have installed instances! Checking it's settings..." ) needReinstall = False #print('debug1') if ini_parser.returnVar('instance_type_server', 'aws') == kwargs['instance_type_server'] \ and ini_parser.returnVar('instance_type_client', 'aws') == kwargs['instance_type_client']: print("instances types are same!") #print('debug2') else: print("instance types are not same!") needReinstall = True #print('debug3') if ini_parser.returnVar('region', 'aws') == kwargs['region']: print("Regions is same!") #print('debug4') else: print("region is not same!") needReinstall = True #print('debug5') #print(f"debug. ini: {ini_parser.returnVar('launch_mode_with_vcpu','aws')}, kwargs: {kwargs['launch_mode_with_vcpu']}") if strtobool(ini_parser.returnVar( 'launch_mode_with_vcpu', 'aws')) == kwargs['launch_mode_with_vcpu']: #if strtobool(ini_parser.returnVar('launch_mode_with_vcpu', 'aws')) == kwargs['launch_mode_with_vcpu']: print( f"looks like we already installed instances in the required mode(vCpu or general instances)" ) #print('debug6') # print(f"debug vcpu amount: {ini_parser.returnVar('vcpu_server', 'aws')}") #print('debug6.6') # print(f"debug vcpu_amount: {kwargs['vcpu_server']}") if kwargs['launch_mode_with_vcpu'] == True: if int(ini_parser.returnVar( 'vcpu_server', 'aws')) == kwargs['vcpu_server'] and int( ini_parser.returnVar( 'vcpu_client', 'aws')) == kwargs['vcpu_client']: print( 'we have same amount of vCpus in both - client and server!' ) #print('debug7') else: #print('vCPU amount mistmatch!') needReinstall = True else: print("looks like we have a different mode here!") needReinstall = True #print('debug9') #print('debug10') return needReinstall
#from perf_tester_modules import commander #ToDo: rewrite? try: from perf_tester_modules import commander except: pass try: from perf_tester_modules import iperf_receiver except: pass #clientHost = ini_parser.returnVar('iperf3_client_host','connections') awsCreds = { 'aws_access_key': ini_parser.returnVar('aws_access_key', 'aws'), 'aws_secret_key': ini_parser.returnVar('aws_secret_key', 'aws'), } sshCreds = { #'path2folder_with_ssh_key': ini_parser.returnVar('path2folder_with_ssh_key','aws'), 'ssh_key_name': ini_parser.returnVar('ssh_key_name', 'aws'), } gitSettings = { 'git_repo': ini_parser.returnVar('git_repo', 'git'), 'git_puppet_dest': ini_parser.returnVar('git_puppet_dest', 'git'), 'puppet_requirements': ini_parser.returnVar('puppet_requirements', 'git'), 'puppet_name': ini_parser.returnVar('puppet_name', 'git') }