Conversation
Signed-off-by: Vivek Reddy Karri <vkarri@nvidia.com>
Signed-off-by: Vivek Reddy Karri <vkarri@nvidia.com>
Signed-off-by: Vivek Reddy Karri <vkarri@nvidia.com>
| "distance": "0", | ||
| "ifname": ",", | ||
| "nexthop": "1.1.1.2", | ||
| "nexthop-vrf": "," |
tests/dump_input/route/appl_db.json
Outdated
| "ifname": "PortChannel0001,PortChannel0002,PortChannel0003,PortChannel0004", | ||
| "nexthop": "fc00::72,fc00::76,fc00::7a,fc00::7e" | ||
| } | ||
| } No newline at end of file |
| ddiff = DeepDiff(returned, expect, ignore_order=True) | ||
| assert not ddiff, ddiff | ||
|
|
||
| def test_caching_redis_keys(self, match_engine): |
There was a problem hiding this comment.
Is there a way to test whether return comes from cache or redis call?
tests/dump_input/route/asic_db.json
Outdated
| "SAI_ROUTE_ENTRY_ATTR_NEXT_HOP_ID":"oid:0x60000000002cd" | ||
| }, | ||
| "ASIC_STATE:SAI_OBJECT_TYPE_ROUTER_INTERFACE:oid:0x60000000002cd": { | ||
| "SAI_ROUTER_INTERFACE_ATTR_MTU": "9100", |
There was a problem hiding this comment.
Have uniform indentation.
tests/dump_input/route/appl_db.json
Outdated
| "nexthop":"::" | ||
| }, | ||
| "ROUTE_TABLE:20c0:e6e0:0:80::/64": { | ||
| "ifname": "PortChannel0001,PortChannel0002,PortChannel0003,PortChannel0004", |
There was a problem hiding this comment.
Correct indentation here and below
…o dump_module_route
Signed-off-by: Vivek Reddy Karri <vkarri@nvidia.com>
dump/plugins/route.py
Outdated
|
|
||
| class NextHopGroupMatchOptimizer(): | ||
| """ | ||
| A Stateful Wrapper which optimizes the the queries by caching the redis keys. |
dump/plugins/route.py
Outdated
| """ | ||
|
|
||
| def __init__(self, m_engine): | ||
| self.key_cache = dict() |
There was a problem hiding this comment.
Suggest to use one way to initialize dictionary.
In some places it is dict() and in some {}, e.g. line 27.
(BTW, {} is a bit faster comparing to dict())
| def __init__(self, route_obj): | ||
| self.rt = route_obj | ||
|
|
||
| def collect(self): |
There was a problem hiding this comment.
Looks like it is abstract method which is required to be overridden by derived classes.
At least I as I see all derived classes always implement it so it looks likes it is must.
If it is the case then there is recommended exception to raise in base class in such abstract methods: NotImplementedError
There was a problem hiding this comment.
This is invoked from here:
def init_asic_nh(self):
self.nh_type = self.get_nh_type()
nh_ex = NHExtractor.initialize(self) # This will call the actual derived class of NHExtractor
nh_ex.collect()
@staticmethod
def initialize(route_obj):
if route_obj.nh_type == NH:
return SingleNextHop(route_obj)
elif route_obj.nh_type == NH_GRP:
return MultipleNextHop(route_obj)
elif route_obj.nh_type == RIF:
return DirecAttachedRt(route_obj)
elif route_obj.nh_type == CPU_PORT:
return CPUPort(route_obj)
return NHExtractor(route_obj)
When a nh_type apart from NH, NH_GRP, RIF or CPU_PORT is provided, the base class itself is initialized, so a NotImplemented exception will cause the dump module to not exit gracefully.
…o dump_module_route
Signed-off-by: Vivek Reddy Karri <vkarri@nvidia.com>
Signed-off-by: Vivek Reddy Karri vkarri@nvidia.com
What I did
HLD for Dump Utility: HLD.
How I did it
How to verify it
Previous command output (if the output of a command-line utility has changed)
New command output (if the output of a command-line utility has changed)