Class: Train::Transports::SSH::CiscoIOSConnection

Inherits:
BaseConnection
  • Object
show all
Defined in:
lib/train/transports/cisco_ios_connection.rb

Defined Under Namespace

Classes: BadEnablePassword

Instance Method Summary collapse

Constructor Details

#initialize(options) ⇒ CiscoIOSConnection

Returns a new instance of CiscoIOSConnection.



5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
# File 'lib/train/transports/cisco_ios_connection.rb', line 5

def initialize(options)
  super(options)

  # Extract options to avoid passing them in to `Net::SSH.start` later
  @host = options.delete(:host)
  @user = options.delete(:user)
  @port = options.delete(:port)
  @enable_password = options.delete(:enable_password)

  # Use all options left that are not `nil` for `Net::SSH.start` later
  @ssh_options = options.reject { |_key, value| value.nil? }

  # Allow older algorithms
  @ssh_options[:append_all_supported_algorithms] = true

  @prompt = /^\S+[>#]\r\n.*$/
end

Instance Method Details

#download(remotes, local) ⇒ Object

Raises:

  • (NotImplementedError)


36
37
38
# File 'lib/train/transports/cisco_ios_connection.rb', line 36

def download(remotes, local)
  raise NotImplementedError, "#{self.class} does not implement #download()"
end

#unique_identifierObject



27
28
29
30
# File 'lib/train/transports/cisco_ios_connection.rb', line 27

def unique_identifier
  result = run_command_via_connection("show version | include Processor")
  result.stdout.split(" ")[-1]
end

#upload(locals, remote) ⇒ Object

Raises:

  • (NotImplementedError)


32
33
34
# File 'lib/train/transports/cisco_ios_connection.rb', line 32

def upload(locals, remote)
  raise NotImplementedError, "#{self.class} does not implement #upload()"
end

#uriObject



23
24
25
# File 'lib/train/transports/cisco_ios_connection.rb', line 23

def uri
  "ssh://#{@user}@#{@host}:#{@port}"
end