Exemple #1
0
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
"""Pub/sub mechanism for status messages."""


from threading import Lock
from collections import deque
from logging import DEBUG

from twisted.internet import reactor

from aquilon.python_patches import load_uuid_quickly

uuid = load_uuid_quickly()  # pylint: disable=C0103


# Some requests can generate many debug messages.  After this limit is
# passed older records will be replaced with None.
# This is somewhat arbitrary as a number.  If each log message was a
# string of 100 bytes then 10000 would be about 1 MB.  However the log
# record object has quite a few more fields (source file, line, function
# name, and potentially exception info) which can bloat this quite a bit.
MAX_DEBUG_MESSAGES_PER_REQUEST = 10000


class RequestStatus(object):
    """Store status information for each incoming request.

    Each request will get one of these objects to write status
Exemple #2
0
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
"""Pub/sub mechanism for status messages."""

from threading import Lock
from collections import deque
from logging import DEBUG

from twisted.internet import reactor

from aquilon.python_patches import load_uuid_quickly

uuid = load_uuid_quickly()  # pylint: disable=C0103

# Some requests can generate many debug messages.  After this limit is
# passed older records will be replaced with None.
# This is somewhat arbitrary as a number.  If each log message was a
# string of 100 bytes then 10000 would be about 1 MB.  However the log
# record object has quite a few more fields (source file, line, function
# name, and potentially exception info) which can bloat this quite a bit.
MAX_DEBUG_MESSAGES_PER_REQUEST = 10000


class RequestStatus(object):
    """Store status information for each incoming request.

    Each request will get one of these objects to write status
    information into.  Other commands (currently only show_request)
Exemple #3
0
    if transport is None:
        print >> sys.stderr, "Unimplemented command ", command
        exit(1)

    # Convert unicode options to strings
    newOptions = {}
    for k, v in commandOptions.iteritems():
        newOptions[str(k)] = str(v)
    commandOptions = newOptions
    # Should maybe have an input.xml flag on which global options
    # to include... for now it's just debug.
    if globalOptions.get("debug", None):
        commandOptions["debug"] = str(globalOptions["debug"])
    if command != "show_request" and globalOptions.get("verbose"):
        uuid = load_uuid_quickly()
        commandOptions["requestid"] = str(uuid.uuid1())

    # Quote options so that they can be safely included in the URI
    cleanOptions = {}
    for k, v in commandOptions.iteritems():
        # urllib.quote() does not escape '/' by default. We have to turn off
        # this behavior because otherwise a parameter containing '/' would
        # confuse the URL parsing logic on the server side.
        cleanOptions[k] = urllib.quote(v, safe="")

    # Decent amount of magic here...
    # Even though the server connection might be tunneled through
    # knc, the easiest way to consistently address the server is with
    # a URI.  That's the first half.
    # The relative URI defined by transport.path comes from the xml
Exemple #4
0
    if transport is None:
        print >>sys.stderr, "Unimplemented command ", command
        exit(1)

    # Convert unicode options to strings
    newOptions = {}
    for k, v in commandOptions.iteritems():
        newOptions[str(k)] = str(v)
    commandOptions = newOptions
    # Should maybe have an input.xml flag on which global options
    # to include... for now it's just debug.
    if globalOptions.get("debug", None):
        commandOptions["debug"] = str(globalOptions["debug"])
    if command != "show_request" and globalOptions.get("verbose"):
        uuid = load_uuid_quickly()
        commandOptions["requestid"] = str(uuid.uuid1())

    # Quote options so that they can be safely included in the URI
    cleanOptions = {}
    for k, v in commandOptions.iteritems():
        # urllib.quote() does not escape '/' by default. We have to turn off
        # this behavior because otherwise a parameter containing '/' would
        # confuse the URL parsing logic on the server side.
        cleanOptions[k] = urllib.quote(v, safe='')

    # Decent amount of magic here...
    # Even though the server connection might be tunneled through
    # knc, the easiest way to consistently address the server is with
    # a URI.  That's the first half.
    # The relative URI defined by transport.path comes from the xml