kitchen-wpar 0.2.0 → 0.4.0

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: afa57801e169dc52a54a101f9c69be57b242d551
4
- data.tar.gz: 03096da58cdb37af094edb4eaa60b905ea6d5cb3
3
+ metadata.gz: 3e0233ac43573699543e48d649035f5ea153d90d
4
+ data.tar.gz: eddc62479f83d58ce5f14dc6eb2b06f35fb7ffc2
5
5
  SHA512:
6
- metadata.gz: 66ee5dc1546e8fbbe217d08e51ba23a21ae7ed3eeec073d88b1cd80a73f50e182ad83765afb05d0455479c41b9aebd2c005dd18cc59c93a04398cec1e1dc1011
7
- data.tar.gz: 50da5618019029bb93c305355faf619e6c592a6f17025d691336477c8ec1e95df08914788809dfb18cd1703d21595a01888d4970bddea1df3d8cd4b8006586e1
6
+ metadata.gz: 33071aa96867e62f3f54c0982a7d202ade59f421fa00487c124703604b4ed93343a0d6a6064628a0e2d08a7e64e3926b621dba9fffab4f635fe6a137484694ce
7
+ data.tar.gz: 7c2dff031be297cac01ccaf67fc2e3b8a85653ead8026c6aa0b502fae2c8b67dd4f7b72a700a52ed621cee1804e366bc12e2f9996938b8eaff48ce7f4f1d6b40
data/CHANGELOG.md CHANGED
@@ -1,3 +1,7 @@
1
+ ## 0.1.1
2
+
3
+ * Add mkwpar option ' -t' which copies root file systems from global WPAR
4
+
1
5
  ## 0.1.0 / Unreleased
2
6
 
3
7
  * Initial release
data/README.md CHANGED
@@ -21,6 +21,7 @@ Please read the [Driver usage][driver_usage] page for more details.
21
21
  * **wpar_vg** Volume group to use to store shared wpar filesystems. Default to **rootvg**.
22
22
  * **wpar_rootvg** Specify the `hdisk` to use to create a rootvg system wpar.
23
23
  * **wpar_mksysb** uses a wpar backup. Specify a path to a backup to save time.
24
+ * **wpar_copy_rootvg** adds the option ' -t' to copy rootvg file systems.
24
25
  * **isVersioned** create a versioned wpar. Used only with **wpar_mksysb**.
25
26
  * **isWritable** adds the option ' -l' to have a non-shared, writable /usr file system and /opt file system.
26
27
 
@@ -38,10 +38,19 @@ module Kitchen
38
38
  default_config :rmwpar, '/usr/sbin/rmwpar'
39
39
  default_config :lswpar, '/usr/sbin/lswpar'
40
40
  default_config :wpar_name, 'kitchenwpar'
41
+ default_config :wpar_copy_rootvg, false
41
42
  default_config :aix_host, 'localhost'
42
43
  default_config :aix_user, 'root'
43
44
  default_config :isWritable, false
44
45
  default_config :isVersioned, false
46
+ default_config :echo, '/bin/echo'
47
+ default_config :clogin, '/usr/sbin/clogin'
48
+ default_config :lssrc, '/usr/bin/lssrc'
49
+ default_config :mkssys, '/usr/bin/mkssys'
50
+ default_config :startsrc, '/usr/bin/startsrc'
51
+ default_config :stopsrc, '/usr/bin/stopsrc'
52
+ default_config :pam_sshd_account_rule, 'sshd account required pam_aix'
53
+ default_config :pam_sshd_session_rule, 'sshd session required pam_aix'
45
54
 
46
55
  def create(state)
47
56
  if wpar_exists?(state)
@@ -56,12 +65,19 @@ module Kitchen
56
65
  end
57
66
  state[:hostname]= config[:wpar_address] || config[:wpar_name]
58
67
  copy_key()
59
- end
60
68
 
61
- def destroy(state)
62
- ssh_command("#{config[:rmwpar]} -F #{config[:wpar_name]}", :stderr)
63
- if wpar_exists?(state)
64
- raise ActionFailed, "couldn't destroy wpar !"
69
+ # Ensure sshd is a defined service and is running so that
70
+ # kitchen can connect to the host and do work.
71
+ unless sshd_service_exists?
72
+ create_sshd_service
73
+ end
74
+
75
+ unless sshd_service_running?
76
+ start_sshd_service
77
+ end
78
+
79
+ unless pam_supports_sshd?
80
+ configure_pam
65
81
  end
66
82
  end
67
83
 
@@ -88,6 +104,10 @@ module Kitchen
88
104
  cmd += " -B #{config[:wpar_mksysb]}"
89
105
  end
90
106
 
107
+ if config[:wpar_copy_rootvg]
108
+ cmd += ' -t'
109
+ end
110
+
91
111
  if config[:isWritable]
92
112
  cmd += ' -l'
93
113
  end
@@ -112,6 +132,72 @@ module Kitchen
112
132
  true
113
133
  end
114
134
 
135
+ # Determines if the sshd service is defined in the WPAR.
136
+ def sshd_service_exists?
137
+ # FIXME: We should probably check exit status rather than AIX-specific error codes.
138
+ output=ssh_command("#{config[:clogin]} #{config[:wpar_name]} #{config[:lssrc]} -s sshd", :stderr)
139
+ if output.include?('0513-085') # 0513-085 The sshd Subsystem is not on file.
140
+ return false
141
+ end
142
+ true
143
+ end
144
+
145
+ # Creates an sshd service.
146
+ def create_sshd_service
147
+ # FIXME: We should probably check exit status rather than AIX-specific error codes.
148
+ output=ssh_command("#{config[:clogin]} #{config[:wpar_name]} #{config[:mkssys]} -s sshd -p /usr/sbin/sshd -a '-D' -u 0 -S -n 15 -f 9 -R -G local", :stderr)
149
+ if output.include?('0513-071') # 0513-071 The sshd Subsystem has been added.
150
+ return true
151
+ end
152
+ false
153
+ end
154
+
155
+ # Determines if the sshd service is running.
156
+ def sshd_service_running?
157
+ # FIXME: We should probably check exit status rather than AIX-specific error codes.
158
+ output=ssh_command("#{config[:clogin]} #{config[:wpar_name]} #{config[:lssrc]} -s sshd", :stderr)
159
+ if output.include?('active')
160
+ return true
161
+ end
162
+ false # Status == inoperative
163
+ end
164
+
165
+ # Starts the sshd service.
166
+ def start_sshd_service
167
+ # FIXME: We should probably check exit status rather than AIX-specific error codes.
168
+ output=ssh_command("#{config[:clogin]} #{config[:wpar_name]} #{config[:startsrc]} -s sshd", :stderr)
169
+ if output.include?('0513-059') # 0513-059 The sshd Subsystem has been started. Subsystem PID is 2688212.
170
+ return true
171
+ end
172
+ false
173
+ end
174
+
175
+ # Determines if PAM support for sshd exists in this WPAR.
176
+ # This includes account and session rules.
177
+ def pam_supports_sshd?
178
+ pam_config_path = "/wpars/#{config[:wpar_name]}/etc/pam.conf"
179
+ account_output=ssh_command("grep '#{config[:pam_sshd_account_rule]}' #{pam_config_path}", :stderr)
180
+ session_output=ssh_command("grep '#{config[:pam_sshd_session_rule]}' #{pam_config_path}", :stderr)
181
+
182
+ unless account_output.include?("#{config[:pam_sshd_account_rule]}")
183
+ return false
184
+ end
185
+ unless session_output.include?("#{config[:pam_sshd_session_rule]}")
186
+ return false
187
+ end
188
+
189
+ true
190
+ end
191
+
192
+ # Configures PAM support for sshd in the WPAR.
193
+ def configure_pam
194
+ pam_config_path = "/wpars/#{config[:wpar_name]}/etc/pam.conf"
195
+ pam_sshd_rules = "#{config[:pam_sshd_account_rule]}\\n#{config[:pam_sshd_session_rule]}"
196
+ header = "\\n\\n# sshd Rules\\n"
197
+ cmd = "#{config[:echo]} \"#{header}#{pam_sshd_rules}\" >> #{pam_config_path}"
198
+ ssh_command(cmd, :stderr)
199
+ end
200
+
115
201
  def ssh_command(cmd, stream)
116
202
  out = ''
117
203
  begin
@@ -21,6 +21,6 @@ module Kitchen
21
21
  module Driver
22
22
 
23
23
  # Version string for Wpar Kitchen driver
24
- WPAR_VERSION = "0.2.0"
24
+ WPAR_VERSION = "0.4.0"
25
25
  end
26
26
  end
data/test/wpar_spec.rb CHANGED
@@ -75,6 +75,13 @@ describe Kitchen::Driver::Wpar do
75
75
  expect(driver.send(:build_mkwpar_command)).to eq(default_string)
76
76
  end
77
77
 
78
+ it 'sets wpar_copy_rootvg to true' do
79
+ config[:wpar_copy_rootvg] = true
80
+ default_string = '/usr/sbin/mkwpar -s -n kitchenwpar -t'
81
+
82
+ expect(driver.send(:build_mkwpar_command)).to eq(default_string)
83
+ end
84
+
78
85
  it 'sets isWritable to false' do
79
86
  config[:isWritable] = false
80
87
  default_string = '/usr/sbin/mkwpar -s -n kitchenwpar'
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: kitchen-wpar
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.2.0
4
+ version: 0.4.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Alain Dejoux
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2017-02-21 00:00:00.000000000 Z
11
+ date: 2017-07-06 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: bundler
@@ -201,7 +201,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
201
201
  version: '0'
202
202
  requirements: []
203
203
  rubyforge_project:
204
- rubygems_version: 2.6.10
204
+ rubygems_version: 2.6.12
205
205
  signing_key:
206
206
  specification_version: 4
207
207
  summary: test kitchen driver using AIX wpar