capistrano-karaf 1.7.1 → 1.7.2

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.
@@ -2,74 +2,82 @@ require 'sshkit/backends/netssh'
2
2
 
3
3
  module Capistrano_karaf
4
4
  module Backend
5
+ class KarafCommand
6
+ attr_reader :karaf_username, :karaf_password, :karaf_port
7
+
8
+ def initialize
9
+ @karaf_username = fetch :karaf_username, "smx"
10
+ @karaf_password = fetch :karaf_password, "smx"
11
+ @karaf_port = fetch :karaf_port, "8101"
12
+ end
13
+
14
+ def create(*args)
15
+ command = args.shift.to_s.strip
16
+ command1 = SSHKit.config.command_map[command.to_sym].split(' ')
17
+ args1 = command1.concat(args)
18
+ ["sshpass", "-p", karaf_password, "ssh", "-o", "NoHostAuthenticationForLocalhost=yes", "-o", "StrictHostKeyChecking=no", "#{karaf_username}@localhost", "-p", karaf_port].concat(args1)
19
+ end
20
+ end
21
+
22
+
5
23
  class SshProxy < SSHKit::Backend::Netssh
6
24
 
7
25
  @pool = SSHKit::Backend::ConnectionPool.new
8
26
 
9
27
  def capture(*args)
10
- karaf_role = fetch :karaf_role, :karaf
11
- if host.has_role? karaf_role
12
-
13
- karaf_username = fetch :karaf_username, "smx"
14
- karaf_password = fetch :karaf_password, "smx"
15
- karaf_port = fetch :karaf_port, "8101"
28
+ karaf_role = fetch :karaf_role, :karaf
29
+ if host.has_role? karaf_role
16
30
 
17
- args1 = ["sshpass", "-p", karaf_password, "ssh", "-o", "NoHostAuthenticationForLocalhost=yes", "-o", "StrictHostKeyChecking=no", "#{karaf_username}@localhost", "-p", karaf_port].concat(args)
18
- options = { verbosity: Logger::DEBUG }.merge(args1.extract_options!)
19
-
20
- r = nil
21
- counter = 0
22
- ex = nil
23
- begin
24
- counter += 1
25
- begin
26
- r = _execute(*[*args1, options])
27
- ex = nil
28
- break
29
- rescue SSHKit::Command::Failed => e
30
- output << SSHKit::LogMessage.new(Logger::WARN, "Got exception while running command #{args1} on host #{host.hostname}")
31
- ex = e
32
- end
33
- end while counter < 4
34
-
35
- raise ex unless ex.nil?
36
- r.full_stdout.strip
37
- else
38
- options = { verbosity: Logger::DEBUG }.merge(args.extract_options!)
39
- _execute(*[*args, options]).full_stdout.strip
40
- end
31
+ karaf_command = KarafCommand.new
32
+ args1 = karaf_command.create(*args)
33
+ options = { verbosity: Logger::DEBUG }.merge(args1.extract_options!)
34
+
35
+ r = _execute_command args1, options
36
+ r.full_stdout.strip
37
+ else
38
+ options = { verbosity: Logger::DEBUG }.merge(args.extract_options!)
39
+ _execute(*[*args, options]).full_stdout.strip
40
+ end
41
41
  end
42
42
 
43
43
  def execute(*args)
44
- karaf_role = fetch :karaf_role, :karaf
45
- if host.has_role? karaf_role
44
+ args1 = resolve_command(*args)
45
+
46
+ karaf_role = fetch :karaf_role, :karaf
47
+ if host.has_role? karaf_role
48
+
49
+ karaf_command = KarafCommand.new
50
+ args1 = karaf_command.create(*args)
51
+ options = { verbosity: Logger::DEBUG }.merge(args1.extract_options!)
46
52
 
47
- karaf_username = fetch :karaf_username, "smx"
48
- karaf_password = fetch :karaf_password, "smx"
49
- karaf_port = fetch :karaf_port, "8101"
53
+ r = _execute_command args1, options
54
+ r.success?
55
+ else
56
+ _execute(*args).success?
57
+ end
58
+ end
59
+
60
+ private
50
61
 
51
- args1 = ["sshpass", "-p", karaf_password, "ssh", "-o", "NoHostAuthenticationForLocalhost=yes", "-o", "StrictHostKeyChecking=no", "#{karaf_username}@localhost", "-p", karaf_port].concat(args)
52
- r = nil
53
- counter = 0
62
+ def _execute_command(args, options)
63
+ r = nil
64
+ counter = 0
65
+ ex = nil
66
+ begin
67
+ counter += 1
68
+ begin
69
+ r = _execute *args.push(options)
54
70
  ex = nil
55
- begin
56
- counter += 1
57
- begin
58
- r = _execute(*args1)
59
- ex = nil
60
- break
61
- rescue SSHKit::Command::Failed => e
62
- output << SSHKit::LogMessage.new(Logger::WARN, "Got exception while running command #{args1} on host #{host.hostname}")
63
- ex = e
64
- end
65
- end while counter < 4
66
-
67
- raise ex unless ex.nil?
68
- r.success?
69
- else
70
- _execute(*args).success?
71
+ break
72
+ rescue SSHKit::Command::Failed => e
73
+ output << SSHKit::LogMessage.new(Logger::WARN, "Got exception while running command #{args} on host #{host.hostname}: #{e}")
74
+ ex = e
71
75
  end
76
+ end while counter < 4
77
+ raise ex unless ex.nil?
78
+ r
72
79
  end
73
- end
80
+ end
74
81
  end
75
82
  end
83
+
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: capistrano-karaf
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.7.1
4
+ version: 1.7.2
5
5
  prerelease:
6
6
  platform: ruby
7
7
  authors: