Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- class DialInClient(object):
- def __init__(self, host, port, timeout=100000000, user='root', password='lablab'):
- self._host = host
- self._port = port
- self._timeout = float(timeout)
- self._channel = None
- self._cisco_ems_stub = None
- self._connected = False
- self._metadata = [('username', user), ('password', password)]
- def subscribe(self, sub_id):
- sub_args = CreateSubsArgs(ReqId=1, encode=3, subidstr=sub_id)
- stream = self._cisco_ems_stub.CreateSubs(sub_args, timeout=self._timeout, metadata=self._metadata)
- for segment in stream:
- yield segment
- def connect(self):
- self._channel = grpc.insecure_channel(':'.join([self._host,self._port]))
- try:
- grpc.channel_ready_future(self._channel).result(timeout=10)
- self._connected = True
- except grpc.FutureTimeoutError as e:
- raise DeviceFailedToConnect from e
- else:
- self._cisco_ems_stub = gRPCConfigOperStub(self._channel)
Add Comment
Please, Sign In to add comment