Method: Cisco::Client::GRPC#handle_text_output
- Defined in:
- lib/cisco_node_utils/client/grpc/client.rb
#handle_text_output(args, output) ⇒ Object
271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 |
# File 'lib/cisco_node_utils/client/grpc/client.rb', line 271 def handle_text_output(args, output) # For a successful show command, gRPC presents the output as: # \n--------- <cmd> ---------- # \n<output of command> # \n\n # For an invalid CLI, gRPC presents the output as: # \n--------- <cmd> -------- # \n<cmd> # \n<error output> # \n\n # Discard the leading whitespace, header, and trailing whitespace output = output.split("\n").drop(2) return '' if output.nil? || output.empty? # Now we have either [<output_line_1>, <output_line_2>, ...] or # [<cmd>, <error_line_1>, <error_line_2>, ...] if output[0].strip == args.cli.strip fail Cisco::CliError.new( # rubocop:disable Style/RaiseArgs rejected_input: args.cli, clierror: output.join("\n"), ) end output.join("\n") end |