3 # Copyright 2016 Telefónica Investigación y Desarrollo, S.A.U.
4 # This file is part of openvim
7 # Licensed under the Apache License, Version 2.0 (the "License"); you may
8 # not use this file except in compliance with the License. You may obtain
9 # a copy of the License at
11 # http://www.apache.org/licenses/LICENSE-2.0
13 # Unless required by applicable law or agreed to in writing, software
14 # distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
15 # WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
16 # License for the specific language governing permissions and limitations
19 # For those usages not covered by the Apache License, Version 2.0 please
20 # contact with: nfvlabs@tid.es
23 if [ -e /var
/lib
/dhcp
/dhcpd.leases
]
26 ($1=="lease" && $3=="{"){ lease=$2; active="no"; found="no" }
27 ($1=="binding" && $2=="state" && $3=="active;"){ active="yes" }
28 ($1=="hardware" && $2=="ethernet" && $3==tolower("'$1';")){ found="yes" }
29 ($1=="client-hostname"){ name=$2 }
30 ($1=="}"){ if (active=="yes" && found=="yes"){ target_lease=lease; target_name=name}}
31 END{printf("%s", target_lease)} #print target_name
32 ' /var
/lib
/dhcp
/dhcpd.leases
33 elif [ -e /var
/lib
/lxd-bridge
/dnsmasq.lxdbr0.leases
]
36 ($2=="'$1'"){ lease=$3; name=$4}
37 END{printf("%s", lease)}
38 ' /var
/lib
/lxd-bridge
/dnsmasq.lxdbr0.leases