# {{ ansible_managed }}

# OVN Northbound Database
OVN_NB_DB_OPTS="
{% if tripleo_ovn_cluster_nb_db_protocol == 'ssl' %}
--db-nb-create-insecure-remote=no \
--ovn-nb-db-ssl-key={{ tripleo_ovn_cluster_nb_ssl_key }} \
--ovn-nb-db-ssl-cert={{ tripleo_ovn_cluster_nb_ssl_cert }} \
--ovn-nb-db-ssl-ca-cert={{ tripleo_ovn_cluster_nb_ssl_ca_cert }} \
{% else %}
--db-nb-create-insecure-remote=yes \
{% endif %}
{% if not is_ovn_dbs_bootstrap_node|bool %}
--db-nb-cluster-remote-proto={{ tripleo_ovn_cluster_nb_db_protocol }} \
--db-nb-cluster-remote-addr={{ ovn_dbs_bootstrap_node_ip }} \
--db-nb-cluster-remote-port={{ tripleo_ovn_cluster_nb_remote_port }} \
{% endif %}
--db-nb-cluster-local-proto={{ tripleo_ovn_cluster_nb_db_protocol }} \
--db-nb-cluster-local-addr={{ hostvars[inventory_hostname][tripleo_ovn_cluster_network ~ '_ip'] }} \
--db-nb-cluster-local-port={{ tripleo_ovn_cluster_nb_local_port }} \
--db-nb-addr={{ hostvars[inventory_hostname][tripleo_ovn_cluster_network ~ '_ip'] }} \
--db-nb-port={{ tripleo_ovn_cluster_nb_db_port }}"

# OVN Southbound Database
OVN_SB_DB_OPTS="
{% if tripleo_ovn_cluster_sb_db_protocol == 'ssl' %}
--db-sb-create-insecure-remote=no \
--ovn-sb-db-ssl-key={{ tripleo_ovn_cluster_sb_ssl_key }} \
--ovn-sb-db-ssl-cert={{ tripleo_ovn_cluster_sb_ssl_cert }} \
--ovn-sb-db-ssl-ca-cert={{ tripleo_ovn_cluster_sb_ssl_ca_cert }} \
{% else %}
--db-sb-create-insecure-remote=yes \
{% endif %}
{% if not is_ovn_dbs_bootstrap_node|bool %}
--db-sb-cluster-remote-proto={{ tripleo_ovn_cluster_sb_db_protocol }} \
--db-sb-cluster-remote-addr={{ ovn_dbs_bootstrap_node_ip }} \
--db-sb-cluster-remote-port={{ tripleo_ovn_cluster_sb_remote_port }} \
{% endif %}
--db-sb-cluster-local-proto={{ tripleo_ovn_cluster_sb_db_protocol }} \
--db-sb-cluster-local-addr={{ hostvars[inventory_hostname][tripleo_ovn_cluster_network ~ '_ip'] }} \
--db-sb-cluster-local-port={{ tripleo_ovn_cluster_sb_local_port }} \
--db-sb-addr={{ hostvars[inventory_hostname][tripleo_ovn_cluster_network ~ '_ip'] }} \
--db-sb-port={{ tripleo_ovn_cluster_sb_db_port }}"

# OVN Northd
OVN_NORTHD_OPTS="
--no-chdir -vconsole:emer -vsyslog:err -vfile:info --pidfile=/run/openvswitch/ovn-northd.pid --log-file=/var/log/openvswitch/ovn-northd.log \
{% if tripleo_ovn_cluster_northd_protocol == 'ssl' %}
--private-key={{ tripleo_ovn_cluster_northd_ssl_key }} \
--certificate={{ tripleo_ovn_cluster_northd_ssl_cert }} \
--ca-cert={{ tripleo_ovn_cluster_northd_ssl_ca_cert }} \
{% endif %}
--ovnnb-db={{ [tripleo_ovn_cluster_nb_db_protocol] | product(ovn_dbs_node_ips) | map('join', ':') | product([tripleo_ovn_cluster_nb_db_port]) | map('join', ':') | join(',') }} \
--ovnsb-db={{ [tripleo_ovn_cluster_nb_db_protocol] | product(ovn_dbs_node_ips) | map('join', ':') | product([tripleo_ovn_cluster_sb_db_port]) | map('join', ':') | join(',') }}"
