summaryrefslogtreecommitdiffstats
path: root/playbooks/roles/configure-vms/templates/Debian.interface.j2
diff options
context:
space:
mode:
authorRihab Banday <rihab.banday@ericsson.com>2021-05-31 20:23:21 +0200
committerRihab Banday <rihab.banday@ericsson.com>2021-09-01 15:03:29 +0000
commitbc1786a24447121b5005492aaea8ca786135be29 (patch)
treecd6ced17b39538afc2bb97c733bf9a18560af5c5 /playbooks/roles/configure-vms/templates/Debian.interface.j2
parent3fe71dc93fb81199401f921c10d4fe6220aa7175 (diff)
Add initial config to support deployments on VMs
* Add initial version of PDF and IDF that will be consumed by the hardware provisioner used in Kuberef to bring up libvirt VMs (for now 2 VMs for dev purposes). * Add deploy_on_vms.sh script to deploy Kuberef on VMs * Add new functions referenced by the deploy_on_vms.sh script - these can be merged with existing functions * Modify some of te BMRA templates to accomodate new changes. This has been tested on Ubuntu 18.04 baremetal server. Change-Id: I95a5e85cdab95befd24a1cae9f367b32ce26621e Signed-off-by: Rihab Banday <rihab.banday@ericsson.com> Reviewed-on: https://gerrit.opnfv.org/gerrit/c/kuberef/+/72621 Tested-by: jenkins-ci <jenkins-opnfv-ci@opnfv.org> Reviewed-by: Michael Pedersen <michaelx.pedersen@intel.com> Reviewed-by: Georg Kunz <georg.kunz@ericsson.com>
Diffstat (limited to 'playbooks/roles/configure-vms/templates/Debian.interface.j2')
-rw-r--r--playbooks/roles/configure-vms/templates/Debian.interface.j233
1 files changed, 33 insertions, 0 deletions
diff --git a/playbooks/roles/configure-vms/templates/Debian.interface.j2 b/playbooks/roles/configure-vms/templates/Debian.interface.j2
new file mode 100644
index 0000000..ef1a9fd
--- /dev/null
+++ b/playbooks/roles/configure-vms/templates/Debian.interface.j2
@@ -0,0 +1,33 @@
+{%- set macaddress = item.key -%}
+{%- set device = item.value -%}
+{%- for selected_net_name, selected_net in idf.net_config.items() if node.interfaces[selected_net.interface].mac_address == macaddress -%}
+{%- set selected_inf = node.interfaces[selected_net.interface] -%}
+{%- set ifname = device if selected_inf.vlan == 'native' else device + '.' + selected_inf.vlan -%}
+{%- set proto = "inet6" if selected_net.network | ipv6 else "inet" -%}
+{%- set method = selected_inf.address if selected_inf.address in ["dhcp", "manual"] else "static" -%}
+
+auto {{ ifname }}
+iface {{ ifname }} {{ proto }} {{ method }}
+{% if selected_net.gateway is defined %}
+up route add default gateway {{ selected_net.gateway | ipaddr('address') }}
+{% endif %}
+{% if method != "manual" %}
+address {{ selected_inf.address | ipaddr('address') }}
+{% endif %}
+{% if selected_inf.address | ipv6 %}
+netmask {{ selected_net.mask }}
+{% endif %}
+{% if selected_inf.address | ipv4 %}
+netmask {{ (selected_net.network + "/" + (selected_net.mask | string)) | ipaddr('netmask') }}
+{% endif %}
+{% if selected_net.gateway is defined %}
+gateway {{ selected_net.gateway | ipaddr('address') }}
+{% endif %}
+{% if selected_net.routes is defined %}
+{% for route in selected_net.routes %}
+up route add -net {{ route.network }}/{{ route.mask }} gw {{ route.gateway }}
+{% endfor %}
+{% endif %}
+
+{%- endfor -%}
+