Join a Swarm Worker to the cluster

    remote_addr
        The manager node you want to connect to for the swarm

    listen_addr
        Listen address used for inter-manager communication if the node gets promoted to manager,
        as well as determining the networking interface used for the VXLAN Tunnel Endpoint (VTEP)

    token
        Either the manager join token or the worker join token.
        You can get the worker or manager token via ``salt '*' swarm.swarm_tokens``

    CLI Example:

    .. code-block:: bash

        salt '*' swarm.joinswarm remote_addr=192.168.50.10 listen_addr='0.0.0.0' \
            token='SWMTKN-1-64tux2g0701r84ofq93zppcih0pe081akq45owe9ts61f30x4t-06trjugdu7x2z47j938s54il'

def joinswarm(remote_addr=int,
              listen_addr=int,
              token=str):
    '''
    Join a Swarm Worker to the cluster

    remote_addr
        The manager node you want to connect to for the swarm

    listen_addr
        Listen address used for inter-manager communication if the node gets promoted to manager,
        as well as determining the networking interface used for the VXLAN Tunnel Endpoint (VTEP)

    token
        Either the manager join token or the worker join token.
        You can get the worker or manager token via ``salt '*' swarm.swarm_tokens``

    CLI Example:

    .. code-block:: bash

        salt '*' swarm.joinswarm remote_addr=192.168.50.10 listen_addr='0.0.0.0' \
            token='SWMTKN-1-64tux2g0701r84ofq93zppcih0pe081akq45owe9ts61f30x4t-06trjugdu7x2z47j938s54il'
    '''
    try:
        salt_return = {}
        __context__['client'].swarm.join(remote_addrs=[remote_addr],
                                         listen_addr=listen_addr,
                                         join_token=token)
        output = __context__['server_name'] + ' has joined the Swarm'
        salt_return.update({'Comment': output, 'Manager_Addr': remote_addr})
    except TypeError:
        salt_return = {}
        salt_return.update({'Error': 'Please make sure this minion is not part of a swarm and you are '
                                     'passing remote_addr, listen_addr and token correctly.'})
    return salt_return