Validates give port for use as rpc server port.

def _validate_rpc_port(port):
    """Validates give port for use as rpc server port.
    """
    if not port:
        raise NetworkControllerError(desc='Invalid rpc port number.')
    if isinstance(port, str):
        port = int(port)

    if port <= 0:
        raise NetworkControllerError(desc='Invalid rpc port number %s' % port)
    return port