Method: Cisco::Client::GRPC#initialize
- Defined in:
- lib/cisco_node_utils/client/grpc/client.rb
#initialize(**kwargs) ⇒ GRPC
Returns a new instance of GRPC.
36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 |
# File 'lib/cisco_node_utils/client/grpc/client.rb', line 36 def initialize(**kwargs) # Defaults for gRPC: kwargs[:host] ||= '127.0.0.1' kwargs[:port] ||= 57_400 # rubocop:disable Style/HashSyntax super(data_formats: [:cli, :yang_json], platform: :ios_xr, **kwargs) # rubocop:enable Style/HashSyntax @config = GRPCConfigOper::Stub.new(@address, :this_channel_is_insecure) @exec = GRPCExec::Stub.new(@address, :this_channel_is_insecure) # Make sure we can actually connect @timeout = 10 begin base_msg = 'gRPC client creation failure: ' get(command: 'show clock') rescue Cisco::ClientError => e error 'initial connect failed: ' + e.to_s if e.[/deadline exceeded/i] raise Cisco::ConnectionRefused, \ base_msg + 'timed out during initial connection: ' + e. end raise e.class, base_msg + e. end # Let commands in general take up to 2 minutes @timeout = 120 end |