Check exists tunnel interface
Change-Id: I641cee9777e62523cdafe8646746be15002709b0
diff --git a/de/heat-templates/scripts/instance_boot.sh b/de/heat-templates/scripts/instance_boot.sh
index 2d5db67..db1a290 100644
--- a/de/heat-templates/scripts/instance_boot.sh
+++ b/de/heat-templates/scripts/instance_boot.sh
@@ -718,18 +718,21 @@
function collect_interfaces_metadata {
local if_metadata_file="/usr/share/metadata/interfaces.yaml"
+ if [ -z "${TUNNEL_INTERFACE}" ] ; then
+ echo "Tunnel interface is empty"
+ else
+ pci_id=$(ethtool -i ${TUNNEL_INTERFACE} |grep bus-info | awk '{print $2}')
+ mac=$(cat $(find /sys/bus/pci/devices/${pci_id}/ -name net)/${TUNNEL_INTERFACE}/address)
+ ip=${TUNNEL_INTERFACE_IP}/${TUNNEL_INTERFACE_NETWORK_NETMASK}
- pci_id=$(ethtool -i ${TUNNEL_INTERFACE} |grep bus-info | awk '{print $2}')
- mac=$(cat $(find /sys/bus/pci/devices/${pci_id}/ -name net)/${TUNNEL_INTERFACE}/address)
- ip=${TUNNEL_INTERFACE_IP}/${TUNNEL_INTERFACE_NETWORK_NETMASK}
-
- cat << EOF > ${if_metadata_file}
+ cat << EOF > ${if_metadata_file}
${TUNNEL_INTERFACE}:
pci_id: "${pci_id}"
ip_addr: "${ip}"
mac: "${mac}"
EOF
+ fi
HW_METADATA=$(echo ${HW_METADATA} | jq -cr ". += {\"interfaces\": {\"$(hostname)\": \"$(base64 -w 0 ${if_metadata_file})\"}}")
}