Ejemplo n.º 1
0
def _create_provider_int(spec, singleton=True):
    """
    Parse the spec and create ApiProviders

    :type  spec: :class:`str`
    :param spec: Provider configuration
    :type  singleton: :class:`bool`
    :kwarg singleton: Specify whether to create new instances of Providers or
                      use existing ones
    :rtype:  :class:`vmware.vapi.core.ApiProvider`
    :return: Api provider instance
    """
    provider_config = config.ProviderConfig(spec)

    # Configure logging
    configure_logging(provider_config.cfg, spec)
    providers = setup_provider_chain(provider_config, singleton)
    if not providers:
        return (provider_config, providers)

    if 'ENABLE_VAPI_PROVIDER_WIRE_LOGGING' in os.environ:
        get_provider_wire_logger().propagate = True
    # Get the first API Provider to connect to RPC
    provider = providers[0]
    return (provider_config, providers)
Ejemplo n.º 2
0
 def setUp(self):
     self.raw_request_logger = get_raw_request_logger()
     self.client_wire_logger = get_client_wire_logger()
     self.provider_wire_logger = get_provider_wire_logger()
     self.log_capture_string = cStringIO()
     self.ch = logging.StreamHandler(self.log_capture_string)
     self.ch.setLevel(logging.DEBUG)
     self.root_logger = logging.getLogger()
     self.root_logger.addHandler(self.ch)
Ejemplo n.º 3
0
import six
import ssl
import werkzeug
from werkzeug.exceptions import HTTPException
from werkzeug.routing import (Rule, Map)
from werkzeug.wrappers import Request, Response
from wsgiref.simple_server import make_server

from vmware.vapi.lib.addr_url_parser import parse_addr_url
from vmware.vapi.lib.constants import (JSON_CONTENT_TYPE, JSONRPC)
from vmware.vapi.lib.log import get_vapi_logger, get_provider_wire_logger
from vmware.vapi.rest.handler import RESTHandler
from vmware.vapi.server.server_interface import ServerInterface

logger = get_vapi_logger(__name__)
provider_wire_logger = get_provider_wire_logger()


class WsgiApplication(object):
    """
    Python WSGI application. For more details about WSGI
    specification, see PEP 333.
    """
    def __init__(self, msg_handler_map, provider_config):
        """
        Initialize WsgiApplication

        :type  msg_handler_map: :class:`dict` of :class:`str` and
            :class:`vmware.vapi.protocol.server.api_handler.ApiHandler`
        :param msg_handler_map: Map of content type to the message
            handler for that content type