refactoring final step

* added endpoint attributes (moved from common)
* removed qpid as a messaging option (can be incuded in a wrapper)
* deleted default attributes from nova.conf.rb originated in
  openstack-common
* adapted optimized endpoint logic
* removed rubocop exceptions in recipes and regenerated the
  .rubocop_todo.yaml containing all remaining exceptions
* added versionbumb for refactored os-identity and common
* moved version up to 13.0.0 for mitaka release
* removed fedora, suse as supported platform
* adapted the specs (unit tests) to work again
* added new logic into templates/default/cinder.conf.erb
* refactored attributes throughout all recipes that were connected to
  the attributes used for the cinder.conf.erb template to adapt the new
  template attribute syntax
* moved all attributes from attributes/default.rb that were used in
  cinder_conf.erb to attributes/cinder_conf.rb
* refactored attributes to fit upcomming template logic
* refactored recipes to fit upcomming template logic
* removed all attributes from default.rb and cinder.conf.erb which are set
  as default in attributes, openstack doc and used to render the template

Depends-On: Ifa5a7f4e1df47a3961976e64f654224864c3dcb4
Depends-On: I3262b2e6f792f37c32a446e6567790b82bdd4613
Depends-On: I0547182085eed91d05384fdd7734408a839a9a2c
Implements: blueprint cookbook-refactoring
Change-Id: Idadc97bd7380d6c4f9f6f33d9c6b1215a5f24772
This commit is contained in:
Christoph Albers 2015-12-03 17:07:34 +01:00
parent 8a2f26d6fe
commit 4a7dc692b9
32 changed files with 350 additions and 3783 deletions

View File

@ -1,21 +1,31 @@
# This configuration was generated by `rubocop --auto-gen-config` # This configuration was generated by
# on 2015-05-28 14:36:48 -0500 using RuboCop version 0.29.1. # `rubocop --auto-gen-config`
# The point is for the user to remove these configuration records # on 2016-02-04 16:35:09 +0100 using RuboCop version 0.35.1.
# one by one as the offenses are removed from the code base. # The point is for the user to remove these configuration records
# Note that changes in the inspected code, or installation of new # one by one as the offenses are removed from the code base.
# versions of RuboCop, may require this file to be generated again. # Note that changes in the inspected code, or installation of new
# versions of RuboCop, may require this file to be generated again.
# Offense count: 1
Metrics/AbcSize: # Offense count: 10
Max: 18 Lint/ParenthesesAsGroupedExpression:
Exclude:
# Offense count: 5 - 'recipes/identity_registration.rb'
# Configuration parameters: EnforcedStyle, SupportedStyles.
Style/ClassAndModuleChildren: # Offense count: 1
Enabled: false Metrics/AbcSize:
Max: 18
# Offense count: 1
# Cop supports --auto-correct. # Offense count: 1
# Configuration parameters: IgnoredMethods. # Configuration parameters: CountComments.
Style/SymbolProc: Metrics/MethodLength:
Enabled: false Max: 13
# Offense count: 5
# Configuration parameters: EnforcedStyle, SupportedStyles.
Style/ClassAndModuleChildren:
Exclude:
- 'recipes/api.rb'
- 'recipes/cinder-common.rb'
- 'recipes/client.rb'
- 'recipes/identity_registration.rb'
- 'recipes/volume.rb'

19
attributes/cinder_conf.rb Normal file
View File

@ -0,0 +1,19 @@
default['openstack']['block-storage']['conf_secrets'] = {}
default['openstack']['block-storage']['conf'].tap do |conf|
conf['DEFAULT']['notification_driver'] = 'cinder.openstack.common.notifier.rpc_notifier'
if node['openstack']['block-storage']['syslog']['use']
conf['DEFAULT']['log_config'] = '/etc/openstack/logging.conf'
end
conf['DEFAULT']['rpc_backend'] = node['openstack']['mq']['service_type']
conf['DEFAULT']['my_ip'] = '127.0.0.1'
conf['DEFAULT']['auth_strategy'] = 'keystone'
conf['DEFAULT']['control_exchange'] = 'cinder'
conf['DEFAULT']['volume_group'] = 'cinder-volumes'
conf['DEFAULT']['state_path'] = '/var/lib/cinder'
conf['keystone_authtoken']['auth_plugin'] = 'v2password'
conf['keystone_authtoken']['region_name'] = node['openstack']['region']
conf['keystone_authtoken']['username'] = 'cinder'
conf['keystone_authtoken']['tenant_name'] = 'service'
conf['keystone_authtoken']['signing_dir'] = '/var/cache/cinder/api'
conf['oslo_concurrency']['lock_path'] = '/var/lib/cinder/tmp'
end

View File

@ -24,7 +24,7 @@
######################################################################## ########################################################################
# Toggles - These can be overridden at the environment level # Toggles - These can be overridden at the environment level
default['developer_mode'] = false # we want secure passwords by default default['developer_mode'] = false # we want secure passwords by default
######################################################################## ########################################################################
# Set to some text value if you want templated config files # Set to some text value if you want templated config files
@ -34,32 +34,13 @@ default['openstack']['block-storage']['custom_template_banner'] = '
# Do not edit, changes will be overwritten # Do not edit, changes will be overwritten
' '
default['openstack']['block-storage']['verbose'] = 'False'
default['openstack']['block-storage']['debug'] = 'False'
# Name of this node. This can be an opaque identifier. It is
# not necessarily a hostname, FQDN, or IP address. (StrOpt)
default['openstack']['block-storage']['host'] = nil
# Specify policy.json remote file to import # Specify policy.json remote file to import
default['openstack']['block-storage']['policyfile_url'] = nil default['openstack']['block-storage']['policyfile_url'] = nil
# Default notification_driver and control exchange
default['openstack']['block-storage']['notification_driver'] = 'cinder.openstack.common.notifier.rpc_notifier'
default['openstack']['block-storage']['control_exchange'] = 'cinder'
# Availability zone/region for the OpenStack Block-Storage service # Availability zone/region for the OpenStack Block-Storage service
default['openstack']['block-storage']['region'] = node['openstack']['region'] default['openstack']['block-storage']['region'] = node['openstack']['region']
default['openstack']['block-storage']['scheduler_role'] = 'os-block-storage-scheduler' default['openstack']['block-storage']['scheduler_role'] = 'os-block-storage-scheduler'
# Number of workers for OpenStack Volume API service. The
# default is equal to the number of CPUs available. (integer
# value)
default['openstack']['block-storage']['osapi_volume_workers'] = [8, node['cpu']['total'].to_i].min
# Template strings to be used to generate resource names
default['openstack']['block-storage']['volume_name_template'] = 'volume-%s'
default['openstack']['block-storage']['snapshot_name_template'] = 'snapshot-%s'
# The name of the Chef role that knows about the message queue server # The name of the Chef role that knows about the message queue server
# that Cinder uses # that Cinder uses
default['openstack']['block-storage']['rabbit_server_chef_role'] = 'os-ops-messaging' default['openstack']['block-storage']['rabbit_server_chef_role'] = 'os-ops-messaging'
@ -67,212 +48,18 @@ default['openstack']['block-storage']['rabbit_server_chef_role'] = 'os-ops-messa
# This is the name of the Chef role that will install the Keystone Service API # This is the name of the Chef role that will install the Keystone Service API
default['openstack']['block-storage']['keystone_service_chef_role'] = 'keystone' default['openstack']['block-storage']['keystone_service_chef_role'] = 'keystone'
# Whether to enable cinder-backup service or not
default['openstack']['block-storage']['backup']['enabled'] = false
# Keystone PKI signing directory
default['openstack']['block-storage']['api']['auth']['cache_dir'] = '/var/cache/cinder/api'
default['openstack']['block-storage']['api']['auth']['version'] = node['openstack']['api']['auth']['version']
# A list of memcached server(s) to use for caching
default['openstack']['block-storage']['api']['auth']['memcached_servers'] = nil
# Whether token data should be authenticated or authenticated and encrypted. Acceptable values are MAC or ENCRYPT
default['openstack']['block-storage']['api']['auth']['memcache_security_strategy'] = nil
# This string is used for key derivation
default['openstack']['block-storage']['api']['auth']['memcache_secret_key'] = nil
# Hash algorithms to use for hashing PKI tokens
default['openstack']['block-storage']['api']['auth']['hash_algorithms'] = 'md5'
# A PEM encoded Certificate Authority to use when verifying HTTPs connections
default['openstack']['block-storage']['api']['auth']['cafile'] = nil
# Verify HTTPS connections
default['openstack']['block-storage']['api']['auth']['insecure'] = false
# If True, this indicates that glance-api allows the client to perform
# insecure SSL(https) requests; this should be the same as the setting
# in the glance-api service.
default['openstack']['block-storage']['image']['glance_api_insecure'] = false
# Location of ca certificates file to use for glance client requests
default['openstack']['block-storage']['image']['glance_ca_certificates_file'] = nil
# Which version of the glance API cinder should use when talking to glance.
default['openstack']['block-storage']['image']['glance_api_version'] = 1
# Maximum allocatable gigabytes
# Should equal total backend storage, default is 10TB
default['openstack']['block-storage']['max_gigabytes'] = '10000'
# Storage availability zone
# Default is nova
default['openstack']['block-storage']['storage_availability_zone'] = 'nova'
# Quota definitions
default['openstack']['block-storage']['quota_volumes'] = '10'
default['openstack']['block-storage']['quota_gigabytes'] = '1000'
default['openstack']['block-storage']['quota_driver'] = 'cinder.quota.DbQuotaDriver'
default['openstack']['block-storage']['quota_snapshots'] = 10
default['openstack']['block-storage']['no_snapshot_gb_quota'] = false
default['openstack']['block-storage']['use_default_quota_class'] = true
# Common rpc definitions
default['openstack']['block-storage']['rpc_thread_pool_size'] = 64
default['openstack']['block-storage']['rpc_conn_pool_size'] = 30
default['openstack']['block-storage']['rpc_response_timeout'] = 60
case node['openstack']['mq']['service_type']
when 'rabbitmq'
default['openstack']['block_storage']['rpc_backend'] = 'cinder.openstack.common.rpc.impl_kombu'
when 'qpid'
default['openstack']['block_storage']['rpc_backend'] = 'cinder.openstack.common.rpc.impl_qpid'
end
default['openstack']['block-storage']['service_tenant_name'] = 'service'
default['openstack']['block-storage']['service_user'] = 'cinder' default['openstack']['block-storage']['service_user'] = 'cinder'
default['openstack']['block-storage']['service_tenant_name'] = 'service'
default['openstack']['block-storage']['service_role'] = 'service' default['openstack']['block-storage']['service_role'] = 'service'
default['openstack']['block-storage']['service_name'] = 'cinderv2' default['openstack']['block-storage']['service_name'] = 'cinderv2'
default['openstack']['block-storage']['service_type'] = 'volumev2' default['openstack']['block-storage']['service_type'] = 'volumev2'
# SAN Support
default['openstack']['block-storage']['san']['san_ip'] = '127.0.0.1'
default['openstack']['block-storage']['san']['san_login'] = 'admin'
default['openstack']['block-storage']['san']['san_private_key'] = '/v7000_rsa'
# The location(URL) of the san_private_key. This value may also specify HTTP(http://), FTP("ftp://"), or local(file://), if the san private key is in the local, you should also specify this attribute using(file://)
default['openstack']['block-storage']['san']['san_private_key_url'] = nil
# NFS support
default['openstack']['block-storage']['nfs']['nas_ip'] = '127.0.0.1'
default['openstack']['block-storage']['nfs']['nas_login'] = 'admin'
default['openstack']['block-storage']['nfs']['nas_ssh_port'] = '22'
# Netapp support
default['openstack']['block-storage']['netapp']['protocol'] = 'http'
default['openstack']['block-storage']['netapp']['dfm_hostname'] = nil
default['openstack']['block-storage']['netapp']['dfm_login'] = nil
default['openstack']['block-storage']['netapp']['dfm_password'] = nil
default['openstack']['block-storage']['netapp']['dfm_port'] = '8088'
default['openstack']['block-storage']['netapp']['dfm_web_port'] = '8080'
default['openstack']['block-storage']['netapp']['storage_service'] = 'storage_service'
# Netapp direct NFS
default['openstack']['block-storage']['netapp']['netapp_server_port'] = '80'
default['openstack']['block-storage']['netapp']['netapp_server_hostname'] = nil
default['openstack']['block-storage']['netapp']['netapp_server_password'] = nil
default['openstack']['block-storage']['netapp']['netapp_server_login'] = nil
default['openstack']['block-storage']['netapp']['export'] = nil
default['openstack']['block-storage']['nfs']['shares_config'] = '/etc/cinder/shares.conf'
default['openstack']['block-storage']['nfs']['mount_point_base'] = '/mnt/cinder-volumes'
default['openstack']['block-storage']['nfs']['nfs_disk_util'] = 'df'
default['openstack']['block-storage']['nfs']['nfs_sparsed_volumes'] = 'true'
# Storwize/SVC Support
default['openstack']['block-storage']['storwize']['san_ip'] = node['openstack']['block-storage']['san']['san_ip']
default['openstack']['block-storage']['storwize']['san_login'] = node['openstack']['block-storage']['san']['san_login']
# If the key is set to nil, the san_login and san_password will be used.
default['openstack']['block-storage']['storwize']['san_private_key'] = node['openstack']['block-storage']['san']['san_private_key']
default['openstack']['block-storage']['storwize']['san_private_key_url'] = node['openstack']['block-storage']['san']['san_private_key_url']
default['openstack']['block-storage']['storwize']['storwize_svc_volpool_name'] = 'volpool'
default['openstack']['block-storage']['storwize']['storwize_svc_vol_rsize'] = 2
default['openstack']['block-storage']['storwize']['storwize_svc_vol_warning'] = 0
default['openstack']['block-storage']['storwize']['storwize_svc_vol_autoexpand'] = true
default['openstack']['block-storage']['storwize']['storwize_svc_vol_grainsize'] = 256
default['openstack']['block-storage']['storwize']['storwize_svc_vol_compression'] = false
default['openstack']['block-storage']['storwize']['storwize_svc_vol_easytier'] = true
default['openstack']['block-storage']['storwize']['storwize_svc_flashcopy_timeout'] = 120
default['openstack']['block-storage']['storwize']['storwize_svc_vol_iogrp'] = 0
default['openstack']['block-storage']['storwize']['storwize_svc_connection_protocol'] = 'iSCSI'
default['openstack']['block-storage']['storwize']['storwize_svc_iscsi_chap_enabled'] = true
default['openstack']['block-storage']['storwize']['storwize_svc_multipath_enabled'] = false
default['openstack']['block-storage']['storwize']['storwize_svc_multihostmap_enabled'] = true
default['openstack']['block-storage']['storwize']['storwize_svc_allow_tenant_qos'] = false
default['openstack']['block-storage']['storwize']['storwize_svc_stretched_cluster_partner'] = nil
# SolidFire Support
default['openstack']['block-storage']['solidfire']['san_ip'] = node['openstack']['block-storage']['san']['san_ip']
default['openstack']['block-storage']['solidfire']['san_login'] = node['openstack']['block-storage']['san']['san_login']
default['openstack']['block-storage']['solidfire']['sf_emulate'] = 'False'
default['openstack']['block-storage']['solidfire']['iscsi_ip_prefix'] = nil
# FlashSystem Support
default['openstack']['block-storage']['flashsystem']['san_ip'] = node['openstack']['block-storage']['san']['san_ip']
default['openstack']['block-storage']['flashsystem']['san_login'] = node['openstack']['block-storage']['san']['san_login']
# The connection protocol for FlashSystem data path (FC only, will introduce iSCSI in Liberty)
default['openstack']['block-storage']['flashsystem']['flashsystem_connection_protocol'] = 'FC'
# The multipath enablement flag (FC only, iSCSI multipath will be controlled by Nova)
default['openstack']['block-storage']['flashsystem']['flashsystem_multipath_enabled'] = false
# Enable vdisk to multi-host mapping
default['openstack']['block-storage']['flashsystem']['flashsystem_multihostmap_enabled'] = true
# EMC VMAX/VNX tSupport
# The EmcUserName user's password is stored in an encrypted databag and
# accessed with openstack-common cookbook library's "get_password" routeine. You
# are expected to create the user and pass in a wrapper cookbook.
default['openstack']['block-storage']['emc']['iscsi_target_prefix'] = 'iqn.1992-04.com.emc'
default['openstack']['block-storage']['emc']['cinder_emc_config_file'] = '/etc/cinder/cinder_emc_config.xml'
default['openstack']['block-storage']['emc']['StorageType'] = 0
default['openstack']['block-storage']['emc']['EcomServerIP'] = '127.0.0.1'
default['openstack']['block-storage']['emc']['EcomServerPort'] = '5988'
default['openstack']['block-storage']['emc']['EcomUserName'] = 'admin'
default['openstack']['block-storage']['emc']['MaskingView'] = nil
# VMware Support
default['openstack']['block-storage']['vmware']['secret_name'] = 'openstack_vmware_secret_name'
default['openstack']['block-storage']['vmware']['vmware_host_ip'] = ''
default['openstack']['block-storage']['vmware']['vmware_host_username'] = ''
default['openstack']['block-storage']['vmware']['vmware_wsdl_location'] = nil
default['openstack']['block-storage']['vmware']['vmware_api_retry_count'] = 10
default['openstack']['block-storage']['vmware']['vmware_task_poll_interval'] = 5
default['openstack']['block-storage']['vmware']['vmware_volume_folder'] = 'cinder-volumes'
default['openstack']['block-storage']['vmware']['vmware_image_transfer_timeout_secs'] = 7200
default['openstack']['block-storage']['vmware']['vmware_max_objects_retrieval'] = 100
# IBM GPFS Support
default['openstack']['block-storage']['gpfs']['gpfs_mount_point_base'] = node['openstack']['block-storage']['gpfs']['gpfs_mount_point_base']
default['openstack']['block-storage']['gpfs']['gpfs_images_dir'] = node['openstack']['block-storage']['gpfs']['gpfs_images_dir']
default['openstack']['block-storage']['gpfs']['gpfs_images_share_mode'] = 'copy_on_write'
default['openstack']['block-storage']['gpfs']['gpfs_sparse_volumes'] = true
default['openstack']['block-storage']['gpfs']['gpfs_max_clone_depth'] = 8
default['openstack']['block-storage']['gpfs']['gpfs_storage_pool'] = 'system'
# IBMNAS (SONAS, Storwize V7000 Unified) Support
# The attribute "nas_password" is stored in databag and
# accessed with openstack-common cookbook library's "get_password" routeine.
default['openstack']['block-storage']['ibmnas']['nas_ip'] = node['openstack']['block-storage']['nfs']['nas_ip']
default['openstack']['block-storage']['ibmnas']['nas_login'] = node['openstack']['block-storage']['nfs']['nas_login']
default['openstack']['block-storage']['ibmnas']['nas_ssh_port'] = node['openstack']['block-storage']['nfs']['nas_ssh_port']
default['openstack']['block-storage']['ibmnas']['shares_config'] = '/etc/cinder/nfs_shares.conf'
default['openstack']['block-storage']['ibmnas']['mount_point_base'] = '/mnt/cinder-volumes'
default['openstack']['block-storage']['ibmnas']['nfs_sparsed_volumes'] = 'true'
default['openstack']['block-storage']['ibmnas']['nas_access_ip'] = nil
default['openstack']['block-storage']['ibmnas']['export'] = nil
# Platform type to be used as backend storage, valid values are:
# 'v7ku : for using IBM Storwize V7000 Unified
# 'sonas : for using IBM Scale Out NAS
# 'gpfs-nas : for using NFS based IBM GPFS deployments
default['openstack']['block-storage']['ibmnas']['ibmnas_platform_type'] = 'v7ku'
# logging attribute # logging attribute
default['openstack']['block-storage']['syslog']['use'] = false default['openstack']['block-storage']['syslog']['use'] = false
default['openstack']['block-storage']['syslog']['facility'] = 'LOG_LOCAL2' default['openstack']['block-storage']['syslog']['facility'] = 'LOG_LOCAL2'
default['openstack']['block-storage']['syslog']['config_facility'] = 'local2' default['openstack']['block-storage']['syslog']['config_facility'] = 'local2'
default['openstack']['block-storage']['api']['ratelimit'] = 'True'
default['openstack']['block-storage']['cron']['minute'] = '00'
default['openstack']['block-storage']['cron']['audit_logfile'] = '/var/log/cinder/audit.log'
default['openstack']['block-storage']['volume']['state_path'] = '/var/lib/cinder'
default['openstack']['block-storage']['volume']['volumes_dir'] = '/var/lib/cinder/volumes'
default['openstack']['block-storage']['volume']['driver'] = 'cinder.volume.drivers.lvm.LVMVolumeDriver'
default['openstack']['block-storage']['volume']['volume_group'] = 'cinder-volumes'
default['openstack']['block-storage']['volume']['volume_group_size'] = 40 default['openstack']['block-storage']['volume']['volume_group_size'] = 40
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: # Type of volume group to create:
# - 'file' for basic 40g file for testing # - 'file' for basic 40g file for testing
# - 'block_devices' for using block devices, specified in block_devices attribute # - 'block_devices' for using block devices, specified in block_devices attribute
@ -281,72 +68,13 @@ default['openstack']['block-storage']['volume']['create_volume_group_type'] = 'f
# Examples: '/dev/sdx /dev/sdx1' or '/dev/sd[k-m]1' # Examples: '/dev/sdx /dev/sdx1' or '/dev/sd[k-m]1'
default['openstack']['block-storage']['volume']['block_devices'] = nil default['openstack']['block-storage']['volume']['block_devices'] = nil
default['openstack']['block-storage']['volume']['iscsi_helper'] = 'tgtadm' default['openstack']['block-storage']['user'] = 'cinder'
default['openstack']['block-storage']['volume']['iscsi_ip_address'] = node['ipaddress'] default['openstack']['block-storage']['group'] = 'cinder'
default['openstack']['block-storage']['volume']['iscsi_port'] = '3260'
# Ceph/RADOS options
default['openstack']['block-storage']['rbd']['cinder']['pool'] = 'volumes'
default['openstack']['block-storage']['rbd']['glance']['pool'] = 'images'
default['openstack']['block-storage']['rbd']['nova']['pool'] = 'instances'
default['openstack']['block-storage']['rbd']['user'] = 'cinder'
default['openstack']['block-storage']['rbd']['secret_uuid'] = '00000000-0000-0000-0000-000000000000'
default['openstack']['block-storage']['rbd']['flatten_volume'] = false
default['openstack']['block-storage']['rbd']['max_clone_depth'] = 5
default['openstack']['block-storage']['rbd']['chunk_size'] = 4
default['openstack']['block-storage']['rbd']['rados_timeout'] = '-1'
default['openstack']['block-storage']['rbd']['conf_dir'] = '/etc/ceph/ceph.conf'
# Multiple backend support
# Allow multiple backends configured in cinder.conf
# For example: {
# 'lvm1' => {
# 'volume_driver': 'cinder.volume.drivers.lvm.LVMISCSIDriver',
# 'volume_backend_name': 'lvm-backend-1'
# }
# 'lvm2' => {
# 'volume_driver': 'cinder.volume.drivers.lvm.LVMISCSIDriver',
# 'volume_backend_name': 'lvm-backend-2'
# }
# }
default['openstack']['block-storage']['volume']['multi_backend'] = nil
# Default volume-type for volumes to be created as when client does not request
# a specific type. Volume types are configured from cinder-client and
# will reference the backend name.
default['openstack']['block-storage']['volume']['default_volume_type'] = nil
# Misc option support
# Allow additional strings to be added to cinder.conf
# For example: ['# Comment', 'key=value']
default['openstack']['block-storage']['misc_cinder'] = []
# Default lock_path
# The lock_path normally uses /var/lock/cinder, but it's does not work
# in cases like systemd, so setting lock_path to $state_path/lock like
# in nova and neutron.
default['openstack']['block-storage']['lock_path'] =
"#{node['openstack']['block-storage']['volume']['state_path']}/lock"
# Whether to enable cinder v1 api or not
default['openstack']['block-storage']['enable_v1_api'] = 'False'
# Whether to enable cinder v2 api or not
default['openstack']['block-storage']['enable_v2_api'] = 'True'
# The full class name of the key manager api class
default['openstack']['block-storage']['keymgr']['api_class'] = 'cinder.keymgr.conf_key_mgr.ConfKeyManager'
# Fixed key returned by key manager, specified in hex
default['openstack']['block-storage']['keymgr']['fixed_key'] = nil
case platform_family case platform_family
when 'fedora', 'rhel' # :pragma-foodcritic: ~FC024 - won't fix this when 'rhel' # :pragma-foodcritic: ~FC024 - won't fix this
# operating system user and group names # operating system user and group names
default['openstack']['block-storage']['user'] = 'cinder'
default['openstack']['block-storage']['group'] = 'cinder'
default['openstack']['block-storage']['volume']['iscsi_helper'] = 'lioadm' default['openstack']['block-storage']['volume']['iscsi_helper'] = 'lioadm'
default['openstack']['block-storage']['platform'] = { default['openstack']['block-storage']['platform'] = {
'cinder_common_packages' => ['openstack-cinder'], 'cinder_common_packages' => ['openstack-cinder'],
'cinder_api_packages' => ['python-cinderclient'], 'cinder_api_packages' => ['python-cinderclient'],
@ -368,39 +96,12 @@ when 'fedora', 'rhel' # :pragma-foodcritic: ~FC024 - won't fix this
'cinder_flashsystem_packages' => ['sysfsutils'], 'cinder_flashsystem_packages' => ['sysfsutils'],
'package_overrides' => '' 'package_overrides' => ''
} }
when 'suse'
# operating system user and group names
default['openstack']['block-storage']['user'] = 'openstack-cinder'
default['openstack']['block-storage']['group'] = 'openstack-cinder'
default['openstack']['block-storage']['platform'] = {
'cinder_common_packages' => ['openstack-cinder'],
'cinder_api_packages' => ['openstack-cinder-api'],
'cinder_api_service' => 'openstack-cinder-api',
'cinder_client_packages' => ['python-cinderclient'],
'cinder_scheduler_packages' => ['openstack-cinder-scheduler'],
'cinder_scheduler_service' => 'openstack-cinder-scheduler',
'cinder_backup_packages' => ['openstack-cinder-backup'],
'cinder_backup_service' => 'openstack-cinder-backup',
'cinder_volume_packages' => ['openstack-cinder-volume', 'qemu-img'],
'cinder_volume_service' => 'openstack-cinder-volume',
'cinder_ceph_packages' => ['python-ceph', 'ceph-common'],
'cinder_iscsitarget_packages' => ['tgt'],
'cinder_iscsitarget_service' => 'tgtd',
'cinder_nfs_packages' => ['nfs-utils'],
'cinder_emc_packages' => ['python-pywbem'],
'cinder_svc_packages' => ['sysfsutils'],
'cinder_lvm_packages' => ['lvm2'],
'cinder_flashsystem_packages' => ['sysfsutils']
}
when 'debian' when 'debian'
# operating system user and group names # operating system user and group names
default['openstack']['block-storage']['user'] = 'cinder'
default['openstack']['block-storage']['group'] = 'cinder'
default['openstack']['block-storage']['platform'] = { default['openstack']['block-storage']['platform'] = {
'cinder_common_packages' => ['cinder-common'], 'cinder_common_packages' => ['cinder-common'],
'cinder_api_packages' => ['cinder-api', 'python-cinderclient'], 'cinder_api_packages' => ['cinder-api', 'python-cinderclient'],
'cinder_api_service' => 'cinder-api', 'cinder_api_service' => 'cinder-api',
'cinder_client_packages' => ['python-cinderclient'],
'cinder_volume_packages' => ['cinder-volume', 'qemu-utils'], 'cinder_volume_packages' => ['cinder-volume', 'qemu-utils'],
'cinder_volume_service' => 'cinder-volume', 'cinder_volume_service' => 'cinder-volume',
'cinder_scheduler_packages' => ['cinder-scheduler'], 'cinder_scheduler_packages' => ['cinder-scheduler'],
@ -419,33 +120,26 @@ when 'debian'
} }
end end
# Attributes for cinder-backup service # ******************** OpenStack Volume Endpoints *****************************
default['openstack']['block-storage']['backup']['driver'] = 'cinder.backup.drivers.swift'
# Swift support # The OpenStack Volume (Cinder) API endpoint
# The URL of Swift endpoint (string value) %w(public internal admin).each do |ep_type|
default['openstack']['block-storage']['backup']['swift']['url'] = nil default['openstack']['endpoints']['block-storage'][ep_type]['scheme'] = 'http'
# Info to match when looking for swift in the service catalog default['openstack']['endpoints']['block-storage'][ep_type]['path'] = '/v2/%(tenant_id)s'
default['openstack']['block-storage']['backup']['swift']['catalog_info'] = 'object-store:swift:publicURL' %w(endpoints bind_service).each do |type|
# Swift authentication mechanism (string value) default['openstack'][type]['block-storage'][ep_type]['host'] = '127.0.0.1'
default['openstack']['block-storage']['backup']['swift']['auth'] = 'per_user' default['openstack'][type]['block-storage'][ep_type]['port'] = '8776'
# Swift authentication version end
default['openstack']['block-storage']['backup']['swift']['auth_version'] = 1 end
# Swift user name
default['openstack']['block-storage']['backup']['swift']['user'] = nil # ============================= rootwrap Configuration ===================
# Swift tenant/account name. Required when connecting # use cinder root wrap
default['openstack']['block-storage']['backup']['swift']['tenant'] = nil default['openstack']['block-storage']['use_rootwrap'] = true
# Swift key for authentication (string value) # rootwrap.conf
default['openstack']['block-storage']['backup']['swift']['key'] = nil default['openstack']['block-storage']['rootwrap']['conf'].tap do |conf|
# The default Swift container to use conf['DEFAULT']['filters_path'] = '/etc/cinder/rootwrap.d,/usr/share/cinder/rootwrap'
default['openstack']['block-storage']['backup']['swift']['container'] = 'volumebackups' conf['DEFAULT']['exec_dirs'] = '/sbin,/usr/sbin,/bin,/usr/bin'
# The size in bytes of Swift backup objects conf['DEFAULT']['use_syslog'] = false
default['openstack']['block-storage']['backup']['swift']['object_size'] = 52428800 conf['DEFAULT']['syslog_log_facility'] = 'syslog'
# The size in bytes that changes are tracked for incremental backups conf['DEFAULT']['syslog_log_level'] = 'ERROR'
default['openstack']['block-storage']['backup']['swift']['block_size'] = 32768 end
# The number of retries to make for Swift operations
default['openstack']['block-storage']['backup']['swift']['retry_attempts'] = 3
# The backoff time in seconds between Swift retries
default['openstack']['block-storage']['backup']['swift']['retry_backoff'] = 2
# Enable or Disable the timer to send the periodic progress notifications to Ceilometer when backing up the volume to the Swift backend storage.
default['openstack']['block-storage']['backup']['swift']['enable_progress_timer'] = 'True'

View File

@ -5,7 +5,7 @@ maintainer_email 'openstack-dev@lists.openstack.org'
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 '12.0.0' version '13.0.0'
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'
@ -15,14 +15,13 @@ recipe 'openstack-block-storage::scheduler', 'Installs the cinder-scheduler serv
recipe 'openstack-block-storage::volume', 'Installs the cinder-volume service and sets up the iscsi helper' recipe 'openstack-block-storage::volume', 'Installs the cinder-volume service and sets up the iscsi helper'
recipe 'openstack-block-storage::backup', 'Installs the cinder-backup service' recipe 'openstack-block-storage::backup', 'Installs the cinder-backup service'
%w(ubuntu fedora redhat centos suse).each do |os| %w(ubuntu redhat centos).each do |os|
supports os supports os
end end
depends 'apt', '~> 2.8' depends 'apt', '~> 2.8'
depends 'openstack-common', '>= 12.0.0' depends 'openstack-common', '>= 13.0.0'
depends 'openstack-identity', '>= 12.0.0' depends 'openstack-identity', '>= 13.0.0'
depends 'openstack-image', '>= 12.0.0' depends 'openstack-image', '>= 13.0.0'
depends 'selinux', '~> 0.9.0' depends 'selinux', '~> 0.9.0'
depends 'python', '~> 1.4.6' depends 'python', '~> 1.4.6'
depends 'ceph', '>= 0.8.1'

View File

@ -20,8 +20,8 @@
# See the License for the specific language governing permissions and # See the License for the specific language governing permissions and
# limitations under the License. # limitations under the License.
# #
# Make Openstack object available in Chef::Recipe
class ::Chef::Recipe # rubocop:disable Documentation class ::Chef::Recipe
include ::Openstack include ::Openstack
end end
@ -43,9 +43,10 @@ node['openstack']['db']['python_packages'][db_type].each do |pkg|
end end
end end
directory ::File.dirname(node['openstack']['block-storage']['api']['auth']['cache_dir']) do directory node['openstack']['block-storage']['conf']['keystone_authtoken']['signing_dir'] 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']
recursive true
mode 00700 mode 00700
end end
@ -53,7 +54,10 @@ service 'cinder-api' do
service_name platform_options['cinder_api_service'] service_name platform_options['cinder_api_service']
supports status: true, restart: true supports status: true, restart: true
action :enable action :enable
subscribes :restart, 'template[/etc/cinder/cinder.conf]' subscribes :restart, [
'template[/etc/cinder/cinder.conf]',
'remote_file[/etc/cinder/policy.json]'
]
end end
execute 'cinder-manage db sync' do execute 'cinder-manage db sync' do
@ -67,6 +71,5 @@ if node['openstack']['block-storage']['policyfile_url']
owner node['openstack']['block-storage']['user'] owner node['openstack']['block-storage']['user']
group node['openstack']['block-storage']['group'] group node['openstack']['block-storage']['group']
mode 00644 mode 00644
notifies :restart, 'service[cinder-api]'
end end
end end

View File

@ -16,8 +16,6 @@
# limitations under the License. # limitations under the License.
# #
return unless node['openstack']['block-storage']['backup']['enabled']
include_recipe 'openstack-block-storage::cinder-common' include_recipe 'openstack-block-storage::cinder-common'
platform_options = node['openstack']['block-storage']['platform'] platform_options = node['openstack']['block-storage']['platform']

View File

@ -11,9 +11,8 @@
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and # See the License for the specific language governing permissions and
# limitations under the License. # limitations under the License.
# # Make Openstack object available in Chef::Recipe
class ::Chef::Recipe
class ::Chef::Recipe # rubocop:disable Documentation
include ::Openstack include ::Openstack
end end
@ -32,39 +31,32 @@ end
db_user = node['openstack']['db']['block-storage']['username'] db_user = node['openstack']['db']['block-storage']['username']
db_pass = get_password 'db', 'cinder' db_pass = get_password 'db', 'cinder'
sql_connection = db_uri('block-storage', db_user, db_pass) node.default['openstack']['block-storage']['conf_secrets']
.[]('database')['connection'] =
db_uri('block-storage', db_user, db_pass)
if node['openstack']['endpoints']['db']['enabled_slave'] if node['openstack']['endpoints']['db']['enabled_slave']
slave_connection = db_uri('block-storage', db_user, db_pass, true) node.default['openstack']['block-storage']['conf_secrets']
.[]('database')['slave_connection'] =
db_uri('block-storage', db_user, db_pass, true)
end end
mq_service_type = node['openstack']['mq']['block-storage']['service_type'] if node['openstack']['block-storage']['conf']['DEFAULT']['rpc_backend'] == 'rabbit'
user = node['openstack']['mq']['block-storage']['rabbit']['userid']
if mq_service_type == 'rabbitmq' node.default['openstack']['block-storage']['conf_secrets']
if node['openstack']['mq']['block-storage']['rabbit']['ha'] .[]('oslo_messaging_rabbit')['rabbit_userid'] = user
rabbit_hosts = rabbit_servers node.default['openstack']['block-storage']['conf_secrets']
end .[]('oslo_messaging_rabbit')['rabbit_password'] =
mq_password = get_password 'user', node['openstack']['mq']['block-storage']['rabbit']['userid'] get_password 'user', user
elsif mq_service_type == 'qpid'
mq_password = get_password 'user', node['openstack']['mq']['block-storage']['qpid']['username']
end end
case node['openstack']['block-storage']['volume']['driver'] glance_api_endpoint = internal_endpoint 'image_api'
when 'cinder.volume.drivers.ibm.storwize_svc.StorwizeSVCDriver' cinder_api_bind = node['openstack']['bind_service']['block-storage']['public']
if node['openstack']['block-storage']['storwize']['san_private_key'].to_s.empty? identity_endpoint = public_endpoint 'identity'
storwize_pass = get_password 'user', node['openstack']['block-storage']['storwize']['san_login'] node.default['openstack']['block-storage']['conf_secrets']
end .[]('keystone_authtoken')['password'] =
when 'cinder.volume.drivers.solidfire.SolidFire' get_password 'service', 'openstack-block-storage'
solidfire_pass = get_password 'user', node['openstack']['block-storage']['solidfire']['san_login'] auth_url = auth_uri_transform(identity_endpoint.to_s, node['openstack']['api']['auth']['version'])
when 'cinder.volume.drivers.ibm.flashsystem.FlashSystemDriver'
flashsystem_pass = get_password 'user', node['openstack']['block-storage']['flashsystem']['san_login']
when 'cinder.volume.drivers.ibm.ibmnas.IBMNAS_NFSDriver'
ibmnas_pass = get_password 'user', node['openstack']['block-storage']['ibmnas']['nas_login']
when 'cinder.volume.drivers.vmware.vmdk.VMwareVcVmdkDriver'
vmware_host_pass = get_password 'token', node['openstack']['block-storage']['vmware']['secret_name']
end
glance_api_endpoint = internal_endpoint 'image-api'
cinder_api_bind = endpoint 'block-storage-api-bind'
directory '/etc/cinder' do directory '/etc/cinder' do
group node['openstack']['block-storage']['group'] group node['openstack']['block-storage']['group']
@ -73,67 +65,53 @@ directory '/etc/cinder' do
action :create action :create
end end
multi_backend_sections = {} node.default['openstack']['block-storage']['conf'].tap do |conf|
multi_backend = node['openstack']['block-storage']['volume']['multi_backend'] conf['DEFAULT']['glance_host'] = glance_api_endpoint.host
if multi_backend.nil? conf['DEFAULT']['glance_port'] = glance_api_endpoint.port
enabled_drivers = [node['openstack']['block-storage']['volume']['driver']] conf['DEFAULT']['glance_api_servers'] = "#{glance_api_endpoint.scheme}://#{glance_api_endpoint.host}:#{glance_api_endpoint.port}"
else conf['DEFAULT']['osapi_volume_listen'] = cinder_api_bind.host
enabled_drivers = [] conf['DEFAULT']['osapi_volume_listen_port'] = cinder_api_bind.port
multi_backend.each do |drv, options| conf['keystone_authtoken']['auth_url'] = auth_url
optlines = []
options.each do |optkey, optvalue|
optlines.push "#{optkey} = #{optvalue}"
enabled_drivers.push optvalue if optkey == 'volume_driver'
end
multi_backend_sections[drv] = optlines
end
end end
identity_endpoint = internal_endpoint 'identity-internal' # merge all config options and secrets to be used in the nova.conf.erb
identity_admin_endpoint = admin_endpoint 'identity-admin' cinder_conf_options = merge_config_options 'block-storage'
service_pass = get_password 'service', 'openstack-block-storage'
auth_uri = auth_uri_transform(identity_endpoint.to_s, node['openstack']['block-storage']['api']['auth']['version'])
identity_uri = identity_uri_transform(identity_admin_endpoint)
template '/etc/cinder/cinder.conf' do template '/etc/cinder/cinder.conf' do
source 'cinder.conf.erb' source 'openstack-service.conf.erb'
cookbook 'openstack-common'
group node['openstack']['block-storage']['group'] group node['openstack']['block-storage']['group']
owner node['openstack']['block-storage']['user'] owner node['openstack']['block-storage']['user']
mode 00640 mode 00640
variables( variables(
sql_connection: sql_connection, service_config: cinder_conf_options
slave_connection: slave_connection,
mq_service_type: mq_service_type,
mq_password: mq_password,
rabbit_hosts: rabbit_hosts,
glance_scheme: glance_api_endpoint.scheme,
glance_host: glance_api_endpoint.host,
glance_port: glance_api_endpoint.port,
ibmnas_pass: ibmnas_pass,
solidfire_pass: solidfire_pass,
flashsystem_pass: flashsystem_pass,
storwize_pass: storwize_pass,
volume_api_bind_address: cinder_api_bind.host,
volume_api_bind_port: cinder_api_bind.port,
vmware_host_pass: vmware_host_pass,
enabled_drivers: enabled_drivers,
multi_backend_sections: multi_backend_sections,
auth_uri: auth_uri,
identity_uri: identity_uri,
service_pass: service_pass
) )
end end
directory node['openstack']['block-storage']['lock_path'] do # delete all secrets saved in the attribute
# node['openstack']['block-storage']['conf_secrets'] after creating the cinder.conf
ruby_block "delete all attributes in node['openstack']['block-storage']['conf_secrets']" do
block do
node.rm(:openstack, :'block-storage', :conf_secrets)
end
end
directory node['openstack']['block-storage']['conf']['oslo_concurrency']['lock_path'] do
group node['openstack']['block-storage']['group'] group node['openstack']['block-storage']['group']
owner node['openstack']['block-storage']['user'] owner node['openstack']['block-storage']['user']
recursive true
mode 00755 mode 00755
end end
template '/etc/cinder/rootwrap.conf' do if node['openstack']['block-storage']['use_rootwrap']
source 'rootwrap.conf.erb' template '/etc/cinder/rootwrap.conf' do
owner 'root' source 'openstack-service.conf.erb'
group 'root' cookbook 'openstack-common'
mode 00644 owner 'root'
group 'root'
mode 00644
variables(
service_config: node['openstack']['block-storage']['rootwrap']['conf']
)
end
end end

View File

@ -17,8 +17,8 @@
# See the License for the specific language governing permissions and # See the License for the specific language governing permissions and
# limitations under the License. # limitations under the License.
# #
# Make Openstack object available in Chef::Recipe
class ::Chef::Recipe # rubocop:disable Documentation class ::Chef::Recipe
include ::Openstack include ::Openstack
end end
@ -26,7 +26,6 @@ platform_options = node['openstack']['block-storage']['platform']
platform_options['cinder_client_packages'].each do |pkg| platform_options['cinder_client_packages'].each do |pkg|
package pkg do package pkg do
options platform_options['package_overrides'] options platform_options['package_overrides']
action :upgrade action :upgrade
end end
end end

View File

@ -21,17 +21,17 @@
# #
require 'uri' require 'uri'
# Make Openstack object available in Chef::Recipe
class ::Chef::Recipe # rubocop:disable Documentation class ::Chef::Recipe
include ::Openstack include ::Openstack
end end
identity_admin_endpoint = admin_endpoint 'identity-admin' identity_admin_endpoint = admin_endpoint 'identity'
bootstrap_token = get_password 'token', 'openstack_identity_bootstrap_token' bootstrap_token = get_password 'token', 'openstack_identity_bootstrap_token'
auth_uri = ::URI.decode identity_admin_endpoint.to_s auth_uri = ::URI.decode identity_admin_endpoint.to_s
admin_cinder_api_endpoint = admin_endpoint 'block-storage-api' admin_cinder_api_endpoint = admin_endpoint 'block-storage'
internal_cinder_api_endpoint = internal_endpoint 'block-storage-api' internal_cinder_api_endpoint = internal_endpoint 'block-storage'
public_cinder_api_endpoint = public_endpoint 'block-storage-api' public_cinder_api_endpoint = public_endpoint 'block-storage'
service_pass = get_password 'service', 'openstack-block-storage' service_pass = get_password 'service', 'openstack-block-storage'
region = node['openstack']['block-storage']['region'] region = node['openstack']['block-storage']['region']
service_tenant_name = node['openstack']['block-storage']['service_tenant_name'] service_tenant_name = node['openstack']['block-storage']['service_tenant_name']
@ -45,7 +45,6 @@ openstack_identity_register 'Register Service Tenant' do
bootstrap_token bootstrap_token bootstrap_token bootstrap_token
tenant_name service_tenant_name tenant_name service_tenant_name
tenant_description 'Service Tenant' tenant_description 'Service Tenant'
action :create_tenant action :create_tenant
end end
@ -75,6 +74,40 @@ openstack_identity_register 'Register Cinder V2 Volume Endpoint' do
action :create_endpoint action :create_endpoint
end end
# --------------------- WORKAROUND --------------------------------------#
# Currently this bug is still open
# (https://bugs.launchpad.net/horizon/+bug/1415712) and we need to register and
# enable the cinder v1 api to make it available via the dashboard. This should
# be removed with the final mitaka release.
openstack_identity_register 'Register Cinder V1 Volume Service' do
auth_uri auth_uri
bootstrap_token bootstrap_token
service_name ((service_name).gsub(/v2/, ''))
service_type ((service_type).gsub(/v2/, ''))
service_description 'Cinder Volume Service V1'
endpoint_region region
endpoint_adminurl ((::URI.decode admin_cinder_api_endpoint.to_s).gsub(/v2/, 'v1'))
endpoint_internalurl ((::URI.decode internal_cinder_api_endpoint.to_s).gsub(/v2/, 'v1'))
endpoint_publicurl ((::URI.decode public_cinder_api_endpoint.to_s).gsub(/v2/, 'v1'))
action :create_service
end
openstack_identity_register 'Register Cinder V1 Volume Endpoint' do
auth_uri auth_uri
bootstrap_token bootstrap_token
service_name ((service_name).gsub(/v2/, ''))
service_type ((service_type).gsub(/v2/, ''))
service_description 'Cinder Volume Service V1'
endpoint_region region
endpoint_adminurl ((::URI.decode admin_cinder_api_endpoint.to_s).gsub(/v2/, 'v1'))
endpoint_internalurl ((::URI.decode internal_cinder_api_endpoint.to_s).gsub(/v2/, 'v1'))
endpoint_publicurl ((::URI.decode public_cinder_api_endpoint.to_s).gsub(/v2/, 'v1'))
action :create_endpoint
end
# --------------------- WORKAROUND --------------------------------------#
openstack_identity_register 'Register Cinder Service User' do openstack_identity_register 'Register Cinder Service User' do
auth_uri auth_uri auth_uri auth_uri
bootstrap_token bootstrap_token bootstrap_token bootstrap_token

View File

@ -28,7 +28,6 @@ platform_options = node['openstack']['block-storage']['platform']
platform_options['cinder_scheduler_packages'].each do |pkg| platform_options['cinder_scheduler_packages'].each do |pkg|
package pkg do package pkg do
options platform_options['package_overrides'] options platform_options['package_overrides']
action :upgrade action :upgrade
end end
end end
@ -46,24 +45,3 @@ service 'cinder-scheduler' do
action [:enable, :start] action [:enable, :start]
subscribes :restart, 'template[/etc/cinder/cinder.conf]' subscribes :restart, 'template[/etc/cinder/cinder.conf]'
end end
audit_bin_dir = platform_family?('debian') ? '/usr/bin' : '/usr/local/bin'
audit_log = node['openstack']['block-storage']['cron']['audit_logfile']
if node['openstack']['telemetry']
scheduler_role = node['openstack']['block-storage']['scheduler_role']
results = search(:node, "roles:#{scheduler_role}")
cron_node = results.map { |a| a.name }.sort[0]
Chef::Log.debug("Volume audit cron node: #{cron_node}")
cron 'cinder-volume-usage-audit' do
day node['openstack']['block-storage']['cron']['day'] || '*'
hour node['openstack']['block-storage']['cron']['hour'] || '*'
minute node['openstack']['block-storage']['cron']['minute']
month node['openstack']['block-storage']['cron']['month'] || '*'
weekday node['openstack']['block-storage']['cron']['weekday'] || '*'
command "#{audit_bin_dir}/cinder-volume-usage-audit > #{audit_log} 2>&1"
action cron_node == node.name ? :create : :delete
user node['openstack']['block-storage']['user']
end
end

View File

@ -52,209 +52,6 @@ platform_options['cinder_iscsitarget_packages'].each do |pkg|
end end
end end
case node['openstack']['block-storage']['volume']['driver']
when 'cinder.volume.drivers.netapp.iscsi.NetAppISCSIDriver'
node.override['openstack']['block-storage']['netapp']['dfm_password'] = get_password 'service', 'netapp'
when 'cinder.volume.drivers.rbd.RBDDriver'
include_recipe 'ceph'
cinder_pool = node['openstack']['block-storage']['rbd']['cinder']['pool']
nova_pool = node['openstack']['block-storage']['rbd']['nova']['pool']
glance_pool = node['openstack']['block-storage']['rbd']['glance']['pool']
caps = { 'mon' => 'allow r',
'osd' => "allow class-read object_prefix rbd_children, allow rwx pool=#{cinder_pool}, allow rwx pool=#{nova_pool}, allow rx pool=#{glance_pool}" }
ceph_client node['openstack']['block-storage']['rbd']['user'] do
name node['openstack']['block-storage']['rbd']['user']
caps caps
keyname "client.#{node['openstack']['block-storage']['rbd']['user']}"
filename "/etc/ceph/ceph.client.#{node['openstack']['block-storage']['rbd']['user']}.keyring"
owner node['openstack']['block-storage']['user']
group node['openstack']['block-storage']['group']
action :add
notifies :restart, 'service[cinder-volume]'
end
when 'cinder.volume.drivers.netapp.nfs.NetAppDirect7modeNfsDriver'
node.override['openstack']['block-storage']['netapp']['netapp_server_password'] = get_password 'service', 'netapp-filer'
directory node['openstack']['block-storage']['nfs']['mount_point_base'] do
owner node['openstack']['block-storage']['user']
group node['openstack']['block-storage']['group']
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.ibm.storwize_svc.StorwizeSVCDriver'
san_private_key = node['openstack']['block-storage']['storwize']['san_private_key']
san_private_key_url = node['openstack']['block-storage']['storwize']['san_private_key_url']
if san_private_key && san_private_key_url
remote_file san_private_key do
source san_private_key_url
mode '0400'
owner node['openstack']['block-storage']['user']
group node['openstack']['block-storage']['group']
end
end
platform_options['cinder_svc_packages'].each do |pkg|
package pkg do
options platform_options['package_overrides']
action :upgrade
end
end
when 'cinder.volume.drivers.ibm.flashsystem.FlashSystemDriver'
platform_options['cinder_flashsystem_packages'].each do |pkg|
package pkg do
options platform_options['package_overrides']
action :upgrade
end
end
when 'cinder.volume.drivers.ibm.gpfs.GPFSDriver'
directory node['openstack']['block-storage']['gpfs']['gpfs_mount_point_base'] do
mode '0755'
owner node['openstack']['block-storage']['user']
group node['openstack']['block-storage']['group']
recursive true
end
multi_backend = node['openstack']['block-storage']['volume']['multi_backend']
unless multi_backend.nil?
multi_backend.each do |_drv, options|
options.select { |optkey, _optvalue| optkey == 'gpfs_mount_point_base' }.each do |_optkey, optvalue|
directory optvalue do
mode '0755'
owner node['openstack']['block-storage']['user']
group node['openstack']['block-storage']['group']
recursive true
end
end
end
end
when 'cinder.volume.drivers.ibm.ibmnas.IBMNAS_NFSDriver'
directory node['openstack']['block-storage']['ibmnas']['mount_point_base'] do
owner node['openstack']['block-storage']['user']
group node['openstack']['block-storage']['group']
mode '0755'
recursive true
action :create
end
platform_options['cinder_nfs_packages'].each do |pkg|
package pkg do
options platform_options['package_overrides']
action :upgrade
end
end
template node['openstack']['block-storage']['ibmnas']['shares_config'] do
source 'nfs_shares.conf.erb'
mode '0600'
owner node['openstack']['block-storage']['user']
group node['openstack']['block-storage']['group']
variables(
host: node['openstack']['block-storage']['ibmnas']['nas_access_ip'],
export: node['openstack']['block-storage']['ibmnas']['export']
)
notifies :restart, 'service[cinder-volume]'
end
when 'cinder.volume.drivers.lvm.LVMVolumeDriver'
platform_options['cinder_lvm_packages'].each do |pkg|
package pkg do
options platform_options['package_overrides']
action :upgrade
end
end
if node['openstack']['block-storage']['volume']['create_volume_group']
vg_name = node['openstack']['block-storage']['volume']['volume_group']
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"
# 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
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
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
when 'cinder.volume.drivers.emc.emc_smis_iscsi.EMCSMISISCSIDriver'
platform_options['cinder_emc_packages'].each do |pkg|
package pkg do
options platform_options['package_overrides']
action :upgrade
end
end
ecom_password = get_password('user', node['openstack']['block-storage']['emc']['EcomUserName'])
template node['openstack']['block-storage']['emc']['cinder_emc_config_file'] do
source 'cinder_emc_config.xml.erb'
variables(
ecom_password: ecom_password
)
mode 00644
notifies :restart, 'service[iscsitarget]', :immediately
end
end
service 'cinder-volume' do service 'cinder-volume' do
service_name platform_options['cinder_volume_service'] service_name platform_options['cinder_volume_service']
supports status: true, restart: true supports status: true, restart: true

View File

@ -0,0 +1,66 @@
# encoding: UTF-8
#
# Cookbook Name:: openstack-block-storage
# Recipe:: volume_driver_lvm
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
#
platform_options = node['openstack']['block-storage']['platform']
platform_options['cinder_lvm_packages'].each do |pkg|
package pkg do
options platform_options['package_overrides']
action :upgrade
end
end
# TODO: (jklare) this whole section should be refactored and probably include an
# external cookbook for managing lvm stuff
vg_name = node['openstack']['block-storage']['conf']['DEFAULT']['volume_group']
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']['conf']['DEFAULT']['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
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
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

View File

@ -1,37 +0,0 @@
# encoding: UTF-8
#
# Cookbook Name:: openstack-block-storage
require_relative 'spec_helper'
describe 'openstack-block-storage::api' do
describe 'suse' do
let(:runner) { ChefSpec::SoloRunner.new(SUSE_OPTS) }
let(:node) { runner.node }
let(:chef_run) { runner.converge(described_recipe) }
include_context 'block-storage-stubs'
it 'upgrades cinder api package' do
expect(chef_run).to upgrade_package 'openstack-cinder-api'
end
it 'upgrades mysql python package' do
expect(chef_run).to upgrade_package 'python-mysql'
end
it 'upgrades postgresql python packages if explicitly told' do
node.set['openstack']['db']['block-storage']['service_type'] = 'postgresql'
expect(chef_run).to upgrade_package 'python-psycopg2'
expect(chef_run).not_to upgrade_package 'python-mysql'
end
it 'starts cinder api on boot' do
expect(chef_run).to enable_service 'openstack-cinder-api'
end
expect_creates_cinder_conf(
'service[cinder-api]', 'openstack-cinder', 'openstack-cinder')
end
end

View File

@ -35,8 +35,8 @@ describe 'openstack-block-storage::api' do
expect(chef_run).not_to upgrade_package('python-mysqldb') expect(chef_run).not_to upgrade_package('python-mysqldb')
end end
describe '/var/cache/cinder' do describe '/var/cache/cinder/api' do
let(:dir) { chef_run.directory('/var/cache/cinder') } let(:dir) { chef_run.directory('/var/cache/cinder/api') }
it 'should create the directory' do it 'should create the directory' do
expect(chef_run).to create_directory(dir.name).with( expect(chef_run).to create_directory(dir.name).with(

View File

@ -1,43 +0,0 @@
# encoding: UTF-8
#
# Cookbook Name:: openstack-block-storage
require_relative 'spec_helper'
describe 'openstack-block-storage::backup' do
describe 'suse' do
let(:runner) { ChefSpec::SoloRunner.new(SUSE_OPTS) }
let(:node) { runner.node }
let(:chef_run) { runner.converge(described_recipe) }
include_context 'block-storage-stubs'
describe 'enable cinder backup service' do
before do
node.set['openstack']['block-storage']['backup']['enabled'] = true
end
it 'upgrades cinder backup package' do
expect(chef_run).to upgrade_package 'openstack-cinder-backup'
end
it 'starts cinder backup' do
expect(chef_run).to start_service 'openstack-cinder-backup'
end
it 'starts cinder backup on boot' do
expect(chef_run).to enable_service 'openstack-cinder-backup'
end
it 'upgrades mysql python package' do
expect(chef_run).to upgrade_package 'python-mysql'
end
it 'upgrades postgresql python packages if explicitly told' do
node.set['openstack']['db']['block-storage']['service_type'] = 'postgresql'
expect(chef_run).to upgrade_package 'python-psycopg2'
expect(chef_run).not_to upgrade_package 'python-mysql'
end
end
end
end

View File

@ -13,9 +13,6 @@ describe 'openstack-block-storage::backup' do
include_context 'block-storage-stubs' include_context 'block-storage-stubs'
describe 'enable cinder backup service' do describe 'enable cinder backup service' do
before do
node.set['openstack']['block-storage']['backup']['enabled'] = true
end
it 'upgrades cinder backup package' do it 'upgrades cinder backup package' do
expect(chef_run).to upgrade_package 'cinder-backup' expect(chef_run).to upgrade_package 'cinder-backup'
end end
@ -43,37 +40,5 @@ describe 'openstack-block-storage::backup' do
expect(chef_run).not_to upgrade_package 'python-mysqldb' expect(chef_run).not_to upgrade_package 'python-mysqldb'
end end
end end
describe 'disable cinder backup service' do
before do
node.set['openstack']['block-storage']['backup']['enabled'] = false
end
it 'not to upgrades cinder backup package' do
expect(chef_run).not_to upgrade_package 'cinder-backup'
end
it 'not to starts cinder backup' do
expect(chef_run).not_to start_service 'cinder-backup'
end
it 'not to starts cinder backup on boot' do
expect(chef_run).not_to enable_service 'cinder-backup'
end
it 'not to subscribes to the template change' do
expect(chef_run.service('cinder-backup')).not_to subscribe_to('template[/etc/cinder/cinder.conf]')
end
it 'not to upgrades mysql python package' do
expect(chef_run).not_to upgrade_package 'python-mysqldb'
end
it 'not to upgrades postgresql python packages if explicitly told' do
node.set['openstack']['db']['block-storage']['service_type'] = 'postgresql'
expect(chef_run).not_to upgrade_package 'python-psycopg2'
expect(chef_run).not_to upgrade_package 'python-mysqldb'
end
end
end end
end end

View File

@ -1,19 +0,0 @@
# encoding: UTF-8
#
# Cookbook Name:: openstack-block-storage
require_relative 'spec_helper'
describe 'openstack-block-storage::cinder-common' do
describe 'suse' do
let(:runner) { ChefSpec::SoloRunner.new(SUSE_OPTS) }
let(:node) { runner.node }
let(:chef_run) { runner.converge(described_recipe) }
include_context 'block-storage-stubs'
it 'upgrades the openstack-cinder package' do
expect(chef_run).to upgrade_package 'openstack-cinder'
end
end
end

File diff suppressed because it is too large Load Diff

View File

@ -8,9 +8,5 @@ describe 'openstack-block-storage::client' do
let(:chef_run) do let(:chef_run) do
runner.converge(described_recipe) runner.converge(described_recipe)
end end
it 'upgrades packages' do
expect(chef_run).to upgrade_package('python-cinderclient')
end
end end
end end

View File

@ -56,86 +56,14 @@ describe 'openstack-block-storage::identity_registration' do
) )
end end
it 'with different admin URL' do
admin_url = 'https://admin.host:123/admin_path'
general_url = 'http://general.host:456/general_path'
# Set the general endpoint
node.set['openstack']['endpoints']['block-storage-api']['uri'] = general_url
# Set the admin endpoint override
node.set['openstack']['endpoints']['admin']['block-storage-api']['uri'] = admin_url
expect(chef_run).to create_endpoint_openstack_identity_register(
'Register Cinder V2 Volume Endpoint'
).with(
auth_uri: 'http://127.0.0.1:35357/v2.0',
bootstrap_token: 'bootstrap-token',
service_name: 'cinderv2',
service_type: 'volumev2',
service_description: 'Cinder Volume Service V2',
endpoint_region: 'RegionOne',
endpoint_adminurl: admin_url,
endpoint_internalurl: general_url,
endpoint_publicurl: general_url
)
end
it 'with different public URL' do
public_url = 'https://public.host:789/public_path'
general_url = 'http://general.host:456/general_path'
# Set the general endpoint
node.set['openstack']['endpoints']['block-storage-api']['uri'] = general_url
# Set the public endpoint override
node.set['openstack']['endpoints']['public']['block-storage-api']['uri'] = public_url
expect(chef_run).to create_endpoint_openstack_identity_register(
'Register Cinder V2 Volume Endpoint'
).with(
auth_uri: 'http://127.0.0.1:35357/v2.0',
bootstrap_token: 'bootstrap-token',
service_name: 'cinderv2',
service_type: 'volumev2',
service_description: 'Cinder Volume Service V2',
endpoint_region: 'RegionOne',
endpoint_adminurl: general_url,
endpoint_internalurl: general_url,
endpoint_publicurl: public_url
)
end
it 'with different internal URL' do
internal_url = 'http://internal.host:456/internal_path'
general_url = 'http://general.host:456/general_path'
# Set the general endpoint
node.set['openstack']['endpoints']['block-storage-api']['uri'] = general_url
# Set the internal endpoint override
node.set['openstack']['endpoints']['internal']['block-storage-api']['uri'] = internal_url
expect(chef_run).to create_endpoint_openstack_identity_register(
'Register Cinder V2 Volume Endpoint'
).with(
auth_uri: 'http://127.0.0.1:35357/v2.0',
bootstrap_token: 'bootstrap-token',
service_name: 'cinderv2',
service_type: 'volumev2',
service_description: 'Cinder Volume Service V2',
endpoint_region: 'RegionOne',
endpoint_adminurl: general_url,
endpoint_internalurl: internal_url,
endpoint_publicurl: general_url
)
end
it 'with all different URLs' do it 'with all different URLs' do
admin_url = 'https://admin.host:123/admin_path' admin_url = 'https://admin.host:123/admin_path'
internal_url = 'http://internal.host:456/internal_path' internal_url = 'http://internal.host:456/internal_path'
public_url = 'https://public.host:789/public_path' public_url = 'https://public.host:789/public_path'
node.set['openstack']['endpoints']['internal']['block-storage-api']['uri'] = internal_url node.set['openstack']['endpoints']['block-storage']['internal']['uri'] = internal_url
node.set['openstack']['endpoints']['admin']['block-storage-api']['uri'] = admin_url node.set['openstack']['endpoints']['block-storage']['admin']['uri'] = admin_url
node.set['openstack']['endpoints']['public']['block-storage-api']['uri'] = public_url node.set['openstack']['endpoints']['block-storage']['public']['uri'] = public_url
expect(chef_run).to create_endpoint_openstack_identity_register( expect(chef_run).to create_endpoint_openstack_identity_register(
'Register Cinder V2 Volume Endpoint' 'Register Cinder V2 Volume Endpoint'
@ -203,5 +131,35 @@ describe 'openstack-block-storage::identity_registration' do
role_name: 'service' role_name: 'service'
) )
end end
it do
expect(chef_run).to create_service_openstack_identity_register(
'Register Cinder V1 Volume Service'
).with(
auth_uri: 'http://127.0.0.1:35357/v2.0',
bootstrap_token: 'bootstrap-token',
service_name: 'cinder',
service_type: 'volume',
service_description: 'Cinder Volume Service V1',
endpoint_region: 'RegionOne',
endpoint_adminurl: 'http://127.0.0.1:8776/v1/%(tenant_id)s',
endpoint_internalurl: 'http://127.0.0.1:8776/v1/%(tenant_id)s',
endpoint_publicurl: 'http://127.0.0.1:8776/v1/%(tenant_id)s'
)
end
it do
expect(chef_run).to create_endpoint_openstack_identity_register(
'Register Cinder V1 Volume Endpoint'
).with(
auth_uri: 'http://127.0.0.1:35357/v2.0',
bootstrap_token: 'bootstrap-token',
service_name: 'cinder',
service_type: 'volume',
service_description: 'Cinder Volume Service V1',
endpoint_region: 'RegionOne',
endpoint_adminurl: 'http://127.0.0.1:8776/v1/%(tenant_id)s',
endpoint_internalurl: 'http://127.0.0.1:8776/v1/%(tenant_id)s',
endpoint_publicurl: 'http://127.0.0.1:8776/v1/%(tenant_id)s'
)
end
end end
end end

View File

@ -1,42 +0,0 @@
# encoding: UTF-8
#
# Cookbook Name:: openstack-block-storage
require_relative 'spec_helper'
describe 'openstack-block-storage::scheduler' do
describe 'suse' do
let(:runner) { ChefSpec::SoloRunner.new(SUSE_OPTS) }
let(:node) { runner.node }
let(:chef_run) { runner.converge(described_recipe) }
include_context 'block-storage-stubs'
it 'upgrades cinder scheduler package' do
expect(chef_run).to upgrade_package 'openstack-cinder-scheduler'
end
it 'starts cinder scheduler' do
expect(chef_run).to start_service 'openstack-cinder-scheduler'
end
it 'starts cinder scheduler on boot' do
expect(chef_run).to enable_service 'openstack-cinder-scheduler'
end
it 'does not upgrade stevedore' do
expect(chef_run).not_to upgrade_python_pip 'stevedore'
end
it 'upgrades mysql python package' do
expect(chef_run).to upgrade_package 'python-mysql'
end
it 'upgrades postgresql python packages if explicitly told' do
node.set['openstack']['db']['block-storage']['service_type'] = 'postgresql'
expect(chef_run).to upgrade_package 'python-psycopg2'
expect(chef_run).not_to upgrade_package 'python-mysql'
end
end
end

View File

@ -37,46 +37,5 @@ describe 'openstack-block-storage::scheduler' do
expect(chef_run).to upgrade_package 'python-psycopg2' expect(chef_run).to upgrade_package 'python-psycopg2'
expect(chef_run).not_to upgrade_package 'python-mysqldb' expect(chef_run).not_to upgrade_package 'python-mysqldb'
end end
it 'does not setup cron when no metering' do
expect(chef_run.cron('cinder-volume-usage-audit')).to be_nil
end
it 'creates cron metering default' do
allow_any_instance_of(Chef::Recipe).to receive(:search)
.with(:node, 'roles:os-block-storage-scheduler')
.and_return([OpenStruct.new(name: 'fauxhai.local')])
node.set['openstack']['telemetry'] = true
cron = chef_run.cron 'cinder-volume-usage-audit'
bin_str = '/usr/bin/cinder-volume-usage-audit > /var/log/cinder/audit.log'
expect(cron.command).to match(/#{bin_str}/)
crontests = [[:minute, '00'], [:hour, '*'], [:day, '*'],
[:weekday, '*'], [:month, '*'], [:user, 'cinder']]
crontests.each do |k, v|
expect(cron.send(k)).to eq v
expect(chef_run).to create_cron('cinder-volume-usage-audit')
end
expect(cron.action).to include :create
end
it 'creates cron metering custom' do
crontests = [[:minute, '50'], [:hour, '23'], [:day, '6'],
[:weekday, '5'], [:month, '11'], [:user, 'foobar']]
allow_any_instance_of(Chef::Recipe).to receive(:search)
.with(:node, 'roles:os-block-storage-scheduler')
.and_return([OpenStruct.new(name: 'foobar')])
node.set['openstack']['telemetry'] = true
crontests.each do |k, v|
node.set['openstack']['block-storage']['cron'][k.to_s] = v
end
node.set['openstack']['block-storage']['user'] = 'foobar'
cron = chef_run.cron 'cinder-volume-usage-audit'
crontests.each do |k, v|
expect(cron.send(k)).to eq v
end
expect(cron.action).to include :delete
end
end end
end end

View File

@ -10,11 +10,6 @@ ChefSpec::Coverage.start! { add_filter 'openstack-block-storage' }
require 'chef/application' require 'chef/application'
LOG_LEVEL = :fatal LOG_LEVEL = :fatal
SUSE_OPTS = {
platform: 'suse',
version: '11.3',
log_level: LOG_LEVEL
}
REDHAT_OPTS = { REDHAT_OPTS = {
platform: 'redhat', platform: 'redhat',
version: '7.1', version: '7.1',
@ -95,7 +90,7 @@ def expect_runs_openstack_common_logging_recipe
end end
end end
def expect_creates_cinder_conf(service, user, group, action = :restart) # rubocop:disable MethodLength def expect_creates_cinder_conf(service, user, group, action = :restart)
describe 'cinder.conf' do describe 'cinder.conf' do
let(:file) { chef_run.template('/etc/cinder/cinder.conf') } let(:file) { chef_run.template('/etc/cinder/cinder.conf') }

View File

@ -44,159 +44,5 @@ describe 'openstack-block-storage::volume' do
expect(chef_run).to enable_service('target') expect(chef_run).to enable_service('target')
end end
end end
context 'IBMNAS Driver' do
let(:file) { chef_run.template('/etc/cinder/nfs_shares.conf') }
before do
node.set['openstack']['block-storage']['volume']['driver'] = 'cinder.volume.drivers.ibm.ibmnas.IBMNAS_NFSDriver'
node.set['openstack']['block-storage']['ibmnas']['nas_access_ip'] = '127.0.0.1'
node.set['openstack']['block-storage']['ibmnas']['export'] = '/ibm/fs/export'
end
it 'creates IBMNAS shares_config file' do
expect(chef_run).to create_template(file.name).with(
owner: 'cinder',
group: 'cinder',
mode: '0600'
)
expect(chef_run).to render_file(file.name).with_content('127.0.0.1:/ibm/fs/export')
end
it 'upgrades nfs packages' do
expect(chef_run).to upgrade_package 'nfs-utils'
expect(chef_run).to upgrade_package 'nfs-utils-lib'
end
it 'creates the nfs mount point' do
expect(chef_run).to create_directory('/mnt/cinder-volumes').with(
owner: 'cinder',
group: 'cinder',
mode: '0755'
)
end
end
context 'NFS Driver' do
before do
node.set['openstack']['block-storage']['volume']['driver'] = 'cinder.volume.drivers.netapp.nfs.NetAppDirect7modeNfsDriver'
end
it 'upgrades nfs packages' do
expect(chef_run).to upgrade_package('nfs-utils')
expect(chef_run).to upgrade_package('nfs-utils-lib')
end
end
context 'EMC ISCSI Driver' do
before do
node.set['openstack']['block-storage']['volume']['driver'] = 'cinder.volume.drivers.emc.emc_smis_iscsi.EMCSMISISCSIDriver'
end
it 'upgrades emc package' do
expect(chef_run).to upgrade_package('pywbem')
end
end
describe 'IBM GPFS volume driver' do
before do
@chef_run = ::ChefSpec::SoloRunner.new ::REDHAT_OPTS do |n|
n.set['openstack']['block-storage']['volume']['driver'] = 'cinder.volume.drivers.ibm.gpfs.GPFSDriver'
n.set['openstack']['block-storage']['gpfs']['gpfs_mount_point_base'] = 'volumes'
n.set['openstack']['block-storage']['volume']['multi_backend'] =
{
'gpfs01' => {
'gpfs_mount_point_base' => 'gpfs_volume01',
'volume_driver' => 'cinder.volume.drivers.ibm.gpfs.GPFSDriver'
},
'gpfs02' => {
'gpfs_mount_point_base' => 'gpfs_volume02',
'volume_driver' => 'cinder.volume.drivers.ibm.gpfs.GPFSDriver'
}
}
end
@conf = '/etc/cinder/cinder.conf'
@chef_run.converge 'openstack-block-storage::volume'
end
it 'verifies gpfs_mount_point_base' do
expect(@chef_run).to render_file(@conf).with_content(
/^gpfs_mount_point_base = volumes$/)
end
it 'verifies gpfs_images_dir and gpfs_images_share_mode is set with default value' do
@chef_run.node.set['openstack']['block-storage']['gpfs']['gpfs_images_dir'] = 'images'
expect(@chef_run).to render_file(@conf).with_content(
/^gpfs_images_dir = images$/)
expect(@chef_run).to render_file(@conf).with_content(
/^gpfs_images_share_mode = copy_on_write$/)
end
it 'verifies gpfs_images_dir and gpfs_images_share_mode set correctly' do
@chef_run.node.set['openstack']['block-storage']['gpfs']['gpfs_images_dir'] = 'images'
@chef_run.node.set['openstack']['block-storage']['gpfs']['gpfs_images_share_mode'] = 'copy'
expect(@chef_run).to render_file(@conf).with_content(
/^gpfs_images_dir = images$/)
expect(@chef_run).to render_file(@conf).with_content(
/^gpfs_images_share_mode = copy$/)
end
it 'verifies gpfs_sparse_volumes is default' do
expect(@chef_run).to render_file(@conf).with_content(
/^gpfs_sparse_volumes = true$/)
end
it 'verifies gpfs_max_clone_depth is default' do
expect(@chef_run).to render_file(@conf).with_content(
/^gpfs_max_clone_depth = 8$/)
end
it 'verifies gpfs_storage_pool is default' do
expect(@chef_run).to render_file(@conf).with_content(
/^gpfs_storage_pool = system$/)
end
it 'verifies gpfs volume directory is created with owner and mode set correctly' do
expect(@chef_run).to create_directory('volumes').with(
owner: 'cinder',
group: 'cinder',
mode: '0755'
)
end
it 'verifies mount point base is created in multi backend case' do
expect(@chef_run).to create_directory('gpfs_volume01').with(
owner: 'cinder',
group: 'cinder',
mode: '0755'
)
expect(@chef_run).to create_directory('gpfs_volume02').with(
owner: 'cinder',
group: 'cinder',
mode: '0755'
)
end
end
describe 'create_vg' do
let(:file) { chef_run.template('/etc/init.d/cinder-group-active') }
before do
node.set['openstack']['block-storage']['volume']['driver'] = 'cinder.volume.drivers.lvm.LVMVolumeDriver'
node.set['openstack']['block-storage']['volume']['create_volume_group'] = true
stub_command('vgs cinder-volumes').and_return(false)
end
describe 'template contents' do
it 'sources /etc/rc.d/init.d/functions' do
expect(chef_run).to render_file(file.name).with_content(%r{^\s*. /etc/rc.d/init.d/functions$})
end
it 'calls success and echo' do
[/^\s*success$/, /^\s*echo$/].each do |cmd|
expect(chef_run).to render_file(file.name).with_content(cmd)
end
end
end
end
end end
end end

View File

@ -1,79 +0,0 @@
# encoding: UTF-8
#
# Cookbook Name:: openstack-block-storage
require_relative 'spec_helper'
describe 'openstack-block-storage::volume' do
describe 'suse' do
let(:runner) { ChefSpec::SoloRunner.new(SUSE_OPTS) }
let(:node) { runner.node }
let(:chef_run) { runner.converge(described_recipe) }
include_context 'block-storage-stubs'
it 'upgrades cinder volume package' do
expect(chef_run).to upgrade_package('openstack-cinder-volume')
end
it 'upgrades qemu img package' do
expect(chef_run).to upgrade_package('qemu-img')
end
it 'upgrades mysql python package' do
expect(chef_run).to upgrade_package('python-mysql')
end
it 'upgrades postgresql python packages if explicitly told' do
node.set['openstack']['db']['block-storage']['service_type'] = 'postgresql'
expect(chef_run).to upgrade_package('python-psycopg2')
expect(chef_run).not_to upgrade_package('python-mysql')
end
it 'upgrades cinder iscsi package' do
expect(chef_run).to upgrade_package('tgt')
end
it 'starts cinder volume' do
expect(chef_run).to start_service('openstack-cinder-volume')
end
it 'starts cinder volume on boot' do
expect(chef_run).to enable_service('openstack-cinder-volume')
end
context 'ISCSI' do
let(:file) { chef_run.template('/etc/tgt/targets.conf') }
it 'starts iscsi target on boot' do
expect(chef_run).to enable_service('tgtd')
end
it 'has suse include' do
expect(chef_run).to render_file(file.name).with_content('include /var/lib/cinder/volumes/*')
expect(chef_run).not_to render_file(file.name).with_content('include /etc/tgt/conf.d/*.conf')
end
end
context 'NFS Driver' do
before do
node.set['openstack']['block-storage']['volume']['driver'] = 'cinder.volume.drivers.netapp.nfs.NetAppDirect7modeNfsDriver'
end
it 'installs nfs packages' do
expect(chef_run).to upgrade_package('nfs-utils')
expect(chef_run).not_to upgrade_package('nfs-utils-lib')
end
end
context 'EMC ISCSI Driver' do
before do
node.set['openstack']['block-storage']['volume']['driver'] = 'cinder.volume.drivers.emc.emc_smis_iscsi.EMCSMISISCSIDriver'
end
it 'installs emc packages' do
expect(chef_run).to upgrade_package('python-pywbem')
end
end
end
end

View File

@ -50,168 +50,6 @@ describe 'openstack-block-storage::volume' do
expect(chef_run).to upgrade_package 'tgt' expect(chef_run).to upgrade_package 'tgt'
end end
it 'upgrades emc package' do
node.set['openstack']['block-storage']['volume']['driver'] = 'cinder.volume.drivers.emc.emc_smis_iscsi.EMCSMISISCSIDriver'
expect(chef_run).to upgrade_package 'python-pywbem'
end
context 'IBMNAS Driver' do
let(:file) { chef_run.template('/etc/cinder/nfs_shares.conf') }
before do
node.set['openstack']['block-storage']['volume']['driver'] = 'cinder.volume.drivers.ibm.ibmnas.IBMNAS_NFSDriver'
end
context 'IBMNAS shares_config file' do
it 'creates the file' do
expect(chef_run).to create_template(file.name).with(
owner: 'cinder',
group: 'cinder',
mode: '0600'
)
end
it 'sets the ibmnas access_ip attribute' do
node.set['openstack']['block-storage']['ibmnas']['nas_access_ip'] = '127.0.0.1'
node.set['openstack']['block-storage']['ibmnas']['export'] = '/ibm/fs/export'
expect(chef_run).to render_file(file.name).with_content('127.0.0.1:/ibm/fs/export')
end
end
it 'upgrades nfs package' do
expect(chef_run).to upgrade_package 'nfs-common'
end
it 'creates the nfs mount point' do
expect(chef_run).to create_directory('/mnt/cinder-volumes').with(
owner: 'cinder',
group: 'cinder',
mode: '0755'
)
end
end
context 'NetApp Driver' do
describe 'NFS' do
before do
node.set['openstack']['block-storage']['volume']['driver'] = 'cinder.volume.drivers.netapp.nfs.NetAppDirect7modeNfsDriver'
end
it 'upgrades nfs package' do
expect(chef_run).to upgrade_package 'nfs-common'
end
it 'creates the nfs mount point' do
expect(chef_run).to create_directory '/mnt/cinder-volumes'
end
context 'shares config file' do
let(:shares_config_file) { 'nfs_shares_config_file' }
let(:file) { chef_run.template(shares_config_file) }
before do
node.set['openstack']['block-storage']['nfs']['shares_config'] = shares_config_file
end
it 'creates the file' do
node.set['openstack']['block-storage']['user'] = 'test_user'
node.set['openstack']['block-storage']['group'] = 'test_group'
expect(chef_run).to create_template(file.name).with(
owner: 'test_user',
group: 'test_group',
mode: '0600'
)
end
it 'sets netapp server hostname export settings' do
netapp_server_hostname = %w(hostname1 hostname2)
node.set['openstack']['block-storage']['netapp']['netapp_server_hostname'] = netapp_server_hostname
node.set['openstack']['block-storage']['netapp']['export'] = 'netapp_export_value'
netapp_server_hostname.each do |hostname|
expect(chef_run).to render_file(file.name).with_content(/^#{hostname}:netapp_export_value$/)
end
end
end
end
describe 'ISCSI' do
before do
node.set['openstack']['block-storage']['volume']['driver'] = 'cinder.volume.drivers.netapp.iscsi.NetAppISCSIDriver'
end
it 'configures netapp dfm password' do
n = chef_run.node['openstack']['block-storage']['netapp']['dfm_password']
expect(n).to eq 'netapp-pass'
end
end
end
context 'Ceph (RBD) Driver' do
let(:file) { chef_run.template('/etc/ceph/ceph.client.cinder.keyring') }
before do
node.set['openstack']['block-storage']['volume']['driver'] = 'cinder.volume.drivers.rbd.RBDDriver'
node.set['ceph']['config']['fsid'] = '00000000-0000-0000-0000-000000000000'
end
it 'includes the ceph recipe' do
expect(chef_run).to include_recipe('ceph')
end
end
context 'Storewize Driver' do
let(:file) { chef_run.template('/etc/cinder/cinder.conf') }
before do
node.set['openstack']['block-storage']['volume']['driver'] = 'cinder.volume.drivers.ibm.storwize_svc.StorwizeSVCDriver'
end
it 'download san private key if needed' do
node.set['openstack']['block-storage']['storwize']['san_private_key_url'] = 'http://server/key'
expect(chef_run).to create_remote_file('/v7000_rsa').with(
source: 'http://server/key',
user: 'cinder',
group: 'cinder',
mode: '0400'
)
end
it 'upgrades svc package' do
expect(chef_run).to upgrade_package 'sysfsutils'
end
context 'ISCSI' do
before do
node.set['openstack']['block-storage']['storwize']['storwize_svc_connection_protocol'] = 'iSCSI'
end
it 'configures storewize with iscsi' do
# Test that the FC specific options are not set when connected via iSCSI
expect(chef_run).not_to render_file(file.name).with_content('storwize_svc_multipath_enabled')
end
end
context 'FC' do
before do
node.set['openstack']['block-storage']['storwize']['storwize_svc_connection_protocol'] = 'FC'
end
it 'configures storewize with fc' do
# Test that the iSCSI specific options are not set when connected via FC
expect(chef_run).not_to render_file(file.name).with_content('storwize_svc_iscsi_chap_enabled')
end
end
end
context 'FlashSystem Driver' do
before do
node.set['openstack']['block-storage']['volume']['driver'] = 'cinder.volume.drivers.ibm.flashsystem.FlashSystemDriver'
end
it 'upgrades sysfsutils package' do
expect(chef_run).to upgrade_package 'sysfsutils'
end
end
describe 'targets.conf' do describe 'targets.conf' do
let(:file) { chef_run.template('/etc/tgt/targets.conf') } let(:file) { chef_run.template('/etc/tgt/targets.conf') }
@ -232,125 +70,5 @@ describe 'openstack-block-storage::volume' do
expect(chef_run).not_to render_file(file.name).with_content('include volumes_dir_value/*') expect(chef_run).not_to render_file(file.name).with_content('include volumes_dir_value/*')
end end
end end
describe 'create_vg' do
let(:file) { chef_run.template('/etc/init.d/cinder-group-active') }
before do
node.set['openstack']['block-storage']['volume']['driver'] = 'cinder.volume.drivers.lvm.LVMVolumeDriver'
node.set['openstack']['block-storage']['volume']['create_volume_group'] = true
stub_command('vgs cinder-volumes').and_return(false)
end
it 'upgrades lvm packages' do
expect(chef_run).to upgrade_package 'lvm2'
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
it 'notifies cinder group active start' do
expect(file).to notify('service[cinder-group-active]').to(:start)
end
it 'creates cinder group active template file' do
expect(chef_run).to create_template(file.name)
end
describe 'template contents' do
let(:volume_group_value) { 'volume_group_value' }
before do
node.set['openstack']['block-storage']['volume']['volume_group'] = volume_group_value
stub_command("vgs #{volume_group_value}").and_return(true)
end
it 'calls vgs with the volume name attribute' do
expect(chef_run).to render_file(file.name).with_content(%r{vgs #{volume_group_value} > /dev/null 2>&1})
end
it 'calls vgcreate with the volume name and volume file attributes' do
node.set['openstack']['block-storage']['volume']['state_path'] = 'state_path_value'
volume_file = "state_path_value/#{volume_group_value}.img"
expect(chef_run).to render_file(file.name).with_content(/vgcreate #{volume_group_value} \$\(losetup --show -f #{volume_file}\)/)
end
it 'has ubuntu settings' do
expect(chef_run).to render_file(file.name).with_content(/^\s*echo "SUCCESS"/)
expect(chef_run).not_to render_file(file.name).with_content(/^\s*success$/)
end
end
end
describe 'create vg on block devices' do
before do
node.set['openstack']['block-storage']['volume']['driver'] = 'cinder.volume.drivers.lvm.LVMVolumeDriver'
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
node.set['openstack']['block-storage']['volume']['driver'] = 'cinder.volume.drivers.emc.emc_smis_iscsi.EMCSMISISCSIDriver'
end
it 'creates cinder emc config file' do
expect(chef_run).to create_template(file.name).with(
mode: 0644
)
end
describe 'template contents' do
before do
allow_any_instance_of(Chef::Recipe).to receive(:get_password)
.with('user', anything)
.and_return('emc_test_pass')
end
%w(StorageType EcomServerPort EcomUserName).each do |attr|
it "has an emc #{attr} setting" do
node.set['openstack']['block-storage']['emc'][attr] = "emc_#{attr}_value"
expect(chef_run).to render_file(file.name).with_content(%r{^<#{attr}>emc_#{attr}_value</#{attr}>$})
end
end
it 'has a EcomServerIP' do
node.set['openstack']['block-storage']['emc']['EcomServerIP'] = 'emc_EcomServerIP_value'
expect(chef_run).to render_file(file.name).with_content(%r{^<EcomServerIp>emc_EcomServerIP_value</EcomServerIp>$})
end
it 'has EcomPassword' do
node.set['openstack']['block-storage']['emc']['EcomUserName'] = 'emc_username'
expect(chef_run).to render_file(file.name).with_content(%r{^<EcomPassword>emc_test_pass</EcomPassword>$})
end
it 'does not have MaskingView when not specified' do
expect(chef_run).not_to render_file(file.name).with_content(/^<MaskingView>/)
end
it 'has MaskingView when specified' do
node.set['openstack']['block-storage']['emc']['MaskingView'] = 'testMaskingView'
expect(chef_run).to render_file(file.name).with_content(%r{^<MaskingView>testMaskingView</MaskingView>$})
end
end
end
end end
end end

File diff suppressed because it is too large Load Diff

View File

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

View File

@ -1,3 +0,0 @@
<%= node["openstack"]["block-storage"]["custom_template_banner"] %>
<%= @host %>:<%= @export %>

View File

@ -1,29 +0,0 @@
<%= node['openstack']['block-storage']['custom_template_banner'] %>
# Configuration for cinder-rootwrap
# This file should be owned by (and only-writeable by) the root user
[DEFAULT]
# List of directories to load filter definitions from (separated by ',').
# These directories MUST all be only writeable by root !
filters_path=/etc/cinder/rootwrap.d,/usr/share/cinder/rootwrap
# List of directories to search executables in, in case filters do not
# explicitely specify a full path (separated by ',')
# If not specified, defaults to system PATH environment variable.
# These directories MUST all be only writeable by root !
exec_dirs=/sbin,/usr/sbin,/bin,/usr/bin
# Enable logging to syslog
# Default value is False
use_syslog=False
# Which syslog facility to use.
# Valid values include auth, authpriv, syslog, local0, local1...
# Default value is 'syslog'
syslog_log_facility=syslog
# Which messages to log.
# INFO means log all usage
# ERROR means only log unsuccessful attempts
syslog_log_level=ERROR

View File

@ -1,5 +0,0 @@
<%= node["openstack"]["block-storage"]["custom_template_banner"] %>
<% node["openstack"]["block-storage"]["netapp"]["netapp_server_hostname"].each do |h| %>
<%= h %>:<%= @export %>
<% end %>

View File

@ -1,9 +1,9 @@
<%= node["openstack"]["block-storage"]["custom_template_banner"] %> <%= node["openstack"]["block-storage"]["custom_template_banner"] %>
<% if %w{rhel fedora suse}.include?(node["platform_family"]) %> <% if %w(rhel).include?(node["platform_family"]) %>
include <%= node['openstack']['block-storage']['volume']['volumes_dir'] %>/* include <%= node['openstack']['block-storage']['conf']['DEFAULT']['volumes_dir'] %>/*
<% end %> <% end %>
<% if %w{debian}.include?(node["platform_family"]) %> <% if %w(debian).include?(node["platform_family"]) %>
include /etc/tgt/conf.d/*.conf include /etc/tgt/conf.d/*.conf
<% end %> <% end %>
default-driver iscsi default-driver iscsi