beaker 2.13.0 → 2.14.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (62) hide show
  1. checksums.yaml +8 -8
  2. data/Gemfile +19 -0
  3. data/HISTORY.md +335 -2
  4. data/acceptance/pre_suite/puppet_git/install.rb +2 -2
  5. data/lib/beaker/answers.rb +45 -2
  6. data/lib/beaker/answers/version20.rb +9 -9
  7. data/lib/beaker/answers/version28.rb +9 -9
  8. data/lib/beaker/answers/version30.rb +19 -19
  9. data/lib/beaker/answers/version32.rb +1 -1
  10. data/lib/beaker/answers/version34.rb +4 -4
  11. data/lib/beaker/answers/version40.rb +1 -1
  12. data/lib/beaker/cli.rb +11 -4
  13. data/lib/beaker/command.rb +4 -2
  14. data/lib/beaker/command_factory.rb +5 -1
  15. data/lib/beaker/dsl/helpers/host_helpers.rb +17 -5
  16. data/lib/beaker/dsl/install_utils.rb +3 -2
  17. data/lib/beaker/dsl/install_utils/aio_defaults.rb +86 -0
  18. data/lib/beaker/dsl/install_utils/foss_defaults.rb +163 -0
  19. data/lib/beaker/dsl/install_utils/foss_utils.rb +988 -0
  20. data/lib/beaker/dsl/install_utils/pe_defaults.rb +139 -0
  21. data/lib/beaker/dsl/install_utils/pe_utils.rb +140 -38
  22. data/lib/beaker/dsl/install_utils/puppet_utils.rb +26 -751
  23. data/lib/beaker/dsl/structure.rb +7 -1
  24. data/lib/beaker/host.rb +35 -58
  25. data/lib/beaker/host/freebsd.rb +4 -16
  26. data/lib/beaker/host/mac.rb +3 -39
  27. data/lib/beaker/host/mac/pkg.rb +2 -1
  28. data/lib/beaker/host/pswindows.rb +2 -28
  29. data/lib/beaker/host/unix.rb +3 -51
  30. data/lib/beaker/host/unix/pkg.rb +34 -33
  31. data/lib/beaker/host/windows.rb +1 -45
  32. data/lib/beaker/host_prebuilt_steps.rb +11 -24
  33. data/lib/beaker/hypervisor/aixer.rb +1 -1
  34. data/lib/beaker/hypervisor/docker.rb +43 -4
  35. data/lib/beaker/hypervisor/openstack.rb +1 -0
  36. data/lib/beaker/hypervisor/solaris.rb +1 -1
  37. data/lib/beaker/hypervisor/vmpooler.rb +19 -8
  38. data/lib/beaker/network_manager.rb +5 -4
  39. data/lib/beaker/options/command_line_parser.rb +9 -9
  40. data/lib/beaker/options/parser.rb +21 -17
  41. data/lib/beaker/options/presets.rb +0 -33
  42. data/lib/beaker/platform.rb +7 -3
  43. data/lib/beaker/ssh_connection.rb +1 -1
  44. data/lib/beaker/version.rb +1 -1
  45. data/spec/beaker/answers_spec.rb +13 -8
  46. data/spec/beaker/cli_spec.rb +6 -6
  47. data/spec/beaker/command_spec.rb +18 -0
  48. data/spec/beaker/dsl/helpers/puppet_helpers_spec.rb +2 -0
  49. data/spec/beaker/dsl/install_utils/{puppet_utils_spec.rb → foss_utils_spec.rb} +34 -21
  50. data/spec/beaker/dsl/install_utils/pe_utils_spec.rb +2 -0
  51. data/spec/beaker/dsl/structure_spec.rb +8 -0
  52. data/spec/beaker/host/unix/pkg_spec.rb +15 -10
  53. data/spec/beaker/host_prebuilt_steps_spec.rb +1 -1
  54. data/spec/beaker/host_spec.rb +3 -54
  55. data/spec/beaker/hypervisor/docker_spec.rb +2 -0
  56. data/spec/beaker/hypervisor/vmpooler_spec.rb +67 -10
  57. data/spec/beaker/options/command_line_parser_spec.rb +2 -2
  58. data/spec/beaker/options/parser_spec.rb +35 -24
  59. data/spec/beaker/options/presets_spec.rb +0 -26
  60. data/spec/helpers.rb +5 -5
  61. data/spec/mocks.rb +1 -2
  62. metadata +7 -3
@@ -164,6 +164,9 @@ module Beaker
164
164
  # on( solaris, 'zonename' ) =~ /global/
165
165
  # end
166
166
  #
167
+ # @example Confining to an already defined subset of hosts
168
+ # confine :to, {}, agents
169
+ #
167
170
  # @return [Array<Host>] Returns an array of hosts that are still valid
168
171
  # targets for this tests case.
169
172
  # @raise [SkipTest] Raises skip test if there are no valid hosts for
@@ -174,7 +177,9 @@ module Beaker
174
177
  when :except
175
178
  hosts_to_modify = hosts_to_modify - select_hosts(criteria, hosts_to_modify, &block)
176
179
  when :to
177
- hosts_to_modify = select_hosts(criteria, hosts_to_modify, &block)
180
+ if criteria and ( not criteria.empty? )
181
+ hosts_to_modify = select_hosts(criteria, hosts_to_modify, &block)
182
+ end
178
183
  else
179
184
  raise "Unknown option #{type}"
180
185
  end
@@ -193,6 +198,7 @@ module Beaker
193
198
  # @see #confine
194
199
  def confine_block(type, criteria, host_array = nil, &block)
195
200
  begin
201
+ host_array ||= hosts
196
202
  original_hosts = self.hosts.dup
197
203
  confine(type, criteria, host_array)
198
204
 
@@ -3,7 +3,7 @@ require 'timeout'
3
3
  require 'benchmark'
4
4
  require 'rsync'
5
5
 
6
- [ 'command', 'ssh_connection' ].each do |lib|
6
+ [ 'command', 'ssh_connection'].each do |lib|
7
7
  require "beaker/#{lib}"
8
8
  end
9
9
 
@@ -26,59 +26,34 @@ module Beaker
26
26
  end
27
27
  end
28
28
 
29
- def self.create name, options
30
- case options['HOSTS'][name]['platform']
29
+ def self.create name, host_hash, options
30
+ case host_hash['platform']
31
31
  when /windows/
32
- cygwin = options['HOSTS'][name]['is_cygwin']
32
+ cygwin = host_hash['is_cygwin']
33
33
  if cygwin.nil? or cygwin == true
34
- Windows::Host.new name, options
34
+ Windows::Host.new name, host_hash, options
35
35
  else
36
- PSWindows::Host.new name, options
36
+ PSWindows::Host.new name, host_hash, options
37
37
  end
38
38
  when /aix/
39
- Aix::Host.new name, options
39
+ Aix::Host.new name, host_hash, options
40
40
  when /osx/
41
- Mac::Host.new name, options
41
+ Mac::Host.new name, host_hash, options
42
42
  when /freebsd/
43
- FreeBSD::Host.new name, options
43
+ FreeBSD::Host.new name, host_hash, options
44
44
  else
45
- Unix::Host.new name, options
45
+ Unix::Host.new name, host_hash, options
46
46
  end
47
47
  end
48
48
 
49
49
  attr_accessor :logger
50
- attr_reader :name, :defaults
51
- def initialize name, options
52
- @logger = options[:logger]
53
- @name, @options = name.to_s, options.dup
54
-
55
- # This is annoying and its because of drift/lack of enforcement/lack of having
56
- # a explict relationship between our defaults, our setup steps and how they're
57
- # related through 'type' and the differences between the assumption of our two
58
- # configurations we have for many of our products
59
- type = @options.get_type
60
- @defaults = merge_defaults_for_type @options, type
61
- pkg_initialize
62
- end
50
+ attr_reader :name, :host_hash, :options
51
+ def initialize name, host_hash, options
52
+ @logger = host_hash[:logger] || options[:logger]
53
+ @name, @host_hash, @options = name.to_s, host_hash.dup, options.dup
63
54
 
64
- # Builds a deprecated keys array, for checking to see if a key is deprecated.
65
- # The recommended check after using this method is +result.include?(key)+
66
- #
67
- # @note an unsupported host type (meaning it has no _aio_defaults_) will return
68
- # an empty hash
69
- #
70
- # @return [Array<Symbol>] An array of keys that are deprecated for a host
71
- def build_deprecated_keys()
72
- begin
73
- deprecated_keys_hash = self.class.send "foss_defaults".to_sym
74
- delete_exceptions_hash = self.class.send "aio_defaults".to_sym
75
- deprecated_keys_hash.delete_if do |key, value|
76
- delete_exceptions_hash.has_key?(key)
77
- end
78
- rescue NoMethodError
79
- deprecated_keys_hash = {}
80
- end
81
- deprecated_keys_hash.keys()
55
+ @host_hash = self.platform_defaults.merge(@host_hash)
56
+ pkg_initialize
82
57
  end
83
58
 
84
59
  def pkg_initialize
@@ -86,11 +61,6 @@ module Beaker
86
61
  # handle whatever packaging-related initialization is necessary.
87
62
  end
88
63
 
89
- def merge_defaults_for_type options, type
90
- defaults = self.class.send "#{type}_defaults".to_sym
91
- defaults.merge(options.merge((options['HOSTS'][name])))
92
- end
93
-
94
64
  def node_name
95
65
  # TODO: might want to consider caching here; not doing it for now because
96
66
  # I haven't thought through all of the possible scenarios that could
@@ -132,18 +102,21 @@ module Beaker
132
102
  end
133
103
 
134
104
  def []= k, v
135
- @defaults[k] = v
105
+ host_hash[k] = v
136
106
  end
137
107
 
108
+ # Does this host have this key? Either as defined in the host itself, or globally?
138
109
  def [] k
139
- @deprecated_keys ||= build_deprecated_keys()
140
- deprecation_message = "deprecated host key '#{k}'. Perhaps you can use host.puppet[] to get what you're looking for."
141
- @logger.warn( deprecation_message ) if @logger && @deprecated_keys.include?(k.to_sym)
142
- @defaults[k]
110
+ host_hash[k] || options[k]
143
111
  end
144
112
 
113
+ # Does this host have this key? Either as defined in the host itself, or globally?
145
114
  def has_key? k
146
- @defaults.has_key?(k)
115
+ host_hash.has_key?(k) || options.has_key?(k)
116
+ end
117
+
118
+ def delete k
119
+ host_hash.delete(k)
147
120
  end
148
121
 
149
122
  # The {#hostname} of this host.
@@ -159,7 +132,7 @@ module Beaker
159
132
  # Return the public name of the particular host, which may be different then the name of the host provided in
160
133
  # the configuration file as some provisioners create random, unique hostnames.
161
134
  def hostname
162
- @defaults['vmhostname'] || @name
135
+ host_hash['vmhostname'] || @name
163
136
  end
164
137
 
165
138
  def + other
@@ -167,7 +140,7 @@ module Beaker
167
140
  end
168
141
 
169
142
  def is_pe?
170
- @options.is_pe?
143
+ self['type'] && self['type'].to_s =~ /pe/
171
144
  end
172
145
 
173
146
  def is_cygwin?
@@ -220,7 +193,7 @@ module Beaker
220
193
  end
221
194
 
222
195
  def log_prefix
223
- if @defaults['vmhostname']
196
+ if host_hash['vmhostname']
224
197
  "#{self} (#{@name})"
225
198
  else
226
199
  self.to_s
@@ -376,6 +349,9 @@ module Beaker
376
349
 
377
350
  # copy each file to the host
378
351
  dir_source.each do |s|
352
+ # Copy files, not directories (as they are copied recursively)
353
+ next if File.directory?(s)
354
+
379
355
  s_path = Pathname.new(s)
380
356
  if s_path.absolute?
381
357
  file_path = File.join(target, File.dirname(s).gsub(/#{Regexp.escape(File.dirname(File.absolute_path(source)))}/,''))
@@ -420,7 +396,7 @@ module Beaker
420
396
  else
421
397
  user = self['user']
422
398
  end
423
- hostname_with_user = "#{user}@#{self}"
399
+ hostname_with_user = "#{user}@#{reachable_name}"
424
400
 
425
401
  Rsync.host = hostname_with_user
426
402
 
@@ -442,8 +418,8 @@ module Beaker
442
418
  ssh_args << "-i #{key}"
443
419
  end
444
420
 
445
- if ssh_opts.has_key?('port') and
446
- ssh_args << "-p #{ssh_opts['port']}"
421
+ if ssh_opts.has_key?(:port)
422
+ ssh_args << "-p #{ssh_opts[:port]}"
447
423
  end
448
424
 
449
425
  # We disable prompt when host isn't known
@@ -468,6 +444,7 @@ module Beaker
468
444
 
469
445
  @logger.notify "rsync: localhost:#{from_path} to #{hostname_with_user}:#{to_path} {:ignore => #{opts[:ignore]}}"
470
446
  result = Rsync.run(from_path, to_path, rsync_args)
447
+ @logger.debug("rsync returned #{result.inspect}")
471
448
  result
472
449
  end
473
450
 
@@ -13,27 +13,15 @@ module FreeBSD
13
13
 
14
14
  include FreeBSD::Exec
15
15
 
16
- def self.foss_defaults
16
+ def platform_defaults
17
17
  h = Beaker::Options::OptionsHash.new
18
18
  h.merge({
19
19
  'user' => 'root',
20
- 'group' => 'puppet',
21
- 'puppetserver-confdir' => '/etc/puppetserver/conf.d',
22
- 'puppetservice' => 'puppetmaster',
23
- 'puppetpath' => '/usr/local/etc/puppet/modules',
24
- 'puppetvardir' => '/var/lib/puppet',
25
- 'puppetbin' => '/usr/bin/puppet',
26
- 'puppetbindir' => '/usr/bin',
27
- 'hieralibdir' => '/opt/puppet-git-repos/hiera/lib',
28
- 'hierapuppetlibdir' => '/opt/puppet-git-repos/hiera-puppet/lib',
29
- 'hierabindir' => '/opt/puppet-git-repos/hiera/bin',
30
- 'hieradatadir' => '/usr/local/etc/puppet/modules/hieradata',
31
- 'hieraconf' => '/usr/local/etc/puppet/modules/hiera.yaml',
32
- 'distmoduledir' => '/usr/local/etc/puppet/modules',
33
- 'sitemoduledir' => '/usr/share/puppet/modules',
20
+ 'group' => 'root',
34
21
  'pathseparator' => ':',
35
22
  })
36
23
  end
24
+
37
25
  end
38
26
 
39
- end
27
+ end
@@ -13,50 +13,14 @@ module Mac
13
13
  include Mac::Group
14
14
  include Mac::Pkg
15
15
 
16
- def self.pe_defaults
16
+ def platform_defaults
17
17
  h = Beaker::Options::OptionsHash.new
18
18
  h.merge({
19
- 'user' => 'root',
20
- 'group' => 'pe-puppet',
21
- 'puppetserver-confdir' => '/etc/puppetlabs/puppetserver/conf.d',
22
- 'puppetservice' => 'pe-httpd',
23
- 'puppetpath' => '/etc/puppetlabs/puppet',
24
- 'puppetconfdir' => '/etc/puppetlabs/puppet',
25
- 'puppetcodedir' => '/etc/puppetlabs/puppet',
26
- 'puppetbin' => '/opt/puppet/bin/puppet',
27
- 'puppetbindir' => '/opt/puppet/bin',
28
- 'puppetsbindir' => '/opt/puppet/sbin',
29
- 'puppetvardir' => '/var/opt/lib/pe-puppet',
30
- 'hieradatadir' => '/var/lib/hiera',
31
- 'hieraconf' => '/etc/puppetlabs/puppet/hiera.yaml',
32
- 'distmoduledir' => '/etc/puppetlabs/puppet/modules',
33
- 'sitemoduledir' => '/opt/puppet/share/puppet/modules',
19
+ 'user' => 'root',
20
+ 'group' => 'root',
34
21
  'pathseparator' => ':',
35
22
  })
36
23
  end
37
24
 
38
- def self.foss_defaults
39
- h = Beaker::Options::OptionsHash.new
40
- h.merge({
41
- 'user' => 'root',
42
- 'group' => 'puppet',
43
- 'puppetserver-confdir' => '/etc/puppetserver/conf.d',
44
- 'puppetservice' => 'puppetmaster',
45
- 'puppetpath' => '/etc/puppet',
46
- 'puppetconfdir' => '/etc/puppet',
47
- 'puppetcodedir' => '/etc/puppet',
48
- 'puppetvardir' => '/var/lib/puppet',
49
- 'puppetbin' => '/usr/bin/puppet',
50
- 'puppetbindir' => '/usr/bin',
51
- 'hieralibdir' => '/opt/puppet-git-repos/hiera/lib',
52
- 'hierapuppetlibdir' => '/opt/puppet-git-repos/hiera-puppet/lib',
53
- 'hierabindir' => '/opt/puppet-git-repos/hiera/bin',
54
- 'hieradatadir' => '/etc/puppet/hieradata',
55
- 'hieraconf' => '/etc/puppet/hiera.yaml',
56
- 'distmoduledir' => '/etc/puppet/modules',
57
- 'sitemoduledir' => '/usr/share/puppet/modules',
58
- 'pathseparator' => ':',
59
- })
60
- end
61
25
  end
62
26
  end
@@ -6,7 +6,8 @@ module Mac::Pkg
6
6
  end
7
7
 
8
8
  def install_package(name, cmdline_args = '', version = nil)
9
- raise "Package #{name} cannot be installed on #{self}"
9
+ execute("hdiutil attach #{name}.dmg")
10
+ execute("installer -pkg /Volumes/#{name}/#{name}.pkg -target /")
10
11
  end
11
12
 
12
13
  def uninstall_package(name, cmdline_args = '')
@@ -14,40 +14,14 @@ module PSWindows
14
14
  include PSWindows::Exec
15
15
  include PSWindows::Pkg
16
16
 
17
- def self.pe_defaults
18
- h = Beaker::Options::OptionsHash.new
19
- h.merge({
20
- 'user' => 'Administrator',
21
- 'group' => 'Administrators',
22
- 'distmoduledir' => 'C:\\ProgramData\\PuppetLabs\\puppet\\etc\\modules',
23
- 'sitemoduledir' => 'C:\\usr\\share\\puppet\\modules',
24
- 'puppetservice' => 'pe-httpd',
25
- 'pathseparator' => ';',
26
- 'puppetpath' => 'C:\\ProgramData\\PuppetLabs\\puppet\\etc',
27
- 'puppetconfdir' => 'C:\\ProgramData\\PuppetLabs\\puppet\\etc',
28
- 'puppetcodedir' => 'C:\\ProgramData\\PuppetLabs\\puppet\\etc',
29
- 'hieraconf' => 'C:\\ProgramData\\PuppetLabs\\puppet\\etc\\hiera.yaml',
30
- 'puppetvardir' => 'C:\\ProgramData\\PuppetLabs\\puppet\\var',
31
- 'puppetbindir' => '"C:\\Program Files (x86)\\PuppetLabs\\Puppet Enterprise\\bin";"C:\\Program Files\\PuppetLabs\\Puppet Enterprise\\bin"'
32
- })
33
- end
34
-
35
- def self.foss_defaults
17
+ def platform_defaults
36
18
  h = Beaker::Options::OptionsHash.new
37
19
  h.merge({
38
20
  'user' => 'Administrator',
39
21
  'group' => 'Administrators',
40
- 'distmoduledir' => 'C:\\ProgramData\\PuppetLabs\\puppet\\etc\\modules',
41
- 'sitemoduledir' => 'C:\\usr\\share\\puppet\\modules',
42
- 'hieralibdir' => 'C:\\opt\\puppet-git-repos\\hiera\\lib',
43
- 'hierapuppetlibdir' => 'C:\\opt\\puppet-git-repos\\hiera-puppet\\lib',
44
- 'hierabindir' => 'C:\\opt\\puppet-git-repos\\hiera\\bin',
45
22
  'pathseparator' => ';',
46
- 'puppetpath' => '"C:\\Program Files (x86)\\Puppet Labs\\Puppet\\etc";"C:\\Program Files\\Puppet Labs\\Puppet\\etc"',
47
- 'hieraconf' => '"C:\\Program Files (x86)\\Puppet Labs\\Puppet\\etc\\hiera.yaml";"C:\\Program Files\\Puppet Labs\\Puppet\\etc\\hiera.yaml"',
48
- 'puppetvardir' => '"C:\\Program Files (x86)\\Puppet Labs\\Puppet\\var";"C:\\Program Files\\Puppet Labs\\Puppet\\var"',
49
- 'puppetbindir' => '"C:\\Program Files (x86)\\Puppet Labs\\Puppet\\bin";"C:\\Program Files\\Puppet Labs\\Puppet\\bin"',
50
23
  })
51
24
  end
25
+
52
26
  end
53
27
  end
@@ -14,62 +14,14 @@ module Unix
14
14
  include Unix::Exec
15
15
  include Unix::Pkg
16
16
 
17
- def self.pe_defaults
17
+ def platform_defaults
18
18
  h = Beaker::Options::OptionsHash.new
19
19
  h.merge({
20
- 'user' => 'root',
21
- 'group' => 'pe-puppet',
22
- 'puppetserver-confdir' => '/etc/puppetlabs/puppetserver/conf.d',
23
- 'puppetservice' => 'pe-httpd',
24
- 'puppetpath' => '/etc/puppetlabs/puppet',
25
- 'puppetconfdir' => '/etc/puppetlabs/puppet',
26
- 'puppetbin' => '/opt/puppet/bin/puppet',
27
- 'puppetbindir' => '/opt/puppet/bin',
28
- 'puppetsbindir' => '/opt/puppet/sbin',
29
- 'privatebindir' => '/opt/puppetlabs/puppet/bin',
30
- 'puppetvardir' => '/var/opt/lib/pe-puppet',
31
- 'hieradatadir' => '/var/lib/hiera',
32
- 'hieraconf' => '/etc/puppetlabs/puppet/hiera.yaml',
33
- 'distmoduledir' => '/etc/puppetlabs/puppet/modules',
34
- 'sitemoduledir' => '/opt/puppet/share/puppet/modules',
20
+ 'user' => 'root',
21
+ 'group' => 'root',
35
22
  'pathseparator' => ':',
36
23
  })
37
24
  end
38
25
 
39
- def self.foss_defaults
40
- h = Beaker::Options::OptionsHash.new
41
- h.merge({
42
- 'user' => 'root',
43
- 'group' => 'puppet',
44
- 'puppetserver-confdir' => '/etc/puppetserver/conf.d',
45
- 'puppetservice' => 'puppetmaster',
46
- 'puppetpath' => '/etc/puppet',
47
- 'puppetconfdir' => '/etc/puppet',
48
- 'puppetvardir' => '/var/lib/puppet',
49
- 'puppetbin' => '/usr/bin/puppet',
50
- 'puppetbindir' => '/usr/bin',
51
- 'privatebindir' => '/usr/bin',
52
- 'hieralibdir' => '/opt/puppet-git-repos/hiera/lib',
53
- 'hierapuppetlibdir' => '/opt/puppet-git-repos/hiera-puppet/lib',
54
- 'hierabindir' => '/opt/puppet-git-repos/hiera/bin',
55
- 'hieradatadir' => '/etc/puppet/hieradata',
56
- 'hieraconf' => '/etc/puppet/hiera.yaml',
57
- 'distmoduledir' => '/etc/puppet/modules',
58
- 'sitemoduledir' => '/usr/share/puppet/modules',
59
- 'pathseparator' => ':',
60
- })
61
- end
62
-
63
- def self.aio_defaults
64
- h = Beaker::Options::OptionsHash.new
65
- h.merge({
66
- 'user' => 'root',
67
- 'puppetbindir' => '/opt/puppetlabs/bin',
68
- 'privatebindir' => '/opt/puppetlabs/puppet/bin',
69
- 'distmoduledir' => '/etc/puppetlabs/code/modules',
70
- 'sitemoduledir' => '/opt/puppetlabs/puppet/modules',
71
- 'pathseparator' => ':',
72
- })
73
- end
74
26
  end
75
27
  end
@@ -17,28 +17,29 @@ module Unix::Pkg
17
17
  end
18
18
  end
19
19
 
20
- def check_for_package(name)
20
+ def check_for_package(name, opts = {})
21
+ opts = {:accept_all_exit_codes => true}.merge(opts)
21
22
  case self['platform']
22
23
  when /sles-10/
23
- result = exec(Beaker::Command.new("zypper se -i --match-exact #{name}"), :accept_all_exit_codes => true)
24
+ result = execute("zypper se -i --match-exact #{name}", opts) { |result| result }
24
25
  result.stdout =~ /No packages found/ ? (return false) : (return result.exit_code == 0)
25
26
  when /sles-/
26
- result = exec(Beaker::Command.new("zypper se -i --match-exact #{name}"), :accept_all_exit_codes => true)
27
+ result = execute("zypper se -i --match-exact #{name}", opts) { |result| result }
27
28
  when /el-4/
28
29
  @logger.debug("Package query not supported on rhel4")
29
30
  return false
30
- when /fedora|centos|eos|el-/
31
- result = exec(Beaker::Command.new("rpm -q #{name}"), :accept_all_exit_codes => true)
31
+ when /cisco|fedora|centos|eos|el-/
32
+ result = execute("rpm -q #{name}", opts) { |result| result }
32
33
  when /ubuntu|debian|cumulus/
33
- result = exec(Beaker::Command.new("dpkg -s #{name}"), :accept_all_exit_codes => true)
34
+ result = execute("dpkg -s #{name}", opts) { |result| result }
34
35
  when /solaris-11/
35
- result = exec(Beaker::Command.new("pkg info #{name}"), :accept_all_exit_codes => true)
36
+ result = execute("pkg info #{name}", opts) { |result| result }
36
37
  when /solaris-10/
37
- result = exec(Beaker::Command.new("pkginfo #{name}"), :accept_all_exit_codes => true)
38
+ result = execute("pkginfo #{name}", opts) { |result| result }
38
39
  when /freebsd-9/
39
- result = exec(Beaker::Command.new("pkg_info #{name}"), :accept_all_exit_codes => true)
40
+ result = execute("pkg_info #{name}", opts) { |result| result }
40
41
  when /freebsd-10/
41
- result = exec(Beaker::Command.new("pkg info #{name}"), :accept_all_exit_codes => true)
42
+ result = execute("pkg info #{name}", opts) { |result| result }
42
43
  else
43
44
  raise "Package #{name} cannot be queried on #{self}"
44
45
  end
@@ -56,50 +57,50 @@ module Unix::Pkg
56
57
  end
57
58
  end
58
59
 
59
- def install_package(name, cmdline_args = '', version = nil)
60
+ def install_package(name, cmdline_args = '', version = nil, opts = {})
60
61
  case self['platform']
61
62
  when /sles-/
62
- execute("zypper --non-interactive in #{name}")
63
+ execute("zypper --non-interactive in #{name}", opts)
63
64
  when /el-4/
64
65
  @logger.debug("Package installation not supported on rhel4")
65
- when /fedora|centos|eos|el-/
66
+ when /cisco|fedora|centos|eos|el-/
66
67
  if version
67
68
  name = "#{name}-#{version}"
68
69
  end
69
- execute("yum -y #{cmdline_args} install #{name}")
70
+ execute("yum -y #{cmdline_args} install #{name}", opts)
70
71
  when /ubuntu|debian|cumulus/
71
72
  if version
72
73
  name = "#{name}=#{version}"
73
74
  end
74
75
  update_apt_if_needed
75
- execute("apt-get install --force-yes #{cmdline_args} -y #{name}")
76
+ execute("apt-get install --force-yes #{cmdline_args} -y #{name}", opts)
76
77
  when /solaris-11/
77
- execute("pkg #{cmdline_args} install #{name}")
78
+ execute("pkg #{cmdline_args} install #{name}", opts)
78
79
  when /solaris-10/
79
- execute("pkgutil -i -y #{cmdline_args} #{name}")
80
+ execute("pkgutil -i -y #{cmdline_args} #{name}", opts)
80
81
  when /freebsd-9/
81
- execute("pkg_add -fr #{cmdline_args} #{name}")
82
+ execute("pkg_add -fr #{cmdline_args} #{name}", opts)
82
83
  when /freebsd-10/
83
- execute("pkg #{cmdline_args} install #{name}")
84
+ execute("pkg #{cmdline_args} install #{name}", opts)
84
85
  else
85
86
  raise "Package #{name} cannot be installed on #{self}"
86
87
  end
87
88
  end
88
89
 
89
- def uninstall_package(name, cmdline_args = '')
90
+ def uninstall_package(name, cmdline_args = '', opts = {})
90
91
  case self['platform']
91
92
  when /sles-/
92
- execute("zypper --non-interactive rm #{name}")
93
+ execute("zypper --non-interactive rm #{name}", opts)
93
94
  when /el-4/
94
95
  @logger.debug("Package uninstallation not supported on rhel4")
95
- when /fedora|centos|eos|el-/
96
- execute("yum -y #{cmdline_args} remove #{name}")
96
+ when /cisco|fedora|centos|eos|el-/
97
+ execute("yum -y #{cmdline_args} remove #{name}", opts)
97
98
  when /ubuntu|debian|cumulus/
98
- execute("apt-get purge #{cmdline_args} -y #{name}")
99
+ execute("apt-get purge #{cmdline_args} -y #{name}", opts)
99
100
  when /solaris-11/
100
- execute("pkg #{cmdline_args} uninstall #{name}")
101
+ execute("pkg #{cmdline_args} uninstall #{name}", opts)
101
102
  when /solaris-10/
102
- execute("pkgutil -r -y #{cmdline_args} #{name}")
103
+ execute("pkgutil -r -y #{cmdline_args} #{name}", opts)
103
104
  else
104
105
  raise "Package #{name} cannot be installed on #{self}"
105
106
  end
@@ -110,21 +111,21 @@ module Unix::Pkg
110
111
  # @param [String] name The name of the package to update
111
112
  # @param [String] cmdline_args Additional command line arguments for
112
113
  # the package manager
113
- def upgrade_package(name, cmdline_args = '')
114
+ def upgrade_package(name, cmdline_args = '', opts = {})
114
115
  case self['platform']
115
116
  when /sles-/
116
- execute("zypper --non-interactive --no-gpg-checks up #{name}")
117
+ execute("zypper --non-interactive --no-gpg-checks up #{name}", opts)
117
118
  when /el-4/
118
119
  @logger.debug("Package upgrade is not supported on rhel4")
119
- when /fedora|centos|eos|el-/
120
- execute("yum -y #{cmdline_args} update #{name}")
120
+ when /cisco|fedora|centos|eos|el-/
121
+ execute("yum -y #{cmdline_args} update #{name}", opts)
121
122
  when /ubuntu|debian|cumulus/
122
123
  update_apt_if_needed
123
- execute("apt-get install -o Dpkg::Options::='--force-confold' #{cmdline_args} -y --force-yes #{name}")
124
+ execute("apt-get install -o Dpkg::Options::='--force-confold' #{cmdline_args} -y --force-yes #{name}", opts)
124
125
  when /solaris-11/
125
- execute("pkg #{cmdline_args} update #{name}")
126
+ execute("pkg #{cmdline_args} update #{name}", opts)
126
127
  when /solaris-10/
127
- execute("pkgutil -u -y #{cmdline_args} ${name}")
128
+ execute("pkgutil -u -y #{cmdline_args} ${name}", opts)
128
129
  else
129
130
  raise "Package #{name} cannot be upgraded on #{self}"
130
131
  end