summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--lib/puppet/util/network_device.rb5
-rw-r--r--lib/puppet/util/network_device/transport/ssh.rb4
-rw-r--r--spec/unit/util/network_device_spec.rb4
3 files changed, 12 insertions, 1 deletions
diff --git a/lib/puppet/util/network_device.rb b/lib/puppet/util/network_device.rb
index d9c1aa34d..a650670ce 100644
--- a/lib/puppet/util/network_device.rb
+++ b/lib/puppet/util/network_device.rb
@@ -9,4 +9,9 @@ class Puppet::Util::NetworkDevice
rescue => detail
raise "Can't load #{device.provider} for #{device.name}: #{detail}"
end
+
+ # for tests reset
+ def self.clear
+ @current = nil
+ end
end \ No newline at end of file
diff --git a/lib/puppet/util/network_device/transport/ssh.rb b/lib/puppet/util/network_device/transport/ssh.rb
index bf0e7193c..3d7976543 100644
--- a/lib/puppet/util/network_device/transport/ssh.rb
+++ b/lib/puppet/util/network_device/transport/ssh.rb
@@ -2,7 +2,6 @@
require 'puppet/util/network_device'
require 'puppet/util/network_device/transport'
require 'puppet/util/network_device/transport/base'
-require 'net/ssh'
# This is an adaptation/simplification of gem net-ssh-telnet, which aims to have
# a sane interface to Net::SSH. Credits goes to net-ssh-telnet authors
@@ -12,6 +11,9 @@ class Puppet::Util::NetworkDevice::Transport::Ssh < Puppet::Util::NetworkDevice:
def initialize
super
+ unless Puppet.features.ssh?
+ raise 'Connecting with ssh to a network device requires the \'net/ssh\' ruby library'
+ end
end
def handles_login?
diff --git a/spec/unit/util/network_device_spec.rb b/spec/unit/util/network_device_spec.rb
index 70cb509b4..347986ac6 100644
--- a/spec/unit/util/network_device_spec.rb
+++ b/spec/unit/util/network_device_spec.rb
@@ -10,6 +10,10 @@ describe Puppet::Util::NetworkDevice do
@device = OpenStruct.new(:name => "name", :provider => "test")
end
+ after(:each) do
+ Puppet::Util::NetworkDevice.clear
+ end
+
class Puppet::Util::NetworkDevice::Test
class Device
def initialize(device)