Merge "Allow create volume group with block devices for lvm"
This commit is contained in:
		@@ -1,6 +1,8 @@
 | 
				
			|||||||
openstack-block-storage Cookbook CHANGELOG
 | 
					openstack-block-storage Cookbook CHANGELOG
 | 
				
			||||||
==============================
 | 
					==============================
 | 
				
			||||||
This file is used to list changes made in each version of the openstack-block-storage cookbook.
 | 
					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
 | 
					## 9.4.0
 | 
				
			||||||
* python_packages database client attributes have been migrated to
 | 
					* python_packages database client attributes have been migrated to
 | 
				
			||||||
 
 | 
				
			|||||||
@@ -103,6 +103,8 @@ Cinder attributes
 | 
				
			|||||||
* `openstack["block-storage"]["volume"]["volume_group"]` - Name for the VG that will contain exported volumes
 | 
					* `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"]["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"]["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_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_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
 | 
					* `openstack["block-storage"]["volume"]["iscsi_port"]` - The port where the iSCSI daemon is listening on
 | 
				
			||||||
 
 | 
				
			|||||||
@@ -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']['volume_clear'] = 'zero'
 | 
				
			||||||
 | 
					
 | 
				
			||||||
default['openstack']['block-storage']['volume']['create_volume_group'] = false
 | 
					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_helper'] = 'tgtadm'
 | 
				
			||||||
default['openstack']['block-storage']['volume']['iscsi_ip_address'] = node['ipaddress']
 | 
					default['openstack']['block-storage']['volume']['iscsi_ip_address'] = node['ipaddress']
 | 
				
			||||||
default['openstack']['block-storage']['volume']['iscsi_port'] = '3260'
 | 
					default['openstack']['block-storage']['volume']['iscsi_port'] = '3260'
 | 
				
			||||||
 
 | 
				
			|||||||
@@ -5,7 +5,7 @@ maintainer_email 'cookbooks@lists.tfoundry.com'
 | 
				
			|||||||
license          'Apache 2.0'
 | 
					license          'Apache 2.0'
 | 
				
			||||||
description      'The OpenStack Advanced Volume Management service Cinder.'
 | 
					description      'The OpenStack Advanced Volume Management service Cinder.'
 | 
				
			||||||
long_description IO.read(File.join(File.dirname(__FILE__), 'README.md'))
 | 
					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::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'
 | 
					recipe           'openstack-block-storage::client', 'Install packages required for cinder client'
 | 
				
			||||||
 
 | 
				
			|||||||
@@ -155,35 +155,47 @@ when 'cinder.volume.drivers.ibm.ibmnas.IBMNAS_NFSDriver'
 | 
				
			|||||||
  end
 | 
					  end
 | 
				
			||||||
 | 
					
 | 
				
			||||||
when 'cinder.volume.drivers.lvm.LVMISCSIDriver'
 | 
					when 'cinder.volume.drivers.lvm.LVMISCSIDriver'
 | 
				
			||||||
 | 
					
 | 
				
			||||||
  if node['openstack']['block-storage']['volume']['create_volume_group']
 | 
					  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_name = node['openstack']['block-storage']['volume']['volume_group']
 | 
				
			||||||
    vg_file = "#{node['openstack']['block-storage']['volume']['state_path']}/#{vg_name}.img"
 | 
					 | 
				
			||||||
 | 
					
 | 
				
			||||||
    # create volume group
 | 
					    case node['openstack']['block-storage']['volume']['create_volume_group_type']
 | 
				
			||||||
    execute 'Create Cinder volume group' do
 | 
					    when 'file'
 | 
				
			||||||
      command "dd if=/dev/zero of=#{vg_file} bs=1M seek=#{seek_count} count=0; vgcreate #{vg_name} $(losetup --show -f #{vg_file})"
 | 
					      volume_size = node['openstack']['block-storage']['volume']['volume_group_size']
 | 
				
			||||||
      action :run
 | 
					      seek_count = volume_size.to_i * 1024
 | 
				
			||||||
      not_if "vgs #{vg_name}"
 | 
					      vg_file = "#{node['openstack']['block-storage']['volume']['state_path']}/#{vg_name}.img"
 | 
				
			||||||
    end
 | 
					 | 
				
			||||||
 | 
					
 | 
				
			||||||
    template '/etc/init.d/cinder-group-active' do
 | 
					      # create volume group
 | 
				
			||||||
      source 'cinder-group-active.erb'
 | 
					      execute 'Create Cinder volume group' do
 | 
				
			||||||
      mode '755'
 | 
					        command "dd if=/dev/zero of=#{vg_file} bs=1M seek=#{seek_count} count=0; vgcreate #{vg_name} $(losetup --show -f #{vg_file})"
 | 
				
			||||||
      variables(
 | 
					        action :run
 | 
				
			||||||
        volume_name: vg_name,
 | 
					        not_if "vgs #{vg_name}"
 | 
				
			||||||
        volume_file: vg_file
 | 
					      end
 | 
				
			||||||
      )
 | 
					 | 
				
			||||||
      notifies :start, 'service[cinder-group-active]', :immediately
 | 
					 | 
				
			||||||
    end
 | 
					 | 
				
			||||||
 | 
					
 | 
				
			||||||
    service 'cinder-group-active' do
 | 
					      template '/etc/init.d/cinder-group-active' do
 | 
				
			||||||
      service_name 'cinder-group-active'
 | 
					        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
 | 
				
			||||||
  end
 | 
					  end
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 
 | 
				
			|||||||
@@ -311,6 +311,21 @@ describe 'openstack-block-storage::volume' do
 | 
				
			|||||||
      end
 | 
					      end
 | 
				
			||||||
    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
 | 
					    describe 'cinder_emc_config.xml' do
 | 
				
			||||||
      let(:file) { chef_run.template('/etc/cinder/cinder_emc_config.xml') }
 | 
					      let(:file) { chef_run.template('/etc/cinder/cinder_emc_config.xml') }
 | 
				
			||||||
      before do
 | 
					      before do
 | 
				
			||||||
 
 | 
				
			|||||||
		Reference in New Issue
	
	Block a user