---
cyborg_services:
  cyborg-api:
    container_name: cyborg_api
    group: cyborg-api
    enabled: true
    image: "{{ cyborg_api_image_full }}"
    volumes: "{{ cyborg_api_default_volumes + cyborg_api_extra_volumes }}"
    dimensions: "{{ cyborg_api_dimensions }}"
    healthcheck: "{{ cyborg_api_healthcheck }}"
  cyborg-agent:
    container_name: cyborg_agent
    group: cyborg-agent
    enabled: true
    privileged: true
    image: "{{ cyborg_agent_image_full }}"
    volumes: "{{ cyborg_agent_default_volumes + cyborg_agent_extra_volumes }}"
    dimensions: "{{ cyborg_agent_dimensions }}"
    healthcheck: "{{ cyborg_agent_healthcheck }}"
  cyborg-conductor:
    container_name: cyborg_conductor
    group: cyborg-conductor
    enabled: true
    image: "{{ cyborg_conductor_image_full }}"
    volumes: "{{ cyborg_conductor_default_volumes + cyborg_conductor_extra_volumes }}"
    dimensions: "{{ cyborg_conductor_dimensions }}"
    healthcheck: "{{ cyborg_conductor_healthcheck }}"

####################
# Config Validate
####################
cyborg_config_validation:
  - generator: "/cyborg/tools/config/cyborg-config-generator.conf"
    config: "/etc/cyborg/cyborg.conf"

####################
# Database
####################
cyborg_database_name: "cyborg"
cyborg_database_user: "{% if use_preconfigured_databases | bool and use_common_mariadb_user | bool %}{{ database_user }}{% else %}cyborg{% endif %}"
cyborg_database_address: "{{ database_address | put_address_in_context('url') }}:{{ database_port }}"

####################
# Database sharding
####################
cyborg_database_shard_root_user: "{% if enable_proxysql | bool %}root_shard_{{ cyborg_database_shard_id }}{% else %}{{ database_user }}{% endif %}"
cyborg_database_shard_id: "{{ mariadb_default_database_shard_id | int }}"
cyborg_database_shard:
  users:
    - user: "{{ cyborg_database_user }}"
      password: "{{ cyborg_database_password }}"
  rules:
    - schema: "{{ cyborg_database_name }}"
      shard_id: "{{ cyborg_database_shard_id }}"


####################
# Docker
####################
cyborg_tag: "{{ openstack_tag }}"

cyborg_api_image: "{{ docker_registry ~ '/' if docker_registry else '' }}{{ docker_namespace }}/cyborg-api"
cyborg_api_tag: "{{ cyborg_tag }}"
cyborg_api_image_full: "{{ cyborg_api_image }}:{{ cyborg_api_tag }}"

cyborg_agent_image: "{{ docker_registry ~ '/' if docker_registry else '' }}{{ docker_namespace }}/cyborg-agent"
cyborg_agent_tag: "{{ cyborg_tag }}"
cyborg_agent_image_full: "{{ cyborg_agent_image }}:{{ cyborg_agent_tag }}"

cyborg_conductor_image: "{{ docker_registry ~ '/' if docker_registry else '' }}{{ docker_namespace }}/cyborg-conductor"
cyborg_conductor_tag: "{{ cyborg_tag }}"
cyborg_conductor_image_full: "{{ cyborg_conductor_image }}:{{ cyborg_conductor_tag }}"

cyborg_api_dimensions: "{{ default_container_dimensions }}"
cyborg_agent_dimensions: "{{ default_container_dimensions }}"
cyborg_conductor_dimensions: "{{ default_container_dimensions }}"

cyborg_api_enable_healthchecks: "{{ enable_container_healthchecks }}"
cyborg_api_healthcheck_interval: "{{ default_container_healthcheck_interval }}"
cyborg_api_healthcheck_retries: "{{ default_container_healthcheck_retries }}"
cyborg_api_healthcheck_start_period: "{{ default_container_healthcheck_start_period }}"
cyborg_api_healthcheck_test: ["CMD-SHELL", "healthcheck_curl http://{{ api_interface_address | put_address_in_context('url') }}:{{ cyborg_api_port }}"]
cyborg_api_healthcheck_timeout: "{{ default_container_healthcheck_timeout }}"
cyborg_api_healthcheck:
  interval: "{{ cyborg_api_healthcheck_interval }}"
  retries: "{{ cyborg_api_healthcheck_retries }}"
  start_period: "{{ cyborg_api_healthcheck_start_period }}"
  test: "{% if cyborg_api_enable_healthchecks | bool %}{{ cyborg_api_healthcheck_test }}{% else %}NONE{% endif %}"
  timeout: "{{ cyborg_api_healthcheck_timeout }}"

cyborg_agent_enable_healthchecks: "{{ enable_container_healthchecks }}"
cyborg_agent_healthcheck_interval: "{{ default_container_healthcheck_interval }}"
cyborg_agent_healthcheck_retries: "{{ default_container_healthcheck_retries }}"
cyborg_agent_healthcheck_start_period: "{{ default_container_healthcheck_start_period }}"
cyborg_agent_healthcheck_test: ["CMD-SHELL", "healthcheck_port cyborg-agent {{ om_rpc_port }}"]
cyborg_agent_healthcheck_timeout: "{{ default_container_healthcheck_timeout }}"
cyborg_agent_healthcheck:
  interval: "{{ cyborg_agent_healthcheck_interval }}"
  retries: "{{ cyborg_agent_healthcheck_retries }}"
  start_period: "{{ cyborg_agent_healthcheck_start_period }}"
  test: "{% if cyborg_agent_enable_healthchecks | bool %}{{ cyborg_agent_healthcheck_test }}{% else %}NONE{% endif %}"
  timeout: "{{ cyborg_agent_healthcheck_timeout }}"

cyborg_conductor_enable_healthchecks: "{{ enable_container_healthchecks }}"
cyborg_conductor_healthcheck_interval: "{{ default_container_healthcheck_interval }}"
cyborg_conductor_healthcheck_retries: "{{ default_container_healthcheck_retries }}"
cyborg_conductor_healthcheck_start_period: "{{ default_container_healthcheck_start_period }}"
cyborg_conductor_healthcheck_test: ["CMD-SHELL", "healthcheck_port cyborg-conductor {{ om_rpc_port }}"]
cyborg_conductor_healthcheck_timeout: "{{ default_container_healthcheck_timeout }}"
cyborg_conductor_healthcheck:
  interval: "{{ cyborg_conductor_healthcheck_interval }}"
  retries: "{{ cyborg_conductor_healthcheck_retries }}"
  start_period: "{{ cyborg_conductor_healthcheck_start_period }}"
  test: "{% if cyborg_conductor_enable_healthchecks | bool %}{{ cyborg_conductor_healthcheck_test }}{% else %}NONE{% endif %}"
  timeout: "{{ cyborg_conductor_healthcheck_timeout }}"

cyborg_api_default_volumes:
  - "{{ node_config_directory }}/cyborg-api/:{{ container_config_directory }}/:ro"
  - "/etc/localtime:/etc/localtime:ro"
  - "{{ '/etc/timezone:/etc/timezone:ro' if ansible_facts.os_family == 'Debian' else '' }}"
  - "cyborg:/var/lib/cyborg/"
  - "kolla_logs:/var/log/kolla/"
  - "{{ '/dev/shm:/dev/shm' if om_enable_queue_manager | bool else '' }}"

cyborg_agent_default_volumes:
  - "{{ node_config_directory }}/cyborg-agent/:{{ 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' if om_enable_queue_manager | bool else '' }}"

cyborg_conductor_default_volumes:
  - "{{ node_config_directory }}/cyborg-conductor/:{{ 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' if om_enable_queue_manager | bool else '' }}"

cyborg_extra_volumes: "{{ default_extra_volumes }}"
cyborg_api_extra_volumes: "{{ cyborg_extra_volumes }}"
cyborg_agent_extra_volumes: "{{ cyborg_extra_volumes }}"
cyborg_conductor_extra_volumes: "{{ cyborg_extra_volumes }}"

####################
# OpenStack
####################
cyborg_internal_endpoint: "{{ cyborg_internal_fqdn | kolla_url(internal_protocol, cyborg_api_port, '/v2') }}"
cyborg_public_endpoint: "{{ cyborg_external_fqdn | kolla_url(public_protocol, cyborg_api_port, '/v2') }}"

cyborg_logging_debug: "{{ openstack_logging_debug }}"

cyborg_keystone_user: "cyborg"

openstack_cyborg_auth: "{{ openstack_auth }}"


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

cyborg_enabled_notification_topics: "{{ cyborg_notification_topics | selectattr('enabled', 'equalto', true) | list }}"

####################
# Keystone
####################
cyborg_ks_services:
  - name: "cyborg"
    type: "accelerator"
    description: "Acceleration Service"
    endpoints:
      - {'interface': 'internal', 'url': '{{ cyborg_internal_endpoint }}'}
      - {'interface': 'public', 'url': '{{ cyborg_public_endpoint }}'}

cyborg_ks_users:
  - project: "service"
    user: "{{ cyborg_keystone_user }}"
    password: "{{ cyborg_keystone_password }}"
    role: "admin"
