RPM info update
[ta/caas-danm.git] / ansible / roles / danm_setup / templates / danm_tenant_config.yaml.j2
1 #jinja2: lstrip_blocks: True
2 {#
3 Copyright 2019 Nokia
4
5 Licensed under the Apache License, Version 2.0 (the "License");
6 you may not use this file except in compliance with the License.
7 You may obtain a copy of the License at
8
9     http://www.apache.org/licenses/LICENSE-2.0
10
11 Unless required by applicable law or agreed to in writing, software
12 distributed under the License is distributed on an "AS IS" BASIS,
13 WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14 See the License for the specific language governing permissions and
15 limitations under the License.
16 #}
17 {%- macro make_host_devices(devices, provider_network) %}
18   {% for device in devices %}
19 - name: {{ device }}
20   {{ make_vni_config(provider_network) | indent(2) }}
21   {% endfor %}
22 {% endmacro -%}
23
24 {%- macro make_vni_config(provider_network) %}
25   {% set vlan_ranges = provider_network.get('vlan_ranges', '') %}
26   {% set vxlan_ranges = provider_network.get('vxlan_ranges', '') %}
27   {% if vlan_ranges %}
28 vniType: vlan
29 vniRange: {{ vlan_ranges | replace(':', '-') }}
30   {% elif vxlan_ranges %}
31 vniType: vxlan
32 vniRange: {{ vxlan_ranges | replace(':', '-') }}
33   {% endif %}
34 {% endmacro -%}
35
36 ---
37 apiVersion: danm.k8s.io/v1
38 kind: TenantConfig
39 metadata:
40   name: danm-tenant-config
41 hostDevices:
42 {% if all_attached_caas_provider_network_profiles %}
43   {% for profile_name in all_attached_caas_provider_network_profiles %}
44     {% set profile = network_profiles[profile_name] %}
45     {% set caas_provider_networks = profile.get('provider_network_interfaces', {}) | filter_provider_networks_by_type('caas') %}
46     {% set caas_sriov_provider_networks = profile.get('sriov_provider_networks', {}) | filter_provider_networks_by_type('caas') %}
47     {% for tenant_network in caas.get('tenant_networks', []) %}
48       {% if tenant_network in caas_provider_networks | get_provider_networks %}
49   {{ make_host_devices(caas_provider_networks.keys(), networking['provider_networks'][tenant_network]) | indent(2) -}}
50       {% elif tenant_network in caas_sriov_provider_networks %}
51         {% set sriov_interaces = caas_sriov_provider_networks | extract_sriov_provider_network_interfaces %}
52         {% set sriov_device_pools = sriov_interaces | map('regex_replace', '(.*)', 'nokia.k8s.io/sriov_\\1') | list %}
53   {{ make_host_devices(sriov_device_pools, networking['provider_networks'][tenant_network]) | indent(2) -}}
54       {% endif %}
55     {% endfor %}
56   {% endfor %}
57 {%- else %}
58  []
59 {% endif %}
60 networkIds:
61   flannel: flannel