Browse Source

Add EMC VMAX/VNX support as a provider for cinder

- Add EMC attributes
- Create cinder_emc_config.xml when EMC driver is used.
- Installs appropriate packages when EMC driver is used.
- Add tests for new cinder_emc_config.xml
- Add tests for changed attributes in existing cinder.conf
- Add tests for package installs

Change-Id: I5a44e3626784814f57e15a43ce459a4d36d31c6b
Implements: blueprint emc-cinder-provider
tags/eol-havana
Andy McCrae 5 years ago
parent
commit
e7bcd475a9

+ 16
- 1
attributes/default.rb View File

@@ -139,6 +139,18 @@ default['openstack']['block-storage']['solidfire']['san_password'] = node['opens
139 139
 default['openstack']['block-storage']['solidfire']['sf_emulate'] = 'False'
140 140
 default['openstack']['block-storage']['solidfire']['iscsi_ip_prefix'] = nil
141 141
 
142
+# EMC VMAX/VNX tSupport
143
+# The EmcUserName user's password is stored in an encrypted databag and
144
+# accessed with openstack-common cookbook library's "get_password" routeine. You
145
+# are expected to create the user and pass in a wrapper cookbook.
146
+default['openstack']['block-storage']['emc']['iscsi_target_prefix'] = 'iqn.1992-04.com.emc'
147
+default['openstack']['block-storage']['emc']['cinder_emc_config_file'] = '/etc/cinder/cinder_emc_config.xml'
148
+default['openstack']['block-storage']['emc']['StorageType'] = 0
149
+default['openstack']['block-storage']['emc']['EcomServerIP'] = '127.0.0.1'
150
+default['openstack']['block-storage']['emc']['EcomServerPort'] = '5988'
151
+default['openstack']['block-storage']['emc']['EcomUserName'] = 'admin'
152
+default['openstack']['block-storage']['emc']['MaskingView'] = nil
153
+
142 154
 # logging attribute
143 155
 default['openstack']['block-storage']['syslog']['use'] = false
144 156
 default['openstack']['block-storage']['syslog']['facility'] = 'LOG_LOCAL2'
@@ -197,6 +209,7 @@ when 'fedora', 'redhat', 'centos' # :pragma-foodcritic: ~FC024 - won't fix this
197 209
     'cinder_iscsitarget_service' => 'tgtd',
198 210
     'cinder_ceph_packages' => ['python-ceph'],
199 211
     'cinder_nfs_packages' => ['nfs-utils', 'nfs-utils-lib'],
212
+    'cinder_emc_packages' => ['pywbem'],
200 213
     'package_overrides' => ''
201 214
   }
202 215
 when 'suse'
@@ -217,7 +230,8 @@ when 'suse'
217 230
     'cinder_ceph_packages' => ['python-ceph'],
218 231
     'cinder_iscsitarget_packages' => ['tgt'],
219 232
     'cinder_iscsitarget_service' => 'tgtd',
220
-    'cinder_nfs_packages' => ['nfs-utils']
233
+    'cinder_nfs_packages' => ['nfs-utils'],
234
+    'cinder_emc_packages' => ['python-pywbem']
221 235
   }
222 236
 when 'ubuntu'
223 237
   # operating system user and group names
@@ -238,6 +252,7 @@ when 'ubuntu'
238 252
     'cinder_iscsitarget_packages' => ['tgt'],
239 253
     'cinder_iscsitarget_service' => 'tgt',
240 254
     'cinder_nfs_packages' => ['nfs-common'],
255
+    'cinder_emc_packages' => ['python-pywbem'],
241 256
     'package_overrides' => "-o Dpkg::Options::='--force-confold' -o Dpkg::Options::='--force-confdef'"
242 257
   }
243 258
 end

+ 19
- 0
recipes/volume.rb View File

@@ -150,6 +150,25 @@ when 'cinder.volume.drivers.lvm.LVMISCSIDriver'
150 150
       action [:enable, :start]
151 151
     end
152 152
   end
153
+
154
+when 'cinder.volume.drivers.emc.emc_smis_iscsi.EMCSMISISCSIDriver'
155
+  platform_options['cinder_emc_packages'].each do |pkg|
156
+    package pkg do
157
+      options platform_options['package_overrides']
158
+      action :upgrade
159
+    end
160
+  end
161
+
162
+  ecom_password = get_password('user', node['openstack']['block-storage']['emc']['EcomUserName'])
163
+
164
+  template node['openstack']['block-storage']['emc']['cinder_emc_config_file'] do
165
+    source 'cinder_emc_config.xml.erb'
166
+    variables(
167
+      ecom_password: ecom_password
168
+    )
169
+    mode 00644
170
+    notifies :restart, 'service[iscsitarget]', :immediately
171
+  end
153 172
 end
154 173
 
155 174
 service 'cinder-volume' do

+ 17
- 1
spec/cinder_common_spec.rb View File

@@ -287,6 +287,23 @@ describe 'openstack-block-storage::cinder-common' do
287 287
         expect(@chef_run).to render_file(@file.name).with_content('iscsi_ip_prefix=203.0.113.*')
288 288
       end
289 289
     end
290
+
291
+    describe 'emc settings' do
292
+      before do
293
+        @chef_run.node.set['openstack']['block-storage']['volume']['driver'] = 'cinder.volume.drivers.emc.emc_smis_iscsi.EMCSMISISCSIDriver'
294
+        @chef_run.node.set['openstack']['block-storage']['emc']['iscsi_target_prefix'] = 'test.prefix'
295
+        @chef_run.node.set['openstack']['block-storage']['emc']['cinder_emc_config_file'] = '/etc/test/config.file'
296
+        @chef_run.converge 'openstack-block-storage::cinder-common'
297
+      end
298
+
299
+      it 'has emc iscsi_target_prefix' do
300
+        expect(@chef_run).to render_file(@file.name).with_content('iscsi_target_prefix=test.prefix')
301
+      end
302
+
303
+      it 'has cinder_emc_config_file' do
304
+        expect(@chef_run).to render_file(@file.name).with_content('cinder_emc_config_file=/etc/test/config.file')
305
+      end
306
+    end
290 307
   end
291 308
 
292 309
   describe '/var/lock/cinder' do
@@ -303,5 +320,4 @@ describe 'openstack-block-storage::cinder-common' do
303 320
       expect(sprintf('%o', @dir.mode)).to eq '700'
304 321
     end
305 322
   end
306
-
307 323
 end

+ 3
- 0
spec/spec_helper.rb View File

@@ -51,6 +51,9 @@ def block_storage_stubs # rubocop:disable MethodLength
51 51
   ::Chef::Recipe.any_instance.stub(:get_password)
52 52
     .with('service', 'openstack_image_cephx_key')
53 53
     .and_return('cephx-key')
54
+  ::Chef::Recipe.any_instance.stub(:get_password)
55
+    .with('user', 'admin')
56
+    .and_return('emc_test_pass')
54 57
   ::Chef::Application.stub(:fatal!)
55 58
 end
56 59
 

+ 9
- 0
spec/volume-redhat_spec.rb View File

@@ -64,6 +64,15 @@ describe 'openstack-block-storage::volume' do
64 64
       expect(chef_run).to upgrade_package 'nfs-utils-lib'
65 65
     end
66 66
 
67
+    it 'installs emc packages' do
68
+      chef_run = ::ChefSpec::Runner.new ::REDHAT_OPTS do |n|
69
+        n.set['openstack']['block-storage']['volume']['driver'] = 'cinder.volume.drivers.emc.emc_smis_iscsi.EMCSMISISCSIDriver'
70
+      end
71
+      chef_run.converge 'openstack-block-storage::volume'
72
+
73
+      expect(chef_run).to upgrade_package 'pywbem'
74
+    end
75
+
67 76
     it 'has redhat include' do
68 77
       file = '/etc/tgt/targets.conf'
69 78
 

+ 9
- 0
spec/volume-suse_spec.rb View File

@@ -57,6 +57,15 @@ describe 'openstack-block-storage::volume' do
57 57
       expect(chef_run).not_to upgrade_package 'nfs-utils-lib'
58 58
     end
59 59
 
60
+    it 'installs emc packages' do
61
+      chef_run = ::ChefSpec::Runner.new ::SUSE_OPTS do |n|
62
+        n.set['openstack']['block-storage']['volume']['driver'] = 'cinder.volume.drivers.emc.emc_smis_iscsi.EMCSMISISCSIDriver'
63
+      end
64
+      chef_run.converge 'openstack-block-storage::volume'
65
+
66
+      expect(chef_run).to upgrade_package 'python-pywbem'
67
+    end
68
+
60 69
     it 'has suse include' do
61 70
       file = '/etc/tgt/targets.conf'
62 71
 

+ 62
- 0
spec/volume_spec.rb View File

@@ -45,6 +45,15 @@ describe 'openstack-block-storage::volume' do
45 45
       expect(@chef_run).to upgrade_package 'tgt'
46 46
     end
47 47
 
48
+    it 'installs emc packages' do
49
+      chef_run = ::ChefSpec::Runner.new ::UBUNTU_OPTS do |n|
50
+        n.set['openstack']['block-storage']['volume']['driver'] = 'cinder.volume.drivers.emc.emc_smis_iscsi.EMCSMISISCSIDriver'
51
+      end
52
+      chef_run.converge 'openstack-block-storage::volume'
53
+
54
+      expect(chef_run).to upgrade_package 'python-pywbem'
55
+    end
56
+
48 57
     it 'installs nfs packages' do
49 58
       chef_run = ::ChefSpec::Runner.new ::UBUNTU_OPTS do |n|
50 59
         n.set['openstack']['block-storage']['volume']['driver'] = 'cinder.volume.drivers.netapp.nfs.NetAppDirect7modeNfsDriver'
@@ -240,5 +249,58 @@ describe 'openstack-block-storage::volume' do
240 249
         expect(@chef_run).to create_template(@filename)
241 250
       end
242 251
     end
252
+
253
+    describe 'cinder_emc_config.xml' do
254
+      before do
255
+        @chef_run = ::ChefSpec::Runner.new ::UBUNTU_OPTS do |n|
256
+          n.set['openstack']['block-storage']['volume']['driver'] = 'cinder.volume.drivers.emc.emc_smis_iscsi.EMCSMISISCSIDriver'
257
+        end
258
+        @chef_run.converge 'openstack-block-storage::volume'
259
+        @filename = '/etc/cinder/cinder_emc_config.xml'
260
+        @file = @chef_run.template(@filename)
261
+      end
262
+
263
+      it 'creates cinder emc config file' do
264
+        expect(@chef_run).to create_template(@filename)
265
+      end
266
+
267
+      it 'has proper modes' do
268
+        expect(sprintf('%o', @file.mode)).to eq('644')
269
+      end
270
+
271
+      it 'has StorageType' do
272
+        expect(@chef_run).to render_file(@file.name).with_content('<StorageType>0</StorageType>')
273
+      end
274
+
275
+      it 'has EcomServerIp' do
276
+        expect(@chef_run).to render_file(@file.name).with_content('<EcomServerIp>127.0.0.1</EcomServerIp>')
277
+      end
278
+
279
+      it 'has EcomServerPort' do
280
+        expect(@chef_run).to render_file(@file.name).with_content('<EcomServerPort>5988</EcomServerPort>')
281
+      end
282
+
283
+      it 'has EcomUserName' do
284
+        expect(@chef_run).to render_file(@file.name).with_content('<EcomUserName>admin</EcomUserName>')
285
+      end
286
+
287
+      it 'has EcomPassword' do
288
+        expect(@chef_run).to render_file(@file.name).with_content('<EcomPassword>emc_test_pass</EcomPassword>')
289
+      end
290
+
291
+      it 'does not have MaskingView when not specified' do
292
+        expect(@chef_run).not_to render_file(@file.name).with_content('<MaskingView>')
293
+      end
294
+
295
+      it 'has MaskingView when specified' do
296
+        @chef_run = ::ChefSpec::Runner.new ::UBUNTU_OPTS do |n|
297
+          n.set['openstack']['block-storage']['emc']['MaskingView'] = 'testMaskingView'
298
+          n.set['openstack']['block-storage']['volume']['driver'] = 'cinder.volume.drivers.emc.emc_smis_iscsi.EMCSMISISCSIDriver'
299
+        end
300
+        @chef_run.converge 'openstack-block-storage::volume'
301
+
302
+        expect(@chef_run).to render_file(@file.name).with_content('<MaskingView>testMaskingView</MaskingView>')
303
+      end
304
+    end
243 305
   end
244 306
 end

+ 7
- 0
templates/default/cinder.conf.erb View File

@@ -808,6 +808,13 @@ storwize_svc_multihostmap_enabled=<%= node["openstack"]["block-storage"]["storwi
808 808
 
809 809
 <% end %>
810 810
 
811
+<% if node["openstack"]["block-storage"]["volume"]["driver"] == "cinder.volume.drivers.emc.emc_smis_iscsi.EMCSMISISCSIDriver" %>
812
+
813
+iscsi_target_prefix=<%= node["openstack"]["block-storage"]["emc"]["iscsi_target_prefix"] %>
814
+cinder_emc_config_file=<%= node["openstack"]["block-storage"]["emc"]["cinder_emc_config_file"] %>
815
+
816
+<% end %>
817
+
811 818
 ######## defined in cinder.volume.xiv ########
812 819
 
813 820
 # xiv_proxy=xiv_openstack.nova_proxy.XIVNovaProxy

+ 10
- 0
templates/default/cinder_emc_config.xml.erb View File

@@ -0,0 +1,10 @@
1
+<EMC>
2
+<StorageType><%= node["openstack"]["block-storage"]["emc"]["StorageType"] %></StorageType>
3
+<EcomServerIp><%= node["openstack"]["block-storage"]["emc"]["EcomServerIP"] %></EcomServerIp>
4
+<EcomServerPort><%= node["openstack"]["block-storage"]["emc"]["EcomServerPort"] %></EcomServerPort>
5
+<EcomUserName><%= node["openstack"]["block-storage"]["emc"]["EcomUserName"] %></EcomUserName>
6
+<EcomPassword><%= @ecom_password %></EcomPassword>
7
+<% unless node["openstack"]["block-storage"]["emc"]["MaskingView"].nil? %>
8
+<MaskingView><%= node["openstack"]["block-storage"]["emc"]["MaskingView"] %></MaskingView>
9
+<% end %>
10
+</EMC>

Loading…
Cancel
Save