<SYSTEM_TASK:>
Solve the following problem using Python, implementing the functions described below, one line at a time
<END_TASK>
<USER_TASK:>
Description:
 def ping(token_or_hostname=None):
 """ Send an echo request to a nago host. Arguments: token_or_host_name -- The remote node to ping If node is not provided, simply return pong You can use the special nodenames "server" or "master" """

    if not token_or_hostname:
        return "Pong!"
    node = nago.core.get_node(token_or_hostname)
    if not node and token_or_hostname in ('master', 'server'):
        token_or_hostname = nago.settings.get_option('server')
        node = nago.core.get_node(token_or_hostname)
    if not node:
        try:
            address = socket.gethostbyname(token_or_hostname)
            node = nago.core.Node()
            node['host_name'] = token_or_hostname
            node['address'] = address
            node['access'] = 'node'
            if token_or_hostname == nago.settings.get_option('server'):
                node['access'] = 'master'
            node.save()
        except Exception:
            raise Exception("'%s' was not found in list of known hosts, and does not resolve to a valid address" % token_or_hostname)
    return node.send_command('nodes', 'ping')