Takes a template file and feeds it values 49/33849/3
authoragardner <agardner@linuxfoundation.org>
Wed, 26 Apr 2017 11:48:59 +0000 (13:48 +0200)
committeragardner <agardner@linuxfoundation.org>
Thu, 27 Apr 2017 13:02:17 +0000 (15:02 +0200)
Values come from a pod config file.
This is just an example, only ipmi_ips are templated at this time.

eg: address: {{ config['global_details']['ipmi_ips'][0] }}

test like this:

./utils/generate_config.py -y labs/intel/pod5/pod.yaml -j
installers/joid/labconfig.jinja2

releng should have a new job, validate-templates
that looks for
pattern: 'utils/generate_config.yml'
pattern: '**/*.jinja2'

and tests that templating does not error.

Change-Id: I7f781abb702afcfccf7ed17674378cffe4a7177d
Signed-off-by: agardner <agardner@linuxfoundation.org>
installers/apex/network_settings.jinja2 [new file with mode: 0755]
installers/joid/labconfig.jinja2 [new file with mode: 0644]
labs/intel/pod5/pod.yaml [new file with mode: 0644]
utils/generate_config.py [new file with mode: 0755]

diff --git a/installers/apex/network_settings.jinja2 b/installers/apex/network_settings.jinja2
new file mode 100755 (executable)
index 0000000..4ef349c
--- /dev/null
@@ -0,0 +1,216 @@
+# This configuration file defines Network Environment for a
+# Baremetal Deployment of OPNFV. It contains default values
+# for 5 following networks:
+#
+# - admin
+# - tenant*
+# - external*
+# - storage*
+# - api*
+# *) optional networks
+#
+# Optional networks will be consolidated with the admin network
+# if not explicitly configured.
+#
+# See short description of the networks in the comments below.
+#
+# "admin" is the short name for Control Plane Network.
+# This network should be IPv4 even it is an IPv6 deployment
+# IPv6 does not have PXE boot support.
+# During OPNFV deployment it is used for node provisioning which will require
+# PXE booting as well as running a DHCP server on this network.  Be sure to
+# disable any other DHCP/TFTP server on this network.
+#
+# "tenant" is the network used for tenant traffic.
+#
+# "external" is the network which should have internet or external
+# connectivity.  External OpenStack networks will be configured to egress this
+# network.  There can be multiple external networks, but only one assigned as
+# "public" which OpenStack public API's will register.
+#
+# "storage" is the network for storage I/O.
+#
+# "api" is an optional network for splitting out OpenStack service API
+# communication.  This should be used for IPv6 deployments.
+
+
+#Meta data for the network configuration
+network-config-metadata:
+  title: LF-POD-1 Network config
+  version: 0.1
+  created: Mon Dec 28 2015
+  comment: None
+
+# DNS Settings
+dns-domain: opnfvlf.org
+dns-search: opnfvlf.org
+dns_nameservers:
+  - 8.8.8.8
+  - 8.8.4.4
+# NTP servers
+ntp:
+  - 0.se.pool.ntp.org
+  - 1.se.pool.ntp.org
+# Syslog server
+syslog:
+  server: 10.128.1.24
+  transport: 'tcp'
+
+# Common network settings
+networks:
+  admin:
+    enabled: true
+    installer_vm:
+      nic_type: interface
+      members:
+        - enp6s0
+      vlan: native
+      ip: 192.30.9.1
+    usable_ip_range:
+      - 192.30.9.12
+      - 192.30.9.99
+    gateway: 192.30.9.1
+    cidr: 192.30.9.0/24
+    dhcp_range:
+      - 192.30.9.2
+      - 192.30.9.10
+    nic_mapping:
+      compute:
+        phys_type: interface
+        members:
+          - enp6s0
+      controller:
+        phys_type: interface
+        members:
+          - enp6s0
+
+  tenant:
+    enabled: true
+    cidr: 11.0.0.0/24
+    mtu: 1500
+    overlay_id_range: 2,65535
+
+    segmentation_type: vxlan
+
+    nic_mapping:
+      compute:
+        phys_type: interface
+        uio_driver: uio_pci_generic  # UIO driver to use for DPDK scenarios.  The value is ignored for non-DPDK scenarios.
+        vlan: native
+        members:
+          - enp7s0
+      controller:
+        phys_type: interface
+        vlan: native
+        members:
+          - enp7s0
+
+  external:
+    - public:
+      enabled: true
+      mtu: 1500
+      installer_vm:
+        nic_type: interface
+        vlan: native
+        members:
+          - enp8s0
+        ip: 172.30.9.67
+      cidr: 172.30.9.0/24
+      gateway: 172.30.9.1
+      floating_ip_range:
+        - 172.30.9.200
+        - 172.30.9.220
+      usable_ip_range:
+        - 172.30.9.70
+        - 172.30.9.199
+
+      nic_mapping:
+        compute:
+          phys_type: interface
+          vlan: native
+          members:
+            - enp8s0
+        controller:
+          phys_type: interface
+          vlan: native
+          members:
+            - enp8s0
+      external_overlay:
+          name: Public_internet
+          type: flat
+          gateway: 172.30.9.1
+    - private_cloud:
+      enabled: false
+      mtu: 1500
+      installer_vm:
+        nic_type: interface
+        vlan: 101
+        members:
+          - em1
+        ip: 192.168.38.1
+      cidr: 192.168.38.0/24
+      gateway: 192.168.38.1
+      floating_ip_range:
+        - 192.168.38.200
+        - 192.168.38.220
+      usable_ip_range:
+        - 192.168.38.10
+        - 192.168.38.199
+
+      nic_mapping:
+        compute:
+          phys_type: interface
+          vlan: 101
+          members:
+            - enp8s0
+        controller:
+          phys_type: interface
+          vlan: 101
+          members:
+            - enp8s0
+      external_overlay:
+          name: private_cloud
+          type: vlan
+          segmentation_id: 101
+          gateway: 192.168.38.1
+
+  storage:
+    enabled: true
+    cidr: 12.0.0.0/24
+    mtu: 1500
+    nic_mapping:
+      compute:
+        phys_type: interface
+        vlan: native
+        members:
+          - enp9s0
+      controller:
+        phys_type: interface
+        vlan: native
+        members:
+          - enp9s0
+
+  api:
+    enabled: false
+    cidr: fd00:fd00:fd00:4000::/64
+    vlan: 13
+    mtu: 1500
+    nic_mapping:
+      compute:
+        phys_type: interface
+        vlan: native
+        members:
+          - enp10s0
+      controller:
+        phys_type: interface
+        vlan: native
+        members:
+          - enp10s0
+
+# Apex specific settings
+apex:
+  networks:
+    admin:
+      introspection_range:
+        - 192.30.9.100
+        - 192.30.9.120
diff --git a/installers/joid/labconfig.jinja2 b/installers/joid/labconfig.jinja2
new file mode 100644 (file)
index 0000000..9e95730
--- /dev/null
@@ -0,0 +1,190 @@
+lab:
+  location: intel
+  racks:
+  - rack: pod5
+    nodes:
+    - name: rack-5-m1
+      architecture: x86_64
+      roles: [network,control]
+      nics:
+      - ifname: enp4s0f3
+        spaces: [admin]
+        mac: ["00:1E:67:CF:BB:54"]
+      - ifname: ens785f0
+        spaces: [data]
+        mac: ["90:E2:BA:85:4E:2C"]
+      - ifname: ens785f1.504
+        spaces: [public]
+        mac: ["90:E2:BA:85:4E:2D"]
+      - ifname: ens785f0.505
+        spaces: [floating]
+        mac: ["90:E2:BA:85:4E:2C"]
+      - ifname: ens785f1
+        spaces: [storage]
+        mac: ["90:E2:BA:85:4E:2D"]
+      power:
+        type: ipmi
+        address: {{ config['global_details']['ipmi_ips'][0] }}
+        user: root
+        pass: root
+    - name: rack-5-m2
+      architecture: x86_64
+      roles: [compute,control,storage]
+      nics:
+      - ifname: enp4s0f3
+        spaces: [admin]
+        mac: ["00:1E:67:CF:B8:93"]
+      - ifname: ens785f0
+        spaces: [data]
+        mac: ["90:E2:BA:84:08:B8"]
+      - ifname: ens785f1.504
+        spaces: [public]
+        mac: ["90:E2:BA:84:08:B9"]
+      - ifname: ens785f0.505
+        spaces: [floating]
+        mac: ["90:E2:BA:85:4E:2C"]
+      - ifname: ens785f1
+        spaces: [storage]
+        mac: ["90:E2:BA:85:4E:2D"]
+      power:
+        type: ipmi
+        address: {{ config['global_details']['ipmi_ips'][1] }}
+        user: root
+        pass: root
+    - name: rack-5-m3
+      architecture: x86_64
+      roles: [compute,control,storage]
+      nics:
+      - ifname: enp4s0f3
+        spaces: [admin]
+        mac: ["00:1E:67:E0:08:7F"]
+      - ifname: ens785f0
+        spaces: [data]
+        mac: ["90:E2:BA:84:07:0D"]
+      - ifname: ens785f1.504
+        spaces: [public]
+        mac: ["90:E2:BA:84:07:0E"]
+      - ifname: ens785f0.505
+        spaces: [floating]
+        mac: ["90:E2:BA:85:4E:2C"]
+      - ifname: ens785f1
+        spaces: [storage]
+        mac: ["90:E2:BA:85:4E:2D"]
+      power:
+        type: ipmi
+        address: {{ config['global_details']['ipmi_ips'][2] }}
+        user: root
+        pass: root
+    - name: rack-5-m4
+      architecture: x86_64
+      roles: [compute,storage]
+      nics:
+      - ifname: enp4s0f3
+        spaces: [admin]
+        mac: ["00:1E:67:E0:08:B1"]
+      - ifname: ens785f0
+        spaces: [data]
+        mac: ["90:E2:BA:83:FD:80"]
+      - ifname: ens785f1.504
+        spaces: [public]
+        mac: ["90:E2:BA:83:FD:81"]
+      - ifname: ens785f0.505
+        spaces: [floating]
+        mac: ["90:E2:BA:85:4E:2C"]
+      - ifname: ens785f1
+        spaces: [storage]
+        mac: ["90:E2:BA:85:4E:2D"]
+      power:
+        type: ipmi
+        address: {{ config['global_details']['ipmi_ips'][3] }}
+        user: root
+        pass: root
+    - name: rack-5-m5
+      architecture: x86_64
+      roles: [compute,storage]
+      nics:
+      - ifname: enp4s0f3
+        spaces: [admin]
+        mac: ["00:1E:67:E0:0A:4B"]
+      - ifname: ens785f0
+        spaces: [data]
+        mac: ["90:E2:BA:75:22:74"]
+      - ifname: ens785f1.504
+        spaces: [public]
+        mac: ["90:E2:BA:75:22:75"]
+      - ifname: ens785f0.505
+        spaces: [floating]
+        mac: ["90:E2:BA:85:4E:2C"]
+      - ifname: ens785f1
+        spaces: [storage]
+        mac: ["90:E2:BA:85:4E:2D"]
+      power:
+        type: ipmi
+        address: {{ config['global_details']['ipmi_ips'][4] }}
+        user: root
+        pass: root
+#    - name: rack-5-m6
+#      architecture: x86_64
+#      roles: [compute,storage]
+#      nics:
+#      - ifname: enp4s0f3
+#        spaces: [admin]
+#        mac: ["98:4F:EE:10:03:43"]
+#      - ifname: ens785f0
+#        spaces: [data]
+#        mac: ["00:1E:67:9C:3E:54"]
+#      - ifname: ens785f1.504
+#        spaces: [public]
+#        mac: ["00:1E:67:9C:3E:55"]
+#      power:
+#        type: ipmi
+        address: {{ config['global_details']['ipmi_ips'][5] }}
+#        user: root
+#        pass: root
+    floating-ip-range: 10.5.15.6,10.5.15.250,10.5.15.1,10.5.15.0/24
+    ext-port: "ens785f0.505"
+    dns: 8.8.8.8
+    osdomainname:
+opnfv:
+    release: c
+    distro: trusty
+    type: nonha
+    openstack: liberty
+    sdncontroller:
+    - type: nosdn
+    storage:
+    - type: ceph
+      disk: /dev/sdb
+    feature: odl_l2
+    spaces:
+    - type: admin
+      bridge: brAdm
+      cidr: 10.5.1.0/24
+      gateway: 10.5.1.1
+      vlan:
+    - type: data
+      bridge: brData
+      cidr: 10.5.12.0/24
+      gateway:
+      vlan:
+    - type: storage
+      bridge: brStor
+      cidr: 10.5.13.0/24
+      gateway:
+      vlan:
+    - type: public
+      bridge: brMgmt
+      cidr: 10.5.14.0/24
+      gateway:
+      vlan: 504
+    - type: floating
+      bridge: brPublic
+      cidr: 10.5.15.0/24
+      gateway:
+      vlan: 505
+    - type: external
+      bridge: brExt
+      cidr:
+      gateway:
+      ipaddress: 10.2.117.92
+      vlan:
diff --git a/labs/intel/pod5/pod.yaml b/labs/intel/pod5/pod.yaml
new file mode 100644 (file)
index 0000000..86077a7
--- /dev/null
@@ -0,0 +1,61 @@
+---
+### intel pod 5 descriptor file ###
+
+global_details:
+  pod owner:
+  contact:
+  arch: x86_64
+  ipmi_username: "root"
+  ipmi_password: "root"
+  ipmi_ips:
+    - 10.2.117.85
+    - 10.2.117.86
+    - 10.2.117.87
+    - 10.2.117.88
+    - 10.2.117.89
+    - 10.2.117.90
+jumphost:
+  name: ''
+  user: ''
+  pass: ''
+  ip:
+interfaces:
+  - features:
+      - dpdk
+      - sriov
+    mac_addresses:
+      jumphost: "00:25:B5:CC:00:4E"
+      node1: "00:25:B5:CC:00:1E"
+      node2: "00:25:B5:CC:00:5D"
+      node3: "00:25:B5:CC:00:1D"
+      node4: "00:25:B5:CC:00:3C"
+      node5: "00:25:B5:A0:00:5B"
+    networks:
+      - vlan: native
+        cidr: 192.30.9.0/24
+        gateway: 192.30.9.1
+        apex:
+          opnfv_net: admin
+        fuel:
+          opnfv_net: pxe
+        joid:
+          opnfv_net: interal_api
+
+      - vlan: 101
+        cidr: 10.0.1.0/24
+        fuel:
+          opnfv_net: tenant
+          tenant_type: vlan
+
+      - vlan: 102
+        cidr: 10.0.2.0/24
+        fuel:
+          opnfv_net: management
+          tenant_type: vlan
+      - vlan: 103
+        cidr: 10.0.3.0/24
+        fuel:
+          opnfv_net: tenant
+          tenant_type: vlan
+# 10  vlans 5 vlans on the private 2+ nics
+# public, private, admin(pxe), management, storage
diff --git a/utils/generate_config.py b/utils/generate_config.py
new file mode 100755 (executable)
index 0000000..2a2f20d
--- /dev/null
@@ -0,0 +1,23 @@
+#!/usr/bin/python
+"""This module does blah blah."""
+import argparse
+import yaml
+from jinja2 import Environment, FileSystemLoader
+
+parser = argparse.ArgumentParser()
+parser.add_argument("--yaml", "-y", type=str, required=True)
+parser.add_argument("--jinja2", "-j", type=str, required=True)
+args = parser.parse_args()
+
+
+ENV = Environment(loader=FileSystemLoader('./'))
+
+with open(args.yaml) as _:
+    dict = yaml.safe_load(_)
+
+# Print dictionary generated from yaml (uncomment for debug)
+#print dict
+
+# Render template and print generated config to console
+template = ENV.get_template(args.jinja2)
+print template.render(config=dict)