Chef Cookbook - OpenStack Block Storage
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

cinder_common_spec.rb 49KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798991001011021031041051061071081091101111121131141151161171181191201211221231241251261271281291301311321331341351361371381391401411421431441451461471481491501511521531541551561571581591601611621631641651661671681691701711721731741751761771781791801811821831841851861871881891901911921931941951961971981992002012022032042052062072082092102112122132142152162172182192202212222232242252262272282292302312322332342352362372382392402412422432442452462472482492502512522532542552562572582592602612622632642652662672682692702712722732742752762772782792802812822832842852862872882892902912922932942952962972982993003013023033043053063073083093103113123133143153163173183193203213223233243253263273283293303313323333343353363373383393403413423433443453463473483493503513523533543553563573583593603613623633643653663673683693703713723733743753763773783793803813823833843853863873883893903913923933943953963973983994004014024034044054064074084094104114124134144154164174184194204214224234244254264274284294304314324334344354364374384394404414424434444454464474484494504514524534544554564574584594604614624634644654664674684694704714724734744754764774784794804814824834844854864874884894904914924934944954964974984995005015025035045055065075085095105115125135145155165175185195205215225235245255265275285295305315325335345355365375385395405415425435445455465475485495505515525535545555565575585595605615625635645655665675685695705715725735745755765775785795805815825835845855865875885895905915925935945955965975985996006016026036046056066076086096106116126136146156166176186196206216226236246256266276286296306316326336346356366376386396406416426436446456466476486496506516526536546556566576586596606616626636646656666676686696706716726736746756766776786796806816826836846856866876886896906916926936946956966976986997007017027037047057067077087097107117127137147157167177187197207217227237247257267277287297307317327337347357367377387397407417427437447457467477487497507517527537547557567577587597607617627637647657667677687697707717727737747757767777787797807817827837847857867877887897907917927937947957967977987998008018028038048058068078088098108118128138148158168178188198208218228238248258268278288298308318328338348358368378388398408418428438448458468478488498508518528538548558568578588598608618628638648658668678688698708718728738748758768778788798808818828838848858868878888898908918928938948958968978988999009019029039049059069079089099109119129139149159169179189199209219229239249259269279289299309319329339349359369379389399409419429439449459469479489499509519529539549559569579589599609619629639649659669679689699709719729739749759769779789799809819829839849859869879889899909919929939949959969979989991000100110021003100410051006100710081009101010111012101310141015101610171018101910201021102210231024102510261027102810291030103110321033103410351036103710381039104010411042104310441045104610471048104910501051105210531054105510561057105810591060106110621063106410651066106710681069107010711072107310741075107610771078107910801081108210831084108510861087108810891090109110921093109410951096109710981099110011011102110311041105
  1. # encoding: utf-8
  2. #
  3. # Cookbook Name:: openstack-block-storage
  4. require_relative 'spec_helper'
  5. describe 'openstack-block-storage::cinder-common' do
  6. describe 'ubuntu' do
  7. let(:runner) { ChefSpec::SoloRunner.new(UBUNTU_OPTS) }
  8. let(:node) { runner.node }
  9. let(:chef_run) do
  10. node.set['openstack']['mq']['host'] = '127.0.0.1'
  11. node.set['openstack']['mq']['block-storage']['rabbit']['notification_topic'] = 'rabbit_topic'
  12. runner.converge(described_recipe)
  13. end
  14. include_context 'block-storage-stubs'
  15. it 'upgrades the cinder-common package' do
  16. expect(chef_run).to upgrade_package 'cinder-common'
  17. end
  18. describe '/etc/cinder' do
  19. let(:dir) { chef_run.directory('/etc/cinder') }
  20. it 'should create the /etc/cinder directory' do
  21. expect(chef_run).to create_directory(dir.name).with(
  22. owner: 'cinder',
  23. group: 'cinder',
  24. mode: 00750
  25. )
  26. end
  27. end
  28. describe 'cinder.conf' do
  29. let(:file) { chef_run.template('/etc/cinder/cinder.conf') }
  30. let(:test_pass) { 'test_pass' }
  31. before do
  32. allow_any_instance_of(Chef::Recipe).to receive(:get_password)
  33. .with('user', anything)
  34. .and_return(test_pass)
  35. end
  36. it 'should create the cinder.conf template' do
  37. expect(chef_run).to create_template(file.name).with(
  38. owner: 'cinder',
  39. group: 'cinder',
  40. mode: 00640
  41. )
  42. end
  43. context 'keystone authtoken attributes with default values' do
  44. it 'sets memcached server(s)' do
  45. expect(chef_run).not_to render_file(file.name).with_content(/^memcached_servers = $/)
  46. end
  47. it 'sets memcache security strategy' do
  48. expect(chef_run).not_to render_file(file.name).with_content(/^memcache_security_strategy = $/)
  49. end
  50. it 'sets memcache secret key' do
  51. expect(chef_run).not_to render_file(file.name).with_content(/^memcache_secret_key = $/)
  52. end
  53. it 'sets cafile' do
  54. expect(chef_run).not_to render_file(file.name).with_content(/^cafile = $/)
  55. end
  56. it 'sets insecure' do
  57. expect(chef_run).to render_file(file.name).with_content(/^insecure = false$/)
  58. end
  59. it 'sets token hash algorithms' do
  60. expect(chef_run).to render_file(file.name).with_content(/^hash_algorithms = md5$/)
  61. end
  62. end
  63. context 'keystone authtoken attributes' do
  64. it 'has signing_dir' do
  65. node.set['openstack']['block-storage']['api']['auth']['cache_dir'] = 'auth_cache_dir'
  66. expect(chef_run).to render_file(file.name).with_content(/^signing_dir = auth_cache_dir$/)
  67. end
  68. it 'sets memcached server(s)' do
  69. node.set['openstack']['block-storage']['api']['auth']['memcached_servers'] = 'localhost:11211'
  70. expect(chef_run).to render_file(file.name).with_content(/^memcached_servers = localhost:11211$/)
  71. end
  72. it 'sets memcache security strategy' do
  73. node.set['openstack']['block-storage']['api']['auth']['memcache_security_strategy'] = 'MAC'
  74. expect(chef_run).to render_file(file.name).with_content(/^memcache_security_strategy = MAC$/)
  75. end
  76. it 'sets memcache secret key' do
  77. node.set['openstack']['block-storage']['api']['auth']['memcache_secret_key'] = '0123456789ABCDEF'
  78. expect(chef_run).to render_file(file.name).with_content(/^memcache_secret_key = 0123456789ABCDEF$/)
  79. end
  80. it 'sets cafile' do
  81. node.set['openstack']['block-storage']['api']['auth']['cafile'] = 'dir/to/path'
  82. expect(chef_run).to render_file(file.name).with_content(%r{^cafile = dir/to/path$})
  83. end
  84. it 'sets insecure' do
  85. node.set['openstack']['block-storage']['api']['auth']['insecure'] = true
  86. expect(chef_run).to render_file(file.name).with_content(/^insecure = true$/)
  87. end
  88. it 'sets token hash algorithms' do
  89. node.set['openstack']['block-storage']['api']['auth']['hash_algorithms'] = 'sha2'
  90. expect(chef_run).to render_file(file.name).with_content(/^hash_algorithms = sha2$/)
  91. end
  92. context 'endpoint related' do
  93. it 'has auth_uri' do
  94. expect(chef_run).to render_file(file.name).with_content(%r{^auth_uri = http://127.0.0.1:5000/v2.0$})
  95. end
  96. it 'has identity_uri' do
  97. expect(chef_run).to render_file(file.name).with_content(%r{^identity_uri = http://127.0.0.1:35357/$})
  98. end
  99. end
  100. it 'has no auth_version when auth_version is v2.0' do
  101. node.set['openstack']['block-storage']['api']['auth']['version'] = 'v2.0'
  102. expect(chef_run).not_to render_file(file.name).with_content(/^auth_version = v2.0$/)
  103. end
  104. it 'has auth_version when auth version is not v2.0' do
  105. node.set['openstack']['block-storage']['api']['auth']['version'] = 'v3.0'
  106. expect(chef_run).to render_file(file.name).with_content(/^auth_version = v3.0$/)
  107. end
  108. it 'has an admin tenant name' do
  109. node.set['openstack']['block-storage']['service_tenant_name'] = 'tenant_name'
  110. expect(chef_run).to render_file(file.name).with_content(/^admin_tenant_name = tenant_name$/)
  111. end
  112. it 'has an admin user' do
  113. node.set['openstack']['block-storage']['service_user'] = 'username'
  114. expect(chef_run).to render_file(file.name).with_content(/^admin_user = username$/)
  115. end
  116. it 'has an admin password' do
  117. # (fgimenez) the get_password mocking is set in spec/spec_helper.rb
  118. expect(chef_run).to render_file(file.name).with_content(/^admin_password = cinder-pass$/)
  119. end
  120. end
  121. context 'template contents' do
  122. context 'commonly named attributes' do
  123. %w(debug verbose host notification_driver
  124. storage_availability_zone quota_volumes quota_gigabytes quota_driver
  125. volume_name_template snapshot_name_template osapi_volume_workers
  126. use_default_quota_class quota_snapshots no_snapshot_gb_quota
  127. control_exchange max_gigabytes).each do |attr_key|
  128. it "has a #{attr_key} attribute" do
  129. node.set['openstack']['block-storage'][attr_key] = "#{attr_key}_value"
  130. expect(chef_run).to render_config_file(file.name).with_section_content('DEFAULT', /^#{attr_key}=#{attr_key}_value$/)
  131. end
  132. end
  133. end
  134. context 'backup swift backend contents' do
  135. before do
  136. node.set['openstack']['block-storage']['backup']['enabled'] = true
  137. node.set['openstack']['block-storage']['backup']['driver'] = 'cinder.backup.drivers.swift'
  138. end
  139. it 'has default attributes' do
  140. %w(swift_catalog_info=object-store:swift:publicURL
  141. backup_swift_auth=per_user
  142. backup_swift_auth_version=1
  143. backup_swift_container=volumebackups
  144. backup_swift_object_size=52428800
  145. backup_swift_block_size=32768
  146. backup_swift_retry_attempts=3
  147. backup_swift_retry_backoff=2
  148. backup_swift_enable_progress_timer=True).each do |attr|
  149. expect(chef_run).to render_config_file(file.name).with_section_content('DEFAULT', /^#{attr}$/)
  150. end
  151. end
  152. it 'has override attributes' do
  153. %w(url
  154. auth
  155. auth_version
  156. tenant
  157. user
  158. key
  159. container
  160. object_size
  161. block_size
  162. retry_attempts
  163. retry_backoff
  164. enable_progress_timer).each do |attr|
  165. node.set['openstack']['block-storage']['backup']['swift'][attr] = "backup_swift_#{attr}"
  166. expect(chef_run).to render_config_file(file.name).with_section_content('DEFAULT', /^backup_swift_#{attr}=backup_swift_#{attr}$/)
  167. end
  168. end
  169. it 'has a custom catalog_info' do
  170. node.set['openstack']['block-storage']['backup']['swift']['catalog_info'] = 'swift_catalog_info'
  171. expect(chef_run).to render_config_file(file.name).with_section_content('DEFAULT', /^swift_catalog_info=swift_catalog_info$/)
  172. end
  173. end
  174. context 'rdb driver' do
  175. # FIXME(galstrom21): this block needs to check all of the default
  176. # rdb_* configuration options
  177. it 'has default rbd_* options set' do
  178. node.set['openstack']['block-storage']['volume'] = {
  179. 'driver' => 'cinder.volume.drivers.rbd.RBDDriver'
  180. }
  181. expect(chef_run).to render_file(file.name).with_content(/^rbd_/)
  182. expect(chef_run).not_to render_file(file.name).with_content(/^netapp_/)
  183. end
  184. end
  185. it 'has a lock_path attribute' do
  186. expect(chef_run).to render_config_file(file.name).with_section_content('oslo_concurrency', %r{^lock_path=/var/lib/cinder/lock$})
  187. end
  188. it 'does not have unique host id by default' do
  189. expect(chef_run).not_to render_config_file(file.name).with_section_content('DEFAULT', /^host=/)
  190. end
  191. it 'has keymgr api_class attribute default set' do
  192. expect(chef_run).to render_config_file(file.name).with_section_content('keymgr', /^api_class=cinder.keymgr.conf_key_mgr.ConfKeyManager$/)
  193. end
  194. it 'does not have keymgr attribute fixed_key set by default' do
  195. expect(chef_run).not_to render_file(file.name).with_content(/^fixed_key=$/)
  196. end
  197. it 'allow override for keymgr attribute fixed_key' do
  198. chef_run.node.set['openstack']['block-storage']['keymgr']['fixed_key'] = '1111111111111111111111111111111111111111111111111111111111111111'
  199. expect(chef_run).to render_config_file(file.name)\
  200. .with_section_content('keymgr', /^fixed_key=1111111111111111111111111111111111111111111111111111111111111111$/)
  201. end
  202. context 'netapp driver' do
  203. # FIXME(galstrom21): this block needs to check all of the default
  204. # netapp_* configuration options
  205. it 'has default netapp_* options set' do
  206. node.set['openstack']['block-storage']['volume'] = {
  207. 'driver' => 'cinder.volume.drivers.netapp.NetAppISCSIDriver'
  208. }
  209. expect(chef_run).to render_file(file.name).with_content(/^netapp_/)
  210. expect(chef_run).not_to render_file(file.name).with_content(/^rbd_/)
  211. end
  212. end
  213. context 'syslog use' do
  214. it 'sets the log_config value when syslog is in use' do
  215. node.set['openstack']['block-storage']['syslog']['use'] = true
  216. expect(chef_run).to render_file(file.name)
  217. .with_content(%r{^log_config = /etc/openstack/logging.conf$})
  218. end
  219. it 'sets the log_file value when syslog is not in use' do
  220. node.set['openstack']['block-storage']['syslog']['use'] = false
  221. expect(chef_run).to render_file(file.name)
  222. .with_content(%r{^log_file = /var/log/cinder/cinder.log$})
  223. end
  224. end
  225. it 'has a db connection attribute' do
  226. allow_any_instance_of(Chef::Recipe).to receive(:db_uri)
  227. .with('block-storage', anything, '').and_return('sql_connection_value')
  228. expect(chef_run).to render_config_file(file.name)
  229. .with_section_content('database', /^connection=sql_connection_value$/)
  230. end
  231. it 'has a db backend attribute' do
  232. expect(chef_run).to render_config_file(file.name).with_section_content('database', /^backend=sqlalchemy$/)
  233. end
  234. it 'has a volume_driver attribute' do
  235. node.set['openstack']['block-storage']['volume']['driver'] = 'volume_driver_value'
  236. expect(chef_run).to render_file(file.name).with_content(/^volume_driver=volume_driver_value$/)
  237. end
  238. it 'has a state_path attribute' do
  239. node.set['openstack']['block-storage']['volume']['state_path'] = 'state_path_value'
  240. expect(chef_run).to render_file(file.name).with_content(/^state_path=state_path_value$/)
  241. end
  242. context 'glance endpoint' do
  243. it 'has a glance_api_servers attribute' do
  244. expect(chef_run).to render_file(file.name).with_content(%r{^glance_api_servers=http://127.0.0.1:9292$})
  245. end
  246. it 'has glance_api_version attribute' do
  247. expect(chef_run).to render_file(file.name).with_content(/^glance_api_version=1$/)
  248. end
  249. it 'has a glance_api_insecure attribute' do
  250. expect(chef_run).to render_file(file.name).with_content(/^glance_api_insecure=false$/)
  251. end
  252. it 'sets insecure for glance' do
  253. node.set['openstack']['block-storage']['image']['glance_api_insecure'] = true
  254. expect(chef_run).to render_file(file.name).with_content(/^glance_api_insecure=true$/)
  255. end
  256. it 'has a glance_ca_certificates_file attribute' do
  257. expect(chef_run).to render_file(file.name).with_content(/^glance_ca_certificates_file=$/)
  258. end
  259. it 'sets glance_ca_certificates_file attribute' do
  260. node.set['openstack']['block-storage']['image']['glance_ca_certificates_file'] = 'dir/to/path'
  261. expect(chef_run).to render_file(file.name).with_content(%r{^glance_ca_certificates_file=dir/to/path$})
  262. end
  263. it 'has a glance host attribute' do
  264. expect(chef_run).to render_file(file.name).with_content(/^glance_host=127.0.0.1$/)
  265. end
  266. it 'has a glance port attribute' do
  267. expect(chef_run).to render_file(file.name).with_content(/^glance_port=9292$/)
  268. end
  269. end
  270. it 'has a api_rate_limit attribute' do
  271. node.set['openstack']['block-storage']['api']['ratelimit'] = 'api_rate_limit_value'
  272. expect(chef_run).to render_file(file.name).with_content(/^api_rate_limit=api_rate_limit_value$/)
  273. end
  274. context 'cinder endpoint' do
  275. it 'has osapi_volume_listen set' do
  276. expect(chef_run).to render_file(file.name).with_content(/^osapi_volume_listen=127.0.0.1$/)
  277. end
  278. it 'has osapi_volume_listen_port set' do
  279. expect(chef_run).to render_file(file.name).with_content(/^osapi_volume_listen_port=8776$/)
  280. end
  281. it 'has default api version set' do
  282. [/^enable_v1_api=False$/,
  283. /^enable_v2_api=True$/].each do |line|
  284. expect(chef_run).to render_config_file(file.name).with_section_content('DEFAULT', line)
  285. end
  286. end
  287. it 'has override api version set' do
  288. node.set['openstack']['block-storage']['enable_v1_api'] = 'True'
  289. node.set['openstack']['block-storage']['enable_v2_api'] = 'False'
  290. [/^enable_v1_api=True$/,
  291. /^enable_v2_api=False$/].each do |line|
  292. expect(chef_run).to render_config_file(file.name).with_section_content('DEFAULT', line)
  293. end
  294. end
  295. end
  296. it 'has a rpc_backend attribute' do
  297. node.set['openstack']['block_storage']['rpc_backend'] = 'rpc_backend_value'
  298. expect(chef_run).to render_file(file.name).with_content(/^rpc_backend=rpc_backend_value$/)
  299. end
  300. it 'has default RPC/AMQP options set' do
  301. [/^rpc_backend=cinder.openstack.common.rpc.impl_kombu$/,
  302. /^rpc_thread_pool_size=64$/,
  303. /^rpc_response_timeout=60$/].each do |line|
  304. expect(chef_run).to render_file(file.name).with_content(line)
  305. end
  306. end
  307. context 'rabbitmq as mq service' do
  308. before do
  309. node.set['openstack']['mq']['block-storage']['service_type'] = 'rabbitmq'
  310. end
  311. it 'has default RPC/AMQP options set' do
  312. [/^rpc_conn_pool_size=30$/,
  313. /^amqp_durable_queues=false$/,
  314. /^amqp_auto_delete=false$/,
  315. /^heartbeat_timeout_threshold=0$/,
  316. /^heartbeat_rate=2$/].each do |line|
  317. expect(chef_run).to render_config_file(file.name).with_section_content('oslo_messaging_rabbit', line)
  318. end
  319. end
  320. context 'ha attributes' do
  321. before do
  322. node.set['openstack']['mq']['block-storage']['rabbit']['ha'] = true
  323. end
  324. it 'has a rabbit_hosts attribute' do
  325. allow_any_instance_of(Chef::Recipe).to receive(:rabbit_servers)
  326. .and_return('rabbit_servers_value')
  327. expect(chef_run).to render_config_file(file.name).with_section_content('oslo_messaging_rabbit', /^rabbit_hosts=rabbit_servers_value$/)
  328. end
  329. %w(host port).each do |attr|
  330. it "does not have rabbit_#{attr} attribute" do
  331. expect(chef_run).not_to render_config_file(file.name).with_section_content('oslo_messaging_rabbit', /^rabbit_#{attr}=/)
  332. end
  333. end
  334. end
  335. context 'non ha attributes' do
  336. before do
  337. node.set['openstack']['mq']['block-storage']['rabbit']['ha'] = false
  338. end
  339. %w(host port).each do |attr|
  340. it "has rabbit_#{attr} attribute" do
  341. node.set['openstack']['mq']['block-storage']['rabbit'][attr] = "rabbit_#{attr}_value"
  342. expect(chef_run).to render_config_file(file.name).with_section_content('oslo_messaging_rabbit', /^rabbit_#{attr}=rabbit_#{attr}_value$/)
  343. end
  344. end
  345. it 'does not have a rabbit_hosts attribute' do
  346. expect(chef_run).not_to render_config_file(file.name).with_section_content('oslo_messaging_rabbit', /^rabbit_hosts=/)
  347. end
  348. end
  349. it 'has rabbit_userid' do
  350. node.set['openstack']['mq']['block-storage']['rabbit']['userid'] = 'rabbit_userid_value'
  351. expect(chef_run).to render_config_file(file.name).with_section_content('oslo_messaging_rabbit', /^rabbit_userid=rabbit_userid_value$/)
  352. end
  353. it 'has rabbit_password' do
  354. expect(chef_run).to render_config_file(file.name).with_section_content('oslo_messaging_rabbit', /^rabbit_password=#{test_pass}$/)
  355. end
  356. it 'has rabbit_virtual_host' do
  357. node.set['openstack']['mq']['block-storage']['rabbit']['vhost'] = 'vhost_value'
  358. expect(chef_run).to render_config_file(file.name).with_section_content('oslo_messaging_rabbit', /^rabbit_virtual_host=vhost_value$/)
  359. end
  360. it 'does not have ssl config set' do
  361. [/^rabbit_use_ssl=/,
  362. /^kombu_ssl_version=/,
  363. /^kombu_ssl_keyfile=/,
  364. /^kombu_ssl_certfile=/,
  365. /^kombu_ssl_ca_certs=/,
  366. /^kombu_reconnect_delay=/,
  367. /^kombu_reconnect_timeout=/].each do |line|
  368. expect(chef_run).not_to render_config_file(file.name).with_section_content('oslo_messaging_rabbit', line)
  369. end
  370. end
  371. it 'sets ssl config' do
  372. node.set['openstack']['mq']['block-storage']['rabbit']['use_ssl'] = true
  373. node.set['openstack']['mq']['block-storage']['rabbit']['kombu_ssl_version'] = 'TLSv1.2'
  374. node.set['openstack']['mq']['block-storage']['rabbit']['kombu_ssl_keyfile'] = 'keyfile'
  375. node.set['openstack']['mq']['block-storage']['rabbit']['kombu_ssl_certfile'] = 'certfile'
  376. node.set['openstack']['mq']['block-storage']['rabbit']['kombu_ssl_ca_certs'] = 'certsfile'
  377. node.set['openstack']['mq']['block-storage']['rabbit']['kombu_reconnect_delay'] = 123.123
  378. node.set['openstack']['mq']['block-storage']['rabbit']['kombu_reconnect_timeout'] = 123
  379. [/^rabbit_use_ssl=true/,
  380. /^kombu_ssl_version=TLSv1.2$/,
  381. /^kombu_ssl_keyfile=keyfile$/,
  382. /^kombu_ssl_certfile=certfile$/,
  383. /^kombu_ssl_ca_certs=certsfile$/,
  384. /^kombu_reconnect_delay=123.123$/,
  385. /^kombu_reconnect_timeout=123$/].each do |line|
  386. expect(chef_run).to render_config_file(file.name).with_section_content('oslo_messaging_rabbit', line)
  387. end
  388. end
  389. it 'has the default rabbit_retry_interval set' do
  390. expect(chef_run).to render_config_file(file.name).with_section_content('oslo_messaging_rabbit', /^rabbit_retry_interval=1$/)
  391. end
  392. it 'has the default rabbit_max_retries set' do
  393. expect(chef_run).to render_config_file(file.name).with_section_content('oslo_messaging_rabbit', /^rabbit_max_retries=0$/)
  394. end
  395. end
  396. context 'qpid as mq service' do
  397. before do
  398. node.set['openstack']['mq']['block-storage']['service_type'] = 'qpid'
  399. end
  400. it 'has default RPC/AMQP options set' do
  401. [/^rpc_conn_pool_size=30$/,
  402. /^amqp_durable_queues=false$/,
  403. /^amqp_auto_delete=false$/].each do |line|
  404. expect(chef_run).to render_config_file(file.name).with_section_content('oslo_messaging_qpid', line)
  405. end
  406. end
  407. %w(port username sasl_mechanisms reconnect reconnect_timeout reconnect_limit
  408. reconnect_interval_min reconnect_interval_max reconnect_interval heartbeat protocol
  409. tcp_nodelay).each do |attr|
  410. it "has qpid_#{attr} attribute" do
  411. node.set['openstack']['mq']['block-storage']['qpid'][attr] = "qpid_#{attr}_value"
  412. expect(chef_run).to render_config_file(file.name).with_section_content('oslo_messaging_qpid', /^qpid_#{attr}=qpid_#{attr}_value$/)
  413. end
  414. end
  415. it 'has qpid_hostname' do
  416. node.set['openstack']['mq']['block-storage']['qpid']['host'] = 'qpid_host_value'
  417. expect(chef_run).to render_config_file(file.name).with_section_content('oslo_messaging_qpid', /^qpid_hostname=qpid_host_value$/)
  418. end
  419. it 'has qpid_password' do
  420. expect(chef_run).to render_config_file(file.name).with_section_content('oslo_messaging_qpid', /^qpid_password=#{test_pass}$/)
  421. end
  422. it 'has default qpid topology version' do
  423. expect(chef_run).to render_config_file(file.name).with_section_content('oslo_messaging_qpid', /^qpid_topology_version=1$/)
  424. end
  425. it 'has qpid notification_topics' do
  426. node.set['openstack']['mq']['block-storage']['qpid']['notification_topic'] = 'qpid_notification_topic_value'
  427. expect(chef_run).to render_config_file(file.name).with_section_content('oslo_messaging_qpid', /^notification_topics=qpid_notification_topic_value$/)
  428. end
  429. end
  430. context 'lvm settings' do
  431. before do
  432. node.set['openstack']['block-storage']['volume']['driver'] = 'cinder.volume.drivers.lvm.LVMVolumeDriver'
  433. end
  434. %w(group clear clear_size).each do |attr|
  435. it "has lvm volume_#{attr} attribute" do
  436. node.set['openstack']['block-storage']['volume']["volume_#{attr}"] = "volume_#{attr}_value"
  437. expect(chef_run).to render_file(file.name).with_content(/^volume_#{attr}=volume_#{attr}_value$/)
  438. end
  439. end
  440. end
  441. context 'commonly named volume attributes' do
  442. %w(iscsi_ip_address iscsi_port iscsi_helper volumes_dir).each do |attr|
  443. it "has volume related #{attr} attribute" do
  444. node.set['openstack']['block-storage']['volume'][attr] = "common_volume_#{attr}_value"
  445. expect(chef_run).to render_file(file.name).with_content(/^#{attr}=common_volume_#{attr}_value$/)
  446. end
  447. end
  448. end
  449. context 'rbd attributes' do
  450. before do
  451. node.set['openstack']['block-storage']['volume']['driver'] = 'cinder.volume.drivers.rbd.RBDDriver'
  452. end
  453. it 'has a rbd_pool attribute' do
  454. node.set['openstack']['block-storage']['rbd']['cinder']['pool'] = 'cinder_value'
  455. expect(chef_run).to render_file(file.name).with_content(/^rbd_pool=cinder_value$/)
  456. end
  457. it 'has a rbd_user attribute' do
  458. node.set['openstack']['block-storage']['rbd']['user'] = 'rbd_user_value'
  459. expect(chef_run).to render_file(file.name).with_content(/^rbd_user=rbd_user_value$/)
  460. end
  461. it 'has a rbd_secret_uuid attribute' do
  462. node.set['openstack']['block-storage']['rbd']['secret_uuid'] = 'rbd_secret_uuid_value'
  463. expect(chef_run).to render_file(file.name).with_content(/^rbd_secret_uuid=rbd_secret_uuid_value$/)
  464. end
  465. end
  466. it 'has volume_driver attribute' do
  467. node.set['openstack']['block-storage']['volume']['driver'] = 'volume_driver_value'
  468. expect(chef_run).to render_file(file.name).with_content(/^volume_driver=volume_driver_value$/)
  469. end
  470. context 'netapp ISCSI settings' do
  471. before do
  472. node.set['openstack']['block-storage']['volume']['driver'] = 'cinder.volume.drivers.netapp.NetAppISCSIDriver'
  473. end
  474. %w(login password).each do |attr|
  475. it "has a netapp_#{attr} attribute" do
  476. node.set['openstack']['block-storage']['netapp']["dfm_#{attr}"] = "dfm_#{attr}_value"
  477. expect(chef_run).to render_file(file.name).with_content(/^netapp_#{attr}=dfm_#{attr}_value$/)
  478. end
  479. end
  480. %w(hostname port).each do |attr|
  481. it "has a netapp_server_#{attr} attribute" do
  482. node.set['openstack']['block-storage']['netapp']["dfm_#{attr}"] = "dfm_#{attr}_value"
  483. expect(chef_run).to render_file(file.name).with_content(/^netapp_server_#{attr}=dfm_#{attr}_value$/)
  484. end
  485. end
  486. it 'has a netapp_storage_service attribute' do
  487. node.set['openstack']['block-storage']['netapp']['storage_service'] = 'netapp_storage_service_value'
  488. expect(chef_run).to render_file(file.name).with_content(/^netapp_storage_service=netapp_storage_service_value$/)
  489. end
  490. end
  491. context 'netapp direct7 mode nfs settings' do
  492. let(:hostnames) { %w(hostname1 hostname2 hostname3) }
  493. before do
  494. node.set['openstack']['block-storage']['volume']['driver'] = 'cinder.volume.drivers.netapp.nfs.NetAppDirect7modeNfsDriver'
  495. node.set['openstack']['block-storage']['netapp']['netapp_server_hostname'] = hostnames
  496. end
  497. %w(mount_point_base shares_config).each do |attr_key|
  498. it "has a nfs_#{attr_key} attribute" do
  499. node.set['openstack']['block-storage']['nfs'][attr_key] = "netapp_nfs_#{attr_key}_value"
  500. expect(chef_run).to render_file(file.name).with_content(/^nfs_#{attr_key}=netapp_nfs_#{attr_key}_value$/)
  501. end
  502. end
  503. it 'has netapp server_hostname attributes' do
  504. hostnames.each do |hostname|
  505. expect(chef_run).to render_file(file.name).with_content(/^netapp_server_hostname=#{hostname}$/)
  506. end
  507. end
  508. it 'has a netapp_server_port attribute' do
  509. node.set['openstack']['block-storage']['netapp']['netapp_server_port'] = 'netapp_server_port_value'
  510. expect(chef_run).to render_file(file.name).with_content(/^netapp_server_port=netapp_server_port_value$/)
  511. end
  512. %w(login password).each do |attr|
  513. it "has a netapp_#{attr} attribute" do
  514. node.set['openstack']['block-storage']['netapp']["netapp_server_#{attr}"] = "netapp_#{attr}_value"
  515. expect(chef_run).to render_file(file.name).with_content(/^netapp_#{attr}=netapp_#{attr}_value$/)
  516. end
  517. end
  518. %w(disk_util sparsed_volumes).each do |attr|
  519. it "has a nfs_#{attr} attribute" do
  520. node.set['openstack']['block-storage']['nfs']["nfs_#{attr}"] = "netapp_nfs_#{attr}_value"
  521. expect(chef_run).to render_file(file.name).with_content(/^nfs_#{attr}=netapp_nfs_#{attr}_value$/)
  522. end
  523. end
  524. end
  525. context 'ibmnas settings' do
  526. before do
  527. node.set['openstack']['block-storage']['volume']['driver'] = 'cinder.volume.drivers.ibm.ibmnas.IBMNAS_NFSDriver'
  528. end
  529. %w(mount_point_base shares_config).each do |attr|
  530. it "has a ibmnas_#{attr} attribute" do
  531. node.set['openstack']['block-storage']['ibmnas'][attr] = "ibmnas_#{attr}_value"
  532. expect(chef_run).to render_file(file.name).with_content(/^nfs_#{attr}=ibmnas_#{attr}_value$/)
  533. end
  534. end
  535. it 'has a nfs_sparsed_volumes attribute' do
  536. node.set['openstack']['block-storage']['ibmnas']['nfs_sparsed_volumes'] = 'ibmnas_nfs_sparsed_volumes_value'
  537. expect(chef_run).to render_file(file.name).with_content(/^nfs_sparsed_volumes=ibmnas_nfs_sparsed_volumes_value$/)
  538. end
  539. %w(nas_ip nas_login nas_ssh_port ibmnas_platform_type).each do |attr|
  540. it "has a ibmnas #{attr} attribute" do
  541. node.set['openstack']['block-storage']['ibmnas'][attr] = "ibmnas_#{attr}_value"
  542. expect(chef_run).to render_file(file.name).with_content(/^#{attr}=ibmnas_#{attr}_value$/)
  543. end
  544. end
  545. it 'has a default attributes' do
  546. %w(nas_ip=127.0.0.1
  547. nas_login=admin
  548. nas_password=test_pass
  549. nas_ssh_port=22
  550. ibmnas_platform_type=v7ku
  551. nfs_sparsed_volumes=true
  552. nfs_mount_point_base=/mnt/cinder-volumes
  553. nfs_shares_config=/etc/cinder/nfs_shares.conf).each do |attr|
  554. expect(chef_run).to render_file(file.name).with_content(/^#{attr}$/)
  555. end
  556. end
  557. end
  558. context 'storwize settings' do
  559. before do
  560. node.set['openstack']['block-storage']['volume']['driver'] = 'cinder.volume.drivers.ibm.storwize_svc.StorwizeSVCDriver'
  561. end
  562. it 'has a default attribute' do
  563. %w(san_ip=127.0.0.1
  564. san_private_key=/v7000_rsa
  565. storwize_svc_volpool_name=volpool
  566. storwize_svc_vol_rsize=2
  567. storwize_svc_vol_warning=0
  568. storwize_svc_vol_autoexpand=true
  569. storwize_svc_vol_grainsize=256
  570. storwize_svc_vol_compression=false
  571. storwize_svc_vol_easytier=true
  572. storwize_svc_vol_iogrp=0
  573. storwize_svc_flashcopy_timeout=120
  574. storwize_svc_connection_protocol=iSCSI
  575. storwize_svc_iscsi_chap_enabled=true
  576. storwize_svc_multihostmap_enabled=true
  577. storwize_svc_allow_tenant_qos=false).each do |attr|
  578. expect(chef_run).to render_file(file.name).with_content(/^#{attr}$/)
  579. end
  580. end
  581. it 'has a overridden attribute' do
  582. %w(san_ip
  583. san_private_key
  584. storwize_svc_volpool_name
  585. storwize_svc_vol_rsize
  586. storwize_svc_vol_warning
  587. storwize_svc_vol_autoexpand
  588. storwize_svc_vol_grainsize
  589. storwize_svc_vol_compression
  590. storwize_svc_vol_easytier
  591. storwize_svc_vol_iogrp
  592. storwize_svc_flashcopy_timeout
  593. storwize_svc_connection_protocol
  594. storwize_svc_multihostmap_enabled
  595. storwize_svc_allow_tenant_qos
  596. storwize_svc_stretched_cluster_partner).each do |attr|
  597. node.set['openstack']['block-storage']['storwize'][attr] = "storwize_#{attr}_value"
  598. expect(chef_run).to render_file(file.name).with_content(/^#{attr}=storwize_#{attr}_value$/)
  599. end
  600. end
  601. context 'storwize with login and password' do
  602. it 'has a login and password' do
  603. node.set['openstack']['block-storage']['storwize']['san_private_key'] = ''
  604. %w(san_login=admin
  605. san_password=test_pass
  606. san_private_key=).each do |attr|
  607. expect(chef_run).to render_file(file.name).with_content(/^#{attr}$/)
  608. end
  609. end
  610. end
  611. context 'storwize with iSCSI connection protocol' do
  612. before do
  613. node.set['openstack']['block-storage']['storwize']['storwize_svc_connection_protocol'] = 'iSCSI'
  614. end
  615. it 'has a iscsi chap enabled attribute' do
  616. node.set['openstack']['block-storage']['storwize']['storwize_svc_iscsi_chap_enabled'] = 'storwize_svc_iscsi_chap_enabled_value'
  617. expect(chef_run).to render_file(file.name).with_content(/^storwize_svc_iscsi_chap_enabled=storwize_svc_iscsi_chap_enabled_value$/)
  618. end
  619. it 'does not have a multipath enabled attribute' do
  620. expect(chef_run).not_to render_file(file.name).with_content(/^storwize_svc_multipath_enabled=/)
  621. end
  622. end
  623. context 'storwize without iSCSI connection protocol' do
  624. before do
  625. node.set['openstack']['block-storage']['storwize']['storwize_svc_connection_protocol'] = 'non-iSCSI'
  626. end
  627. it 'does not have a iscsi chap enabled attribute' do
  628. expect(chef_run).not_to render_file(file.name).with_content(/^storwize_svc_iscsi_enabled=/)
  629. end
  630. it 'has a multipath enabled attribute' do
  631. node.set['openstack']['block-storage']['storwize']['storwize_svc_multipath_enabled'] = 'storwize_svc_multipath_enabled_value'
  632. expect(chef_run).to render_file(file.name).with_content(/^storwize_svc_multipath_enabled=storwize_svc_multipath_enabled_value$/)
  633. end
  634. end
  635. end
  636. context 'solidfire settings' do
  637. before do
  638. node.set['openstack']['block-storage']['volume']['driver'] = 'cinder.volume.drivers.solidfire.SolidFire'
  639. end
  640. it 'has solidfire sf_emulate set' do
  641. node.set['openstack']['block-storage']['solidfire']['sf_emulate'] = 'test'
  642. expect(chef_run).to render_file(file.name).with_content(/^sf_emulate_512=test$/)
  643. end
  644. it 'has solidfire password' do
  645. expect(chef_run).to render_file(file.name).with_content(/^san_password=test_pass$/)
  646. end
  647. %w(san_login san_ip).each do |attr|
  648. it "has solidfire #{attr} set" do
  649. node.set['openstack']['block-storage']['solidfire'][attr] = "solidfire_#{attr}_value"
  650. expect(chef_run).to render_file(file.name).with_content(/^#{attr}=solidfire_#{attr}_value$/)
  651. end
  652. end
  653. it 'does not have iscsi_ip_prefix not specified' do
  654. node.set['openstack']['block-storage']['solidfire']['iscsi_ip_prefix'] = nil
  655. expect(chef_run).to_not render_file(file.name).with_content(/^iscsi_ip_prefix=/)
  656. end
  657. it 'does have iscsi_ip_prefix when specified' do
  658. chef_run.node.set['openstack']['block-storage']['solidfire']['iscsi_ip_prefix'] = '203.0.113.*'
  659. expect(chef_run).to render_file(file.name).with_content(/^iscsi_ip_prefix=203.0.113.*$/)
  660. end
  661. end
  662. context 'flashsystem settings' do
  663. before do
  664. node.set['openstack']['block-storage']['volume']['driver'] = 'cinder.volume.drivers.ibm.flashsystem.FlashSystemDriver'
  665. end
  666. it 'has flashsystem password' do
  667. expect(chef_run).to render_config_file(file.name).with_section_content('DEFAULT', /^san_password=test_pass$/)
  668. end
  669. it 'has a default attribute' do
  670. %w(san_ip=127.0.0.1
  671. flashsystem_connection_protocol=FC
  672. flashsystem_multihostmap_enabled=true).each do |attr|
  673. expect(chef_run).to render_config_file(file.name).with_section_content('DEFAULT', /^#{attr}$/)
  674. end
  675. end
  676. it 'has a overridden attribute' do
  677. %w(san_ip
  678. flashsystem_connection_protocol
  679. flashsystem_multihostmap_enabled).each do |attr|
  680. node.set['openstack']['block-storage']['flashsystem'][attr] = "flashsystem_#{attr}_value"
  681. expect(chef_run).to render_config_file(file.name).with_section_content('DEFAULT', /^#{attr}=flashsystem_#{attr}_value$/)
  682. end
  683. end
  684. context 'FlashSystem with FC connection protocol' do
  685. before do
  686. node.set['openstack']['block-storage']['storwize']['flashsystem_connection_protocol'] = 'FC'
  687. end
  688. it 'has a multipath enabled attribute' do
  689. node.set['openstack']['block-storage']['flashsystem']['flashsystem_multipath_enabled'] = 'flashsystem_multipath_enabled_value'
  690. expect(chef_run).to render_config_file(file.name).with_section_content('DEFAULT', /^flashsystem_multipath_enabled=flashsystem_multipath_enabled_value$/)
  691. end
  692. end
  693. end
  694. context 'emc settings' do
  695. before do
  696. node.set['openstack']['block-storage']['volume']['driver'] = 'cinder.volume.drivers.emc.emc_smis_iscsi.EMCSMISISCSIDriver'
  697. end
  698. %w(iscsi_target_prefix cinder_emc_config_file).each do |attr|
  699. it "has emc #{attr} set" do
  700. node.set['openstack']['block-storage']['emc'][attr] = "emc_#{attr}_value"
  701. expect(chef_run).to render_file(file.name).with_content(/^#{attr}=emc_#{attr}_value$/)
  702. end
  703. end
  704. end
  705. context 'vmware vmdk settings' do
  706. before do
  707. node.set['openstack']['block-storage']['volume']['driver'] = 'cinder.volume.drivers.vmware.vmdk.VMwareVcVmdkDriver'
  708. %w(vmware_host_ip vmware_host_username
  709. vmware_api_retry_count vmware_task_poll_interval vmware_volume_folder
  710. vmware_image_transfer_timeout_secs vmware_max_objects_retrieval).each do |attr|
  711. node.set['openstack']['block-storage']['vmware'][attr] = "vmware_#{attr}_value"
  712. end
  713. end
  714. it 'has vmware attributes set' do
  715. node['openstack']['block-storage']['vmware'].each do |attr, val|
  716. expect(chef_run).to render_file(file.name).with_content(/^#{attr} = #{val}$/)
  717. end
  718. end
  719. it 'has password set which is from databag' do
  720. expect(chef_run).to render_file(file.name).with_content(/^vmware_host_password = vmware_secret_name$/)
  721. end
  722. it 'has no wsdl_location line without the attribute' do
  723. node.set['openstack']['block-storage']['vmware']['vmware_wsdl_location'] = nil
  724. expect(chef_run).not_to render_file(file.name).with_content(/^vmware_wsdl_location = /)
  725. end
  726. it 'has wsdl_location line with attribute present' do
  727. node.set['openstack']['block-storage']['vmware']['vmware_wsdl_location'] = 'http://127.0.0.1/wsdl'
  728. expect(chef_run).to render_file(file.name).with_content(%r{^vmware_wsdl_location = http://127.0.0.1/wsdl$})
  729. end
  730. end
  731. context 'gpfs settings' do
  732. before do
  733. node.set['openstack']['block-storage']['volume']['driver'] = 'cinder.volume.drivers.ibm.gpfs.GPFSDriver'
  734. end
  735. %w(gpfs_mount_point_base gpfs_max_clone_depth
  736. gpfs_sparse_volumes gpfs_storage_pool).each do |attr|
  737. it "has gpfs #{attr} set" do
  738. node.set['openstack']['block-storage']['gpfs'][attr] = "gpfs_#{attr}_value"
  739. expect(chef_run).to render_file(file.name).with_content(/^#{attr} = gpfs_#{attr}_value$/)
  740. end
  741. end
  742. it 'has no gpfs_images_dir line without the attribute' do
  743. node.set['openstack']['block-storage']['gpfs']['gpfs_images_dir'] = nil
  744. expect(chef_run).not_to render_file(file.name).with_content(/^gpfs_images_dir = /)
  745. expect(chef_run).not_to render_file(file.name).with_content(/^gpfs_images_share_mode = /)
  746. end
  747. it 'has gpfs_images_dir line with attribute present' do
  748. node.set['openstack']['block-storage']['gpfs']['gpfs_images_dir'] = 'gpfs_images_dir_value'
  749. expect(chef_run).to render_file(file.name).with_content(/^gpfs_images_dir = gpfs_images_dir_value$/)
  750. expect(chef_run).to render_file(file.name).with_content(/^gpfs_images_share_mode = copy_on_write$/)
  751. end
  752. it 'templates misc_cinder array correctly' do
  753. node.set['openstack']['block-storage']['misc_cinder'] = ['# Comments', 'MISC=OPTION']
  754. expect(chef_run).to render_file(file.name).with_content(
  755. /^# Comments$/)
  756. expect(chef_run).to render_file(file.name).with_content(
  757. /^MISC=OPTION$/)
  758. end
  759. end
  760. context 'multiple backend settings' do
  761. before do
  762. node.set['openstack']['block-storage']['volume']['multi_backend'] = {
  763. 'lvm' => {
  764. 'volume_driver' => 'cinder.volume.drivers.lvm.LVMVolumeDriver',
  765. 'volume_backend_name' => 'lvmdrv'
  766. },
  767. 'rbd' => {
  768. 'volume_driver' => 'cinder.volume.drivers.rbd.RBDDriver',
  769. 'volume_backend_name' => 'rbddrv'
  770. },
  771. 'netapp_iscsi' => {
  772. 'volume_driver' => 'cinder.volume.drivers.netapp.NetAppISCSIDriver',
  773. 'multi_netapp_iscsi' => 'multi-netapp'
  774. },
  775. 'netapp_nfs' => {
  776. 'volume_driver' => 'cinder.volume.drivers.netapp.nfs.NetAppDirect7modeNfsDriver',
  777. 'volume_backend_name' => 'netappnfsdrv',
  778. 'multi_netapp_nfs' => 'multi-netapp'
  779. },
  780. 'ibmnas' => {
  781. 'volume_driver' => 'cinder.volume.drivers.ibm.ibmnas.IBMNAS_NFSDriver',
  782. 'multi_ibmnas' => 'multi-ibmnas'
  783. },
  784. 'ibmsvc' => {
  785. 'volume_driver' => 'cinder.volume.drivers.ibm.storwize_svc.StorwizeSVCDriver',
  786. 'multi_ibmsvc' => 'multi-ibmsvc'
  787. },
  788. 'solidfire' => {
  789. 'volume_driver' => 'cinder.volume.drivers.solidfire.SolidFire',
  790. 'multi_solidfire' => 'multi-solidfire'
  791. },
  792. 'emciscsi' => {
  793. 'volume_driver' => 'cinder.volume.drivers.emc.emc_smis_iscsi.EMCSMISISCSIDriver',
  794. 'multi_emciscsi' => 'multi-emciscsi'
  795. },
  796. 'vmware' => {
  797. 'volume_driver' => 'cinder.volume.drivers.vmware.vmdk.VMwareVcVmdkDriver',
  798. 'multi_vmware' => 'multi-vmware'
  799. },
  800. 'gpfs' => {
  801. 'volume_driver' => 'cinder.volume.drivers.ibm.gpfs.GPFSDriver',
  802. 'multi_gpfs' => 'multi-gpfs'
  803. }
  804. }
  805. node.set['openstack']['block-storage']['volume']['volume_group'] = 'multi-lvm-group'
  806. node.set['openstack']['block-storage']['volume']['default_volume_type'] = 'some-type-name'
  807. node.set['openstack']['block-storage']['rbd']['cinder']['pool'] = 'multi-rbd-pool'
  808. node.set['openstack']['block-storage']['netapp']['dfm_login'] = 'multi-netapp-login'
  809. node.set['openstack']['block-storage']['netapp']['netapp_server_hostname'] = ['netapp-host-1', 'netapp-host-2']
  810. node.set['openstack']['block-storage']['netapp']['netapp_server_port'] = 'multi-netapp-port'
  811. node.set['openstack']['block-storage']['ibmnas']['shares_config'] = 'multi-ibmnas-share'
  812. node.set['openstack']['block-storage']['storwize']['storwize_svc_volpool_name'] = 'multi-svc-volpool'
  813. node.set['openstack']['block-storage']['solidfire']['sf_emulate'] = 'multi-sf-true'
  814. node.set['openstack']['block-storage']['emc']['cinder_emc_config_file'] = 'multi-emc-conf'
  815. node.set['openstack']['block-storage']['vmware']['vmware_host_ip'] = 'multi-vmware-ip'
  816. node.set['openstack']['block-storage']['gpfs']['gpfs_mount_point_base'] = 'multi-gpfs-mnt'
  817. end
  818. it 'enable multiple backends' do
  819. expect(chef_run).to render_file(file.name).with_content(/^enabled_backends = lvm,rbd,netapp_iscsi,netapp_nfs,ibmnas,ibmsvc,solidfire,emciscsi,vmware,gpfs$/)
  820. expect(chef_run).to render_file(file.name).with_content(/^\[lvm\]$/)
  821. expect(chef_run).to render_file(file.name).with_content(/^volume_driver = cinder\.volume\.drivers\.lvm\.LVMVolumeDriver$/)
  822. expect(chef_run).to render_file(file.name).with_content(/^\[rbd\]$/)
  823. expect(chef_run).to render_file(file.name).with_content(/^volume_driver = cinder\.volume\.drivers\.rbd\.RBDDriver$/)
  824. expect(chef_run).to render_file(file.name).with_content(/^\[netapp_iscsi\]$/)
  825. expect(chef_run).to render_file(file.name).with_content(/^volume_driver = cinder\.volume\.drivers\.netapp\.NetAppISCSIDriver$/)
  826. expect(chef_run).to render_file(file.name).with_content(/^netapp_server_hostname=netapp-host-1$/)
  827. expect(chef_run).to render_file(file.name).with_content(/^netapp_server_hostname=netapp-host-2$/)
  828. expect(chef_run).to render_file(file.name).with_content(/^\[netapp_nfs\]$/)
  829. expect(chef_run).to render_file(file.name).with_content(/^volume_driver = cinder\.volume\.drivers\.netapp\.nfs\.NetAppDirect7modeNfsDriver$/)
  830. expect(chef_run).to render_file(file.name).with_content(/^\[ibmnas\]$/)
  831. expect(chef_run).to render_file(file.name).with_content(/^volume_driver = cinder\.volume\.drivers\.ibm\.ibmnas\.IBMNAS_NFSDriver$/)
  832. expect(chef_run).to render_file(file.name).with_content(/^\[ibmsvc\]$/)
  833. expect(chef_run).to render_file(file.name).with_content(/^volume_driver = cinder\.volume\.drivers\.ibm\.storwize_svc\.StorwizeSVCDriver$/)
  834. expect(chef_run).to render_file(file.name).with_content(/^\[solidfire\]$/)
  835. expect(chef_run).to render_file(file.name).with_content(/^volume_driver = cinder\.volume\.drivers\.solidfire\.SolidFire$/)
  836. expect(chef_run).to render_file(file.name).with_content(/^\[emciscsi\]$/)
  837. expect(chef_run).to render_file(file.name).with_content(/^volume_driver = cinder\.volume\.drivers\.emc\.emc_smis_iscsi\.EMCSMISISCSIDriver$/)
  838. expect(chef_run).to render_file(file.name).with_content(/^\[vmware\]$/)
  839. expect(chef_run).to render_file(file.name).with_content(/^volume_driver = cinder\.volume\.drivers\.vmware\.vmdk\.VMwareVcVmdkDriver$/)
  840. expect(chef_run).to render_file(file.name).with_content(/^\[gpfs\]$/)
  841. expect(chef_run).to render_file(file.name).with_content(/^volume_driver = cinder\.volume\.drivers\.ibm\.gpfs\.GPFSDriver$/)
  842. end
  843. it 'set lvm option' do
  844. expect(chef_run).to render_file(file.name).with_content(/^volume_group=multi-lvm-group$/)
  845. end
  846. it 'set default_volume_type option' do
  847. expect(chef_run).to render_file(file.name).with_content(/^default_volume_type=some-type-name$/)
  848. end
  849. it 'set rbd option' do
  850. expect(chef_run).to render_file(file.name).with_content(/^rbd_pool=multi-rbd-pool$/)
  851. end
  852. it 'set netapp_iscsi option' do
  853. expect(chef_run).to render_file(file.name).with_content(/^netapp_login=multi-netapp-login$/)
  854. end
  855. it 'set netapp_nfs option' do
  856. expect(chef_run).to render_file(file.name).with_content(/^netapp_server_port=multi-netapp-port$/)
  857. end
  858. it 'set ibmnas option' do
  859. expect(chef_run).to render_file(file.name).with_content(/^nfs_shares_config=multi-ibmnas-share$/)
  860. end
  861. it 'set ibmsvc option' do
  862. expect(chef_run).to render_file(file.name).with_content(/^storwize_svc_volpool_name=multi-svc-volpool$/)
  863. end
  864. it 'set solidfire option' do
  865. expect(chef_run).to render_file(file.name).with_content(/^sf_emulate_512=multi-sf-true$/)
  866. end
  867. it 'set emciscsi option' do
  868. expect(chef_run).to render_file(file.name).with_content(/^cinder_emc_config_file=multi-emc-conf$/)
  869. end
  870. it 'set vmware option' do
  871. expect(chef_run).to render_file(file.name).with_content(/^vmware_host_ip = multi-vmware-ip$/)
  872. end
  873. it 'set gpfs option' do
  874. expect(chef_run).to render_file(file.name).with_content(/^gpfs_mount_point_base = multi-gpfs-mnt$/)
  875. end
  876. end
  877. it 'no multiple backends configured' do
  878. expect(chef_run).to_not render_file(file.name).with_content(/^enabled_backends = [\w\W]+$/)
  879. end
  880. it 'does not set default_volume_type' do
  881. expect(chef_run).to_not render_file(file.name).with_content(/^default_volume_type=.+$/)
  882. end
  883. end
  884. end
  885. describe '/var/lib/cinder/lock' do
  886. let(:dir) { chef_run.directory('/var/lib/cinder/lock') }
  887. it 'should create the /var/lib/cinder/lock directory' do
  888. expect(chef_run).to create_directory(dir.name).with(
  889. user: 'cinder',
  890. group: 'cinder',
  891. mode: 00755
  892. )
  893. end
  894. end
  895. describe 'rootwrap.conf' do
  896. let(:file) { chef_run.template('/etc/cinder/rootwrap.conf') }
  897. it 'creates the /etc/cinder/rootwrap.conf file' do
  898. expect(chef_run).to create_template(file.name).with(
  899. user: 'root',
  900. group: 'root',
  901. mode: 0644
  902. )
  903. end
  904. context 'template contents' do
  905. it 'shows the custom banner' do
  906. node.set['openstack']['block-storage']['custom_template_banner'] = 'banner'
  907. expect(chef_run).to render_file(file.name)
  908. .with_content(/^banner$/)
  909. end
  910. it 'sets the default attributes' do
  911. [
  912. %r{^filters_path=/etc/cinder/rootwrap.d,/usr/share/cinder/rootwrap$},
  913. %r{^exec_dirs=/sbin,/usr/sbin,/bin,/usr/bin$},
  914. /^use_syslog=False$/,
  915. /^syslog_log_facility=syslog$/,
  916. /^syslog_log_level=ERROR$/
  917. ].each do |line|
  918. expect(chef_run).to render_file(file.name).with_content(line)
  919. end
  920. end
  921. end
  922. end
  923. end
  924. end