library cleanup and refactoring
* version bump to 13.0.0 for mitaka release * removed suse support * removed general endpoint method, since we should be able to always specify which endpoint we need * removed fallbacks in specific_endpoint method, since this behaviour is not a very obvious one to the user and it should rather return an error than an unexpected result * dry public, internal and admin endpoint methods * removed obsolete private methods * adapted method calls for admin_endpoint in libraries/cli.rb * refactored set_endpoints_by_interface recipe to directly call address_for instead of address, since the recipe already checks for an existing attribute ..['bind_interface'] and therefore address would redirect to address_for anyways * moved the nested hash order for the public, internal and admin attributes to to be more clear and to break all existing calls to fix them during the refactoring process of all cookbooks e.g: node['openstack']['endpoints']['internal']['identity'] is now node['openstack']['endpoints']['identity']['internal'] and can be moved into the identity cookbook. This also streamlines these endpoint attributes with the bind_interface and host attributes * removed dependency on openstack-identity cookbooks by moving openrc recipe to opentack-identity (same for corrensponding specs and template) * removed address method and use the address (or hostname) defined in the endpoints hash directly (logic to set this attribute should rather be done in a wrapper (with a fitting method) instead of a static and predefined one) * removed set_endpoints_by_interface recipe since logic for defining the endpoints will be moved to wrapper cookbooks * added helper method merge_config_options for generation of config hashes used in service config templates * added template for openstack-service.conf.erb which can be used by all service cookbooks * deleted all endpoints attibutes, since these are moved to the service cookbooks for easier dependency handling Implements: blueprint cookbook-refactoring Change-Id: I0547182085eed91d05384fdd7734408a839a9a2c
This commit is contained in:
parent
42214704ac
commit
1858c025b2
|
@ -117,12 +117,6 @@ when 'rhel'
|
|||
default['openstack']['db']['python_packages']['mariadb'] = ['MySQL-python']
|
||||
default['openstack']['db']['python_packages']['percona-cluster'] = ['MySQL-python']
|
||||
default['openstack']['db']['python_packages']['galera'] = ['MySQL-python']
|
||||
when 'suse'
|
||||
default['openstack']['db']['service_type'] = 'mysql'
|
||||
default['openstack']['db']['python_packages']['mysql'] = ['python-mysql']
|
||||
default['openstack']['db']['python_packages']['mariadb'] = ['python-mysql']
|
||||
default['openstack']['db']['python_packages']['galera'] = ['python-mysql']
|
||||
default['openstack']['db']['python_packages']['percona-cluster'] = ['python-mysql']
|
||||
when 'debian'
|
||||
default['openstack']['db']['service_type'] = 'mysql'
|
||||
default['openstack']['db']['python_packages']['mysql'] = ['python-mysqldb']
|
||||
|
|
|
@ -129,395 +129,12 @@ default['openstack']['apt']['components'] = ["#{node['lsb']['codename']}-updates
|
|||
# For the SRU packaging, use this:
|
||||
# default['openstack']['apt']['components'] = [ '%codename%-proposed/%release%', 'main' ]
|
||||
|
||||
default['openstack']['zypp']['repo-key'] = 'd85f9316' # 32 bit key ID
|
||||
default['openstack']['zypp']['uri'] = 'http://download.opensuse.org/repositories/Cloud:/OpenStack:/%release%/%suse-release%/'
|
||||
|
||||
default['openstack']['yum']['rdo_enabled'] = true
|
||||
default['openstack']['yum']['uri'] = "http://mirror.centos.org/centos/$releasever/cloud/$basearch/openstack-#{node['openstack']['release']}"
|
||||
default['openstack']['yum']['repo-key'] = 'https://raw.githubusercontent.com/redhat-openstack/rdo-release/master/RPM-GPG-KEY-CentOS-SIG-Cloud'
|
||||
# Enforcing GnuPG signature check for RDO repo. Set this to false if you want to disable the check.
|
||||
default['openstack']['yum']['gpgcheck'] = true
|
||||
# ======================== OpenStack Endpoints ================================
|
||||
#
|
||||
# OpenStack recipes often need information about the various service
|
||||
# endpoints in the deployment. For instance, the cookbook that deploys
|
||||
# the Nova API service will need to set the glance_api_servers configuration
|
||||
# option in the nova.conf, and the cookbook setting up the Glance image
|
||||
# service might need information on the Swift proxy endpoint, etc. Having
|
||||
# all of this related OpenStack endpoint information in a single set of
|
||||
# common attributes in the openstack-common cookbook attributes means that
|
||||
# instead of doing funky role-based lookups, a deployment zone's OpenStack
|
||||
# endpoint information can simply be accessed by having the
|
||||
# openstack-common::default recipe added to some base role definition file
|
||||
# that all OpenStack nodes add to their run list.
|
||||
#
|
||||
# node['openstack']['endpoints'] is a hash of hashes, where each value hash
|
||||
# contains one of more of the following keys:
|
||||
#
|
||||
# - scheme
|
||||
# - uri
|
||||
# - host
|
||||
# - port
|
||||
# - path
|
||||
# - bind_interface
|
||||
#
|
||||
# If the uri key is set, its value is used as the full URI for the endpoint.
|
||||
# If the uri key is not set, the endpoint's full URI is constructed from the
|
||||
# component parts. This allows setups that use some standardized DNS names for
|
||||
# OpenStack service endpoints in a deployment zone as well as setups that
|
||||
# instead assign IP addresses (for an actual node or a load balanced virtual
|
||||
# IP) in a network to a particular OpenStack service endpoint. If the
|
||||
# bind_interface is set, it will set the host IP in the
|
||||
# set_endpoints_by_interface recipe.
|
||||
#
|
||||
# If you wish to use different values for the admin, public, and internal
|
||||
# URIs for a service, you can easily do so by putting that service's
|
||||
# information within the node['openstack']['endpoints'][type][service] hash
|
||||
# (where type is one of 'admin', 'public', or 'internal').
|
||||
# For example, to use a special public URI for compute-api, it could be
|
||||
# specified within...
|
||||
# node['openstack']['endpoints']['public']['compute-api'] = ...
|
||||
#
|
||||
# If you have no need for separate URIs for any of the admin, public, or
|
||||
# internal endpoints for compute-api, then you could just set the general
|
||||
# service endpoint within...
|
||||
# node['openstack']['endpoints']['compute-api'] = ...
|
||||
|
||||
# ******************** OpenStack Identity Endpoints ***************************
|
||||
default['openstack']['endpoints']['host'] = '127.0.0.1'
|
||||
default['openstack']['endpoints']['family'] = 'inet'
|
||||
default['openstack']['endpoints']['scheme'] = 'http'
|
||||
|
||||
# Note: The ['<service-name>-bind'] for each service exist so that a user can
|
||||
# have a service bind to a local IP per API node, that is different to the
|
||||
# actual endpoint for that service, which may be a load balanced IP.
|
||||
default['openstack']['endpoints']['bind-host'] = '127.0.0.1'
|
||||
# Also allow a common bind interface for easier configuration.
|
||||
default['openstack']['endpoints']['bind_interface'] = nil
|
||||
|
||||
# The OpenStack Identity (Keystone) API endpoint. This is commonly called
|
||||
# the Keystone Service endpoint...
|
||||
|
||||
# NOTE(mancdaz): There is a single 'identity-bind' mash that is used
|
||||
# by the identity cookbook, for both service and admin endpoint binds.
|
||||
# This is because keystone presents two ports but only a single service,
|
||||
# that can only be bound to a single IP.
|
||||
default['openstack']['endpoints']['identity-bind']['host'] = node['openstack']['endpoints']['bind-host']
|
||||
default['openstack']['endpoints']['identity-bind']['bind_interface'] = node['openstack']['endpoints']['bind_interface']
|
||||
|
||||
default['openstack']['endpoints']['identity-api']['host'] = node['openstack']['endpoints']['host']
|
||||
default['openstack']['endpoints']['identity-api']['scheme'] = node['openstack']['endpoints']['scheme']
|
||||
default['openstack']['endpoints']['identity-api']['port'] = '5000'
|
||||
default['openstack']['endpoints']['identity-api']['path'] = '/v2.0'
|
||||
default['openstack']['endpoints']['identity-api']['bind_interface'] = nil
|
||||
|
||||
# The OpenStack Identity (Keystone) Internal API endpoint
|
||||
# For a reference architecture this is a sensable default, however with a more
|
||||
# complex network setup the public endpoint may not be reachable by internal
|
||||
# systems, thus the ability to set this to something different must be present.
|
||||
# Even if the public endpoint is reachable there may be other reasons to send
|
||||
# interal communications to a different endpoint, for security or auditing
|
||||
# purposes for example.
|
||||
# Generally this listens on the same IP as the admin interface, but with the
|
||||
# public pipeline(5000) instead of the admin pipeline(35357).
|
||||
default['openstack']['endpoints']['identity-internal']['host'] = node['openstack']['endpoints']['host']
|
||||
default['openstack']['endpoints']['identity-internal']['scheme'] = node['openstack']['endpoints']['scheme']
|
||||
default['openstack']['endpoints']['identity-internal']['port'] = '5000'
|
||||
default['openstack']['endpoints']['identity-internal']['path'] = '/v2.0'
|
||||
default['openstack']['endpoints']['identity-internal']['bind_interface'] = nil
|
||||
|
||||
# The OpenStack Identity (Keystone) Admin API endpoint
|
||||
default['openstack']['endpoints']['identity-admin-bind']['host'] = node['openstack']['endpoints']['bind-host']
|
||||
default['openstack']['endpoints']['identity-admin-bind']['port'] = '35357'
|
||||
default['openstack']['endpoints']['identity-admin-bind']['bind_interface'] = node['openstack']['endpoints']['bind_interface']
|
||||
|
||||
default['openstack']['endpoints']['identity-admin']['host'] = node['openstack']['endpoints']['host']
|
||||
default['openstack']['endpoints']['identity-admin']['scheme'] = node['openstack']['endpoints']['scheme']
|
||||
default['openstack']['endpoints']['identity-admin']['port'] = '35357'
|
||||
default['openstack']['endpoints']['identity-admin']['path'] = '/v2.0'
|
||||
default['openstack']['endpoints']['identity-admin']['bind_interface'] = nil
|
||||
|
||||
# ****************** OpenStack Compute Endpoints ******************************
|
||||
|
||||
# The OpenStack Compute (Nova) Native API endpoint
|
||||
default['openstack']['endpoints']['compute-api-bind']['host'] = node['openstack']['endpoints']['bind-host']
|
||||
default['openstack']['endpoints']['compute-api-bind']['port'] = '8774'
|
||||
default['openstack']['endpoints']['compute-api-bind']['bind_interface'] = node['openstack']['endpoints']['bind_interface']
|
||||
|
||||
default['openstack']['endpoints']['compute-api']['host'] = node['openstack']['endpoints']['host']
|
||||
default['openstack']['endpoints']['compute-api']['scheme'] = node['openstack']['endpoints']['scheme']
|
||||
default['openstack']['endpoints']['compute-api']['port'] = '8774'
|
||||
default['openstack']['endpoints']['compute-api']['path'] = '/v2/%(tenant_id)s'
|
||||
default['openstack']['endpoints']['compute-api']['bind_interface'] = nil
|
||||
|
||||
# The OpenStack Compute (Nova) EC2 API endpoint
|
||||
default['openstack']['endpoints']['compute-ec2-api-bind']['host'] = node['openstack']['endpoints']['bind-host']
|
||||
default['openstack']['endpoints']['compute-ec2-api-bind']['port'] = '8773'
|
||||
default['openstack']['endpoints']['compute-ec2-api-bind']['bind_interface'] = node['openstack']['endpoints']['bind_interface']
|
||||
|
||||
default['openstack']['endpoints']['compute-ec2-api']['host'] = node['openstack']['endpoints']['host']
|
||||
default['openstack']['endpoints']['compute-ec2-api']['scheme'] = node['openstack']['endpoints']['scheme']
|
||||
default['openstack']['endpoints']['compute-ec2-api']['port'] = '8773'
|
||||
default['openstack']['endpoints']['compute-ec2-api']['path'] = '/services/Cloud'
|
||||
default['openstack']['endpoints']['compute-ec2-api']['bind_interface'] = nil
|
||||
|
||||
# The OpenStack Compute (Nova) EC2 Admin API endpoint
|
||||
default['openstack']['endpoints']['compute-ec2-admin-bind']['host'] = node['openstack']['endpoints']['bind-host']
|
||||
default['openstack']['endpoints']['compute-ec2-admin-bind']['port'] = '8773'
|
||||
default['openstack']['endpoints']['compute-ec2-admin-bind']['bind_interface'] = node['openstack']['endpoints']['bind_interface']
|
||||
|
||||
default['openstack']['endpoints']['compute-ec2-admin']['host'] = node['openstack']['endpoints']['host']
|
||||
default['openstack']['endpoints']['compute-ec2-admin']['scheme'] = node['openstack']['endpoints']['scheme']
|
||||
default['openstack']['endpoints']['compute-ec2-admin']['port'] = '8773'
|
||||
default['openstack']['endpoints']['compute-ec2-admin']['path'] = '/services/Admin'
|
||||
default['openstack']['endpoints']['compute-ec2-admin']['bind_interface'] = nil
|
||||
|
||||
# The OpenStack Compute (Nova) XVPvnc endpoint
|
||||
default['openstack']['endpoints']['compute-xvpvnc-bind']['host'] = node['openstack']['endpoints']['bind-host']
|
||||
default['openstack']['endpoints']['compute-xvpvnc-bind']['port'] = '6081'
|
||||
default['openstack']['endpoints']['compute-xvpvnc-bind']['bind_interface'] = node['openstack']['endpoints']['bind_interface']
|
||||
|
||||
default['openstack']['endpoints']['compute-xvpvnc']['host'] = node['openstack']['endpoints']['host']
|
||||
default['openstack']['endpoints']['compute-xvpvnc']['scheme'] = node['openstack']['endpoints']['scheme']
|
||||
default['openstack']['endpoints']['compute-xvpvnc']['port'] = '6081'
|
||||
default['openstack']['endpoints']['compute-xvpvnc']['path'] = '/console'
|
||||
default['openstack']['endpoints']['compute-xvpvnc']['bind_interface'] = nil
|
||||
|
||||
# The OpenStack Compute (Nova) novnc endpoint
|
||||
default['openstack']['endpoints']['compute-novnc-bind']['host'] = node['openstack']['endpoints']['bind-host']
|
||||
default['openstack']['endpoints']['compute-novnc-bind']['port'] = '6080'
|
||||
default['openstack']['endpoints']['compute-novnc-bind']['bind_interface'] = node['openstack']['endpoints']['bind_interface']
|
||||
|
||||
default['openstack']['endpoints']['compute-novnc']['host'] = node['openstack']['endpoints']['host']
|
||||
default['openstack']['endpoints']['compute-novnc']['scheme'] = node['openstack']['endpoints']['scheme']
|
||||
default['openstack']['endpoints']['compute-novnc']['port'] = '6080'
|
||||
default['openstack']['endpoints']['compute-novnc']['path'] = '/vnc_auto.html'
|
||||
default['openstack']['endpoints']['compute-novnc']['bind_interface'] = nil
|
||||
|
||||
# The OpenStack Compute (Nova) vnc endpoint
|
||||
default['openstack']['endpoints']['compute-vnc-bind']['host'] = node['openstack']['endpoints']['bind-host']
|
||||
default['openstack']['endpoints']['compute-vnc-bind']['bind_interface'] = node['openstack']['endpoints']['bind_interface']
|
||||
|
||||
default['openstack']['endpoints']['compute-vnc']['host'] = node['openstack']['endpoints']['host']
|
||||
default['openstack']['endpoints']['compute-vnc']['scheme'] = nil
|
||||
default['openstack']['endpoints']['compute-vnc']['port'] = nil
|
||||
default['openstack']['endpoints']['compute-vnc']['path'] = nil
|
||||
default['openstack']['endpoints']['compute-vnc']['bind_interface'] = nil
|
||||
|
||||
# The OpenStack Compute (Nova) vnc proxy endpoint
|
||||
default['openstack']['endpoints']['compute-vnc-proxy-bind']['host'] = node['openstack']['endpoints']['compute-vnc-bind']['host']
|
||||
default['openstack']['endpoints']['compute-vnc-proxy-bind']['bind_interface'] = node['openstack']['endpoints']['compute-vnc-bind']['bind_interface']
|
||||
|
||||
# The OpenStack Compute (Nova) metadata API endpoint
|
||||
default['openstack']['endpoints']['compute-metadata-api-bind']['host'] = node['openstack']['endpoints']['bind-host']
|
||||
default['openstack']['endpoints']['compute-metadata-api-bind']['port'] = '8775'
|
||||
default['openstack']['endpoints']['compute-metadata-api-bind']['bind_interface'] = node['openstack']['endpoints']['bind_interface']
|
||||
|
||||
default['openstack']['endpoints']['compute-metadata-api']['host'] = node['openstack']['endpoints']['host']
|
||||
default['openstack']['endpoints']['compute-metadata-api']['scheme'] = node['openstack']['endpoints']['scheme']
|
||||
default['openstack']['endpoints']['compute-metadata-api']['port'] = '8775'
|
||||
default['openstack']['endpoints']['compute-metadata-api']['path'] = nil
|
||||
default['openstack']['endpoints']['compute-metadata-api']['bind_interface'] = nil
|
||||
|
||||
# The OpenStack Compute (Nova) serial console endpoint
|
||||
default['openstack']['endpoints']['compute-serial-console-bind']['host'] = node['openstack']['endpoints']['bind-host']
|
||||
default['openstack']['endpoints']['compute-serial-console-bind']['bind_interface'] = node['openstack']['endpoints']['bind_interface']
|
||||
|
||||
# The OpenStack Compute (Nova) serial proxy endpoint
|
||||
default['openstack']['endpoints']['compute-serial-proxy']['host'] = node['openstack']['endpoints']['host']
|
||||
default['openstack']['endpoints']['compute-serial-proxy']['scheme'] = 'ws'
|
||||
default['openstack']['endpoints']['compute-serial-proxy']['port'] = '6083'
|
||||
default['openstack']['endpoints']['compute-serial-proxy']['path'] = '/'
|
||||
default['openstack']['endpoints']['compute-serial-proxy']['bind_interface'] = nil
|
||||
|
||||
# ******************** OpenStack Network Endpoints ****************************
|
||||
|
||||
# The OpenStack Network (Neutron) API endpoint.
|
||||
default['openstack']['endpoints']['network-api-bind']['host'] = node['openstack']['endpoints']['bind-host']
|
||||
default['openstack']['endpoints']['network-api-bind']['port'] = '9696'
|
||||
default['openstack']['endpoints']['network-api-bind']['bind_interface'] = node['openstack']['endpoints']['bind_interface']
|
||||
|
||||
default['openstack']['endpoints']['network-api']['host'] = node['openstack']['endpoints']['host']
|
||||
default['openstack']['endpoints']['network-api']['scheme'] = node['openstack']['endpoints']['scheme']
|
||||
default['openstack']['endpoints']['network-api']['port'] = '9696'
|
||||
# neutronclient appends the protocol version to the endpoint URL, so the
|
||||
# path needs to be empty
|
||||
default['openstack']['endpoints']['network-api']['path'] = ''
|
||||
default['openstack']['endpoints']['network-api']['bind_interface'] = nil
|
||||
|
||||
# The OpenStack Network Linux Bridge endpoint
|
||||
default['openstack']['endpoints']['network-linuxbridge']['host'] = node['openstack']['endpoints']['host']
|
||||
default['openstack']['endpoints']['network-linuxbridge']['scheme'] = nil
|
||||
default['openstack']['endpoints']['network-linuxbridge']['port'] = nil
|
||||
default['openstack']['endpoints']['network-linuxbridge']['path'] = nil
|
||||
default['openstack']['endpoints']['network-linuxbridge']['bind_interface'] = nil
|
||||
|
||||
# The OpenStack Network Open vSwitch endpoint
|
||||
default['openstack']['endpoints']['network-openvswitch']['host'] = node['openstack']['endpoints']['host']
|
||||
default['openstack']['endpoints']['network-openvswitch']['scheme'] = nil
|
||||
default['openstack']['endpoints']['network-openvswitch']['port'] = nil
|
||||
default['openstack']['endpoints']['network-openvswitch']['path'] = nil
|
||||
default['openstack']['endpoints']['network-openvswitch']['bind_interface'] = nil
|
||||
|
||||
# ******************** OpenStack Image Endpoints ******************************
|
||||
|
||||
# The OpenStack Image (Glance) API endpoint
|
||||
default['openstack']['endpoints']['image-api-bind']['host'] = node['openstack']['endpoints']['bind-host']
|
||||
default['openstack']['endpoints']['image-api-bind']['port'] = '9292'
|
||||
default['openstack']['endpoints']['image-api-bind']['bind_interface'] = node['openstack']['endpoints']['bind_interface']
|
||||
|
||||
default['openstack']['endpoints']['image-api']['host'] = node['openstack']['endpoints']['host']
|
||||
default['openstack']['endpoints']['image-api']['scheme'] = node['openstack']['endpoints']['scheme']
|
||||
default['openstack']['endpoints']['image-api']['port'] = '9292'
|
||||
# The glance client appends the protocol version to the endpoint URL,
|
||||
# so the path needs to be empty
|
||||
default['openstack']['endpoints']['image-api']['path'] = ''
|
||||
default['openstack']['endpoints']['image-api']['bind_interface'] = nil
|
||||
|
||||
# The OpenStack Image (Glance) Registry API endpoint
|
||||
default['openstack']['endpoints']['image-registry-bind']['host'] = node['openstack']['endpoints']['bind-host']
|
||||
default['openstack']['endpoints']['image-registry-bind']['port'] = '9191'
|
||||
default['openstack']['endpoints']['image-registry-bind']['bind_interface'] = node['openstack']['endpoints']['bind_interface']
|
||||
|
||||
default['openstack']['endpoints']['image-registry']['host'] = node['openstack']['endpoints']['host']
|
||||
default['openstack']['endpoints']['image-registry']['scheme'] = node['openstack']['endpoints']['scheme']
|
||||
default['openstack']['endpoints']['image-registry']['port'] = '9191'
|
||||
default['openstack']['endpoints']['image-registry']['path'] = '/v2'
|
||||
default['openstack']['endpoints']['image-registry']['bind_interface'] = nil
|
||||
|
||||
# ******************** OpenStack Volume Endpoints *****************************
|
||||
|
||||
# The OpenStack Volume (Cinder) API endpoint
|
||||
default['openstack']['endpoints']['block-storage-api-bind']['host'] = node['openstack']['endpoints']['bind-host']
|
||||
default['openstack']['endpoints']['block-storage-api-bind']['port'] = '8776'
|
||||
default['openstack']['endpoints']['block-storage-api-bind']['bind_interface'] = node['openstack']['endpoints']['bind_interface']
|
||||
|
||||
default['openstack']['endpoints']['block-storage-api']['host'] = node['openstack']['endpoints']['host']
|
||||
default['openstack']['endpoints']['block-storage-api']['scheme'] = node['openstack']['endpoints']['scheme']
|
||||
default['openstack']['endpoints']['block-storage-api']['port'] = '8776'
|
||||
default['openstack']['endpoints']['block-storage-api']['path'] = '/v2/%(tenant_id)s'
|
||||
default['openstack']['endpoints']['block-storage-api']['bind_interface'] = nil
|
||||
|
||||
# ******************** OpenStack Object Storage Endpoint *****************************
|
||||
|
||||
# The OpenStack Object Storage (Swift) API endpoint
|
||||
default['openstack']['endpoints']['object-storage-api-bind']['host'] = node['openstack']['endpoints']['bind-host']
|
||||
default['openstack']['endpoints']['object-storage-api-bind']['port'] = '8080'
|
||||
default['openstack']['endpoints']['object-storage-api-bind']['bind_interface'] = node['openstack']['endpoints']['bind_interface']
|
||||
|
||||
default['openstack']['endpoints']['object-storage-api']['host'] = node['openstack']['endpoints']['host']
|
||||
default['openstack']['endpoints']['object-storage-api']['scheme'] = node['openstack']['endpoints']['scheme']
|
||||
default['openstack']['endpoints']['object-storage-api']['port'] = '8080'
|
||||
default['openstack']['endpoints']['object-storage-api']['path'] = '/v1/AUTH_%(tenant_id)s'
|
||||
default['openstack']['endpoints']['object-storage-api']['bind_interface'] = nil
|
||||
|
||||
# ******************** OpenStack Metering Endpoints ***************************
|
||||
|
||||
# The OpenStack Metering (Ceilometer) API endpoint
|
||||
default['openstack']['endpoints']['telemetry-api-bind']['host'] = node['openstack']['endpoints']['bind-host']
|
||||
default['openstack']['endpoints']['telemetry-api-bind']['port'] = '8777'
|
||||
default['openstack']['endpoints']['telemetry-api-bind']['bind_interface'] = node['openstack']['endpoints']['bind_interface']
|
||||
|
||||
default['openstack']['endpoints']['telemetry-api']['host'] = node['openstack']['endpoints']['host']
|
||||
default['openstack']['endpoints']['telemetry-api']['scheme'] = node['openstack']['endpoints']['scheme']
|
||||
default['openstack']['endpoints']['telemetry-api']['port'] = '8777'
|
||||
# The ceilometer client appends the protocol version to the endpoint URL,
|
||||
# so the path needs to be empty
|
||||
default['openstack']['endpoints']['telemetry-api']['path'] = ''
|
||||
default['openstack']['endpoints']['telemetry-api']['bind_interface'] = nil
|
||||
|
||||
# ******************** OpenStack Orchestration Endpoints ***************************
|
||||
|
||||
# The OpenStack Orchestration (Heat) API endpoint
|
||||
default['openstack']['endpoints']['orchestration-api-bind']['host'] = node['openstack']['endpoints']['bind-host']
|
||||
default['openstack']['endpoints']['orchestration-api-bind']['port'] = '8004'
|
||||
default['openstack']['endpoints']['orchestration-api-bind']['bind_interface'] = node['openstack']['endpoints']['bind_interface']
|
||||
|
||||
default['openstack']['endpoints']['orchestration-api']['host'] = node['openstack']['endpoints']['host']
|
||||
default['openstack']['endpoints']['orchestration-api']['scheme'] = node['openstack']['endpoints']['scheme']
|
||||
default['openstack']['endpoints']['orchestration-api']['port'] = '8004'
|
||||
default['openstack']['endpoints']['orchestration-api']['path'] = '/v1/%(tenant_id)s'
|
||||
default['openstack']['endpoints']['orchestration-api']['bind_interface'] = nil
|
||||
|
||||
# The OpenStack Orchestration (Heat) CloudFormation API endpoint
|
||||
default['openstack']['endpoints']['orchestration-api-cfn-bind']['host'] = node['openstack']['endpoints']['bind-host']
|
||||
default['openstack']['endpoints']['orchestration-api-cfn-bind']['port'] = '8000'
|
||||
default['openstack']['endpoints']['orchestration-api-cfn-bind']['bind_interface'] = node['openstack']['endpoints']['bind_interface']
|
||||
|
||||
default['openstack']['endpoints']['orchestration-api-cfn']['host'] = node['openstack']['endpoints']['host']
|
||||
default['openstack']['endpoints']['orchestration-api-cfn']['scheme'] = node['openstack']['endpoints']['scheme']
|
||||
default['openstack']['endpoints']['orchestration-api-cfn']['port'] = '8000'
|
||||
default['openstack']['endpoints']['orchestration-api-cfn']['path'] = '/v1'
|
||||
default['openstack']['endpoints']['orchestration-api-cfn']['bind_interface'] = nil
|
||||
|
||||
# The OpenStack Orchestration (Heat) CloudWatch API endpoint
|
||||
default['openstack']['endpoints']['orchestration-api-cloudwatch-bind']['host'] = node['openstack']['endpoints']['bind-host']
|
||||
default['openstack']['endpoints']['orchestration-api-cloudwatch-bind']['port'] = '8003'
|
||||
default['openstack']['endpoints']['orchestration-api-cloudwatch-bind']['bind_interface'] = node['openstack']['endpoints']['bind_interface']
|
||||
|
||||
default['openstack']['endpoints']['orchestration-api-cloudwatch']['host'] = node['openstack']['endpoints']['host']
|
||||
default['openstack']['endpoints']['orchestration-api-cloudwatch']['scheme'] = node['openstack']['endpoints']['scheme']
|
||||
default['openstack']['endpoints']['orchestration-api-cloudwatch']['port'] = '8003'
|
||||
default['openstack']['endpoints']['orchestration-api-cloudwatch']['path'] = '/v1'
|
||||
default['openstack']['endpoints']['orchestration-api-cloudwatch']['bind_interface'] = nil
|
||||
|
||||
# ******************** OpenStack Database Endpoints ***************************
|
||||
|
||||
# The OpenStack Database (Trove) API endpoint
|
||||
default['openstack']['endpoints']['database-api-bind']['host'] = node['openstack']['endpoints']['bind-host']
|
||||
default['openstack']['endpoints']['database-api-bind']['port'] = '8779'
|
||||
default['openstack']['endpoints']['database-api-bind']['bind_interface'] = node['openstack']['endpoints']['bind_interface']
|
||||
|
||||
default['openstack']['endpoints']['database-api']['host'] = node['openstack']['endpoints']['host']
|
||||
default['openstack']['endpoints']['database-api']['scheme'] = node['openstack']['endpoints']['scheme']
|
||||
default['openstack']['endpoints']['database-api']['port'] = '8779'
|
||||
default['openstack']['endpoints']['database-api']['path'] = '/v1.0/%(tenant_id)s'
|
||||
default['openstack']['endpoints']['database-api']['bind_interface'] = nil
|
||||
|
||||
# ******************** OpenStack Bare Metal Endpoints *****************************
|
||||
|
||||
# The OpenStack Bare Metal (Ironic) API endpoint
|
||||
default['openstack']['endpoints']['bare-metal-api-bind']['host'] = node['openstack']['endpoints']['bind-host']
|
||||
default['openstack']['endpoints']['bare-metal-api-bind']['port'] = '6385'
|
||||
default['openstack']['endpoints']['bare-metal-api-bind']['bind_interface'] = node['openstack']['endpoints']['bind_interface']
|
||||
|
||||
default['openstack']['endpoints']['bare-metal-api']['host'] = node['openstack']['endpoints']['host']
|
||||
default['openstack']['endpoints']['bare-metal-api']['scheme'] = node['openstack']['endpoints']['scheme']
|
||||
default['openstack']['endpoints']['bare-metal-api']['port'] = '6385'
|
||||
default['openstack']['endpoints']['bare-metal-api']['path'] = ''
|
||||
default['openstack']['endpoints']['bare-metal-api']['bind_interface'] = nil
|
||||
|
||||
# ****************** OpenStack Dashboard Endpoints ******************************
|
||||
|
||||
# The OpenStack Dashboard non-SSL endpoint
|
||||
default['openstack']['endpoints']['dashboard-http-bind']['host'] = node['openstack']['endpoints']['bind-host']
|
||||
default['openstack']['endpoints']['dashboard-http-bind']['port'] = '80'
|
||||
default['openstack']['endpoints']['dashboard-http-bind']['bind_interface'] = node['openstack']['endpoints']['bind_interface']
|
||||
|
||||
# The OpenStack Dashboard SSL endpoint
|
||||
default['openstack']['endpoints']['dashboard-https-bind']['host'] = node['openstack']['endpoints']['bind-host']
|
||||
default['openstack']['endpoints']['dashboard-https-bind']['port'] = '443'
|
||||
default['openstack']['endpoints']['dashboard-https-bind']['bind_interface'] = node['openstack']['endpoints']['bind_interface']
|
||||
|
||||
# ********************************************************************************
|
||||
|
||||
# Alternately, if you used some standardized DNS naming scheme, you could
|
||||
# do something like this, which would override any part-wise specifications above.
|
||||
#
|
||||
# default['openstack']['endpoints']['identity-api']['uri'] = 'https://identity.example.com:35357/v2.0'
|
||||
# default['openstack']['endpoints']['identity-admin']['uri'] = 'https://identity.example.com:5000/v2.0'
|
||||
# default['openstack']['endpoints']['compute-api']['uri'] = 'https://compute.example.com:8774/v2/%(tenant_id)s'
|
||||
# default['openstack']['endpoints']['compute-ec2-api']['uri'] = 'https://ec2.example.com:8773/services/Cloud'
|
||||
# default['openstack']['endpoints']['compute-ec2-admin']['uri'] = 'https://ec2.example.com:8773/services/Admin'
|
||||
# default['openstack']['endpoints']['compute-xvpvnc']['uri'] = 'https://xvpvnc.example.com:6081/console'
|
||||
# default['openstack']['endpoints']['compute-novnc']['uri'] = 'https://novnc.example.com:6080/vnc_auto.html'
|
||||
# default['openstack']['endpoints']['image-api']['uri'] = 'https://image.example.com:9292/v2'
|
||||
# default['openstack']['endpoints']['image-registry']['uri'] = 'https://image.example.com:9191/v2'
|
||||
# default['openstack']['endpoints']['block-storage-api']['uri'] = 'https://volume.example.com:8776/v1/%(tenant_id)s'
|
||||
# default['openstack']['endpoints']['telemetry-api']['uri'] = 'https://telemetry.example.com:9000/v1'
|
||||
# default['openstack']['endpoints']['orchestration-api']['uri'] = 'https://orchestration.example.com:8004//v1/%(tenant_id)s'
|
||||
# default['openstack']['endpoints']['orchestration-api-cfn']['uri'] = 'https://orchestration.example.com:8000/v1'
|
||||
# default['openstack']['endpoints']['orchestration-api-cloudwatch']['uri'] = 'https://orchestration.example.com:8003/v1'
|
||||
|
||||
# Set a default region that other regions are set to - such that changing the region for all services can be done in one place
|
||||
default['openstack']['region'] = 'RegionOne'
|
||||
|
@ -664,11 +281,8 @@ default['openstack']['memcached_servers'] = nil
|
|||
default['openstack']['sysctl']['net.ipv4.conf.all.rp_filter'] = 0
|
||||
default['openstack']['sysctl']['net.ipv4.conf.default.rp_filter'] = 0
|
||||
|
||||
# Default OpenStack Network Type: nova (optional: neutron)
|
||||
default['openstack']['compute']['network']['service_type'] = 'nova'
|
||||
|
||||
case node['platform_family']
|
||||
when 'rhel', 'suse'
|
||||
when 'rhel'
|
||||
default['openstack']['common']['platform'] = {
|
||||
'common_client_packages' => ['python-openstackclient'],
|
||||
'package_overrides' => ''
|
||||
|
@ -685,14 +299,3 @@ default['openstack']['identity_service_chef_role'] = 'os-identity'
|
|||
|
||||
# The name of the Chef role that sets up the compute worker
|
||||
default['openstack']['compute_worker_chef_role'] = 'os-compute-worker'
|
||||
|
||||
# Array of bare options for openrc (e.g. 'option=value')
|
||||
default['openstack']['misc_openrc'] = nil
|
||||
|
||||
# openrc location and owner
|
||||
default['openstack']['openrc']['path'] = '/root'
|
||||
default['openstack']['openrc']['file'] = 'openrc'
|
||||
default['openstack']['openrc']['user'] = 'root'
|
||||
default['openstack']['openrc']['group'] = 'root'
|
||||
default['openstack']['openrc']['file_mode'] = '0600'
|
||||
default['openstack']['openrc']['path_mode'] = '0700'
|
||||
|
|
|
@ -41,7 +41,7 @@ services = %w(bare-metal block-storage compute database image
|
|||
# Generic default attributes
|
||||
###################################################################
|
||||
default['openstack']['mq']['server_role'] = 'os-ops-messaging'
|
||||
default['openstack']['mq']['service_type'] = 'rabbitmq'
|
||||
default['openstack']['mq']['service_type'] = 'rabbit'
|
||||
default['openstack']['mq']['user'] = 'guest'
|
||||
default['openstack']['mq']['vhost'] = '/'
|
||||
|
||||
|
@ -50,9 +50,8 @@ default['openstack']['mq']['durable_queues'] = false
|
|||
default['openstack']['mq']['auto_delete'] = false
|
||||
|
||||
###################################################################
|
||||
# Default qpid and rabbit values (for attribute assignment below)
|
||||
# Default rabbit values (for attribute assignment below)
|
||||
###################################################################
|
||||
default['openstack']['mq']['qpid']['protocol'] = 'tcp'
|
||||
# global switch for handling rabbit ssl
|
||||
default['openstack']['mq']['rabbitmq']['use_ssl'] = false
|
||||
# SSL version to use (valid only if SSL enabled)
|
||||
|
@ -75,26 +74,6 @@ default['openstack']['mq']['rabbitmq']['heartbeat_timeout_threshold'] = 0
|
|||
# global switch for how often times during the heartbeat_timeout_threshold we check the heartbeat
|
||||
default['openstack']['mq']['rabbitmq']['heartbeat_rate'] = 2
|
||||
|
||||
# defined in oslo/messaging/_drivers/impl_qpid.py
|
||||
default['openstack']['mq']['qpid']['topology_version'] = 1
|
||||
qpid_defaults = {
|
||||
username: node['openstack']['mq']['user'],
|
||||
sasl_mechanisms: '',
|
||||
reconnect: true,
|
||||
reconnect_timeout: 0,
|
||||
reconnect_limit: 0,
|
||||
reconnect_interval_min: 0,
|
||||
reconnect_interval_max: 0,
|
||||
reconnect_interval: 0,
|
||||
heartbeat: 60,
|
||||
protocol: node['openstack']['mq']['qpid']['protocol'],
|
||||
tcp_nodelay: true,
|
||||
host: node['openstack']['endpoints']['mq']['host'],
|
||||
port: node['openstack']['endpoints']['mq']['port'],
|
||||
qpid_hosts: ["#{node['openstack']['endpoints']['mq']['host']}:#{node['openstack']['endpoints']['mq']['port']}"],
|
||||
topology_version: node['openstack']['mq']['qpid']['topology_version']
|
||||
}
|
||||
|
||||
rabbit_defaults = {
|
||||
rabbit_max_retries: 0,
|
||||
rabbit_retry_interval: 1,
|
||||
|
@ -126,15 +105,8 @@ services.each do |svc|
|
|||
default['openstack']['mq'][svc]['auto_delete'] =
|
||||
node['openstack']['mq']['auto_delete']
|
||||
|
||||
case node['openstack']['mq'][svc]['service_type']
|
||||
when 'qpid'
|
||||
qpid_defaults.each do |key, val|
|
||||
default['openstack']['mq'][svc]['qpid'][key.to_s] = val
|
||||
end
|
||||
when 'rabbitmq'
|
||||
rabbit_defaults.each do |key, val|
|
||||
default['openstack']['mq'][svc]['rabbit'][key.to_s] = val
|
||||
end
|
||||
rabbit_defaults.each do |key, val|
|
||||
default['openstack']['mq'][svc]['rabbit'][key.to_s] = val
|
||||
end
|
||||
end
|
||||
|
||||
|
@ -142,15 +114,11 @@ end
|
|||
# Overrides and additional attributes for individual services
|
||||
###################################################################
|
||||
# bare-metal
|
||||
default['openstack']['mq']['bare-metal']['qpid']['notification_topic'] =
|
||||
node['openstack']['mq']['bare-metal']['notification_topic']
|
||||
default['openstack']['mq']['bare-metal']['rabbit']['notification_topic'] =
|
||||
node['openstack']['mq']['bare-metal']['notification_topic']
|
||||
default['openstack']['mq']['bare-metal']['control_exchange'] = 'ironic'
|
||||
|
||||
# block-storage
|
||||
default['openstack']['mq']['block-storage']['qpid']['notification_topic'] =
|
||||
node['openstack']['mq']['block-storage']['notification_topic']
|
||||
default['openstack']['mq']['block-storage']['rabbit']['notification_topic'] =
|
||||
node['openstack']['mq']['block-storage']['notification_topic']
|
||||
default['openstack']['mq']['block-storage']['control_exchange'] = 'cinder'
|
||||
|
@ -158,8 +126,6 @@ default['openstack']['mq']['block-storage']['control_exchange'] = 'cinder'
|
|||
# image
|
||||
default['openstack']['mq']['image']['notifier_strategy'] = 'noop'
|
||||
default['openstack']['mq']['image']['notification_topic'] = 'glance_notifications'
|
||||
default['openstack']['mq']['image']['qpid']['notification_topic'] =
|
||||
node['openstack']['mq']['image']['notification_topic']
|
||||
default['openstack']['mq']['image']['rabbit']['notification_topic'] =
|
||||
node['openstack']['mq']['image']['notification_topic']
|
||||
default['openstack']['mq']['image']['control_exchange'] = 'glance'
|
||||
|
|
|
@ -31,7 +31,7 @@ module ::Openstack
|
|||
# @param [String] tenant name
|
||||
# @return [Hash] environment
|
||||
def openstack_command_env(name, tenant)
|
||||
identity_admin_endpoint = endpoint 'identity-admin'
|
||||
identity_admin_endpoint = admin_endpoint 'identity'
|
||||
auth_uri = ::URI.decode identity_admin_endpoint.to_s
|
||||
pass = get_password 'user', name
|
||||
{
|
||||
|
@ -78,7 +78,7 @@ module ::Openstack
|
|||
# @param [String] optional uuid field to match
|
||||
# @return [String] uuid or nil
|
||||
#
|
||||
def get_uuid(client, type, key, value, env, args = {}, uuid_field = 'id') # rubocop: disable ParameterLists
|
||||
def get_uuid(client, type, key, value, env, args = {}, uuid_field = 'id') # rubocop: disable ParameterLists
|
||||
begin
|
||||
output = openstack_command(client, "#{type}-list", env, args)
|
||||
prettytable_to_array(output).each do |obj|
|
||||
|
|
|
@ -0,0 +1,48 @@
|
|||
# encoding: UTF-8
|
||||
|
||||
#
|
||||
# Cookbook Name:: openstack-common
|
||||
# library:: config_helpers
|
||||
#
|
||||
# Copyright 2016, cloudbau GmbH
|
||||
#
|
||||
# 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.
|
||||
#
|
||||
|
||||
# config helper methods
|
||||
module ::Openstack
|
||||
# return a Mash with config options which can be used for the service config
|
||||
# templates
|
||||
# @param [String] service
|
||||
def merge_config_options(service)
|
||||
conf = deep_dup(node['openstack'][service]['conf'])
|
||||
if node['openstack'][service]['conf_secrets']
|
||||
conf_secrets = deep_dup(node['openstack'][service]['conf_secrets'])
|
||||
else
|
||||
conf_secrets = {}
|
||||
end
|
||||
Chef::Mixin::DeepMerge.merge(conf, conf_secrets)
|
||||
end
|
||||
|
||||
# return a full dup of the given Mash even if nested
|
||||
# @param kind_of(Mash) can be a Chef::Node::ImmutableMash and will output a
|
||||
# simple Mash on all layers
|
||||
def deep_dup(mash)
|
||||
duplicate = mash.dup
|
||||
duplicate.each_pair do |k, v|
|
||||
tv = duplicate[k]
|
||||
duplicate[k] = tv.is_a?(Hash) && v.is_a?(Hash) ? deep_dup(tv) : v
|
||||
end
|
||||
duplicate
|
||||
end
|
||||
end
|
|
@ -19,29 +19,8 @@
|
|||
# limitations under the License.
|
||||
#
|
||||
|
||||
require 'uri'
|
||||
|
||||
# Endpoint methods
|
||||
module ::Openstack
|
||||
# Shortcut to get the full URI for an endpoint, and return it as a URI object
|
||||
# First we get the attribute hash for the endpoint, using endpoint_for().
|
||||
# Then we call uri_from_hash(). If the hash has a 'uri' key,
|
||||
# this gets converted to a URI object and returned. If not, a URI object is
|
||||
# constructed from the endpoint parts in the endpoint hash, and returned
|
||||
def endpoint(name)
|
||||
ep = endpoint_for(name)
|
||||
uri_from_hash(ep) if ep
|
||||
end
|
||||
|
||||
# Useful for iterating over the OpenStack endpoints
|
||||
def endpoints(&block)
|
||||
node['openstack']['endpoints'].each do |name, info|
|
||||
block.call(name, info)
|
||||
end
|
||||
rescue
|
||||
nil
|
||||
end
|
||||
|
||||
# Instead of specifying the verbose node['openstack']['db'][service],
|
||||
# this shortcut allows the simpler and shorter db(service), where
|
||||
# service can be: 'compute', 'image', 'identity', 'network', etc.
|
||||
|
@ -57,7 +36,7 @@ module ::Openstack
|
|||
return unless info
|
||||
|
||||
if is_slave
|
||||
host = info['slave_host']
|
||||
host = info['slave_host']
|
||||
port = info['slave_port'].to_s
|
||||
else
|
||||
host = info['host']
|
||||
|
@ -89,67 +68,11 @@ module ::Openstack
|
|||
end
|
||||
end
|
||||
|
||||
# Return the address for the hash.
|
||||
#
|
||||
# If the bind_interface is set, then return the first IP on the interface.
|
||||
# otherwise return the IP specified in the host attribute.
|
||||
def address(hash)
|
||||
bind_interface = hash['bind_interface'] if hash['bind_interface']
|
||||
|
||||
if bind_interface
|
||||
return address_for bind_interface
|
||||
else
|
||||
return hash['host']
|
||||
# Find the specific endpoint type ('internal', 'admin' or
|
||||
# 'public') for the given service.
|
||||
%w(public internal admin).each do |ep_type|
|
||||
define_method "#{ep_type}_endpoint" do |service|
|
||||
uri_from_hash(node['openstack']['endpoints'][service][ep_type])
|
||||
end
|
||||
end
|
||||
|
||||
# Get the admin endpoint for the specified service.
|
||||
# If there's no specific endpoint, then get the general service endpoint.
|
||||
def admin_endpoint(name)
|
||||
ep = specific_endpoint('admin', name)
|
||||
uri_from_hash(ep) if ep
|
||||
end
|
||||
|
||||
# Get the public endpoint for the specified service.
|
||||
# If there's no specific endpoint, then get the general service endpoint.
|
||||
def public_endpoint(name)
|
||||
ep = specific_endpoint('public', name)
|
||||
uri_from_hash(ep) if ep
|
||||
end
|
||||
|
||||
# Get the internal endpoint for the specified service.
|
||||
# If there's no specific endpoint, then get the general service endpoint.
|
||||
def internal_endpoint(name)
|
||||
ep = specific_endpoint('internal', name)
|
||||
uri_from_hash(ep) if ep
|
||||
end
|
||||
|
||||
private
|
||||
|
||||
# Instead of specifying the verbose node['openstack']['endpoints'][name],
|
||||
# this shortcut allows the simpler and shorter endpoint(name)
|
||||
def endpoint_for(name)
|
||||
node['openstack']['endpoints'][name]
|
||||
rescue
|
||||
nil
|
||||
end
|
||||
|
||||
# Attempt to find the specific endpoint type ('internal', 'admin', or
|
||||
# 'public') for the given name. If it's not found, then return the
|
||||
# general endpoint.
|
||||
def specific_endpoint(type, name)
|
||||
if node['openstack']['endpoints'][type].include? name
|
||||
node['openstack']['endpoints'][type][name]
|
||||
else
|
||||
# There may have been a subhash for the specified type, but it
|
||||
# didn't have the name we were looking for (and didn't throw
|
||||
# an exception either). In this case, attempt to use the general
|
||||
# endpoit
|
||||
endpoint_for(name)
|
||||
end
|
||||
rescue
|
||||
# Problem doing hash lookups for requested type of endpoint. Use
|
||||
# general endpoint instead
|
||||
endpoint_for(name)
|
||||
end
|
||||
end
|
||||
|
|
|
@ -45,7 +45,7 @@ module ::Openstack
|
|||
|
||||
private
|
||||
|
||||
def get_address(addresses, family, drop_vips)
|
||||
def get_address(addresses, family, drop_vips)
|
||||
case family
|
||||
when 'inet'
|
||||
vip_prefixlen = '32'
|
||||
|
|
|
@ -26,21 +26,12 @@ module ::Openstack
|
|||
# Returns a uri::URI from a hash. If the hash has a 'uri' key, the value
|
||||
# of that is returned. If not, then the routine attempts to construct
|
||||
# the URI from other parts of the hash. The values of the 'port' and 'path'
|
||||
# keys are used directly from the hash. For the host, if the
|
||||
# 'bind_interface' key is non-nil then it will use the first IP address on
|
||||
# the specified interface, otherwise it will use the value of the 'host' key
|
||||
# from the hash.
|
||||
#
|
||||
# Returns nil if the 'uri' key does not exist in the supplied hash and if
|
||||
# the determined host is nil (both the values of the 'bind_interface' and
|
||||
# 'host' keys are nil).
|
||||
# keys are used directly from the hash.
|
||||
def uri_from_hash(hash)
|
||||
if hash['uri']
|
||||
::URI.parse ::URI.encode(hash['uri'])
|
||||
else
|
||||
host = address hash
|
||||
return nil unless host
|
||||
|
||||
host = hash['host']
|
||||
scheme = hash['scheme'] ? hash['scheme'] : 'http'
|
||||
port = hash['port'] # Returns nil if missing, which is fine.
|
||||
path = hash['path'] # Returns nil if missing, which is fine.
|
||||
|
|
|
@ -4,15 +4,13 @@ maintainer_email 'openstack-dev@lists.openstack.org'
|
|||
license 'Apache 2.0'
|
||||
description 'Common OpenStack attributes, libraries and recipes.'
|
||||
long_description IO.read(File.join(File.dirname(__FILE__), 'README.md'))
|
||||
version '12.0.0'
|
||||
version '13.0.0'
|
||||
|
||||
recipe 'openstack-common', 'Installs/Configures common recipes'
|
||||
recipe 'openstack-common::set_endpoints_by_interface', 'Set endpoints by interface'
|
||||
recipe 'openstack-common::logging', 'Installs/Configures common logging'
|
||||
recipe 'openstack-common::sysctl', 'Configures sysctl settings'
|
||||
recipe 'openstack-common::openrc', 'Creates openrc file'
|
||||
|
||||
%w(ubuntu suse redhat centos).each do |os|
|
||||
%w(ubuntu redhat centos).each do |os|
|
||||
supports os
|
||||
end
|
||||
|
||||
|
|
|
@ -70,7 +70,7 @@ def create_db(db_name, db_prov, connection_info, db_type)
|
|||
end
|
||||
|
||||
def create_db_user(user, user_prov, connection_info, pass)
|
||||
database_user "create database user #{user}" do
|
||||
database_user "create database user #{user}" do
|
||||
provider user_prov
|
||||
connection connection_info
|
||||
username user
|
||||
|
|
|
@ -61,52 +61,6 @@ when 'rhel'
|
|||
enabled true
|
||||
action repo_action
|
||||
end
|
||||
|
||||
when 'suse'
|
||||
if node['lsb']['description'].nil?
|
||||
# Ohai lsb does not work at all on SLES11SP3
|
||||
# See https://tickets.opscode.com/browse/OHAI-454
|
||||
# Until then, copy chef's lsb_release parsing code from its lsb module.
|
||||
package 'lsb-release'
|
||||
|
||||
Mixlib::ShellOut.new('lsb_release -a').run_command.stdout.split("\n").each do |line|
|
||||
case line
|
||||
when /^Description:\s+(.+)$/
|
||||
node.set_unless['lsb']['description'] = Regexp.last_match[1]
|
||||
when /^Release:\s+(.+)$/
|
||||
node.set_unless['lsb']['release'] = Regexp.last_match[1]
|
||||
end
|
||||
end
|
||||
end
|
||||
if node['lsb']['description'][/^SUSE Linux Enterprise Server/]
|
||||
release, patchlevel = node['platform_version'].split('.')
|
||||
zypp_release = "SLE_#{release}_SP#{patchlevel}"
|
||||
elsif node['lsb']['description'][/^openSUSE/]
|
||||
zypp_release = 'openSUSE_' + node['lsb']['release']
|
||||
end
|
||||
zypp = node['openstack']['zypp']
|
||||
repo_uri = zypp['uri'].gsub(
|
||||
'%release%', node['openstack']['release'].capitalize)
|
||||
repo_uri.gsub! '%suse-release%', zypp_release
|
||||
repo_alias = 'Cloud:OpenStack:' + node['openstack']['release'].capitalize
|
||||
|
||||
# TODO(iartarisi) this should be moved to its own cookbook
|
||||
bash 'add repository key' do
|
||||
cwd '/tmp'
|
||||
code <<-EOH
|
||||
gpg --keyserver pgp.mit.edu --recv-keys #{zypp['repo-key']}
|
||||
gpg --armor --export #{zypp['repo-key']} > cloud.asc
|
||||
rpm --import cloud.asc
|
||||
rm -f cloud.asc
|
||||
EOH
|
||||
|
||||
not_if { Mixlib::ShellOut.new('rpm -qa gpg-pubkey*').run_command.stdout.include? zypp['repo-key'].downcase }
|
||||
end
|
||||
|
||||
execute 'add repository' do
|
||||
command "zypper addrepo --check #{repo_uri} #{repo_alias}"
|
||||
not_if { Mixlib::ShellOut.new('zypper repos --export -').run_command.stdout.include? repo_uri }
|
||||
end
|
||||
end
|
||||
|
||||
if node['openstack']['databag_type'] == 'vault'
|
||||
|
|
|
@ -1,69 +0,0 @@
|
|||
# encoding: UTF-8
|
||||
#
|
||||
# Cookbook Name:: openstack-common
|
||||
# recipe:: openrc
|
||||
#
|
||||
# Copyright 2014 IBM Corp.
|
||||
#
|
||||
# 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.
|
||||
#
|
||||
|
||||
# Chef
|
||||
class ::Chef::Recipe
|
||||
include ::Openstack
|
||||
end
|
||||
|
||||
# check attributes before searching
|
||||
if node['openstack']['identity'] && node['openstack']['identity']['admin_tenant_name'] && node['openstack']['identity']['admin_user']
|
||||
ksadmin_tenant_name = node['openstack']['identity']['admin_tenant_name']
|
||||
ksadmin_user = node['openstack']['identity']['admin_user']
|
||||
else
|
||||
identity_service_role = node['openstack']['identity_service_chef_role']
|
||||
keystone = search_for(identity_service_role).first
|
||||
|
||||
if keystone.nil?
|
||||
Chef::Log.warn("openrc not created, identity role node not found: #{identity_service_role}")
|
||||
return
|
||||
end
|
||||
|
||||
ksadmin_tenant_name = keystone['openstack']['identity']['admin_tenant_name']
|
||||
ksadmin_user = keystone['openstack']['identity']['admin_user']
|
||||
end
|
||||
|
||||
ksadmin_pass = get_password 'user', ksadmin_user
|
||||
identity_endpoint = endpoint 'identity-api'
|
||||
volume_api_version = 2
|
||||
volume_api_path = node['openstack']['endpoints']['block-storage-api']['path']
|
||||
volume_api_version = volume_api_path[/\d/].to_i unless volume_api_path.to_s.empty?
|
||||
|
||||
directory node['openstack']['openrc']['path'] do
|
||||
owner node['openstack']['openrc']['user']
|
||||
group node['openstack']['openrc']['group']
|
||||
mode node['openstack']['openrc']['path_mode']
|
||||
recursive true
|
||||
end
|
||||
|
||||
template "#{node['openstack']['openrc']['path']}/#{node['openstack']['openrc']['file']}" do
|
||||
source 'openrc.erb'
|
||||
owner node['openstack']['openrc']['user']
|
||||
group node['openstack']['openrc']['group']
|
||||
mode node['openstack']['openrc']['file_mode']
|
||||
sensitive true
|
||||
variables(
|
||||
user: ksadmin_user,
|
||||
tenant: ksadmin_tenant_name,
|
||||
password: ksadmin_pass,
|
||||
identity_endpoint: identity_endpoint.to_s,
|
||||
volume_api_version: volume_api_version
|
||||
)
|
||||
end
|
|
@ -1,35 +0,0 @@
|
|||
# encoding: UTF-8
|
||||
#
|
||||
# Cookbook Name:: openstack-common
|
||||
# recipe:: set_endpoints_by_interface
|
||||
#
|
||||
# Copyright 2013, Opscode, Inc.
|
||||
#
|
||||
# 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.
|
||||
#
|
||||
|
||||
# Chef
|
||||
class ::Chef::Recipe
|
||||
include ::Openstack
|
||||
end
|
||||
|
||||
# iterate over the endpoints, look for bind_interface to set the host
|
||||
node['openstack']['endpoints'].keys.each do |component|
|
||||
# Skip the overrides at the parent level
|
||||
unless %w(host, family, bind-host, bind_interface).include? component
|
||||
unless node['openstack']['endpoints'][component]['bind_interface'].nil?
|
||||
ip_address = address node['openstack']['endpoints'][component]
|
||||
node.default['openstack']['endpoints'][component]['host'] = ip_address
|
||||
end
|
||||
end
|
||||
end
|
|
@ -14,6 +14,14 @@ describe 'openstack-common::default' do
|
|||
include_context 'library-stubs'
|
||||
|
||||
describe 'openstack_command_env' do
|
||||
before do
|
||||
node.set['openstack']['endpoints']['identity']['admin'] = {
|
||||
host: '127.0.0.1',
|
||||
scheme: 'http',
|
||||
path: '/v2.0',
|
||||
port: '35357'
|
||||
}
|
||||
end
|
||||
it 'returns cli enviroment' do
|
||||
allow(subject).to receive(:get_password)
|
||||
.with('user', 'name')
|
||||
|
|
|
@ -0,0 +1,56 @@
|
|||
# encoding: UTF-8
|
||||
require_relative 'spec_helper'
|
||||
require ::File.join ::File.dirname(__FILE__), '..', 'libraries', 'config_helpers'
|
||||
|
||||
describe 'openstack-common::default' do
|
||||
describe 'module Openstack config_helpers' do
|
||||
let(:runner) { ChefSpec::SoloRunner.new(CHEFSPEC_OPTS) }
|
||||
let(:node) { runner.node }
|
||||
let(:chef_run) do
|
||||
runner.converge(described_recipe)
|
||||
end
|
||||
let(:subject) { Object.new.extend(Openstack) }
|
||||
include_context 'library-stubs'
|
||||
before do
|
||||
node.set['openstack']['anyservice']['conf'] =
|
||||
{
|
||||
'Default' => { 'logfile' => 'file_to_log' },
|
||||
'secret_section' => {},
|
||||
'another_section' => { 'foo' => 'bar', 'baz' => 'yay' },
|
||||
'deep_section' => {
|
||||
'foo' => { key: 'bar', value: 'baz' },
|
||||
'baz' => 'yay'
|
||||
}
|
||||
}
|
||||
node.set['openstack']['anyservice']['conf_secrets'] =
|
||||
{
|
||||
'Default' => { 'secret_log' => 'secret_file_to_log' },
|
||||
'secret_section' => { 'password' => '1234' },
|
||||
'another_section' => { 'secret_foo' => 'secret_bar' },
|
||||
'another_secret_section' => { 'secret_baz' => 'secret_yay' }
|
||||
}
|
||||
end
|
||||
|
||||
describe 'merge_config_options' do
|
||||
it ' node objects should be duped and be kind of Mash afterwards' do
|
||||
expect(
|
||||
subject.merge_config_options('anyservice')
|
||||
).to be_a(Mash)
|
||||
end
|
||||
it 'duped node objects should be merged correctly' do
|
||||
expect(
|
||||
subject.merge_config_options('anyservice')
|
||||
).to eq(
|
||||
'Default' => { 'logfile' => 'file_to_log', 'secret_log' => 'secret_file_to_log' },
|
||||
'secret_section' => { 'password' => '1234' },
|
||||
'another_section' => { 'foo' => 'bar', 'baz' => 'yay', 'secret_foo' => 'secret_bar' },
|
||||
'another_secret_section' => { 'secret_baz' => 'secret_yay' },
|
||||
'deep_section' => {
|
||||
'foo' => { 'key' => 'bar', 'value' => 'baz' },
|
||||
'baz' => 'yay'
|
||||
}
|
||||
)
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
|
@ -1,46 +0,0 @@
|
|||
# encoding: UTF-8
|
||||
require_relative 'spec_helper'
|
||||
|
||||
describe 'openstack-common::default' do
|
||||
describe 'suse' do
|
||||
let(:runner) { ChefSpec::SoloRunner.new(SUSE_OPTS) }
|
||||
let(:node) { runner.node }
|
||||
let(:chef_run) do
|
||||
node.set_unless['lsb']['description'] = 'SUSE Linux Enterprise Server 11 (x86_64)'
|
||||
node.set_unless['lsb']['release'] = '11'
|
||||
runner.converge(described_recipe)
|
||||
end
|
||||
|
||||
it 'adds the openstack repository key, but not the repository' do
|
||||
allow(Mixlib::ShellOut).to receive_message_chain(
|
||||
new: 'rpm -qa gpg-pubkey', run_command: nil, stdout: nil,
|
||||
new: 'zypper repos --export -').and_return(
|
||||
'http://download.opensuse.org/repositories/Cloud:/OpenStack:/Liberty/SLE_11_SP3/')
|
||||
|
||||
expect(chef_run).to run_bash('add repository key')
|
||||
expect(chef_run).not_to run_execute('add repository').with(command: /zypper addrepo/)
|
||||
end
|
||||
|
||||
it 'adds the repository and the key' do
|
||||
allow(Mixlib::ShellOut).to receive_message_chain(
|
||||
new: 'rpm -qa gpg-pubkey', run_command: nil, stdout: nil,
|
||||
new: 'zypper repos --export -').and_return('')
|
||||
|
||||
expect(chef_run).to run_bash('add repository key')
|
||||
expect(chef_run).to run_execute('add repository').with(
|
||||
command: 'zypper addrepo --check '\
|
||||
"http://download.opensuse.org/repositories/Cloud:/OpenStack:/#{node['openstack']['release'].capitalize}/SLE_11_SP3/ "\
|
||||
'Cloud:OpenStack:Liberty')
|
||||
end
|
||||
|
||||
it 'does not add the repository nor the key' do
|
||||
allow(Mixlib::ShellOut).to receive_message_chain(
|
||||
new: 'rpm -qa gpg-pubkey', run_command: nil, stdout: nil,
|
||||
new: 'zypper repos --export -').and_return(
|
||||
'd85f9316',
|
||||
'http://download.opensuse.org/repositories/Cloud:/OpenStack:/Liberty/SLE_11_SP3/')
|
||||
expect(chef_run).not_to run_bash('add repository key')
|
||||
expect(chef_run).not_to run_execute('add repository').with(command: /zypper addrepo/)
|
||||
end
|
||||
end
|
||||
end
|
|
@ -49,50 +49,6 @@ describe 'openstack-common::default' do
|
|||
.with(version: '~> 2.3')
|
||||
end
|
||||
|
||||
it 'has correct host for endpoints' do
|
||||
%w(identity-api identity-internal identity-admin compute-api compute-ec2-api compute-ec2-admin
|
||||
compute-xvpvnc compute-novnc compute-vnc compute-metadata-api compute-serial-proxy network-api
|
||||
network-linuxbridge network-openvswitch image-api block-storage-api object-storage-api
|
||||
telemetry-api orchestration-api orchestration-api-cfn orchestration-api-cloudwatch
|
||||
database-api bare-metal-api).each do |endpoint|
|
||||
expect(chef_run.node['openstack']['endpoints'][endpoint]['host']).to eq('127.0.0.1')
|
||||
end
|
||||
end
|
||||
|
||||
it 'allows bind_interface override for all bind endpoints' do
|
||||
node.set['openstack']['endpoints']['bind_interface'] = 'eth1'
|
||||
%w(identity-bind identity-admin-bind compute-api-bind compute-ec2-api-bind compute-ec2-admin-bind
|
||||
compute-xvpvnc-bind compute-novnc-bind compute-vnc-bind compute-vnc-proxy-bind compute-metadata-api-bind
|
||||
compute-serial-console-bind network-api-bind image-api-bind image-registry-bind block-storage-api-bind
|
||||
object-storage-api-bind telemetry-api-bind orchestration-api-bind orchestration-api-cfn-bind
|
||||
orchestration-api-cloudwatch-bind database-api-bind bare-metal-api-bind dashboard-http-bind
|
||||
dashboard-https-bind).each do |endpoint|
|
||||
expect(chef_run.node['openstack']['endpoints'][endpoint]['bind_interface']).to eq('eth1')
|
||||
end
|
||||
end
|
||||
|
||||
it 'has correct bind-host for all bind endpoints' do
|
||||
%w(identity-bind identity-admin-bind compute-api-bind compute-ec2-api-bind compute-ec2-admin-bind
|
||||
compute-xvpvnc-bind compute-novnc-bind compute-vnc-bind compute-metadata-api-bind
|
||||
compute-serial-console-bind network-api-bind image-api-bind image-registry-bind block-storage-api-bind
|
||||
object-storage-api-bind telemetry-api-bind orchestration-api-bind orchestration-api-cfn-bind
|
||||
orchestration-api-cloudwatch-bind database-api-bind bare-metal-api-bind dashboard-http-bind
|
||||
dashboard-https-bind).each do |endpoint|
|
||||
expect(chef_run.node['openstack']['endpoints'][endpoint]['host']).to eq('127.0.0.1')
|
||||
end
|
||||
end
|
||||
|
||||
it 'allows scheme for all bind endpoints' do
|
||||
node.set['openstack']['endpoints']['scheme'] = 'https'
|
||||
%w(identity-api identity-internal identity-admin compute-api compute-ec2-api compute-ec2-admin
|
||||
compute-xvpvnc compute-novnc compute-metadata-api
|
||||
network-api image-api image-registry block-storage-api object-storage-api
|
||||
telemetry-api orchestration-api orchestration-api-cfn orchestration-api-cloudwatch
|
||||
database-api bare-metal-api).each do |endpoint|
|
||||
expect(chef_run.node['openstack']['endpoints'][endpoint]['scheme']).to eq('https')
|
||||
end
|
||||
end
|
||||
|
||||
context 'rabbit mq' do
|
||||
rabbit_opts = {
|
||||
'userid' => 'guest',
|
||||
|
|
|
@ -3,303 +3,99 @@ require_relative 'spec_helper'
|
|||
require ::File.join ::File.dirname(__FILE__), '..', 'libraries', 'uri'
|
||||
require ::File.join ::File.dirname(__FILE__), '..', 'libraries', 'endpoints'
|
||||
|
||||
describe 'openstack-common::set_endpoints_by_interface' do
|
||||
describe 'openstack-common::default' do
|
||||
describe 'Openstack endpoints' do
|
||||
let(:runner) { ChefSpec::SoloRunner.new(CHEFSPEC_OPTS) }
|
||||
let(:node) { runner.node }
|
||||
let(:chef_run) { runner.converge(described_recipe) }
|
||||
let(:subject) { Object.new.extend(Openstack) }
|
||||
|
||||
describe '#endpoint' do
|
||||
it 'returns nil when no openstack.endpoints not in node attrs' do
|
||||
allow(subject).to receive(:node).and_return({})
|
||||
expect(
|
||||
subject.endpoint('nonexisting')
|
||||
).to be_nil
|
||||
end
|
||||
|
||||
it 'returns nil when no such endpoint was found' do
|
||||
allow(subject).to receive(:node).and_return(node)
|
||||
expect(
|
||||
subject.endpoint('nonexisting')
|
||||
).to be_nil
|
||||
end
|
||||
|
||||
it 'handles a URI needing escaped' do
|
||||
uri_hash = {
|
||||
'openstack' => {
|
||||
'endpoints' => {
|
||||
'compute-api' => {
|
||||
'uri' => 'http://localhost:8080/v2/%(tenant_id)s'
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
allow(subject).to receive(:node).and_return(uri_hash)
|
||||
expect(
|
||||
subject.endpoint('compute-api').path
|
||||
).to eq('/v2/%25(tenant_id)s')
|
||||
end
|
||||
|
||||
it 'returns endpoint URI object when uri key in endpoint hash' do
|
||||
uri_hash = {
|
||||
'openstack' => {
|
||||
'endpoints' => {
|
||||
'compute-api' => {
|
||||
'uri' => 'http://localhost:8080/path'
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
allow(subject).to receive(:node).and_return(uri_hash)
|
||||
expect(
|
||||
subject.endpoint('compute-api').port
|
||||
).to eq(8080)
|
||||
end
|
||||
|
||||
it 'returns endpoint URI string when uri key in endpoint hash and host also in hash' do
|
||||
uri_hash = {
|
||||
'openstack' => {
|
||||
'endpoints' => {
|
||||
'compute-api' => {
|
||||
'uri' => 'http://localhost',
|
||||
'host' => 'ignored'
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
allow(subject).to receive(:node).and_return(uri_hash)
|
||||
expect(subject.endpoint('compute-api').to_s).to eq('http://localhost')
|
||||
end
|
||||
|
||||
it 'returns endpoint URI object when uri key not in endpoint hash but host is in hash' do
|
||||
skip 'TODO: implement'
|
||||
subject.should_receive(:uri_from_hash).with('host' => 'localhost', 'port' => '8080')
|
||||
uri_hash = {
|
||||
'openstack' => {
|
||||
'endpoints' => {
|
||||
'compute-api' => {
|
||||
'host' => 'localhost',
|
||||
'port' => '8080'
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
allow(subject).to receive(:node).and_return(uri_hash)
|
||||
subject.endpoint 'compute-api'
|
||||
end
|
||||
|
||||
it 'endpoints recipe bind_interface sets host' do
|
||||
node.set['openstack']['endpoints']['identity-api']['bind_interface'] = 'eth0'
|
||||
node.set['network'] = {
|
||||
'interfaces' => {
|
||||
'lo' => {
|
||||
'addresses' => {
|
||||
'127.0.0.1' => {
|
||||
'family' => 'inet',
|
||||
'netmask' => '255.0.0.0',
|
||||
'scope' => 'Node'
|
||||
}
|
||||
}
|
||||
},
|
||||
'eth0' => {
|
||||
'addresses' => {
|
||||
'10.0.0.100' => {
|
||||
'family' => 'inet',
|
||||
'netmask' => '255.255.255.0',
|
||||
'scope' => 'Global'
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
allow(subject).to receive('address_for').and_return('10.0.0.100')
|
||||
expect(
|
||||
chef_run.node['openstack']['endpoints']['identity-api']['host']
|
||||
).to eq('10.0.0.100')
|
||||
end
|
||||
end
|
||||
|
||||
describe '#admin_endpoint' do
|
||||
it 'returns nil admin_endpoint when not exists' do
|
||||
allow(subject).to receive(:node).and_return({})
|
||||
expect(
|
||||
subject.admin_endpoint('nonexisting')
|
||||
).to be_nil
|
||||
end
|
||||
|
||||
it 'returns general endpoint no admin endpoint exists' do
|
||||
uri_hash = {
|
||||
'openstack' => {
|
||||
'endpoints' => {
|
||||
'compute-api' => {
|
||||
'uri' => 'http://localhost:8080/path'
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
allow(subject).to receive(:node).and_return(uri_hash)
|
||||
expect(subject.admin_endpoint('compute-api').to_s).to eq('http://localhost:8080/path')
|
||||
end
|
||||
|
||||
it 'returns admin endpoint when it exists' do
|
||||
uri_hash = {
|
||||
'openstack' => {
|
||||
'endpoints' => {
|
||||
'compute-api' => {
|
||||
'uri' => 'http://localhost:8080/path'
|
||||
},
|
||||
'admin' => {
|
||||
'compute-api' => {
|
||||
'uri' => 'https://localhost:1234/path'
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
allow(subject).to receive(:node).and_return(uri_hash)
|
||||
expect(subject.admin_endpoint('compute-api').to_s).to eq('https://localhost:1234/path')
|
||||
# Make sure that the general endpoint didn't break
|
||||
expect(subject.endpoint('compute-api').to_s).to eq('http://localhost:8080/path')
|
||||
end
|
||||
|
||||
it 'one admin endpoint not masking another' do
|
||||
uri_hash = {
|
||||
'openstack' => {
|
||||
'endpoints' => {
|
||||
'compute-api' => {
|
||||
'uri' => 'http://localhost:8080/path'
|
||||
},
|
||||
'foo' => {
|
||||
'uri' => 'http://localhost:8080/foo'
|
||||
},
|
||||
'admin' => {
|
||||
'compute-api' => {
|
||||
'uri' => 'https://localhost:1234/path'
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
allow(subject).to receive(:node).and_return(uri_hash)
|
||||
expect(subject.admin_endpoint('compute-api').to_s).to eq('https://localhost:1234/path')
|
||||
# Make sure that the general endpoint didn't break
|
||||
expect(subject.endpoint('compute-api').to_s).to eq('http://localhost:8080/path')
|
||||
# Make sure foo admin_endpoint is from general definition
|
||||
expect(subject.admin_endpoint('foo').to_s).to eq('http://localhost:8080/foo')
|
||||
end
|
||||
end
|
||||
|
||||
describe '#public_endpoint' do
|
||||
it 'returns nil public_endpoint when not exists' do
|
||||
allow(subject).to receive(:node).and_return({})
|
||||
expect(
|
||||
subject.public_endpoint('nonexisting')
|
||||
).to be_nil
|
||||
end
|
||||
|
||||
it 'returns general endpoint no public endpoint exists' do
|
||||
uri_hash = {
|
||||
'openstack' => {
|
||||
'endpoints' => {
|
||||
'compute-api' => {
|
||||
'uri' => 'http://localhost:8080/path'
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
allow(subject).to receive(:node).and_return(uri_hash)
|
||||
expect(subject.public_endpoint('compute-api').to_s).to eq('http://localhost:8080/path')
|
||||
end
|
||||
|
||||
it 'returns public endpoint when it exists' do
|
||||
uri_hash = {
|
||||
'openstack' => {
|
||||
'endpoints' => {
|
||||
'compute-api' => {
|
||||
'uri' => 'http://localhost:8080/path'
|
||||
},
|
||||
'public' => {
|
||||
'compute-api' => {
|
||||
'uri' => 'https://localhost:1234/path'
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
allow(subject).to receive(:node).and_return(uri_hash)
|
||||
expect(subject.public_endpoint('compute-api').to_s).to eq('https://localhost:1234/path')
|
||||
# Make sure that the general endpoint didn't break
|
||||
expect(subject.endpoint('compute-api').to_s).to eq('http://localhost:8080/path')
|
||||
end
|
||||
end
|
||||
|
||||
describe '#internal_endpoint' do
|
||||
it 'returns nil internal_endpoint when not exists' do
|
||||
allow(subject).to receive(:node).and_return({})
|
||||
expect(
|
||||
subject.internal_endpoint('nonexisting')
|
||||
).to be_nil
|
||||
end
|
||||
|
||||
it 'returns general endpoint no internal endpoint exists' do
|
||||
uri_hash = {
|
||||
'openstack' => {
|
||||
'endpoints' => {
|
||||
'compute-api' => {
|
||||
'uri' => 'http://localhost:8080/path'
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
allow(subject).to receive(:node).and_return(uri_hash)
|
||||
expect(subject.internal_endpoint('compute-api').to_s).to eq('http://localhost:8080/path')
|
||||
end
|
||||
|
||||
it 'returns internal endpoint when it exists' do
|
||||
uri_hash = {
|
||||
'openstack' => {
|
||||
'endpoints' => {
|
||||
'compute-api' => {
|
||||
'uri' => 'http://localhost:8080/path'
|
||||
},
|
||||
'internal' => {
|
||||
'compute-api' => {
|
||||
'uri' => 'https://localhost:1234/path'
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
allow(subject).to receive(:node).and_return(uri_hash)
|
||||
expect(subject.internal_endpoint('compute-api').to_s).to eq('https://localhost:1234/path')
|
||||
# Make sure that the general endpoint didn't break
|
||||
expect(subject.endpoint('compute-api').to_s).to eq('http://localhost:8080/path')
|
||||
end
|
||||
end
|
||||
|
||||
describe '#endpoints' do
|
||||
it 'does nothing when no endpoints' do
|
||||
allow(subject).to receive(:node).and_return({})
|
||||
expect(subject.endpoints).to be_nil
|
||||
end
|
||||
|
||||
it 'does nothing when empty endpoints' do
|
||||
allow(subject).to receive(:node).and_return('openstack' => { 'endpoints' => {} })
|
||||
count = 0
|
||||
subject.endpoints do
|
||||
count += 1
|
||||
%w(public internal admin).each do |ep_type|
|
||||
describe "#{ep_type}_endpoint" do
|
||||
it 'fails with a NoMethodError when no openstack.endpoints in node attrs' do
|
||||
allow(subject).to receive(:node).and_return({})
|
||||
expect do
|
||||
subject.send("#{ep_type}_endpoint", 'someservice')
|
||||
end.to raise_error(NoMethodError)
|
||||
end
|
||||
expect(count).to eq(0)
|
||||
end
|
||||
|
||||
it 'executes block count when have endpoints' do
|
||||
allow(subject).to receive(:node).and_return(chef_run.node)
|
||||
count = 0
|
||||
subject.endpoints do
|
||||
count += 1
|
||||
it 'fails with a NoMethodError when no endpoint was found' do
|
||||
allow(subject).to receive(:node).and_return(node)
|
||||
expect do
|
||||
subject.send("#{ep_type}_endpoint", 'someservice')
|
||||
end.to raise_error(NoMethodError)
|
||||
end
|
||||
|
||||
it 'handles a URI needing escaped' do
|
||||
uri_hash = {
|
||||
'openstack' => {
|
||||
'endpoints' => {
|
||||
'compute-api' => {
|
||||
ep_type => {
|
||||
'uri' => 'http://localhost:8080/v2/%(tenant_id)s'
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
allow(subject).to receive(:node).and_return(uri_hash)
|
||||
expect(
|
||||
subject.send("#{ep_type}_endpoint", 'compute-api').path
|
||||
).to eq('/v2/%25(tenant_id)s')
|
||||
end
|
||||
|
||||
it 'returns endpoint URI object when uri key in endpoint hash' do
|
||||
uri_hash = {
|
||||
'openstack' => {
|
||||
'endpoints' => {
|
||||
'compute-api' => {
|
||||
ep_type => {
|
||||
'uri' => 'http://localhost:1234/path'
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
allow(subject).to receive(:node).and_return(uri_hash)
|
||||
expect(
|
||||
subject.send("#{ep_type}_endpoint", 'compute-api').port
|
||||
).to eq(1234)
|
||||
end
|
||||
|
||||
it 'returns endpoint URI string when uri key in endpoint hash and host also in hash' do
|
||||
uri_hash = {
|
||||
'openstack' => {
|
||||
'endpoints' => {
|
||||
'compute-api' => {
|
||||
ep_type => {
|
||||
'uri' => 'http://localhost',
|
||||
'host' => 'ignored'
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
allow(subject).to receive(:node).and_return(uri_hash)
|
||||
expect(subject.send("#{ep_type}_endpoint", 'compute-api').to_s).to eq('http://localhost')
|
||||
end
|
||||
|
||||
it 'returns endpoint URI object when uri key not in endpoint hash but host is in hash' do
|
||||
subject.should_receive(:uri_from_hash).with('host' => 'localhost', 'port' => '1234')
|
||||
uri_hash = {
|
||||
'openstack' => {
|
||||
'endpoints' => {
|
||||
'compute-api' => {
|
||||
ep_type => {
|
||||
'host' => 'localhost',
|
||||
'port' => '1234'
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
allow(subject).to receive(:node).and_return(uri_hash)
|
||||
subject.send("#{ep_type}_endpoint", 'compute-api')
|
||||
end
|
||||
expect(count).to be >= 1
|
||||
end
|
||||
end
|
||||
|
||||
|
@ -404,28 +200,5 @@ describe 'openstack-common::set_endpoints_by_interface' do
|
|||
end
|
||||
end
|
||||
end
|
||||
|
||||
describe '#address' do
|
||||
it 'returns interface IP if bind_interface specified' do
|
||||
ep_hash = {
|
||||
'bind_interface' => 'eth0',
|
||||
'host' => '5.6.7.8'
|
||||
}
|
||||
allow(subject).to receive('address_for').and_return('1.2.3.4')
|
||||
expect(
|
||||
subject.address(ep_hash)
|
||||
).to eq('1.2.3.4')
|
||||
end
|
||||
it 'returns host IP if bind_interface not specified' do
|
||||
ep_hash = {
|
||||
'bind_interface' => nil,
|
||||
'host' => '5.6.7.8'
|
||||
}
|
||||
allow(subject).to receive('address_for').and_return('1.2.3.4')
|
||||
expect(
|
||||
subject.address(ep_hash)
|
||||
).to eq('5.6.7.8')
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
|
|
|
@ -1,66 +0,0 @@
|
|||
# encoding: UTF-8
|
||||
|
||||
require_relative 'spec_helper'
|
||||
|
||||
describe 'openstack-common::openrc' do
|
||||
describe 'ubuntu' do
|
||||
let(:runner) { ChefSpec::SoloRunner.new(UBUNTU_OPTS) }
|
||||
let(:node) { runner.node }
|
||||
let(:chef_run) do
|
||||
runner.converge(described_recipe)
|
||||
end
|
||||
|
||||
include_context 'common-stubs'
|
||||
|
||||
describe '/root/openrc' do
|
||||
let(:file) { chef_run.template('/root/openrc') }
|
||||
|
||||
it 'creates the /root/openrc file' do
|
||||
expect(chef_run).to create_directory('/root').with(
|
||||
owner: 'root',
|
||||
group: 'root',
|
||||
mode: '0700',
|
||||
recursive: true
|
||||
)
|
||||
expect(chef_run).to create_template(file.name).with(
|
||||
sensitive: true,
|
||||
user: 'root',
|
||||
group: 'root',
|
||||
mode: '0600'
|
||||
)
|
||||
end
|
||||
|
||||
it 'contains auth environment variables' do
|
||||
[
|
||||
/^export OS_USERNAME=admin$/,
|
||||
/^export OS_TENANT_NAME=admin$/,
|
||||
/^export OS_PASSWORD=admin$/,
|
||||
%r{^export OS_AUTH_URL=http://127.0.0.1:5000/v2.0$},
|
||||
/^export OS_REGION_NAME=RegionOne$/,
|
||||
/^export OS_VOLUME_API_VERSION=2$/
|
||||
].each do |line|
|
||||
expect(chef_run).to render_file(file.name).with_content(line)
|
||||
end
|
||||
end
|
||||
|
||||
it 'templates misc_openrc array correctly' do
|
||||
node.set['openstack']['misc_openrc'] = ['export MISC1=OPTION1', 'export MISC2=OPTION2']
|
||||
expect(chef_run).to render_file(file.name).with_content(
|
||||
/^export MISC1=OPTION1$/)
|
||||
expect(chef_run).to render_file(file.name).with_content(
|
||||
/^export MISC2=OPTION2$/)
|
||||
end
|
||||
|
||||
it 'contains overridden auth environment variables' do
|
||||
node.set['openstack']['identity']['admin_tenant_name'] = 'admin-tenant-name-override'
|
||||
node.set['openstack']['identity']['admin_user'] = 'admin-user-override'
|
||||
[
|
||||
/^export OS_USERNAME=admin-user-override$/,
|
||||
/^export OS_TENANT_NAME=admin-tenant-name-override$/
|
||||
].each do |line|
|
||||
expect(chef_run).to render_file(file.name).with_content(line)
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
|
@ -115,9 +115,9 @@ describe 'openstack-common::default' do
|
|||
|
||||
it 'returns sorted rabbit servers' do
|
||||
nodes = [
|
||||
{ 'openstack' => { 'mq' => { 'listen' => '3.3.3.3' }, 'endpoints' => { 'mq' => { 'port' => '5672' } } } },
|
||||
{ 'openstack' => { 'mq' => { 'listen' => '3.3.3.3' }, 'endpoints' => { 'mq' => { 'port' => '5672' } } } },
|
||||
{ 'openstack' => { 'mq' => { 'listen' => '1.1.1.1' }, 'endpoints' => { 'mq' => { 'port' => '5672' } } } },
|
||||
{ 'openstack' => { 'mq' => { 'listen' => '2.2.2.2' }, 'endpoints' => { 'mq' => { 'port' => '5672' } } } }
|
||||
{ 'openstack' => { 'mq' => { 'listen' => '2.2.2.2' }, 'endpoints' => { 'mq' => { 'port' => '5672' } } } }
|
||||
]
|
||||
allow(subject).to receive(:node).and_return(chef_run.node)
|
||||
allow(subject).to receive(:search_for)
|
||||
|
|
|
@ -15,11 +15,6 @@ REDHAT_OPTS = {
|
|||
version: '7.1',
|
||||
log_level: LOG_LEVEL
|
||||
}
|
||||
SUSE_OPTS = {
|
||||
platform: 'suse',
|
||||
version: '11.3',
|
||||
log_lovel: LOG_LEVEL
|
||||
}
|
||||
# We set a default platform for non-platform specific test cases
|
||||
CHEFSPEC_OPTS = UBUNTU_OPTS
|
||||
|
||||
|
|
|
@ -7,16 +7,6 @@ describe 'Openstack uri' do
|
|||
let(:subject) { Object.new.extend(Openstack) }
|
||||
|
||||
describe '#uri_from_hash' do
|
||||
it 'returns nil when no host or uri key found' do
|
||||
hash = {
|
||||
'port' => 8888,
|
||||
'path' => '/path'
|
||||
}
|
||||
expect(
|
||||
subject.uri_from_hash(hash)
|
||||
).to be_nil
|
||||
end
|
||||
|
||||
it 'returns uri when uri key found, ignoring other parts' do
|
||||
uri = 'http://localhost/'
|
||||
hash = {
|
||||
|
@ -57,7 +47,7 @@ describe 'Openstack uri' do
|
|||
uri = 'http://localhost'
|
||||
hash = {
|
||||
'host' => 'localhost',
|
||||
'network' => 'public' # To emulate the osops-utils::ip_location way...
|
||||
'network' => 'public' # To emulate the osops-utils::ip_location way...
|
||||
}
|
||||
expect(
|
||||
subject.uri_from_hash(hash).to_s
|
||||
|
|
|
@ -1,16 +0,0 @@
|
|||
<%= node['openstack']['common']['custom_template_banner'] %>
|
||||
|
||||
# COMMON OPENSTACK ENVS
|
||||
export OS_USERNAME=<%= @user %>
|
||||
export OS_PASSWORD=<%= @password %>
|
||||
export OS_TENANT_NAME=<%= @tenant %>
|
||||
export OS_AUTH_URL=<%= @identity_endpoint %>
|
||||
export OS_REGION_NAME=<%= node['openstack']['region'] %>
|
||||
export OS_VOLUME_API_VERSION=<%= @volume_api_version %>
|
||||
|
||||
<% if node['openstack']['misc_openrc'] %>
|
||||
# Misc options
|
||||
<% node['openstack']['misc_openrc'].each do |m| %>
|
||||
<%= m %>
|
||||
<% end %>
|
||||
<% end %>
|
|
@ -0,0 +1,12 @@
|
|||
<%= node['openstack']['common']['custom_template_banner'] %>
|
||||
<% @service_config.each do |section, values| -%>
|
||||
[<%= section %>]
|
||||
<% values.each do |key, value| -%>
|
||||
<% if value.class == Hash -%>
|
||||
<%= "# #{value['comment']}" -%>
|
||||
<%= key %> = <%= value['set_to'] %>
|
||||
<% else -%>
|
||||
<%= key %> = <%= value %>
|
||||
<% end -%>
|
||||
<% end -%>
|
||||
<% end -%>
|
Loading…
Reference in New Issue