Example #1
0
 def start_client(self,
                  host,
                  port=5001,
                  protocol='TCP',
                  timeout=5,
                  parallel=None,
                  bandwidth=None):
     """iperf -D -c host -t 60
     """
     cmd = ['iperf', '-c', host, '-p', str(port), '-t', str(timeout)]
     if not (protocol, 'UDP'):
         cmd.append('-u')
     if parallel:
         cmd.extend(['-P', str(parallel)])
     if bandwidth:
         cmd.extend(['-b', '%sM' % bandwidth])
     stdcode, stdout, stderr = utils.execute_wait(cmd)
     if (not stdcode) or (not stderr):
         out_dict = stdout.split('\n')
         if not out_dict[-1]:
             out_dict.pop()
         out_data = out_dict[-1].split()
         data = dict()
         data['Bandwidth'] = out_data[-2] + ' ' + out_data[-1]
         data['Transfer'] = out_data[-4] + ' ' + out_data[-3]
         data['Interval'] = out_data[-6]
         return data
     raise Exception('Start iperf failed, please check on the node.')
Example #2
0
 def start_client(self, host, port=5001, protocol='TCP', timeout=5,
                  parallel=None, bandwidth=None):
     """iperf -D -c host -t 60
     """
     cmd = ['iperf',  '-c', host, '-p', str(port), '-t', str(timeout)]
     if not (protocol, 'UDP'):
         cmd.append('-u')
     if parallel:
         cmd.extend(['-P', str(parallel)])
     if bandwidth:
         cmd.extend(['-b', '%sM' % bandwidth])
     stdcode, stdout, stderr = utils.execute_wait(cmd)
     if (not stdcode) or (not stderr):
         out_dict = stdout.split('\n')
         if not out_dict[-1]:
             out_dict.pop()
         out_data = out_dict[-1].split()
         data = dict()
         data['Bandwidth'] = out_data[-2] + out_data[-1]
         data['Transfer'] = out_data[-4] + out_data[-3]
         data['Interval'] = out_data[-6]
         return data
     raise Exception('Start iperf failed, please check on the node.')