summaryrefslogtreecommitdiffstats
path: root/scripts/automation/trex_control_plane/common
diff options
context:
space:
mode:
authorimarom <imarom@cisco.com>2016-01-19 08:49:31 -0500
committerimarom <imarom@cisco.com>2016-01-21 10:11:55 -0500
commitc93acc26bf2517c872da716198e76bcf566b836a (patch)
treed8edf7b972eae0d821cee644b720312f97fd5891 /scripts/automation/trex_control_plane/common
parent2d9d5e147b8f15a8308dad46711390f3b168ec56 (diff)
draft #2
Diffstat (limited to 'scripts/automation/trex_control_plane/common')
-rw-r--r--scripts/automation/trex_control_plane/common/trex_types.py12
1 files changed, 9 insertions, 3 deletions
diff --git a/scripts/automation/trex_control_plane/common/trex_types.py b/scripts/automation/trex_control_plane/common/trex_types.py
index 337f0a70..aada5bfc 100644
--- a/scripts/automation/trex_control_plane/common/trex_types.py
+++ b/scripts/automation/trex_control_plane/common/trex_types.py
@@ -14,16 +14,17 @@ class RpcResponseStatus(namedtuple('RpcResponseStatus', ['success', 'id', 'msg']
# simple class to represent complex return value
class RC():
- def __init__ (self, rc = None, data = None):
+ def __init__ (self, rc = None, data = None, is_warn = False):
self.rc_list = []
if (rc != None):
- tuple_rc = namedtuple('RC', ['rc', 'data'])
- self.rc_list.append(tuple_rc(rc, data))
+ tuple_rc = namedtuple('RC', ['rc', 'data', 'is_warn'])
+ self.rc_list.append(tuple_rc(rc, data, is_warn))
def __nonzero__ (self):
return self.good()
+
def add (self, rc):
self.rc_list += rc.rc_list
@@ -33,6 +34,9 @@ class RC():
def bad (self):
return not self.good()
+ def warn (self):
+ return any([x.is_warn for x in self.rc_list])
+
def data (self):
d = [x.data if x.rc else "" for x in self.rc_list]
return (d if len(d) != 1 else d[0])
@@ -83,3 +87,5 @@ def RC_OK(data = ""):
def RC_ERR (err):
return RC(False, err)
+def RC_WARN (warn):
+ return RC(True, warn, is_warn = True)