From 6fd346ef2daa272f37121a817a1e5e5f6bb318a2 Mon Sep 17 00:00:00 2001 From: Alex Yang Date: Wed, 6 Dec 2017 14:22:06 +0800 Subject: Generate daisy network configuration by template JIRA: DAISY-74 Add jinja2 templates for daisy network configuration. For DPDK, TENANT and EXTERNAL networks should share the same interface now. Change-Id: I6e9b7a68fb572e9ad844cfcc6ff383aaa25e3bc1 Signed-off-by: Alex Yang --- config/installers/daisy/network-dpdk.yaml.j2 | 102 +++++++++++++++++++++++++++ config/installers/daisy/network.yaml.j2 | 102 +++++++++++++++++++++++++++ 2 files changed, 204 insertions(+) create mode 100644 config/installers/daisy/network-dpdk.yaml.j2 create mode 100644 config/installers/daisy/network.yaml.j2 diff --git a/config/installers/daisy/network-dpdk.yaml.j2 b/config/installers/daisy/network-dpdk.yaml.j2 new file mode 100644 index 00000000..507e7cfc --- /dev/null +++ b/config/installers/daisy/network-dpdk.yaml.j2 @@ -0,0 +1,102 @@ +############################################################################## +# Copyright (c) 2017 ZTE Corporation and others. +# +# All rights reserved. This program and the accompanying materials +# are made available under the terms of the Apache License, Version 2.0 +# which accompanies this distribution, and is available at +# http://www.apache.org/licenses/LICENSE-2.0 +############################################################################## + +############################################################################## +# Description +# MANAGEMENT: used for management +# STORAGE: used for storage access +# EXTERNAL: tenant public/floating IP associated network +# PUBLICAPI: used for horizon access, openstack API access +# TENANT: used for tenant access, vlan and VxLan supported, default VxLan +# HEARTBEAT: used for heartbeat, requires a dedicated interface +############################################################################## + +--- + +network-config-metadata: + title: 'Deployment Adapter for baremetal POD' + version: '0.1' + created: 'Nov 22 2017' + comment: 'For Daisy initial' + +{%- set mapping = {'HEARTBEAT': 'admin', + 'MANAGEMENT': 'mgmt', + 'PUBLICAPI': 'mgmt', + 'STORAGE': 'storage', + 'TENANT': 'public', + 'EXTERNAL': 'public'} -%} + +{%- if "idf" in conf and ("daisy" in conf["idf"] or "fuel" in conf["idf"]) -%} + {%- if "daisy" in conf["idf"] -%} + {%- set installer = "daisy" -%} + {%- else -%} + {%- set installer = "fuel" -%} + {%- endif %} + +networks: + + {%- set networks = {} -%} + {%- for key in mapping -%} + {%- set net_data = conf['net_config'][mapping[key]] -%} + {%- set interface = net_data['interface'] -%} + {%- set interface_name = conf.idf[installer].network.node[0].interfaces[interface] -%} + {%- set bus_addr = conf.idf[installer].network.node[0].busaddr[interface] -%} + {%- set vlan = net_data['vlan'] -%} + {%- if vlan == "native" or vlan == None -%} + {%- set vlan = "null" -%} + {%- endif -%} + {%- set network = net_data['network'] -%} + {%- set ips = network.split(".") -%} + {%- set mask = net_data['mask'] -%} + {%- if 'ip-range' in net_data -%} + {%- set ip_range = net_data['ip-range'] -%} + {%- set (start, end) = ip_range.split("-") -%} + {%- else -%} + {%- set start = ".".join([ips[0], ips[1], ips[2], "10"]) -%} + {%- set end = ".".join([ips[0], ips[1], ips[2], "200"]) -%} + {%- endif -%} + {%- set vip = start -%} + + {%- if 'gateway' in net_data -%} + {%- set gateway = net_data.gateway -%} + {%- else -%} + {%- set gateway = ".".join([ips[0], ips[1], ips[2], "1"]) -%} + {%- endif -%} + + {%- set networks = networks.update({key: {'interface_name': interface_name, + 'bus_addr': bus_addr, + 'vlan': vlan, + 'network': network, + 'mask': mask, + 'start': start, + 'end': end, + 'vip': vip, + 'gateway': gateway + } + }) %} + + - cidr: '{{ network }}/{{ mask }}' + gateway: '{{ gateway }}' + ip_ranges: + - 'start': '{{ start }}' + 'end': '{{ end }}' + vlan_id: {{ vlan }} + name: '{{ key }}' + {%- endfor %} + +interfaces: + {%- for key in mapping %} + - name: '{{ key }}' + interface: '{{ networks[key].interface_name }}' + {%- endfor %} + +internal_vip: '{{ networks['MANAGEMENT'].vip }}' +public_vip: '{{ networks['PUBLICAPI'].vip }}' + +{%- endif %} diff --git a/config/installers/daisy/network.yaml.j2 b/config/installers/daisy/network.yaml.j2 new file mode 100644 index 00000000..9eef7390 --- /dev/null +++ b/config/installers/daisy/network.yaml.j2 @@ -0,0 +1,102 @@ +############################################################################## +# Copyright (c) 2017 ZTE Corporation and others. +# +# All rights reserved. This program and the accompanying materials +# are made available under the terms of the Apache License, Version 2.0 +# which accompanies this distribution, and is available at +# http://www.apache.org/licenses/LICENSE-2.0 +############################################################################## + +############################################################################## +# Description +# MANAGEMENT: used for management +# STORAGE: used for storage access +# EXTERNAL: tenant public/floating IP associated network +# PUBLICAPI: used for horizon access, openstack API access +# TENANT: used for tenant access, vlan and VxLan supported, default VxLan +# HEARTBEAT: used for heartbeat, requires a dedicated interface +############################################################################## + +--- + +network-config-metadata: + title: 'Deployment Adapter for baremetal POD' + version: '0.1' + created: 'Nov 22 2017' + comment: 'For Daisy initial' + +{%- set mapping = {'HEARTBEAT': 'admin', + 'MANAGEMENT': 'mgmt', + 'PUBLICAPI': 'mgmt', + 'STORAGE': 'storage', + 'TENANT': 'private', + 'EXTERNAL': 'public'} -%} + +{%- if "idf" in conf and ("daisy" in conf["idf"] or "fuel" in conf["idf"]) -%} + {%- if "daisy" in conf["idf"] -%} + {%- set installer = "daisy" -%} + {%- else -%} + {%- set installer = "fuel" -%} + {%- endif %} + +networks: + + {%- set networks = {} -%} + {%- for key in mapping -%} + {%- set net_data = conf['net_config'][mapping[key]] -%} + {%- set interface = net_data['interface'] -%} + {%- set interface_name = conf.idf[installer].network.node[0].interfaces[interface] -%} + {%- set bus_addr = conf.idf[installer].network.node[0].busaddr[interface] -%} + {%- set vlan = net_data['vlan'] -%} + {%- if vlan == "native" or vlan == None -%} + {%- set vlan = "null" -%} + {%- endif -%} + {%- set network = net_data['network'] -%} + {%- set ips = network.split(".") -%} + {%- set mask = net_data['mask'] -%} + {%- if 'ip-range' in net_data -%} + {%- set ip_range = net_data['ip-range'] -%} + {%- set (start, end) = ip_range.split("-") -%} + {%- else -%} + {%- set start = ".".join([ips[0], ips[1], ips[2], "10"]) -%} + {%- set end = ".".join([ips[0], ips[1], ips[2], "200"]) -%} + {%- endif -%} + {%- set vip = start -%} + + {%- if 'gateway' in net_data -%} + {%- set gateway = net_data.gateway -%} + {%- else -%} + {%- set gateway = ".".join([ips[0], ips[1], ips[2], "1"]) -%} + {%- endif -%} + + {%- set networks = networks.update({key: {'interface_name': interface_name, + 'bus_addr': bus_addr, + 'vlan': vlan, + 'network': network, + 'mask': mask, + 'start': start, + 'end': end, + 'vip': vip, + 'gateway': gateway + } + }) %} + + - cidr: '{{ network }}/{{ mask }}' + gateway: '{{ gateway }}' + ip_ranges: + - 'start': '{{ start }}' + 'end': '{{ end }}' + vlan_id: {{ vlan }} + name: '{{ key }}' + {%- endfor %} + +interfaces: + {%- for key in mapping %} + - name: '{{ key }}' + interface: '{{ networks[key].interface_name }}' + {%- endfor %} + +internal_vip: '{{ networks['MANAGEMENT'].vip }}' +public_vip: '{{ networks['PUBLICAPI'].vip }}' + +{%- endif %} -- cgit 1.2.3-korg