From 8971bc4882e588153a3d60a8b0e70fa7b5bb3b32 Mon Sep 17 00:00:00 2001 From: Sirajudeen Date: Thu, 26 Aug 2021 20:58:35 +0000 Subject: [PATCH] skip generating etherenet_mac_address when null * Host-generator template is generating a null value like below when host catalogue is not having any mac value for the interface. ethernet_mac_address: * added another condition to ethernet_mac_address generation logic so generate only if macAddresses is provided and if it has value for the respective interface ( oam, pxe ...) Closes: #404 Change-Id: I2fafe5ceaa4c58855a17929c1c41d60045d1675a --- .../templater/local-resource/example-use.yaml | 14 +++++++++++--- .../function/hostgenerator-m3/hosttemplate.yaml | 2 +- 2 files changed, 12 insertions(+), 4 deletions(-) diff --git a/krm-functions/templater/local-resource/example-use.yaml b/krm-functions/templater/local-resource/example-use.yaml index 8594135fa..981987d8d 100644 --- a/krm-functions/templater/local-resource/example-use.yaml +++ b/krm-functions/templater/local-resource/example-use.yaml @@ -18,10 +18,16 @@ metadata: image: localhost/templater values: hosts: - - macAddress: 00:aa:bb:cc:dd + - macAddresses: + oam: 00:aa:bb:cc:dd + pxe: 00:aa:bb:cc:ee name: node-1 - - macAddress: 00:aa:bb:cc:ee + - macAddresses: + oam: 00:aa:bb:cc:ff name: node-2 + - macAddresses: + pxe: 00:aa:bb:cc:22 + name: node-3 template: | {{ range .hosts -}} --- @@ -30,5 +36,7 @@ template: | metadata: name: {{ .name }} spec: - bootMACAddress: {{ .macAddress }} + {{- if and (.macAddresses) (.macAddresses.oam) }} + bootMACAddress: {{ .macAddresses.oam }} + {{- end }} {{ end -}} diff --git a/manifests/function/hostgenerator-m3/hosttemplate.yaml b/manifests/function/hostgenerator-m3/hosttemplate.yaml index 9e66aba42..4e641fd81 100644 --- a/manifests/function/hostgenerator-m3/hosttemplate.yaml +++ b/manifests/function/hostgenerator-m3/hosttemplate.yaml @@ -92,7 +92,7 @@ template: | {{- range $envAll.commonNetworking.links }} - {{ toYaml . | indent 6 }} - {{- if $host.macAddresses }} + {{- if and ($host.macAddresses) (index $host.macAddresses .id) }} ethernet_mac_address: {{ index $host.macAddresses .id }} {{- end }} {{- end }}