parameters: ()
return_statement: return entries
docstring: Return all current reservations as a list of json objects
      :return: list of objects in this format:
      {
          "ip-address": "192.168.122.171",
          "mac-address": "52:54:00:00:42:00",
          "name": "vmx01"
      }
docstring_summary: Return all current reservations as a list of json objects
      :return: list of objects in this format:
      {
          "ip-address": "192.168.122.171",
          "mac-address": "52:54:00:00:42:00",
          "name": "vmx01"
      }
docstring_tokens: Return all current reservations as a list of json objects : return : list of objects in this format : { ip - address : 192 . 168 . 122 . 171 mac - address : 52 : 54 : 00 : 00 : 42 : 00 name : vmx01 }
function: def get_dhcp_reservations():
      """
      Return all current reservations as a list of json objects
      :return: list of objects in this format:
      {
          "ip-address": "192.168.122.171",
          "mac-address": "52:54:00:00:42:00",
          "name": "vmx01"
      }
      """
      dhcp_hosts_file_path = "/var/lib/libvirt/dnsmasq/default.hostsfile"
  
      if not os.path.exists(dhcp_hosts_file_path):
          return []
  
      # basic strategy is to pull all entries into an array unless the line matches our mac!
      entries = []
      with open(dhcp_hosts_file_path, 'r') as hosts_file:
          for entry in hosts_file:
              e = entry.strip().split(',')
              m = e[0]
              i = e[1]
              if len(e) == 3:
                  n = e[2]
              else:
                  n = ''
              entry_object = dict()
              entry_object["ip-address"] = i
              entry_object["mac-address"] = m
              entry_object['name'] = n
              entries.append(entry_object)
  
      return entries
function_tokens: def get_dhcp_reservations ( ) : dhcp_hosts_file_path = "/var/lib/libvirt/dnsmasq/default.hostsfile" if not os . path . exists ( dhcp_hosts_file_path ) : return [ ] # basic strategy is to pull all entries into an array unless the line matches our mac! entries = [ ] with open ( dhcp_hosts_file_path , 'r' ) as hosts_file : for entry in hosts_file : e = entry . strip ( ) . split ( ',' ) m = e [ 0 ] i = e [ 1 ] if len ( e ) == 3 : n = e [ 2 ] else : n = '' entry_object = dict ( ) entry_object [ "ip-address" ] = i entry_object [ "mac-address" ] = m entry_object [ 'name' ] = n entries . append ( entry_object ) return entries