#In case some of the previous 'bridge_ifaces' are connected to an EXTERNAL dhcp server, provide
# the server parameters to allow openvim getting the allocated IP addresses of virtual machines
# connected to the indicated 'bridge_ifaces' and or 'nets'. Openvim will connect to the dhcp server by ssh.
-#DHCP server must contain a shell script "./get_dhcp_lease.sh" that accept a mac address as parameter
-# and return empty or the allocated IP address. See an example at the end of the file ./openvim/dhcp_thread.py
+#DHCP server must contain a shell script "get_dhcp_lease.sh" included in the path, that accepts a mac address as
+# parameter and return empty or the allocated IP address. See an example at the end of the file
+# ./openvim/dhcp_thread.py
#COMMENT all lines in case you do not have a DHCP server in 'normal', 'development' or 'host only' modes.
# For 'test' or 'OF only' modes you can leave then uncommented, because in these modes fake IP
# address are generated instead of connecting with a real DHCP server.
# For those usages not covered by the Apache License, Version 2.0 please
# contact with: nfvlabs@tid.es
##
-awk '
-($1=="lease" && $3=="{"){ lease=$2; active="no"; found="no" }
-($1=="binding" && $2=="state" && $3=="active;"){ active="yes" }
-($1=="hardware" && $2=="ethernet" && $3==tolower("'$1';")){ found="yes" }
-($1=="client-hostname"){ name=$2 }
-($1=="}"){ if (active=="yes" && found=="yes"){ target_lease=lease; target_name=name}}
-END{printf("%s", target_lease)} #print target_name
-' /var/lib/dhcp/dhcpd.leases
+if [ -e /var/lib/dhcp/dhcpd.leases ]
+then
+ awk '
+ ($1=="lease" && $3=="{"){ lease=$2; active="no"; found="no" }
+ ($1=="binding" && $2=="state" && $3=="active;"){ active="yes" }
+ ($1=="hardware" && $2=="ethernet" && $3==tolower("'$1';")){ found="yes" }
+ ($1=="client-hostname"){ name=$2 }
+ ($1=="}"){ if (active=="yes" && found=="yes"){ target_lease=lease; target_name=name}}
+ END{printf("%s", target_lease)} #print target_name
+ ' /var/lib/dhcp/dhcpd.leases
+elif [ -e /var/lib/lxd-bridge/dnsmasq.lxdbr0.leases ]
+then
+ awk '
+ ($2=="'$1'"){ lease=$3; name=$4}
+ END{printf("%s", lease)}
+ ' /var/lib/lxd-bridge/dnsmasq.lxdbr0.leases
+fi