def verify_socket(interface, pub_port, ret_port):

    addr_family = lookup_family(interface)
    pubsock = socket.socket(addr_family, socket.SOCK_STREAM)
    retsock = socket.socket(addr_family, socket.SOCK_STREAM)
    try:
        pubsock.setsockopt(socket.SOL_SOCKET, socket.SO_REUSEADDR, 1)
        pubsock.bind((interface, int(pub_port)))
        pubsock.close()
        retsock.setsockopt(socket.SOL_SOCKET, socket.SO_REUSEADDR, 1)
        retsock.bind((interface, int(ret_port)))
        retsock.close()
        result = True
    except Exception as exc:
        if exc.args:
            msg = ('Unable to bind socket, error: {0}'.format(str(exc)))
        else:
            msg = ('Unable to bind socket, this might not be a problem.'
                   ' Is there another salt-master running?')
        if is_console_configured():
            log.warning(msg)
        else:
            sys.stderr.write('WARNING: {0}\n'.format(msg))
        result = False
    finally:
        pubsock.close()
        retsock.close()

    return result
Handles allocating the floating IP resources for an instance.
dataset/ETHPy150Open saltstack/salt/salt/utils/verify.py/verify_socket--crossover with--dataset/ETHPy150Open openstack/nova/nova/network/floating_ips.py/FloatingIP.allocate_for_instance