---
manila_services:
  manila-api:
    container_name: "manila_api"
    group: "manila-api"
    image: "{{ manila_api_image_full }}"
    enabled: True
    volumes: "{{ manila_api_default_volumes + manila_api_extra_volumes }}"
    dimensions: "{{ manila_api_dimensions }}"
    healthcheck: "{{ manila_api_healthcheck }}"
    haproxy:
      manila_api:
        enabled: "{{ enable_manila }}"
        mode: "http"
        external: false
        port: "{{ manila_api_port }}"
        listen_port: "{{ manila_api_listen_port }}"
        backend_http_extra:
          - "option httpchk"
      manila_api_external:
        enabled: "{{ enable_manila }}"
        mode: "http"
        external: true
        external_fqdn: "{{ manila_external_fqdn }}"
        port: "{{ manila_api_public_port }}"
        listen_port: "{{ manila_api_listen_port }}"
        backend_http_extra:
          - "option httpchk"
  manila-scheduler:
    container_name: "manila_scheduler"
    group: "manila-scheduler"
    image: "{{ manila_scheduler_image_full }}"
    enabled: True
    volumes: "{{ manila_scheduler_default_volumes + manila_scheduler_extra_volumes }}"
    dimensions: "{{ manila_scheduler_dimensions }}"
    healthcheck: "{{ manila_scheduler_healthcheck }}"
  manila-share:
    container_name: "manila_share"
    group: "manila-share"
    image: "{{ manila_share_image_full }}"
    enabled: True
    privileged: True
    volumes: "{{ manila_share_default_volumes + manila_share_extra_volumes + lookup('vars', 'run_default_volumes_' + kolla_container_engine) }}"
    dimensions: "{{ manila_share_dimensions }}"
    healthcheck: "{{ manila_share_healthcheck }}"
  manila-data:
    container_name: "manila_data"
    group: "manila-data"
    image: "{{ manila_data_image_full }}"
    enabled: True
    privileged: True
    volumes: "{{ manila_data_default_volumes + manila_data_extra_volumes + lookup('vars', 'run_default_volumes_' + kolla_container_engine) }}"
    dimensions: "{{ manila_data_dimensions }}"
    healthcheck: "{{ manila_data_healthcheck }}"

####################
# Config Validate
####################
manila_config_validation:
  - generator: "/manila/etc/oslo-config-generator/manila.conf"
    config: "/etc/manila/manila.conf"

#####################
## Database
#####################
manila_database_name: "manila"
manila_database_user: "{% if use_preconfigured_databases | bool and use_common_mariadb_user | bool %}{{ database_user }}{% else %}manila{% endif %}"
manila_database_address: "{{ database_address | put_address_in_context('url') }}:{{ database_port }}"

####################
# Database sharding
####################
manila_database_shard_root_user: "{% if enable_proxysql | bool %}root_shard_{{ manila_database_shard_id }}{% else %}{{ database_user }}{% endif %}"
manila_database_shard_id: "{{ mariadb_default_database_shard_id | int }}"
manila_database_shard:
  users:
    - user: "{{ manila_database_user }}"
      password: "{{ manila_database_password }}"
  rules:
    - schema: "{{ manila_database_name }}"
      shard_id: "{{ manila_database_shard_id }}"


#####################
## Docker
#####################
manila_tag: "{{ openstack_tag }}"

manila_share_image: "{{ docker_registry ~ '/' if docker_registry else '' }}{{ docker_namespace }}/{{ docker_image_name_prefix }}manila-share"
manila_share_tag: "{{ manila_tag }}"
manila_share_image_full: "{{ manila_share_image }}:{{ manila_share_tag }}"

manila_scheduler_image: "{{ docker_registry ~ '/' if docker_registry else '' }}{{ docker_namespace }}/{{ docker_image_name_prefix }}manila-scheduler"
manila_scheduler_tag: "{{ manila_tag }}"
manila_scheduler_image_full: "{{ manila_scheduler_image }}:{{ manila_scheduler_tag }}"

manila_api_image: "{{ docker_registry ~ '/' if docker_registry else '' }}{{ docker_namespace }}/{{ docker_image_name_prefix }}manila-api"
manila_api_tag: "{{ manila_tag }}"
manila_api_image_full: "{{ manila_api_image }}:{{ manila_api_tag }}"

manila_data_image: "{{ docker_registry ~ '/' if docker_registry else '' }}{{ docker_namespace }}/{{ docker_image_name_prefix }}manila-data"
manila_data_tag: "{{ manila_tag }}"
manila_data_image_full: "{{ manila_data_image }}:{{ manila_data_tag }}"

manila_share_dimensions: "{{ default_container_dimensions }}"
manila_scheduler_dimensions: "{{ default_container_dimensions }}"
manila_api_dimensions: "{{ default_container_dimensions }}"
manila_data_dimensions: "{{ default_container_dimensions }}"

manila_api_enable_healthchecks: "{{ enable_container_healthchecks }}"
manila_api_healthcheck_interval: "{{ default_container_healthcheck_interval }}"
manila_api_healthcheck_retries: "{{ default_container_healthcheck_retries }}"
manila_api_healthcheck_start_period: "{{ default_container_healthcheck_start_period }}"
manila_api_healthcheck_test: ["CMD-SHELL", "healthcheck_curl http://{{ api_interface_address | put_address_in_context('url') }}:{{ manila_api_port }}"]
manila_api_healthcheck_timeout: "{{ default_container_healthcheck_timeout }}"
manila_api_healthcheck:
  interval: "{{ manila_api_healthcheck_interval }}"
  retries: "{{ manila_api_healthcheck_retries }}"
  start_period: "{{ manila_api_healthcheck_start_period }}"
  test: "{% if manila_api_enable_healthchecks | bool %}{{ manila_api_healthcheck_test }}{% else %}NONE{% endif %}"
  timeout: "{{ manila_api_healthcheck_timeout }}"

manila_scheduler_enable_healthchecks: "{{ enable_container_healthchecks }}"
manila_scheduler_healthcheck_interval: "{{ default_container_healthcheck_interval }}"
manila_scheduler_healthcheck_retries: "{{ default_container_healthcheck_retries }}"
manila_scheduler_healthcheck_start_period: "{{ default_container_healthcheck_start_period }}"
manila_scheduler_healthcheck_test: ["CMD-SHELL", "healthcheck_port manila-scheduler {{ om_rpc_port }}"]
manila_scheduler_healthcheck_timeout: "{{ default_container_healthcheck_timeout }}"
manila_scheduler_healthcheck:
  interval: "{{ manila_scheduler_healthcheck_interval }}"
  retries: "{{ manila_scheduler_healthcheck_retries }}"
  start_period: "{{ manila_scheduler_healthcheck_start_period }}"
  test: "{% if manila_scheduler_enable_healthchecks | bool %}{{ manila_scheduler_healthcheck_test }}{% else %}NONE{% endif %}"
  timeout: "{{ manila_scheduler_healthcheck_timeout }}"

manila_share_enable_healthchecks: "{{ enable_container_healthchecks }}"
manila_share_healthcheck_interval: "{{ default_container_healthcheck_interval }}"
manila_share_healthcheck_retries: "{{ default_container_healthcheck_retries }}"
manila_share_healthcheck_start_period: "{{ default_container_healthcheck_start_period }}"
manila_share_healthcheck_test: ["CMD-SHELL", "healthcheck_port manila-share {{ om_rpc_port }}"]
manila_share_healthcheck_timeout: "{{ default_container_healthcheck_timeout }}"
manila_share_healthcheck:
  interval: "{{ manila_share_healthcheck_interval }}"
  retries: "{{ manila_share_healthcheck_retries }}"
  start_period: "{{ manila_share_healthcheck_start_period }}"
  test: "{% if manila_share_enable_healthchecks | bool %}{{ manila_share_healthcheck_test }}{% else %}NONE{% endif %}"
  timeout: "{{ manila_share_healthcheck_timeout }}"

manila_data_enable_healthchecks: "{{ enable_container_healthchecks }}"
manila_data_healthcheck_interval: "{{ default_container_healthcheck_interval }}"
manila_data_healthcheck_retries: "{{ default_container_healthcheck_retries }}"
manila_data_healthcheck_start_period: "{{ default_container_healthcheck_start_period }}"
manila_data_healthcheck_test: ["CMD-SHELL", "healthcheck_port manila-data {{ om_rpc_port }}"]
manila_data_healthcheck_timeout: "{{ default_container_healthcheck_timeout }}"
manila_data_healthcheck:
  interval: "{{ manila_data_healthcheck_interval }}"
  retries: "{{ manila_data_healthcheck_retries }}"
  start_period: "{{ manila_data_healthcheck_start_period }}"
  test: "{% if manila_data_enable_healthchecks | bool %}{{ manila_data_healthcheck_test }}{% else %}NONE{% endif %}"
  timeout: "{{ manila_data_healthcheck_timeout }}"

manila_share_default_volumes:
  - "{{ node_config_directory }}/manila-share/:{{ container_config_directory }}/:ro"
  - "/etc/localtime:/etc/localtime:ro"
  - "{{ '/etc/timezone:/etc/timezone:ro' if ansible_facts.os_family == 'Debian' else '' }}"
  - "/run:/run{{ ':shared' if kolla_container_engine == 'docker' else '' }}"
  - "kolla_logs:/var/log/kolla/"
  - "{{ '/dev/shm:/dev/shm' }}"
  - "/lib/modules:/lib/modules:ro"
  - "{{ kolla_dev_repos_directory ~ '/manila:/dev-mode/manila' if manila_dev_mode | bool else '' }}"
manila_scheduler_default_volumes:
  - "{{ node_config_directory }}/manila-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 ~ '/manila:/dev-mode/manila' if manila_dev_mode | bool else '' }}"
manila_api_default_volumes:
  - "{{ node_config_directory }}/manila-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 ~ '/manila:/dev-mode/manila' if manila_dev_mode | bool else '' }}"
manila_data_default_volumes:
  - "{{ node_config_directory }}/manila-data/:{{ container_config_directory }}/:ro"
  - "/etc/localtime:/etc/localtime:ro"
  - "{{ '/etc/timezone:/etc/timezone:ro' if ansible_facts.os_family == 'Debian' else '' }}"
  - "/dev/:/dev/"
  - "/run:/run{{ ':shared' if kolla_container_engine == 'docker' else '' }}"
  - "kolla_logs:/var/log/kolla/"
  - "{{ kolla_dev_repos_directory ~ '/manila:/dev-mode/manila' if manila_dev_mode | bool else '' }}"

manila_extra_volumes: "{{ default_extra_volumes }}"
manila_share_extra_volumes: "{{ manila_extra_volumes }}"
manila_scheduler_extra_volumes: "{{ manila_extra_volumes }}"
manila_api_extra_volumes: "{{ manila_extra_volumes }}"
manila_data_extra_volumes: "{{ manila_extra_volumes }}"

#####################
## OpenStack
#####################
manila_internal_endpoint: "{{ manila_internal_base_endpoint }}/v1/%(tenant_id)s"
manila_public_endpoint: "{{ manila_public_base_endpoint }}/v1/%(tenant_id)s"

manila_v2_internal_endpoint: "{{ manila_internal_base_endpoint }}/v2"
manila_v2_public_endpoint: "{{ manila_public_base_endpoint }}/v2"

manila_logging_debug: "{{ openstack_logging_debug }}"

manila_keystone_user: "manila"
manila_service_instance_user: "manila"
manila_service_instance_password: "manila"

openstack_manila_auth: "{{ openstack_auth }}"

manila_api_workers: "{{ openstack_service_workers }}"

####################
# Manila
####################
manila_backends:
  - name: "generic"
    driver: "generic"
    enabled: "{{ enable_manila_backend_generic | bool }}"
    protocols:
      - "NFS"
      - "CIFS"
  - name: "hnas1"
    driver: "hnas"
    enabled: "{{ enable_manila_backend_hnas | bool }}"
    protocols:
      - "NFS"
      - "CIFS"
  - name: "glusterfsnfs1"
    driver: "glusterfsnfs"
    enabled: "{{ enable_manila_backend_glusterfs_nfs | bool }}"
    protocols:
      - "NFS"
  - name: "fb1"
    driver: "flashblade"
    enabled: "{{ enable_manila_backend_flashblade | bool }}"
    protocols:
      - "NFS"


manila_ceph_backends:
  - name: "cephfsnative1"
    share_name: "CEPHFS1"
    driver: "cephfsnative"
    cluster: "{{ ceph_cluster }}"
    enabled: "{{ enable_manila_backend_cephfs_native | bool }}"
    protocols:
      - "CEPHFS"
  - name: "cephfsnfs1"
    share_name: "CEPHFSNFS1"
    driver: "cephfsnfs"
    cluster: "{{ ceph_cluster }}"
    enabled: "{{ enable_manila_backend_cephfs_nfs | bool }}"
    protocols:
      - "NFS"
      - "CIFS"

manila_enabled_backends: "{{ manila_backends | selectattr('enabled', 'equalto', true) | list + manila_ceph_backends | selectattr('enabled', 'equalto', true) | list }}"


####################
# Kolla
####################
manila_git_repository: "{{ kolla_dev_repos_git }}/{{ project_name }}"
manila_dev_repos_pull: "{{ kolla_dev_repos_pull }}"
manila_dev_mode: "{{ kolla_dev_mode }}"
manila_source_version: "{{ kolla_source_version }}"


####################
# Notifications
####################
manila_notification_topics:
  - name: notifications
    enabled: "{{ enable_ceilometer | bool }}"

manila_enabled_notification_topics: "{{ manila_notification_topics | selectattr('enabled', 'equalto', true) | list }}"


####################
# Keystone
####################
manila_ks_services:
  - name: "manila"
    type: "share"
    description: "Openstack Shared Filesystems"
    endpoints:
      - {'interface': 'internal', 'url': '{{ manila_internal_endpoint }}'}
      - {'interface': 'public', 'url': '{{ manila_public_endpoint }}'}
  - name: "manilav2"
    type: "sharev2"
    description: "Openstack Shared Filesystems"
    endpoints:
      - {'interface': 'internal', 'url': '{{ manila_v2_internal_endpoint }}'}
      - {'interface': 'public', 'url': '{{ manila_v2_public_endpoint }}'}

manila_ks_users:
  - project: "service"
    user: "{{ manila_keystone_user }}"
    password: "{{ manila_keystone_password }}"
    role: "admin"


####################
# CephFS
####################
manila_cephfs_filesystem_name: ""


####################
# Glusterfs
####################
manila_glusterfs_share_layout: "layout_volume.GlusterfsVolumeMappedLayout"
manila_glusterfs_nfs_server_type: "Gluster"
