diff options
author | Luc Provoost <luc.provoost@intel.com> | 2020-05-29 10:22:45 +0200 |
---|---|---|
committer | Luc Provoost <luc.provoost@intel.com> | 2020-05-29 10:22:45 +0200 |
commit | 6f898f1c73d630bf6e5e75ba1b30d261c8301d2a (patch) | |
tree | b549863cb813a5a2d62da2396ef3b3d0b8117038 /VNFs/DPPD-PROX/helper-scripts/rapid/prox_ctrl.py | |
parent | b3c5a6a20926dc9fca32240b89f3dea09d07aa02 (diff) |
Fix for container .env file and small updates
Since runrapid.py is now supporting more than 1 dataplane interface, we
need to use a port index in the rapid.env file for the dataplane ports.
In k8sdeployment.py, we only support 1 dataplane port, but we are
writing dp_ip1 and dp_mac1 in the environment file. The copyright dates
are also updated. Some references to VM have also been changed to instance.
Change-Id: Ie1d036c13ef5d6f0aa1f35aa068a9760a1cfc2a9
Signed-off-by: Luc Provoost <luc.provoost@intel.com>
Diffstat (limited to 'VNFs/DPPD-PROX/helper-scripts/rapid/prox_ctrl.py')
-rw-r--r-- | VNFs/DPPD-PROX/helper-scripts/rapid/prox_ctrl.py | 77 |
1 files changed, 52 insertions, 25 deletions
diff --git a/VNFs/DPPD-PROX/helper-scripts/rapid/prox_ctrl.py b/VNFs/DPPD-PROX/helper-scripts/rapid/prox_ctrl.py index 163c6d9f..43f7f140 100644 --- a/VNFs/DPPD-PROX/helper-scripts/rapid/prox_ctrl.py +++ b/VNFs/DPPD-PROX/helper-scripts/rapid/prox_ctrl.py @@ -50,7 +50,8 @@ class prox_ctrl(object): def connect(self): attempts = 1 - RapidLog.debug("Trying to connect to VM which was just launched on %s, attempt: %d" % (self._ip, attempts)) + RapidLog.debug("Trying to connect to instance which was just launched \ + on %s, attempt: %d" % (self._ip, attempts)) while True: try: self.test_connect() @@ -58,15 +59,19 @@ class prox_ctrl(object): except RuntimeWarning as ex: attempts += 1 if attempts > 20: - RapidLog.exception("Failed to connect to VM after %d attempts:\n%s" % (attempts, ex)) - raise Exception("Failed to connect to VM after %d attempts:\n%s" % (attempts, ex)) + RapidLog.exception("Failed to connect to instance after %d\ + attempts:\n%s" % (attempts, ex)) + raise Exception("Failed to connect to instance after %d \ + attempts:\n%s" % (attempts, ex)) time.sleep(2) - RapidLog.debug("Trying to connect to VM which was just launched on %s, attempt: %d" % (self._ip, attempts)) - RapidLog.debug("Connected to VM on %s" % self._ip) + RapidLog.debug("Trying to connect to instance which was just \ + launched on %s, attempt: %d" % (self._ip, attempts)) + RapidLog.debug("Connected to instance on %s" % self._ip) def connect_socket(self): attempts = 1 - RapidLog.debug("Trying to connect to PROX (just launched) on %s, attempt: %d" % (self._ip, attempts)) + RapidLog.debug("Trying to connect to PROX (just launched) on %s, \ + attempt: %d" % (self._ip, attempts)) sock = None while True: sock = self.prox_sock() @@ -74,10 +79,13 @@ class prox_ctrl(object): break attempts += 1 if attempts > 20: - RapidLog.exception("Failed to connect to PROX on %s after %d attempts" % (self._ip, attempts)) - raise Exception("Failed to connect to PROX on %s after %d attempts" % (self._ip, attempts)) + RapidLog.exception("Failed to connect to PROX on %s after %d \ + attempts" % (self._ip, attempts)) + raise Exception("Failed to connect to PROX on %s after %d \ + attempts" % (self._ip, attempts)) time.sleep(2) - RapidLog.debug("Trying to connect to PROX (just launched) on %s, attempt: %d" % (self._ip, attempts)) + RapidLog.debug("Trying to connect to PROX (just launched) on %s, \ + attempt: %d" % (self._ip, attempts)) RapidLog.info("Connected to PROX on %s" % self._ip) return sock @@ -93,12 +101,14 @@ class prox_ctrl(object): for child in self._children: ret = os.waitpid(child[0], os.WNOHANG) if ret[0] == 0: - print("Waiting for child process '%s' to complete ..." % child[1]) + print("Waiting for child process '%s' to complete ..." + % child[1]) ret = os.waitpid(child[0], 0) rc = ret[1] if os.WIFEXITED(rc): if os.WEXITSTATUS(rc) == 0: - print("Child process '%s' completed successfully" % child[1]) + print("Child process '%s' completed successfully" + % child[1]) else: print("Child process '%s' returned exit status %d" % ( child[1], os.WEXITSTATUS(rc))) @@ -231,14 +241,16 @@ class prox_sock(object): max_lat = avg_lat = 0 number_tasks_returning_stats = 0 buckets = [0] * 128 - self._send('lat all stats %s %s' % (','.join(map(str, cores)), ','.join(map(str, tasks)))) + self._send('lat all stats %s %s' % (','.join(map(str, cores)), + ','.join(map(str, tasks)))) for core in cores: for task in tasks: stats = self._recv().split(',') if 'is not measuring' in stats[0]: continue if stats[0].startswith('error'): - RapidLog.critical("lat stats error: unexpected reply from PROX (potential incompatibility between scripts and PROX)") + RapidLog.critical("lat stats error: unexpected reply from PROX\ + (potential incompatibility between scripts and PROX)") raise Exception("lat stats error") number_tasks_returning_stats += 1 min_lat = min(int(stats[0]),min_lat) @@ -246,13 +258,17 @@ class prox_sock(object): avg_lat += int(stats[2]) #min_since begin = int(stats[3]) #max_since_begin = int(stats[4]) - tsc = int(stats[5]) # Taking the last tsc as the timestamp since PROX will return the same tsc for each core/task combination + tsc = int(stats[5]) # Taking the last tsc as the timestamp since + # PROX will return the same tsc for each + # core/task combination hz = int(stats[6]) #coreid = int(stats[7]) #taskid = int(stats[8]) stats = self._recv().split(':') if stats[0].startswith('error'): - RapidLog.critical("lat stats error: unexpected lat bucket reply (potential incompatibility between scripts and PROX)") + RapidLog.critical("lat stats error: unexpected lat bucket \ + reply (potential incompatibility between scripts \ + and PROX)") raise Exception("lat bucket reply error") buckets[0] = int(stats[1]) for i in range(1, 128): @@ -263,10 +279,12 @@ class prox_sock(object): used = float(self._recv()) self._send('stats latency(0).total') total = float(self._recv()) - return min_lat, max_lat, avg_lat, (old_div(used,total)), tsc, hz, buckets + return (min_lat, max_lat, avg_lat, (old_div(used,total)), tsc, hz, + buckets) def irq_stats(self, core, bucket, task=0): - self._send('stats task.core(%s).task(%s).irq(%s)' % (core, task, bucket)) + self._send('stats task.core(%s).task(%s).irq(%s)' % + (core, task, bucket)) stats = self._recv().split(',') return int(stats[0]) @@ -279,13 +297,16 @@ class prox_sock(object): def core_stats(self, cores, tasks=[0]): rx = tx = drop = tsc = hz = rx_non_dp = tx_non_dp = tx_fail = 0 - self._send('dp core stats %s %s' % (','.join(map(str, cores)), ','.join(map(str, tasks)))) + self._send('dp core stats %s %s' % (','.join(map(str, cores)), + ','.join(map(str, tasks)))) for core in cores: for task in tasks: stats = self._recv().split(',') if stats[0].startswith('error'): if stats[0].startswith('error: invalid syntax'): - RapidLog.critical("dp core stats error: unexpected invalid syntax (potential incompatibility between scripts and PROX)") + RapidLog.critical("dp core stats error: unexpected \ + invalid syntax (potential incompatibility \ + between scripts and PROX)") raise Exception("dp core stats error") continue rx += int(stats[0]) @@ -303,7 +324,9 @@ class prox_sock(object): self._send('multi port stats %s' % (','.join(map(str, ports)))) result = self._recv().split(';') if result[0].startswith('error'): - RapidLog.critical("multi port stats error: unexpected invalid syntax (potential incompatibility between scripts and PROX)") + RapidLog.critical("multi port stats error: unexpected invalid \ + syntax (potential incompatibility between scripts and \ + PROX)") raise Exception("multi port stats error") for statistics in result: stats = statistics.split(',') @@ -316,16 +339,20 @@ class prox_sock(object): return rx, tx, no_mbufs, errors, tsc def set_random(self, cores, task, offset, mask, length): - self._send('set random %s %s %s %s %s' % (','.join(map(str, cores)), task, offset, mask, length)) + self._send('set random %s %s %s %s %s' % (','.join(map(str, cores)), + task, offset, mask, length)) def set_size(self, cores, task, pkt_size): - self._send('pkt_size %s %s %s' % (','.join(map(str, cores)), task, pkt_size)) + self._send('pkt_size %s %s %s' % (','.join(map(str, cores)), task, + pkt_size)) def set_imix(self, cores, task, imix): - self._send('imix %s %s %s' % (','.join(map(str, cores)), task, ','.join(map(str,imix)))) + self._send('imix %s %s %s' % (','.join(map(str, cores)), task, + ','.join(map(str,imix)))) def set_value(self, cores, task, offset, value, length): - self._send('set value %s %s %s %s %s' % (','.join(map(str, cores)), task, offset, value, length)) + self._send('set value %s %s %s %s %s' % (','.join(map(str, cores)), + task, offset, value, length)) def _send(self, cmd): """Append LF and send command to the PROX instance.""" @@ -334,7 +361,7 @@ class prox_sock(object): self._sock.sendall(cmd.encode() + b'\n') def _recv(self): - """Receive response from PROX instance, and return it with LF removed.""" + """Receive response from PROX instance, return it with LF removed.""" if self._sock is None: raise RuntimeError("PROX socket closed, cannot receive anymore") pos = self._rcvd.find(b'\n') |