Allow create volume group with block devices for lvm

Add new attribute, create_colume_group_type to allow
either create simple test volume based upon a file
(as existing support does),
or create volume group based upon block devices.

Change-Id: Ia81354f9fab9310c1b5e633d4ca05e434f9c2da6
Closes-Bug: #1321336
This commit is contained in:
Mark Vanderwiel 2014-07-10 14:33:42 -05:00
parent ff47560ac4
commit 84e52038f8
6 changed files with 63 additions and 24 deletions

View File

@ -1,6 +1,8 @@
openstack-block-storage Cookbook CHANGELOG
==============================
This file is used to list changes made in each version of the openstack-block-storage cookbook.
## 9.4.1
* Add support for LVMISCSIDriver driver using block devices with LVM
## 9.4.0
* python_packages database client attributes have been migrated to

View File

@ -103,6 +103,8 @@ Cinder attributes
* `openstack["block-storage"]["volume"]["volume_group"]` - Name for the VG that will contain exported volumes
* `openstack["block-storage"]["voluem"]["volume_group_size"]` - The size (GB) of volume group (default is 40)
* `openstack["block-storage"]["voluem"]["create_volume_group"]` - Create volume group or not when using the LVMISCSIDriver (default is false)
* `openstack["block-storage"]["volume"]["create_volume_group_type"]` - 'file' or 'block_devices'. Create volume group from block devices or just a file for testing
* `openstack["block-storage"]["volume"]["block_devices"]` - String of blank separated block devices to use for creating volume group when type is 'block_devices'
* `openstack["block-storage"]["volume"]["iscsi_helper"]` - ISCSI target user-land tool to use
* `openstack["block-storage"]["volume"]["iscsi_ip_address"]` - The IP address where the iSCSI daemon is listening on
* `openstack["block-storage"]["volume"]["iscsi_port"]` - The port where the iSCSI daemon is listening on

View File

@ -210,6 +210,14 @@ default['openstack']['block-storage']['volume']['volume_clear_size'] = 0
default['openstack']['block-storage']['volume']['volume_clear'] = 'zero'
default['openstack']['block-storage']['volume']['create_volume_group'] = false
# Type of volume group to create:
# - 'file' for basic 40g file for testing
# - 'block_devices' for using block devices, specified in block_devices attribute
default['openstack']['block-storage']['volume']['create_volume_group_type'] = 'file'
# String of local disk device paths
# Examples: '/dev/sdx /dev/sdx1' or '/dev/sd[k-m]1'
default['openstack']['block-storage']['volume']['block_devices'] = nil
default['openstack']['block-storage']['volume']['iscsi_helper'] = 'tgtadm'
default['openstack']['block-storage']['volume']['iscsi_ip_address'] = node['ipaddress']
default['openstack']['block-storage']['volume']['iscsi_port'] = '3260'

View File

@ -5,7 +5,7 @@ maintainer_email 'cookbooks@lists.tfoundry.com'
license 'Apache 2.0'
description 'The OpenStack Advanced Volume Management service Cinder.'
long_description IO.read(File.join(File.dirname(__FILE__), 'README.md'))
version '9.4.0'
version '9.4.1'
recipe 'openstack-block-storage::api', 'Installs the cinder-api, sets up the cinder database, and cinder service/user/endpoints in keystone'
recipe 'openstack-block-storage::client', 'Install packages required for cinder client'

View File

@ -155,35 +155,47 @@ when 'cinder.volume.drivers.ibm.ibmnas.IBMNAS_NFSDriver'
end
when 'cinder.volume.drivers.lvm.LVMISCSIDriver'
if node['openstack']['block-storage']['volume']['create_volume_group']
volume_size = node['openstack']['block-storage']['volume']['volume_group_size']
seek_count = volume_size.to_i * 1024
# default volume group is 40G
seek_count = 40 * 1024 if seek_count == 0
vg_name = node['openstack']['block-storage']['volume']['volume_group']
vg_file = "#{node['openstack']['block-storage']['volume']['state_path']}/#{vg_name}.img"
# create volume group
execute 'Create Cinder volume group' do
command "dd if=/dev/zero of=#{vg_file} bs=1M seek=#{seek_count} count=0; vgcreate #{vg_name} $(losetup --show -f #{vg_file})"
action :run
not_if "vgs #{vg_name}"
end
case node['openstack']['block-storage']['volume']['create_volume_group_type']
when 'file'
volume_size = node['openstack']['block-storage']['volume']['volume_group_size']
seek_count = volume_size.to_i * 1024
vg_file = "#{node['openstack']['block-storage']['volume']['state_path']}/#{vg_name}.img"
template '/etc/init.d/cinder-group-active' do
source 'cinder-group-active.erb'
mode '755'
variables(
volume_name: vg_name,
volume_file: vg_file
)
notifies :start, 'service[cinder-group-active]', :immediately
end
# create volume group
execute 'Create Cinder volume group' do
command "dd if=/dev/zero of=#{vg_file} bs=1M seek=#{seek_count} count=0; vgcreate #{vg_name} $(losetup --show -f #{vg_file})"
action :run
not_if "vgs #{vg_name}"
end
service 'cinder-group-active' do
service_name 'cinder-group-active'
template '/etc/init.d/cinder-group-active' do
source 'cinder-group-active.erb'
mode '755'
variables(
volume_name: vg_name,
volume_file: vg_file
)
notifies :start, 'service[cinder-group-active]', :immediately
end
action [:enable, :start]
service 'cinder-group-active' do
service_name 'cinder-group-active'
action [:enable, :start]
end
when 'block_devices'
block_devices = node['openstack']['block-storage']['volume']['block_devices']
execute 'Create Cinder volume group with block devices' do
command "pvcreate #{block_devices}; vgcreate #{vg_name} #{block_devices}"
action :run
not_if "vgs #{vg_name}"
end
end
end

View File

@ -303,6 +303,21 @@ describe 'openstack-block-storage::volume' do
end
end
describe 'create vg on block devices' do
before do
node.set['openstack']['block-storage']['volume']['driver'] = 'cinder.volume.drivers.lvm.LVMISCSIDriver'
node.set['openstack']['block-storage']['volume']['create_volume_group'] = true
node.set['openstack']['block-storage']['volume']['create_volume_group_type'] = 'block_devices'
node.set['openstack']['block-storage']['volume']['block_devices'] = '/dev/sdx /dev/sdx1'
stub_command('vgs cinder-volumes').and_return(false)
end
it 'create volume group on block devices' do
cmd = 'pvcreate /dev/sdx /dev/sdx1; vgcreate cinder-volumes /dev/sdx /dev/sdx1'
expect(chef_run).to run_execute('Create Cinder volume group with block devices').with(command: cmd)
end
end
describe 'cinder_emc_config.xml' do
let(:file) { chef_run.template('/etc/cinder/cinder_emc_config.xml') }
before do