kitchen-ssh_cisco 0.1.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +7 -0
- data/LICENSE.txt +22 -0
- data/README.md +62 -0
- data/kitchen-ssh_cisco.gemspec +25 -0
- data/lib/kitchen/driver/ssh_cisco.rb +116 -0
- metadata +68 -0
checksums.yaml
ADDED
@@ -0,0 +1,7 @@
|
|
1
|
+
---
|
2
|
+
SHA1:
|
3
|
+
metadata.gz: fe9acfbc99cb39340cbf1fd43e29a2a792c00fdc
|
4
|
+
data.tar.gz: b022a60269abff42d3661196566ff0762fef4b15
|
5
|
+
SHA512:
|
6
|
+
metadata.gz: 1c6c10e529d7a2882bd2eafb598e9a58d87ef997bfb8deb121c7a51c63d7272d55e1d69fa7c213ae2b4f39a543fd9a0db868fd7e232b4c119c9f5c2df444835b
|
7
|
+
data.tar.gz: 3ab7d2b1d7f2cf7cb3e608c18aa57959038a18c9a8814ff24175da6febe118abaa139bc6032b28ed0303a63cf12c5184d496bea944d1ddbdca0679681c7aaca5
|
data/LICENSE.txt
ADDED
@@ -0,0 +1,22 @@
|
|
1
|
+
Copyright (c) 2014 Neill Turner
|
2
|
+
|
3
|
+
MIT License
|
4
|
+
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining
|
6
|
+
a copy of this software and associated documentation files (the
|
7
|
+
"Software"), to deal in the Software without restriction, including
|
8
|
+
without limitation the rights to use, copy, modify, merge, publish,
|
9
|
+
distribute, sublicense, and/or sell copies of the Software, and to
|
10
|
+
permit persons to whom the Software is furnished to do so, subject to
|
11
|
+
the following conditions:
|
12
|
+
|
13
|
+
The above copyright notice and this permission notice shall be
|
14
|
+
included in all copies or substantial portions of the Software.
|
15
|
+
|
16
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
|
17
|
+
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
18
|
+
MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
|
19
|
+
NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
|
20
|
+
LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
|
21
|
+
OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
|
22
|
+
WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
data/README.md
ADDED
@@ -0,0 +1,62 @@
|
|
1
|
+
# kitchen-ssh
|
2
|
+
|
3
|
+
ssh and ssh_gzip driver for test-kitchen for any running server with an ip address.
|
4
|
+
|
5
|
+
As well as ssh it supports a second driver called ssh_gzip that will also gzip file before transfer which can provide
|
6
|
+
a big performance improvement when alot of files are transfered.
|
7
|
+
|
8
|
+
server must be created and destroyed natively (e.g. via cloudformation, heat, or cloud or virtualization console).
|
9
|
+
specify driver parameters
|
10
|
+
* hostname
|
11
|
+
* port
|
12
|
+
* username
|
13
|
+
* password
|
14
|
+
* sudo
|
15
|
+
* ssh_key
|
16
|
+
* forward_agent
|
17
|
+
|
18
|
+
NOTE: ssh driver is compatibile with test-kitchen 1.4 while ssh_gzip has legacy driver compatiability
|
19
|
+
with test-kitchen 1.4
|
20
|
+
|
21
|
+
|
22
|
+
## Installation
|
23
|
+
|
24
|
+
Add this line to your application's Gemfile:
|
25
|
+
|
26
|
+
gem 'kitchen-ssh', group: :integration
|
27
|
+
|
28
|
+
And then execute:
|
29
|
+
|
30
|
+
$ bundle
|
31
|
+
|
32
|
+
Or install it yourself as:
|
33
|
+
|
34
|
+
$ gem install kitchen-ssh
|
35
|
+
|
36
|
+
## Usage
|
37
|
+
|
38
|
+
In your .kitchen.yml file set driver to be 'ssh' or 'ssh_gzip'.
|
39
|
+
|
40
|
+
##Example
|
41
|
+
|
42
|
+
```yaml
|
43
|
+
---
|
44
|
+
driver:
|
45
|
+
name: ssh
|
46
|
+
hostname: your-ip
|
47
|
+
port: 22
|
48
|
+
username: username
|
49
|
+
ssh_key: /path/to/id_rsa
|
50
|
+
```
|
51
|
+
|
52
|
+
or
|
53
|
+
|
54
|
+
```yaml
|
55
|
+
---
|
56
|
+
driver:
|
57
|
+
name: ssh_gzip
|
58
|
+
hostname: your-ip
|
59
|
+
port: 22
|
60
|
+
username: username
|
61
|
+
ssh_key: /path/to/id_rsa
|
62
|
+
```
|
@@ -0,0 +1,25 @@
|
|
1
|
+
# encoding: utf-8
|
2
|
+
|
3
|
+
$:.unshift File.expand_path('../lib', __FILE__)
|
4
|
+
|
5
|
+
Gem::Specification.new do |s|
|
6
|
+
s.name = "kitchen-ssh_cisco"
|
7
|
+
s.version = '0.1.0'
|
8
|
+
s.authors = ["Neill Turner","Carl Perry"]
|
9
|
+
s.email = ["neillwturner@gmail.com","partnereng@chef.io"]
|
10
|
+
s.homepage = "https://github.com/chef-partners/kitchen-ssh-cisco"
|
11
|
+
s.add_dependency('minitar', '~> 0.5')
|
12
|
+
s.summary = "ssh driver for test-kitchen for Linux based Cisco platform with an ip address"
|
13
|
+
candidates = Dir.glob("{lib}/**/*") + ['README.md', 'LICENSE.txt', 'kitchen-ssh_cisco.gemspec']
|
14
|
+
s.files = candidates.sort
|
15
|
+
s.platform = Gem::Platform::RUBY
|
16
|
+
s.require_paths = ['lib']
|
17
|
+
s.rubyforge_project = '[none]'
|
18
|
+
s.description = <<-EOF
|
19
|
+
ssh driver for test-kitchen for any Linux based Cisco platform with an ip address
|
20
|
+
|
21
|
+
Works the same as kitchen-ssh but adds a prefix_command directive to prefix a string before every command.
|
22
|
+
Useful for changing network namespace (hint, hint)
|
23
|
+
EOF
|
24
|
+
|
25
|
+
end
|
@@ -0,0 +1,116 @@
|
|
1
|
+
require 'kitchen'
|
2
|
+
require 'kitchen/driver/ssh_base'
|
3
|
+
|
4
|
+
module Kitchen
|
5
|
+
module Driver
|
6
|
+
class SshCisco < SSHBase
|
7
|
+
|
8
|
+
default_config :ssh_command_prefix, nil
|
9
|
+
|
10
|
+
# (see Base#converge)
|
11
|
+
def converge(state) # rubocop:disable Metrics/AbcSize
|
12
|
+
provisioner = instance.provisioner
|
13
|
+
provisioner.create_sandbox
|
14
|
+
sandbox_dirs = Dir.glob("#{provisioner.sandbox_path}/*")
|
15
|
+
|
16
|
+
instance.transport.connection(backcompat_merged_state(state)) do |conn|
|
17
|
+
run_remote(provisioner.install_command,conn)
|
18
|
+
run_remote(provisioner.init_command,conn)
|
19
|
+
info("Transferring files to #{instance.to_str}")
|
20
|
+
conn.upload(sandbox_dirs, provisioner[:root_path])
|
21
|
+
debug("Transfer complete")
|
22
|
+
run_remote(provisioner.prepare_command,conn)
|
23
|
+
run_remote(provisioner.run_command,conn)
|
24
|
+
end
|
25
|
+
rescue Kitchen::Transport::TransportFailed => ex
|
26
|
+
raise ActionFailed, ex.message
|
27
|
+
ensure
|
28
|
+
instance.provisioner.cleanup_sandbox
|
29
|
+
end
|
30
|
+
|
31
|
+
# (see Base#setup)
|
32
|
+
def setup(state)
|
33
|
+
verifier = instance.verifier
|
34
|
+
|
35
|
+
instance.transport.connection(backcompat_merged_state(state)) do |conn|
|
36
|
+
run_remote(verifier.install_command,conn)
|
37
|
+
end
|
38
|
+
rescue Kitchen::Transport::TransportFailed => ex
|
39
|
+
raise ActionFailed, ex.message
|
40
|
+
end
|
41
|
+
|
42
|
+
# (see Base#verify)
|
43
|
+
def verify(state) # rubocop:disable Metrics/AbcSize
|
44
|
+
verifier = instance.verifier
|
45
|
+
verifier.create_sandbox
|
46
|
+
sandbox_dirs = Dir.glob(File.join(verifier.sandbox_path, "*"))
|
47
|
+
|
48
|
+
instance.transport.connection(backcompat_merged_state(state)) do |conn|
|
49
|
+
run_remote(verifier.init_command,conn)
|
50
|
+
info("Transferring files to #{instance.to_str}")
|
51
|
+
conn.upload(sandbox_dirs, verifier[:root_path])
|
52
|
+
debug("Transfer complete")
|
53
|
+
run_remote(verifier.prepare_command,conn)
|
54
|
+
run_remote(verifier.run_command,conn)
|
55
|
+
end
|
56
|
+
rescue Kitchen::Transport::TransportFailed => ex
|
57
|
+
raise ActionFailed, ex.message
|
58
|
+
ensure
|
59
|
+
instance.verifier.cleanup_sandbox
|
60
|
+
end
|
61
|
+
|
62
|
+
# Executes an arbitrary command on an instance over an SSH connection.
|
63
|
+
#
|
64
|
+
# @param state [Hash] mutable instance and driver state
|
65
|
+
# @param command [String] the command to be executed
|
66
|
+
# @raise [ActionFailed] if the command could not be successfully completed
|
67
|
+
def remote_command(state, command)
|
68
|
+
instance.transport.connection(backcompat_merged_state(state)) do |conn|
|
69
|
+
run_remote(command,conn)
|
70
|
+
end
|
71
|
+
end
|
72
|
+
|
73
|
+
# Executes a remote command over SSH.
|
74
|
+
#
|
75
|
+
# @param command [String] remove command to run
|
76
|
+
# @param connection [Kitchen::SSH] an SSH connection
|
77
|
+
# @raise [ActionFailed] if an exception occurs
|
78
|
+
# @api private
|
79
|
+
def run_remote(command, connection)
|
80
|
+
return if command.nil?
|
81
|
+
|
82
|
+
command = command.to_s
|
83
|
+
command = self[:ssh_command_prefix] + " " + command if self[:ssh_command_prefix]
|
84
|
+
|
85
|
+
#require 'pry'; binding.pry
|
86
|
+
print "SSH2 Running remote command: " + command;
|
87
|
+
connection.execute(env_cmd(command))
|
88
|
+
rescue SSHFailed, Net::SSH::Exception => ex
|
89
|
+
raise ActionFailed, ex.message
|
90
|
+
end
|
91
|
+
|
92
|
+
def create(state)
|
93
|
+
state[:sudo] = config[:sudo]
|
94
|
+
state[:port] = config[:port]
|
95
|
+
state[:ssh_key] = config[:ssh_key]
|
96
|
+
state[:forward_agent] = config[:forward_agent]
|
97
|
+
state[:username] = config[:username]
|
98
|
+
state[:hostname] = config[:hostname]
|
99
|
+
state[:password] = config[:password]
|
100
|
+
print "Kitchen-ssh does not start your server '#{state[:hostname]}' but will look for an ssh connection with user '#{state[:username]}'"
|
101
|
+
wait_for_sshd(state[:hostname], state[:username], {:port => state[:port]})
|
102
|
+
print "Kitchen-ssh found ssh ready on host '#{state[:hostname]}' with user '#{state[:username]}'\n"
|
103
|
+
debug("ssh:create '#{state[:hostname]}'")
|
104
|
+
end
|
105
|
+
|
106
|
+
def destroy(state)
|
107
|
+
print "Kitchen-ssh does not destroy your server '#{state[:hostname]}' by shutting it down..."
|
108
|
+
print "Shutdown your server '#{state[:hostname]}' natively with user '#{state[:username]}'"
|
109
|
+
print 'in your cloud or virtualisation console etc.\n'
|
110
|
+
debug("ssh:destroy '#{state[:hostname]}'")
|
111
|
+
end
|
112
|
+
|
113
|
+
|
114
|
+
end
|
115
|
+
end
|
116
|
+
end
|
metadata
ADDED
@@ -0,0 +1,68 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: kitchen-ssh_cisco
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
version: 0.1.0
|
5
|
+
platform: ruby
|
6
|
+
authors:
|
7
|
+
- Neill Turner
|
8
|
+
- Carl Perry
|
9
|
+
autorequire:
|
10
|
+
bindir: bin
|
11
|
+
cert_chain: []
|
12
|
+
date: 2015-09-29 00:00:00.000000000 Z
|
13
|
+
dependencies:
|
14
|
+
- !ruby/object:Gem::Dependency
|
15
|
+
name: minitar
|
16
|
+
requirement: !ruby/object:Gem::Requirement
|
17
|
+
requirements:
|
18
|
+
- - "~>"
|
19
|
+
- !ruby/object:Gem::Version
|
20
|
+
version: '0.5'
|
21
|
+
type: :runtime
|
22
|
+
prerelease: false
|
23
|
+
version_requirements: !ruby/object:Gem::Requirement
|
24
|
+
requirements:
|
25
|
+
- - "~>"
|
26
|
+
- !ruby/object:Gem::Version
|
27
|
+
version: '0.5'
|
28
|
+
description: |
|
29
|
+
ssh driver for test-kitchen for any Linux based Cisco platform with an ip address
|
30
|
+
|
31
|
+
Works the same as kitchen-ssh but adds a prefix_command directive to prefix a string before every command.
|
32
|
+
Useful for changing network namespace (hint, hint)
|
33
|
+
email:
|
34
|
+
- neillwturner@gmail.com
|
35
|
+
- partnereng@chef.io
|
36
|
+
executables: []
|
37
|
+
extensions: []
|
38
|
+
extra_rdoc_files: []
|
39
|
+
files:
|
40
|
+
- LICENSE.txt
|
41
|
+
- README.md
|
42
|
+
- kitchen-ssh_cisco.gemspec
|
43
|
+
- lib/kitchen/driver/ssh_cisco.rb
|
44
|
+
homepage: https://github.com/chef-partners/kitchen-ssh-cisco
|
45
|
+
licenses: []
|
46
|
+
metadata: {}
|
47
|
+
post_install_message:
|
48
|
+
rdoc_options: []
|
49
|
+
require_paths:
|
50
|
+
- lib
|
51
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
52
|
+
requirements:
|
53
|
+
- - ">="
|
54
|
+
- !ruby/object:Gem::Version
|
55
|
+
version: '0'
|
56
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
57
|
+
requirements:
|
58
|
+
- - ">="
|
59
|
+
- !ruby/object:Gem::Version
|
60
|
+
version: '0'
|
61
|
+
requirements: []
|
62
|
+
rubyforge_project: "[none]"
|
63
|
+
rubygems_version: 2.4.4
|
64
|
+
signing_key:
|
65
|
+
specification_version: 4
|
66
|
+
summary: ssh driver for test-kitchen for Linux based Cisco platform with an ip address
|
67
|
+
test_files: []
|
68
|
+
has_rdoc:
|