lib/beaker/host/cisco.rb in beaker-2.36.0 vs lib/beaker/host/cisco.rb in beaker-2.37.0
- old
+ new
@@ -19,11 +19,11 @@
# @param [String] scp_file_actual File path to actual SCP'd file on host
# @param [String] scp_file_target File path to target SCP location on host
#
# @return nil
def scp_post_operations(scp_file_actual, scp_file_target)
- if self[:platform] =~ /cisco-5/
+ if self[:platform] =~ /cisco_nexus/
execute( "mv #{scp_file_actual} #{scp_file_target}" )
end
nil
end
@@ -32,11 +32,11 @@
# @param [String] path File path to SCP to
#
# @return [String] path, changed if needed due to host
# constraints
def scp_path(path)
- if self[:platform] =~ /cisco-5/
+ if self[:platform] =~ /cisco_nexus/
@home_dir ||= execute( 'pwd' )
answer = "#{@home_dir}/#{File.basename( path )}"
answer << '/' if path =~ /\/$/
return answer
end
@@ -70,13 +70,12 @@
# @return [String] Command string as needed for this host
def prepend_commands(command = '', user_pc = '', opts = {})
return user_pc unless command.index('vsh').nil?
prepend_cmds = 'source /etc/profile;'
- if self[:platform] =~ /cisco-5/
- prepend_cmds << ' sudo ip netns exec '
- prepend_cmds << ( self[:vrf] ? self[:vrf] : '' )
+ if self[:vrf]
+ prepend_cmds << "sudo ip netns exec #{self[:vrf]}"
end
return prepend_cmds
end
# Construct the environment string for this command
@@ -93,32 +92,40 @@
def environment_string env
return '' if env.empty?
env_array = self.environment_variable_string_pair_array( env )
environment_string = env_array.join(' ')
- command = self[:platform] =~ /cisco-5/ ? 'export' : 'env'
+ command = self[:platform] =~ /cisco_nexus/ ? 'export' : 'env'
"#{command} #{environment_string};"
end
# Validates that the host was setup correctly
#
# @return nil
# @raise [ArgumentError] If the host is setup incorrectly,
# this will be raised with the appropriate message
def validate_setup
msg = nil
- msg = 'Cisco hosts must be provided with a :vrf value.' unless self[:vrf]
-
- if !msg && self[:platform] =~ /cisco-5/ && self[:user] == 'root'
- msg = 'Cisco-5 hosts must be provided with a :user value, as they can not SSH in as root.'
+ if self[:platform] =~ /cisco_nexus/
+ if !self[:vrf]
+ msg = 'Cisco Nexus hosts must be provided with a :vrf value.'
+ end
+ if !self[:user]
+ msg = 'Cisco hosts must be provided with a :user value'
+ end
end
+ if self[:platform] =~ /cisco_ios_xr/
+ if !self[:user]
+ msg = 'Cisco hosts must be provided with a :user value'
+ end
+ end
if msg
msg << <<-EOF
Check https://github.com/puppetlabs/beaker/blob/master/docs/hosts/cisco.md for more info.'
EOF
raise ArgumentError, msg
end
end
end
-end
\ No newline at end of file
+end