Skip to content

Commit

Permalink
[BFN] Updated SFP platform APIs (#10)
Browse files Browse the repository at this point in the history
Signed-off-by: Volodymyr Boyko <[email protected]>
  • Loading branch information
vboykox authored Dec 10, 2021
1 parent c62a733 commit 9ecd80e
Show file tree
Hide file tree
Showing 4 changed files with 3,753 additions and 775 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -25,9 +25,9 @@ def open(self):
self.transport = TTransport.TBufferedTransport(self.transport)
bprotocol = TBinaryProtocol.TBinaryProtocol(self.transport)

pltfm_mgr_client_module = importlib.import_module(".".join(["pltfm_mgr_rpc", "pltfm_mgr_rpc"]))
self.pltfm_mgr_module = importlib.import_module(".".join(["pltfm_mgr_rpc", "pltfm_mgr_rpc"]))
pltfm_mgr_protocol = TMultiplexedProtocol.TMultiplexedProtocol(bprotocol, "pltfm_mgr_rpc")
self.pltfm_mgr = pltfm_mgr_client_module.Client(pltfm_mgr_protocol)
self.pltfm_mgr = self.pltfm_mgr_module.Client(pltfm_mgr_protocol)

self.transport.open()
return self
Expand All @@ -47,3 +47,12 @@ def thrift_try(func, attempts=35):
if attempt + 1 == attempts:
raise e
time.sleep(1)

def pltfm_mgr_try(func, default=None, thrift_attempts=35):
def pm_cb_run(client):
try:
return (None, func(client.pltfm_mgr))
except client.pltfm_mgr_module.InvalidPltfmMgrOperation as ouch:
return (ouch.code, default)

return thrift_try(pm_cb_run)
Loading

0 comments on commit 9ecd80e

Please sign in to comment.