---
cinder_services:
  cinder-api:
    container_name: cinder_api
    group: cinder-api
    enabled: true
    image: "{{ cinder_api_image_full }}"
    volumes: "{{ cinder_api_default_volumes + cinder_api_extra_volumes }}"
    dimensions: "{{ cinder_api_dimensions }}"
    healthcheck: "{{ cinder_api_healthcheck }}"
    wsgi: "cinder.wsgi.api:application"
    haproxy:
      cinder_api:
        enabled: "{{ enable_cinder }}"
        mode: "http"
        external: false
        port: "{{ cinder_api_port }}"
        listen_port: "{{ cinder_api_listen_port }}"
        tls_backend: "{{ cinder_enable_tls_backend }}"
        backend_http_extra:
          - "option httpchk"
      cinder_api_external:
        enabled: "{{ enable_cinder }}"
        mode: "http"
        external: true
        external_fqdn: "{{ cinder_external_fqdn }}"
        port: "{{ cinder_api_public_port }}"
        listen_port: "{{ cinder_api_listen_port }}"
        tls_backend: "{{ cinder_enable_tls_backend }}"
        backend_http_extra:
          - "option httpchk"
  cinder-scheduler:
    container_name: cinder_scheduler
    group: cinder-scheduler
    enabled: true
    image: "{{ cinder_scheduler_image_full }}"
    volumes: "{{ cinder_scheduler_default_volumes + cinder_scheduler_extra_volumes }}"
    dimensions: "{{ cinder_scheduler_dimensions }}"
    healthcheck: "{{ cinder_scheduler_healthcheck }}"
  cinder-volume:
    container_name: cinder_volume
    group: cinder-volume
    enabled: true
    image: "{{ cinder_volume_image_full }}"
    privileged: True
    ipc_mode: "host"
    tmpfs: "{{ cinder_volume_tmpfs }}"
    volumes: "{{ cinder_volume_default_volumes + cinder_volume_extra_volumes + lookup('vars', 'run_default_volumes_' + kolla_container_engine) }}"
    dimensions: "{{ cinder_volume_dimensions }}"
    healthcheck: "{{ cinder_volume_healthcheck }}"
  cinder-backup:
    container_name: cinder_backup
    group: cinder-backup
    enabled: "{{ enable_cinder_backup | bool }}"
    image: "{{ cinder_backup_image_full }}"
    privileged: True
    volumes: "{{ cinder_backup_default_volumes + cinder_backup_extra_volumes + lookup('vars', 'run_default_volumes_' + kolla_container_engine) }}"
    dimensions: "{{ cinder_backup_dimensions }}"
    healthcheck: "{{ cinder_backup_healthcheck }}"

####################
# Config Validate
####################
cinder_config_validation:
  - generator: "/cinder/tools/config/cinder-config-generator.conf"
    config: "/etc/cinder/cinder.conf"

####################
# Database
####################
cinder_database_name: "cinder"
cinder_database_user: "{% if use_preconfigured_databases | bool and use_common_mariadb_user | bool %}{{ database_user }}{% else %}cinder{% endif %}"
cinder_database_address: "{{ database_address | put_address_in_context('url') }}:{{ database_port }}"

####################
# Database sharding
####################
cinder_database_shard_root_user: "{% if enable_proxysql | bool %}root_shard_{{ cinder_database_shard_id }}{% else %}{{ database_user }}{% endif %}"
cinder_database_shard_id: "{{ mariadb_default_database_shard_id | int }}"
cinder_database_shard:
  users:
    - user: "{{ cinder_database_user }}"
      password: "{{ cinder_database_password }}"
  rules:
    - schema: "{{ cinder_database_name }}"
      shard_id: "{{ cinder_database_shard_id }}"


####################
# Docker
####################
cinder_tag: "{{ openstack_tag }}"

cinder_volume_image: "{{ docker_registry ~ '/' if docker_registry else '' }}{{ docker_namespace }}/{{ docker_image_name_prefix }}cinder-volume"
cinder_volume_tag: "{{ cinder_tag }}"
cinder_volume_image_full: "{{ cinder_volume_image }}:{{ cinder_volume_tag }}"

cinder_scheduler_image: "{{ docker_registry ~ '/' if docker_registry else '' }}{{ docker_namespace }}/{{ docker_image_name_prefix }}cinder-scheduler"
cinder_scheduler_tag: "{{ cinder_tag }}"
cinder_scheduler_image_full: "{{ cinder_scheduler_image }}:{{ cinder_scheduler_tag }}"

cinder_backup_image: "{{ docker_registry ~ '/' if docker_registry else '' }}{{ docker_namespace }}/{{ docker_image_name_prefix }}cinder-backup"
cinder_backup_tag: "{{ cinder_tag }}"
cinder_backup_image_full: "{{ cinder_backup_image }}:{{ cinder_backup_tag }}"

cinder_api_image: "{{ docker_registry ~ '/' if docker_registry else '' }}{{ docker_namespace }}/{{ docker_image_name_prefix }}cinder-api"
cinder_api_tag: "{{ cinder_tag }}"
cinder_api_image_full: "{{ cinder_api_image }}:{{ cinder_api_tag }}"

cinder_api_dimensions: "{{ default_container_dimensions }}"
cinder_backup_dimensions: "{{ default_container_dimensions }}"
cinder_scheduler_dimensions: "{{ default_container_dimensions }}"
cinder_volume_dimensions: "{{ default_container_dimensions }}"

cinder_api_enable_healthchecks: "{{ enable_container_healthchecks }}"
cinder_api_healthcheck_interval: "{{ default_container_healthcheck_interval }}"
cinder_api_healthcheck_retries: "{{ default_container_healthcheck_retries }}"
cinder_api_healthcheck_start_period: "{{ default_container_healthcheck_start_period }}"
cinder_api_healthcheck_test: ["CMD-SHELL", "healthcheck_curl {{ 'https' if cinder_enable_tls_backend | bool else 'http' }}://{{ api_interface_address | put_address_in_context('url') }}:{{ cinder_api_listen_port }}"]
cinder_api_healthcheck_timeout: "{{ default_container_healthcheck_timeout }}"
cinder_api_healthcheck:
  interval: "{{ cinder_api_healthcheck_interval }}"
  retries: "{{ cinder_api_healthcheck_retries }}"
  start_period: "{{ cinder_api_healthcheck_start_period }}"
  test: "{% if cinder_api_enable_healthchecks | bool %}{{ cinder_api_healthcheck_test }}{% else %}NONE{% endif %}"
  timeout: "{{ cinder_api_healthcheck_timeout }}"

cinder_scheduler_enable_healthchecks: "{{ enable_container_healthchecks }}"
cinder_scheduler_healthcheck_interval: "{{ default_container_healthcheck_interval }}"
cinder_scheduler_healthcheck_retries: "{{ default_container_healthcheck_retries }}"
cinder_scheduler_healthcheck_start_period: "{{ default_container_healthcheck_start_period }}"
cinder_scheduler_healthcheck_test: ["CMD-SHELL", "healthcheck_port cinder-scheduler {{ om_rpc_port }}"]
cinder_scheduler_healthcheck_timeout: "{{ default_container_healthcheck_timeout }}"
cinder_scheduler_healthcheck:
  interval: "{{ cinder_scheduler_healthcheck_interval }}"
  retries: "{{ cinder_scheduler_healthcheck_retries }}"
  start_period: "{{ cinder_scheduler_healthcheck_start_period }}"
  test: "{% if cinder_scheduler_enable_healthchecks | bool %}{{ cinder_scheduler_healthcheck_test }}{% else %}NONE{% endif %}"
  timeout: "{{ cinder_scheduler_healthcheck_timeout }}"

cinder_volume_enable_healthchecks: "{{ enable_container_healthchecks }}"
cinder_volume_healthcheck_interval: "{{ default_container_healthcheck_interval }}"
cinder_volume_healthcheck_retries: "{{ default_container_healthcheck_retries }}"
cinder_volume_healthcheck_start_period: "{{ default_container_healthcheck_start_period }}"
cinder_volume_healthcheck_test: ["CMD-SHELL", "healthcheck_port cinder-volume {{ om_rpc_port }}"]
cinder_volume_healthcheck_timeout: "{{ default_container_healthcheck_timeout }}"
cinder_volume_healthcheck:
  interval: "{{ cinder_volume_healthcheck_interval }}"
  retries: "{{ cinder_volume_healthcheck_retries }}"
  start_period: "{{ cinder_volume_healthcheck_start_period }}"
  test: "{% if cinder_volume_enable_healthchecks | bool %}{{ cinder_volume_healthcheck_test }}{% else %}NONE{% endif %}"
  timeout: "{{ cinder_volume_healthcheck_timeout }}"

cinder_backup_enable_healthchecks: "{{ enable_container_healthchecks }}"
cinder_backup_healthcheck_interval: "{{ default_container_healthcheck_interval }}"
cinder_backup_healthcheck_retries: "{{ default_container_healthcheck_retries }}"
cinder_backup_healthcheck_start_period: "{{ default_container_healthcheck_start_period }}"
cinder_backup_healthcheck_test: ["CMD-SHELL", "healthcheck_port cinder-backup {{ om_rpc_port }}"]
cinder_backup_healthcheck_timeout: "{{ default_container_healthcheck_timeout }}"
cinder_backup_healthcheck:
  interval: "{{ cinder_backup_healthcheck_interval }}"
  retries: "{{ cinder_backup_healthcheck_retries }}"
  start_period: "{{ cinder_backup_healthcheck_start_period }}"
  test: "{% if cinder_backup_enable_healthchecks | bool %}{{ cinder_backup_healthcheck_test }}{% else %}NONE{% endif %}"
  timeout: "{{ cinder_backup_healthcheck_timeout }}"

cinder_api_default_volumes:
  - "{{ node_config_directory }}/cinder-api/:{{ container_config_directory }}/:ro"
  - "/etc/localtime:/etc/localtime:ro"
  - "{{ '/etc/timezone:/etc/timezone:ro' if ansible_facts.os_family == 'Debian' else '' }}"
  - "kolla_logs:/var/log/kolla/"
  - "{{ '/dev/shm:/dev/shm' }}"
  - "{{ kolla_dev_repos_directory ~ '/cinder:/dev-mode/cinder' if cinder_dev_mode | bool else '' }}"
cinder_backup_default_volumes:
  - "{{ node_config_directory }}/cinder-backup/:{{ container_config_directory }}/:ro"
  - "/etc/localtime:/etc/localtime:ro"
  - "{{ '/etc/timezone:/etc/timezone:ro' if ansible_facts.os_family == 'Debian' else '' }}"
  - "/dev/:/dev/"
  - "/lib/modules:/lib/modules:ro"
  - "/run:/run{{ ':shared' if kolla_container_engine == 'docker' else '' }}"
  - "cinder:/var/lib/cinder"
  - "{% if enable_iscsid | bool %}iscsi_info:/etc/iscsi{% endif %}"
  - "kolla_logs:/var/log/kolla/"
  - "{{ kolla_dev_repos_directory ~ '/cinder:/dev-mode/cinder' if cinder_dev_mode | bool else '' }}"
cinder_scheduler_default_volumes:
  - "{{ node_config_directory }}/cinder-scheduler/:{{ container_config_directory }}/:ro"
  - "/etc/localtime:/etc/localtime:ro"
  - "{{ '/etc/timezone:/etc/timezone:ro' if ansible_facts.os_family == 'Debian' else '' }}"
  - "kolla_logs:/var/log/kolla/"
  - "{{ '/dev/shm:/dev/shm' }}"
  - "{{ kolla_dev_repos_directory ~ '/cinder:/dev-mode/cinder' if cinder_dev_mode | bool else '' }}"
cinder_volume_default_volumes:
  - "{{ node_config_directory }}/cinder-volume/:{{ container_config_directory }}/:ro"
  - "/etc/localtime:/etc/localtime:ro"
  - "{{ '/etc/timezone:/etc/timezone:ro' if ansible_facts.os_family == 'Debian' else '' }}"
  - "/dev/:/dev/"
  - "/lib/modules:/lib/modules:ro"
  - "/run:/run{{ ':shared' if kolla_container_engine == 'docker' else '' }}"
  - "cinder:/var/lib/cinder"
  - "{% if enable_iscsid | bool %}iscsi_info:/etc/iscsi{% endif %}"
  - "{% if enable_cinder_backend_lvm | bool and cinder_target_helper == 'lioadm' %}target_config:/etc/target{% endif %}"
  - "kolla_logs:/var/log/kolla/"
  - "{{ kolla_dev_repos_directory ~ '/cinder:/dev-mode/cinder' if cinder_dev_mode | bool else '' }}"

cinder_extra_volumes: "{{ default_extra_volumes }}"
cinder_api_extra_volumes: "{{ cinder_extra_volumes }}"
cinder_backup_extra_volumes: "{{ cinder_extra_volumes }}"
cinder_scheduler_extra_volumes: "{{ cinder_extra_volumes }}"
cinder_volume_extra_volumes: "{{ cinder_extra_volumes }}"

cinder_volume_tmpfs:
  - "{% if cinder_enable_conversion_tmpfs | bool %}/var/lib/cinder/conversion{% endif %}"

# If true, use a tmpfs mount for the Cinder image conversion directory.
cinder_enable_conversion_tmpfs: false

####################
# OpenStack
####################
cinder_internal_endpoint: "{{ cinder_internal_base_endpoint }}/v3"
cinder_public_endpoint: "{{ cinder_public_base_endpoint }}/v3"
cinder_v3_internal_endpoint: "{{ cinder_internal_base_endpoint }}/v3/%(tenant_id)s"
cinder_v3_public_endpoint: "{{ cinder_public_base_endpoint }}/v3/%(tenant_id)s"

cinder_logging_debug: "{{ openstack_logging_debug }}"

openstack_cinder_auth: "{{ openstack_auth }}"

# After upgrading cinder, services will have an RPC version cap in place.  We
# need to restart all services in order to allow them to use the latest RPC
# version. Ideally, there would be a way to check whether all cinder services
# are using the latest version, but currently there is not. Instead, wait a
# short time for all cinder services to update the version of their service in
# the database.  This seems to take around 10 seconds, but the default is 30 to
# allow room for slowness.
cinder_rpc_version_startup_delay: 30

cinder_api_workers: "{{ openstack_service_workers }}"

####################
# Cinder
####################
cinder_backends:
  - name: "{{ cinder_backend_lvm_name }}"
    enabled: "{{ enable_cinder_backend_lvm | bool }}"
  - name: "{{ cinder_backend_nfs_name }}"
    enabled: "{{ enable_cinder_backend_nfs | bool }}"
  - name: "{{ cinder_backend_vmwarevc_vmdk_name }}"
    enabled: "{{ cinder_backend_vmwarevc_vmdk | bool }}"
  - name: "{{ cinder_backend_vmware_vstorage_object_name }}"
    enabled: "{{ cinder_backend_vmware_vstorage_object | bool }}"
  - name: "{{ cinder_backend_quobyte_name }}"
    enabled: "{{ enable_cinder_backend_quobyte | bool }}"
  - name: "{{ cinder_backend_pure_iscsi_name }}"
    enabled: "{{ enable_cinder_backend_pure_iscsi | bool }}"
  - name: "{{ cinder_backend_pure_fc_name }}"
    enabled: "{{ enable_cinder_backend_pure_fc | bool }}"
  - name: "{{ cinder_backend_pure_roce_name }}"
    enabled: "{{ enable_cinder_backend_pure_roce | bool }}"
  - name: "{{ cinder_backend_pure_nvme_tcp_name }}"
    enabled: "{{ enable_cinder_backend_pure_nvme_tcp | bool }}"
  - name: "{{ cinder_backend_lightbits_name }}"
    enabled: "{{ enable_cinder_backend_lightbits | bool }}"

cinder_backend_ceph_name: "rbd-1"
cinder_backend_lvm_name: "lvm-1"
cinder_backend_nfs_name: "nfs-1"
cinder_backend_vmwarevc_vmdk_name: "vmwarevc-vmdk"
cinder_backend_vmware_vstorage_object_name: "vmware-vstorage-object"
cinder_backend_quobyte_name: "QuobyteHD"
cinder_backend_pure_iscsi_name: "Pure-FlashArray-iscsi"
cinder_backend_pure_fc_name: "Pure-FlashArray-fc"
cinder_backend_pure_roce_name: "Pure-FlashArray-roce"
cinder_backend_pure_nvme_tcp_name: "Pure-FlashArray-nvme-tcp"
cinder_backend_lightbits_name: "Lightbits-NVMe-TCP"

cinder_ceph_backends:
  - name: "{{ cinder_backend_ceph_name }}"
    backend_name: "{{ cinder_backend_ceph_name }}"
    cluster: "{{ ceph_cluster }}"
    user: "{{ ceph_cinder_user }}"
    pool: "{{ ceph_cinder_pool_name }}"
    enabled: "{{ cinder_backend_ceph | bool }}"

cinder_backup_backend_ceph_name: "rbd-1"
cinder_backup_ceph_backend: "{{ cinder_ceph_backends | selectattr('name', 'equalto', cinder_backup_backend_ceph_name) | list | first | combine({'pool': ceph_cinder_backup_pool_name, 'user': ceph_cinder_backup_user }) }}"

skip_cinder_backend_check: False

cinder_enabled_backends: "{{ cinder_backends | selectattr('enabled', 'equalto', true) | list + cinder_ceph_backends | selectattr('enabled', 'equalto', true) | list }}"

####################
# Notification
####################
cinder_notification_topics:
  - name: notifications
    enabled: "{{ enable_ceilometer | bool }}"

cinder_enabled_notification_topics: "{{ cinder_notification_topics | selectattr('enabled', 'equalto', true) | list }}"

#########################
# Quobyte Storage Driver
#########################
quobyte_storage_host:
quobyte_storage_volume:


################################
# Pure FlashArray Storage Driver
################################
pure_iscsi_backend: "pure_iscsi_backend"
pure_fc_backend: "pure_fc_backend"
pure_api_token:
pure_san_ip:

################################
# Lightbits Storage Driver
###############################
lightbits_nvme_tcp_backend_name: "lightbits_nvme_backend"
lightos_skip_ssl_verify: False
lightos_api_port: 443
lightos_default_num_replicas: 3
lightos_api_address:
lightos_jwt:

################################
# Cinder Backup S3
################################
cinder_backup_s3_url: "{{ s3_url }}"
cinder_backup_s3_bucket: "{{ s3_bucket }}"
cinder_backup_s3_access_key: "{{ s3_access_key }}"
cinder_backup_s3_secret_key: "{{ s3_secret_key }}"

####################
# Kolla
####################
cinder_git_repository: "{{ kolla_dev_repos_git }}/{{ project_name }}"
cinder_dev_repos_pull: "{{ kolla_dev_repos_pull }}"
cinder_dev_mode: "{{ kolla_dev_mode }}"
cinder_source_version: "{{ kolla_source_version }}"

####################
# Keystone
####################
cinder_ks_services:
  - name: "cinder"
    type: "block-storage"
    description: "Openstack Block Storage"
    endpoints:
      - {'interface': 'internal', 'url': '{{ cinder_internal_endpoint }}'}
      - {'interface': 'public', 'url': '{{ cinder_public_endpoint }}'}
  # TODO(mattcrees): switch to absent in G-cycle, remove in H
  - name: "cinderv3"
    type: "volumev3"
    description: "Openstack Block Storage (deprecated)"
    endpoints:
      - {'interface': 'internal', 'url': '{{ cinder_v3_internal_endpoint }}'}
      - {'interface': 'public', 'url': '{{ cinder_v3_public_endpoint }}'}

cinder_ks_users:
  - project: "service"
    user: "{{ cinder_keystone_user }}"
    password: "{{ cinder_keystone_password }}"
    role: "admin"

cinder_ks_user_roles:
  - project: "service"
    user: "{{ cinder_keystone_user }}"
    role: "service"

####################
# TLS
####################
cinder_enable_tls_backend: "{{ kolla_enable_tls_backend }}"
cinder_copy_certs: "{{ kolla_copy_ca_into_containers | bool or cinder_enable_tls_backend | bool }}"

############
# Clustering
############
cinder_cluster_name: ""
cinder_cluster_skip_precheck: false

############
# WSGI
############
cinder_wsgi_provider: "uwsgi"
