Create volume group when use the LVMISCSIDriver
Create volume group when set volume_driver to cinder.volume.drivers.lvm.LVMISCSIDriver otherwise we can not create volume with cinder. Change-Id: I9d27a19254aa62130c13171d68c0c67e4e3686ce
This commit is contained in:
		
							
								
								
									
										32
									
								
								README.md
									
									
									
									
									
								
							
							
						
						
									
										32
									
								
								README.md
									
									
									
									
									
								
							| @@ -35,7 +35,7 @@ scheduler | |||||||
|  |  | ||||||
| volume | volume | ||||||
| ---- | ---- | ||||||
| - Installs the cinder-volume service and sets up the iscsi helper | - Installs the cinder-volume service, sets up the iscsi helper and create volume group when using the LVMISCSIDriver | ||||||
|  |  | ||||||
| Defaults to the ISCSI (LVM) Driver. | Defaults to the ISCSI (LVM) Driver. | ||||||
|  |  | ||||||
| @@ -79,30 +79,32 @@ TODO: move rabbit parameters under openstack["block-storage"]["mq"] | |||||||
| * `openstack["block-storage"]["volume"]["state_path"]` - Top-level directory for maintaining cinder's state | * `openstack["block-storage"]["volume"]["state_path"]` - Top-level directory for maintaining cinder's state | ||||||
| * `openstack["block-storage"]["volume"]["driver"]` - Driver to use for volume creation | * `openstack["block-storage"]["volume"]["driver"]` - Driver to use for volume creation | ||||||
| * `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"]["create_volume_group"]` - Create volume group or not when using the LVMISCSIDriver (default is false) | ||||||
| * `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"]["rbd_pool"]` - RADOS Block Device pool to use | * `openstack["block-storage"]["rbd_pool"]` - RADOS Block Device pool to use | ||||||
| * `openstack["block-storage"]["rbd_user"]` - User for Cephx Authentication | * `openstack["block-storage"]["rbd_user"]` - User for Cephx Authentication | ||||||
| * `openstack["block-storage"]["rbd_secret_uuid"]` - Secret UUID for Cephx Authentication | * `openstack["block-storage"]["rbd_secret_uuid"]` - Secret UUID for Cephx Authentication | ||||||
| * `openstack["block-storage"]["policy"]["context_is_admin"]` - Define administrators | * `openstack["block-storage"]["policy"]["context_is_admin"]` - Define administrators | ||||||
| * `openstack["block-storage"]["policy"]["default"]` - default volume operations rule | * `openstack["block-storage"]["policy"]["default"]` - Default volume operations rule | ||||||
| * `openstack["block-storage"]["policy"]["admin_or_owner"]` - Define an admin or owner | * `openstack["block-storage"]["policy"]["admin_or_owner"]` - Define an admin or owner | ||||||
| * `openstack["block-storage"]["policy"]["admin_api"]` - Define api admin | * `openstack["block-storage"]["policy"]["admin_api"]` - Define api admin | ||||||
| * `openstack["block-storage"]["netapp"]["protocol"]` - how are we talking to either dfm or filer, http or https | * `openstack["block-storage"]["netapp"]["protocol"]` - How are we talking to either dfm or filer, http or https | ||||||
| * `openstack["block-storage"]["netapp"]["dfm_hostname"]` - Host or IP of your dfm server | * `openstack["block-storage"]["netapp"]["dfm_hostname"]` - Host or IP of your dfm server | ||||||
| * `openstack["block-storage"]["netapp"]["dfm_login"]` - Username for dfm | * `openstack["block-storage"]["netapp"]["dfm_login"]` - Username for dfm | ||||||
| * `openstack["block-storage"]["netapp"]["dfm_password"]` - password for the dfm user | * `openstack["block-storage"]["netapp"]["dfm_password"]` - Password for the dfm user | ||||||
| * `openstack["block-storage"]["netapp"]["dfm_port"]` - default port for dfm | * `openstack["block-storage"]["netapp"]["dfm_port"]` - Default port for dfm | ||||||
| * `openstack["block-storage"]["netapp"]["dfm_web_port"]` - web gui port for wsdl file download | * `openstack["block-storage"]["netapp"]["dfm_web_port"]` - Web gui port for wsdl file download | ||||||
| * `openstack["block-storage"]["netapp"]["storage_service"]` - name of the service in dfpm | * `openstack["block-storage"]["netapp"]["storage_service"]` - Name of the service in dfpm | ||||||
| * `openstack["block-storage"]["netapp"]["netapp_server_port"]` - web admin port of the filer itself | * `openstack["block-storage"]["netapp"]["netapp_server_port"]` - Web admin port of the filer itself | ||||||
| * `openstack["block-storage"]["netapp"]["netapp_server_hostname"]` - hostname of your filer, needs to be resolvable | * `openstack["block-storage"]["netapp"]["netapp_server_hostname"]` - Hostname of your filer, needs to be resolvable | ||||||
| * `openstack["block-storage"]["netapp"]["netapp_server_login"]` - Username for netapp filer | * `openstack["block-storage"]["netapp"]["netapp_server_login"]` - Username for netapp filer | ||||||
| * `openstack["block-storage"]["netapp"]["netapp_server_password"]` - password for user above | * `openstack["block-storage"]["netapp"]["netapp_server_password"]` - Password for user above | ||||||
| * `openstack["block-storage"]["nfs"]["shares_config"]` - file containing line by line entries of server:export | * `openstack["block-storage"]["nfs"]["shares_config"]` - File containing line by line entries of server:export | ||||||
| * `openstack["block-storage"]["nfs"]["mount_point_base"]` - directory to mount NFS exported shares | * `openstack["block-storage"]["nfs"]["mount_point_base"]` - Directory to mount NFS exported shares | ||||||
| * `openstack["block-storage"]["rpc_thread_pool_size"]` - size of RPC thread pool | * `openstack["block-storage"]["rpc_thread_pool_size"]` - Size of RPC thread pool | ||||||
| * `openstack["block-storage"]["rpc_conn_pool_size"]` - size of RPC connection pool | * `openstack["block-storage"]["rpc_conn_pool_size"]` - Size of RPC connection pool | ||||||
| * `openstack["block-storage"]["rpc_response_timeout"]` - seconds to wait for a response from call or multicall | * `openstack["block-storage"]["rpc_response_timeout"]` - Seconds to wait for a response from call or multicall | ||||||
|  |  | ||||||
| Testing | Testing | ||||||
| ===== | ===== | ||||||
|   | |||||||
| @@ -6,7 +6,7 @@ | |||||||
| # Copyright 2012, Rackspace US, Inc. | # Copyright 2012, Rackspace US, Inc. | ||||||
| # Copyright 2012-2013, AT&T Services, Inc. | # Copyright 2012-2013, AT&T Services, Inc. | ||||||
| # Copyright 2013, Opscode, Inc. | # Copyright 2013, Opscode, Inc. | ||||||
| # Copyright (c) 2013, IBM, Corp | # Copyright 2013, IBM, Corp | ||||||
| # | # | ||||||
| # Licensed under the Apache License, Version 2.0 (the "License"); | # Licensed under the Apache License, Version 2.0 (the "License"); | ||||||
| # you may not use this file except in compliance with the License. | # you may not use this file except in compliance with the License. | ||||||
| @@ -138,6 +138,8 @@ default["openstack"]["block-storage"]["cron"]["audit_logfile"] = "/var/log/cinde | |||||||
| default["openstack"]["block-storage"]["volume"]["state_path"] = "/var/lib/cinder" | default["openstack"]["block-storage"]["volume"]["state_path"] = "/var/lib/cinder" | ||||||
| default["openstack"]["block-storage"]["volume"]["driver"] = "cinder.volume.driver.ISCSIDriver" | default["openstack"]["block-storage"]["volume"]["driver"] = "cinder.volume.driver.ISCSIDriver" | ||||||
| default["openstack"]["block-storage"]["volume"]["volume_group"] = "cinder-volumes" | default["openstack"]["block-storage"]["volume"]["volume_group"] = "cinder-volumes" | ||||||
|  | default["openstack"]["block-storage"]["volume"]["volume_group_size"] = 40 | ||||||
|  | default["openstack"]["block-storage"]["volume"]["create_volume_group"] = false | ||||||
| default["openstack"]["block-storage"]["volume"]["iscsi_helper"] = "tgtadm" | default["openstack"]["block-storage"]["volume"]["iscsi_helper"] = "tgtadm" | ||||||
|  |  | ||||||
| # Ceph/RADOS options | # Ceph/RADOS options | ||||||
|   | |||||||
| @@ -6,6 +6,7 @@ | |||||||
| # Copyright 2012-2013, AT&T Services, Inc. | # Copyright 2012-2013, AT&T Services, Inc. | ||||||
| # Copyright 2013, Opscode, Inc. | # Copyright 2013, Opscode, Inc. | ||||||
| # Copyright 2013, SUSE Linux Gmbh. | # Copyright 2013, SUSE Linux Gmbh. | ||||||
|  | # Copyright 2013, IBM, Corp. | ||||||
| # | # | ||||||
| # Licensed under the Apache License, Version 2.0 (the "License"); | # Licensed under the Apache License, Version 2.0 (the "License"); | ||||||
| # you may not use this file except in compliance with the License. | # you may not use this file except in compliance with the License. | ||||||
| @@ -52,40 +53,73 @@ platform_options["cinder_iscsitarget_packages"].each do |pkg| | |||||||
| end | end | ||||||
|  |  | ||||||
| case node["openstack"]["block-storage"]["volume"]["driver"] | case node["openstack"]["block-storage"]["volume"]["driver"] | ||||||
|   when "cinder.volume.drivers.netapp.iscsi.NetAppISCSIDriver" | when "cinder.volume.drivers.netapp.iscsi.NetAppISCSIDriver" | ||||||
|    node.override["openstack"]["block-storage"]["netapp"]["dfm_password"] = service_password "netapp" |   node.override["openstack"]["block-storage"]["netapp"]["dfm_password"] = service_password "netapp" | ||||||
|  |  | ||||||
|   when "cinder.volume.drivers.RBDDriver" | when "cinder.volume.drivers.RBDDriver" | ||||||
|    node.override["openstack"]["block-storage"]["rbd_secret_uuid"] = service_password "rbd" |   node.override["openstack"]["block-storage"]["rbd_secret_uuid"] = service_password "rbd" | ||||||
|  |  | ||||||
|   when "cinder.volume.drivers.netapp.nfs.NetAppDirect7modeNfsDriver" | when "cinder.volume.drivers.netapp.nfs.NetAppDirect7modeNfsDriver" | ||||||
|     node.override["openstack"]["block-storage"]["netapp"]["netapp_server_password"] = service_password "netapp-filer" |   node.override["openstack"]["block-storage"]["netapp"]["netapp_server_password"] = service_password "netapp-filer" | ||||||
|  |  | ||||||
|     directory node["openstack"]["block-storage"]["nfs"]["mount_point_base"] do |   directory node["openstack"]["block-storage"]["nfs"]["mount_point_base"] do | ||||||
|       owner node["openstack"]["block-storage"]["user"] |     owner node["openstack"]["block-storage"]["user"] | ||||||
|       group node["openstack"]["block-storage"]["group"] |     group node["openstack"]["block-storage"]["group"] | ||||||
|       action :create |     action :create | ||||||
|  |   end | ||||||
|  |  | ||||||
|  |   template node["openstack"]["block-storage"]["nfs"]["shares_config"] do | ||||||
|  |     source "shares.conf.erb" | ||||||
|  |     mode "0600" | ||||||
|  |     owner node["openstack"]["block-storage"]["user"] | ||||||
|  |     group node["openstack"]["block-storage"]["group"] | ||||||
|  |     variables( | ||||||
|  |       "host" => node["openstack"]["block-storage"]["netapp"]["netapp_server_hostname"], | ||||||
|  |       "export" => node["openstack"]["block-storage"]["netapp"]["export"] | ||||||
|  |     ) | ||||||
|  |     notifies :restart, "service[cinder-volume]" | ||||||
|  |   end | ||||||
|  |  | ||||||
|  |   platform_options["cinder_nfs_packages"].each do |pkg| | ||||||
|  |     package pkg do | ||||||
|  |       options platform_options["package_overrides"] | ||||||
|  |  | ||||||
|  |       action :upgrade | ||||||
|  |     end | ||||||
|  |   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 |     end | ||||||
|  |  | ||||||
|     template node["openstack"]["block-storage"]["nfs"]["shares_config"] do |     service "cinder-group-active" do | ||||||
|       source "shares.conf.erb" |       service_name "cinder-group-active" | ||||||
|       mode "0600" |       supports :status => true, :restart => true | ||||||
|       owner node["openstack"]["block-storage"]["user"] |  | ||||||
|       group node["openstack"]["block-storage"]["group"] |       action [ :enable, :start ] | ||||||
|  |     end | ||||||
|  |  | ||||||
|  |     template "/etc/init.d/cinder-group-active" do | ||||||
|  |       source "cinder-group-active.erb" | ||||||
|  |       mode "755" | ||||||
|       variables( |       variables( | ||||||
|         "host" => node["openstack"]["block-storage"]["netapp"]["netapp_server_hostname"], |         "volume_file" => vg_file | ||||||
|         "export" => node["openstack"]["block-storage"]["netapp"]["export"] |  | ||||||
|       ) |       ) | ||||||
|       notifies :restart, "service[cinder-volume]" |       notifies :restart, "service[cinder-group-active]", :immediately | ||||||
|     end |  | ||||||
|  |  | ||||||
|     platform_options["cinder_nfs_packages"].each do |pkg| |  | ||||||
|       package pkg do |  | ||||||
|         options platform_options["package_overrides"] |  | ||||||
|  |  | ||||||
|         action :upgrade |  | ||||||
|       end |  | ||||||
|     end |     end | ||||||
|  |   end | ||||||
| end | end | ||||||
|  |  | ||||||
| service "cinder-volume" do | service "cinder-volume" do | ||||||
|   | |||||||
| @@ -115,5 +115,30 @@ describe "openstack-block-storage::volume" do | |||||||
|         expect(@chef_run).not_to render_file(@file.name).with_content("include /var/lib/cinder/volumes/*") |         expect(@chef_run).not_to render_file(@file.name).with_content("include /var/lib/cinder/volumes/*") | ||||||
|       end |       end | ||||||
|     end |     end | ||||||
|  |  | ||||||
|  |     describe "create_vg" do | ||||||
|  |       before do | ||||||
|  |         @chef_run = ::ChefSpec::Runner.new ::UBUNTU_OPTS do |n| | ||||||
|  |           n.set["openstack"]["block-storage"]["volume"]["driver"] = "cinder.volume.drivers.lvm.LVMISCSIDriver" | ||||||
|  |           n.set["openstack"]["block-storage"]["volume"]["create_volume_group"] = true | ||||||
|  |         end | ||||||
|  |         stub_command("vgs cinder-volumes").and_return(false) | ||||||
|  |         @chef_run.converge "openstack-block-storage::volume" | ||||||
|  |       end | ||||||
|  |  | ||||||
|  |       it "cinder vg active" do | ||||||
|  |         expect(@chef_run).to enable_service "cinder-group-active" | ||||||
|  |       end | ||||||
|  |  | ||||||
|  |       it "create volume group" do | ||||||
|  |         volume_size = @chef_run.node["openstack"]["block-storage"]["volume"]["volume_group_size"] | ||||||
|  |         seek_count = volume_size.to_i * 1024 | ||||||
|  |         group_name = @chef_run.node["openstack"]["block-storage"]["volume"]["volume_group"] | ||||||
|  |         path = @chef_run.node["openstack"]["block-storage"]["volume"]["state_path"] | ||||||
|  |         vg_file = "#{path}/#{group_name}.img" | ||||||
|  |         cmd = "dd if=/dev/zero of=#{vg_file} bs=1M seek=#{seek_count} count=0; vgcreate cinder-volumes $(losetup --show -f #{vg_file})" | ||||||
|  |         expect(@chef_run).to run_execute(cmd) | ||||||
|  |       end | ||||||
|  |     end | ||||||
|   end |   end | ||||||
| end | end | ||||||
|   | |||||||
							
								
								
									
										37
									
								
								templates/default/cinder-group-active.erb
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										37
									
								
								templates/default/cinder-group-active.erb
									
									
									
									
									
										Normal file
									
								
							| @@ -0,0 +1,37 @@ | |||||||
|  | #!/bin/sh | ||||||
|  | # | ||||||
|  | # cinder volume group active script | ||||||
|  | # | ||||||
|  | # only support start action | ||||||
|  | # chkconfig: - 98 02 | ||||||
|  | # | ||||||
|  | ### BEGIN INIT INFO | ||||||
|  | # Required-Start: $remote_fs $network $syslog | ||||||
|  | # Required-Stop: $remote_fs $syslog | ||||||
|  | # Default-Start: 2 3 4 5 | ||||||
|  | # Default-Stop: 0 1 6 | ||||||
|  | # Short-Description: cinder volume group active script | ||||||
|  | ### END INIT INFO | ||||||
|  |  | ||||||
|  | . /etc/rc.d/init.d/functions | ||||||
|  |  | ||||||
|  | start() | ||||||
|  | { | ||||||
|  |   echo -n "Activing cinder volume group ..." | ||||||
|  |   vgcreate cinder-volumes $(losetup --show -f <%= @volume_file %>) | ||||||
|  |   success | ||||||
|  |   echo | ||||||
|  | } | ||||||
|  |  | ||||||
|  | RETVAL=0 | ||||||
|  |  | ||||||
|  | case "$1" in | ||||||
|  |   start) | ||||||
|  |     start | ||||||
|  |     ;; | ||||||
|  |   *) | ||||||
|  |     echo "Usage: $0 {start}" | ||||||
|  |     RETVAL=1 | ||||||
|  | esac | ||||||
|  |  | ||||||
|  | exit $RETVAL | ||||||
		Reference in New Issue
	
	Block a user
	 gengjh
					gengjh