'Returns a host object for the host matching the
specified hostname'

def get_host_by_hostname(self, hostname, collector):

    self.module.debug('Running    LogicMonitor.get_host_by_hostname...')
    self.module.debug(('Looking    for    hostname    ' + hostname))
    self.module.debug("Making    RPC    call    to    'getHosts'")
    hostlist_json = json.loads(self.rpc('getHosts', {'hostGroupId': 1}))
    if collector:
        if (hostlist_json['status'] == 200):
            self.module.debug('RPC    call    succeeded')
            hosts = hostlist_json['data']['hosts']
            self.module.debug(((('Looking    for    host    matching:    hostname    ' + hostname) + '    and    collector    ') + str(collector['id'])))
            for host in hosts:
                if ((host['hostName'] == hostname) and (host['agentId'] == collector['id'])):
                    self.module.debug('Host    match    found')
                    return host
            self.module.debug('No    host    match    found')
            return None
        else:
            self.module.debug('RPC    call    failed')
            self.module.debug(hostlist_json)
    else:
        self.module.debug('No    collector    specified')
        return None
