def _get_used_ports(vms):
    """
        Return a set of ports in use by the ``vms``.

        :param vms: list of virtual machines
        :type vms: list(:class:`~.vm.VM`)

        :return: set of ports
        :rtype: set(int)
    """

    used_ports = set()

    for vm in vms:
        ip, port = vm.get_ssh_info()

        if port:
            used_ports.add(port)

    return used_ports