예제 #1
0
파일: http.py 프로젝트: flyapen/UgFlu
def runHTTPStreamerChecks():
    """Runs all the http checks
    @returns: a deferred returning a guess of the public
              hostname for this worker
    """
    # FIXME: Move over more checks from httpstreamer.py
    log.debug('httpcheck', 'Checking...')
    result = Result()
    result.succeed(guess_public_hostname())
    log.debug('httpcheck', 'done, returning')
    return result
예제 #2
0
파일: http.py 프로젝트: sharky93/flumotion
def runHTTPStreamerChecks():
    """Runs all the http checks
    @returns: a deferred returning a guess of the public
              hostname for this worker
    """
    # FIXME: Move over more checks from httpstreamer.py
    log.debug('httpcheck', 'Checking...')
    result = Result()
    result.succeed(guess_public_hostname())
    log.debug('httpcheck', 'done, returning')
    return result
예제 #3
0
    def parseProperties(self, properties):
        mountPoint = properties.get('mount-point', '')
        if not mountPoint.startswith('/'):
            mountPoint = '/' + mountPoint
        self.mountPoint = mountPoint

        # Hostname is used for a variety of purposes. We do a best-effort guess
        # where nothing else is possible, but it's much preferable to just
        # configure this
        self.hostname = properties.get('hostname', None)
        self.iface = self.hostname # We listen on this if explicitly
                                   # configured, but not if it's only guessed
                                   # at by the below code.
        if not self.hostname:
            # Don't call this nasty, nasty, probably flaky function unless we
            # need to.
            self.hostname = netutils.guess_public_hostname()

        self.description = properties.get('description', None)
        if self.description is None:
            self.description = "Flumotion Stream"

        # check how to set client sync mode

        if 'client-limit' in properties:
            limit = int(properties['client-limit'])
            self.resource.setUserLimit(limit)
            if limit != self.resource.maxclients:
                m = messages.Info(T_(N_(
                    "Your system configuration does not allow the maximum "
                    "client limit to be set to %d clients."),
                    limit))
                m.description = T_(N_(
                    "Learn how to increase the maximum number of clients."))
                m.section = 'chapter-optimization'
                m.anchor = 'section-configuration-system-fd'
                self.addMessage(m)

        if 'bandwidth-limit' in properties:
            limit = int(properties['bandwidth-limit'])
            if limit < 1000:
                # The wizard used to set this as being in Mbps, oops.
                self.debug("Bandwidth limit set to unreasonably low %d bps, "
                    "assuming this is meant to be Mbps", limit)
                limit *= 1000000
            self.resource.setBandwidthLimit(limit)

        if 'redirect-on-overflow' in properties:
            self.resource.setRedirectionOnLimits(
                properties['redirect-on-overflow'])

        if 'bouncer' in properties:
            self.httpauth.setBouncerName(properties['bouncer'])

        if 'allow-default' in properties:
            self.httpauth.setAllowDefault(properties['allow-default'])

        if 'duration' in properties:
            self.httpauth.setDefaultDuration(
                float(properties['duration']))

        if 'domain' in properties:
            self.httpauth.setDomain(properties['domain'])

        if 'avatarId' in self.config:
            self.httpauth.setRequesterId(self.config['avatarId'])

        if 'ip-filter' in properties:
            logFilter = http.LogFilter()
            for f in properties['ip-filter']:
                logFilter.addIPFilter(f)
            self.resource.setLogFilter(logFilter)

        if 'timeout' in properties:
            self.timeout = properties['timeout'] * gst.SECOND

        self.type = properties.get('type', 'master')
        if self.type == 'slave':
            # already checked for these in do_check
            self._porterPath = properties['porter-socket-path']
            self._porterUsername = properties['porter-username']
            self._porterPassword = properties['porter-password']

        self.port = int(properties.get('port', 8800))
예제 #4
0
    def have_properties(self, props):
        desc = props.get('description', None)
        if desc:
            self._description = desc

        # always make sure the mount point starts with /
        mountPoint = props.get('mount-point', '/')
        if not mountPoint.startswith('/'):
            mountPoint = '/' + mountPoint
        self.mountPoint = mountPoint
        self.hostname = props.get('hostname', None)
        if not self.hostname:
            self.hostname = netutils.guess_public_hostname()

        self.type = props.get('type', 'master')
        self.port = props.get('port', 8801)
        self._allowBrowsing = props.get('allow-browsing', False)
        if self.type == 'slave':
            # already checked for these in do_check
            self._porterPath = props['porter-socket-path']
            self._porterUsername = props['porter-username']
            self._porterPassword = props['porter-password']
        socket = 'flumotion.component.plugs.request.RequestLoggerPlug'
        self._loggers = self.plugs.get(socket, [])
        socket = \
          'flumotion.component.plugs.requestmodifier.RequestModifierPlug'
        self._requestModifiers = self.plugs.get(socket, [])

        self.httpauth = httpbase.HTTPAuthentication(self)
        if 'avatarId' in self.config:
            self.httpauth.setRequesterId(self.config['avatarId'])
        if 'bouncer' in props:
            self.httpauth.setBouncerName(props['bouncer'])
        if 'issuer-class' in props:
            self.warning("The component property 'issuer-class' has been"
                         "deprecated.")
            msg = messages.Warning(
                T_(
                    N_("The component property 'issuer-class' has "
                       "been deprecated.")))
            self.addMessage(msg)

        if 'allow-default' in props:
            self.httpauth.setAllowDefault(props['allow-default'])
        if 'ip-filter' in props:
            logFilter = http.LogFilter()
            for f in props['ip-filter']:
                logFilter.addIPFilter(f)
            self._logfilter = logFilter
        socket = \
          'flumotion.component.misc.httpserver.ratecontrol.RateControllerPlug'
        plugs = self.plugs.get(socket, [])
        if plugs:
            # Rate controller factory plug; only one supported.
            self._rateControlPlug = self.plugs[socket][-1]

        plugs = self.plugs.get(FILEPROVIDER_SOCKET, [])
        if plugs:
            # FileProvider factory plug; only one supported.
            self._fileProviderPlug = plugs[-1]
        else:
            # Create a default local provider using path property
            # Delegate the property checks to the plug
            plugProps = {"properties": {"path": props.get('path', None)}}
            self._fileProviderPlug = localprovider.FileProviderLocalPlug(
                plugProps)

        socket = ('flumotion.component.misc.httpserver'
                  '.metadataprovider.MetadataProviderPlug')
        plugs = self.plugs.get(socket, [])
        if plugs:
            self._metadataProviderPlug = plugs[-1]

        # Update uiState
        self.uiState.set('stream-url', self.getUrl())
        self.uiState.set('allow-browsing', self._allowBrowsing)
예제 #5
0
    def have_properties(self, props):
        desc = props.get('description', None)
        if desc:
            self._description = desc

        # always make sure the mount point starts with /
        mountPoint = props.get('mount-point', '/')
        if not mountPoint.startswith('/'):
            mountPoint = '/' + mountPoint
        self.mountPoint = mountPoint
        self.hostname = props.get('hostname', None)
        if not self.hostname:
            self.hostname = netutils.guess_public_hostname()

        self.type = props.get('type', 'master')
        self.port = props.get('port', 8801)
        self._allowBrowsing = props.get('allow-browsing', False)
        if self.type == 'slave':
            # already checked for these in do_check
            self._porterPath = props['porter-socket-path']
            self._porterUsername = props['porter-username']
            self._porterPassword = props['porter-password']
        socket = 'flumotion.component.plugs.request.RequestLoggerPlug'
        self._loggers = self.plugs.get(socket, [])
        socket = \
          'flumotion.component.plugs.requestmodifier.RequestModifierPlug'
        self._requestModifiers = self.plugs.get(socket, [])

        self.httpauth = httpbase.HTTPAuthentication(self)
        if 'avatarId' in self.config:
            self.httpauth.setRequesterId(self.config['avatarId'])
        if 'bouncer' in props:
            self.httpauth.setBouncerName(props['bouncer'])
        if 'issuer-class' in props:
            self.warning("The component property 'issuer-class' has been"
                         "deprecated.")
            msg = messages.Warning(T_(N_(
                        "The component property 'issuer-class' has "
                        "been deprecated.")))
            self.addMessage(msg)

        if 'allow-default' in props:
            self.httpauth.setAllowDefault(props['allow-default'])
        if 'ip-filter' in props:
            logFilter = http.LogFilter()
            for f in props['ip-filter']:
                logFilter.addIPFilter(f)
            self._logfilter = logFilter
        socket = \
          'flumotion.component.misc.httpserver.ratecontrol.RateControllerPlug'
        plugs = self.plugs.get(socket, [])
        if plugs:
            # Rate controller factory plug; only one supported.
            self._rateControlPlug = self.plugs[socket][-1]

        plugs = self.plugs.get(FILEPROVIDER_SOCKET, [])
        if plugs:
            # FileProvider factory plug; only one supported.
            self._fileProviderPlug = plugs[-1]
        else:
            # Create a default local provider using path property
            # Delegate the property checks to the plug
            plugProps = {"properties": {"path": props.get('path', None)}}
            self._fileProviderPlug = localprovider.FileProviderLocalPlug(
                plugProps)

        socket = ('flumotion.component.misc.httpserver'
                 '.metadataprovider.MetadataProviderPlug')
        plugs = self.plugs.get(socket, [])
        if plugs:
            self._metadataProviderPlug = plugs[-1]

        # Update uiState
        self.uiState.set('stream-url', self.getUrl())
        self.uiState.set('allow-browsing', self._allowBrowsing)
예제 #6
0
    def parseProperties(self, properties):
        mountPoint = properties.get('mount-point', '')
        if not mountPoint.startswith('/'):
            mountPoint = '/' + mountPoint
        self.mountPoint = mountPoint

        # Hostname is used for a variety of purposes. We do a best-effort guess
        # where nothing else is possible, but it's much preferable to just
        # configure this
        self.hostname = properties.get('hostname', None)
        self.iface = self.hostname  # We listen on this if explicitly
        # configured, but not if it's only guessed
        # at by the below code.
        if not self.hostname:
            # Don't call this nasty, nasty, probably flaky function unless we
            # need to.
            self.hostname = netutils.guess_public_hostname()

        self.description = properties.get('description', None)
        if self.description is None:
            self.description = "Flumotion Stream"

        # check how to set client sync mode

        if 'client-limit' in properties:
            limit = int(properties['client-limit'])
            self.resource.setUserLimit(limit)
            if limit != self.resource.maxclients:
                m = messages.Info(
                    T_(
                        N_("Your system configuration does not allow the maximum "
                           "client limit to be set to %d clients."), limit))
                m.description = T_(
                    N_("Learn how to increase the maximum number of clients."))
                m.section = 'chapter-optimization'
                m.anchor = 'section-configuration-system-fd'
                self.addMessage(m)

        if 'bandwidth-limit' in properties:
            limit = int(properties['bandwidth-limit'])
            if limit < 1000:
                # The wizard used to set this as being in Mbps, oops.
                self.debug(
                    "Bandwidth limit set to unreasonably low %d bps, "
                    "assuming this is meant to be Mbps", limit)
                limit *= 1000000
            self.resource.setBandwidthLimit(limit)

        if 'redirect-on-overflow' in properties:
            self.resource.setRedirectionOnLimits(
                properties['redirect-on-overflow'])

        if 'bouncer' in properties:
            self.httpauth.setBouncerName(properties['bouncer'])

        if 'allow-default' in properties:
            self.httpauth.setAllowDefault(properties['allow-default'])

        if 'duration' in properties:
            self.httpauth.setDefaultDuration(float(properties['duration']))

        if 'domain' in properties:
            self.httpauth.setDomain(properties['domain'])

        if 'avatarId' in self.config:
            self.httpauth.setRequesterId(self.config['avatarId'])

        if 'ip-filter' in properties:
            logFilter = http.LogFilter()
            for f in properties['ip-filter']:
                logFilter.addIPFilter(f)
            self.resource.setLogFilter(logFilter)

        if 'timeout' in properties:
            self.timeout = properties['timeout'] * gst.SECOND

        self.type = properties.get('type', 'master')
        if self.type == 'slave':
            # already checked for these in do_check
            self._porterPath = properties['porter-socket-path']
            self._porterUsername = properties['porter-username']
            self._porterPassword = properties['porter-password']

        self.port = int(properties.get('port', 8800))
예제 #7
0
    def configure_pipeline(self, pipeline, properties):
        Stats.__init__(self, sink=self.get_element('sink'))

        self._updateCallLaterId = reactor.callLater(10, self._updateStats)

        mountPoint = properties.get('mount-point', '')
        if not mountPoint.startswith('/'):
            mountPoint = '/' + mountPoint
        self.mountPoint = mountPoint

        # Hostname is used for a variety of purposes. We do a best-effort guess
        # where nothing else is possible, but it's much preferable to just
        # configure this
        self.hostname = properties.get('hostname', None)
        self.iface = self.hostname # We listen on this if explicitly
                                   # configured, but not if it's only guessed
                                   # at by the below code.
        if not self.hostname:
            # Don't call this nasty, nasty, probably flaky function unless we
            # need to.
            self.hostname = netutils.guess_public_hostname()

        self.description = properties.get('description', None)
        if self.description is None:
            self.description = "Flumotion Stream"

        # FIXME: tie these together more nicely
        self.httpauth = http.HTTPAuthentication(self)
        self.resource = resources.HTTPStreamingResource(self,
                                                        self.httpauth)

        # check how to set client sync mode
        sink = self.get_element('sink')
        self.burst_on_connect = properties.get('burst-on-connect', False)
        self.burst_size = properties.get('burst-size', 0)
        self.burst_time = properties.get('burst-time', 0.0)

        self.setup_burst_mode(sink)

        sink.connect('deep-notify::caps', self._notify_caps_cb)

        # these are made threadsafe using idle_add in the handler
        sink.connect('client-added', self._client_added_handler)

        # We now require a sufficiently recent multifdsink anyway that we can
        # use the new client-fd-removed signal
        sink.connect('client-fd-removed', self._client_fd_removed_cb)
        sink.connect('client-removed', self._client_removed_cb)

        if 'client-limit' in properties:
            limit = int(properties['client-limit'])
            self.resource.setUserLimit(limit)
            if limit != self.resource.maxclients:
                m = messages.Info(T_(N_(
                    "Your system configuration does not allow the maximum "
                    "client limit to be set to %d clients."),
                    limit))
                m.description = T_(N_(
                    "Learn how to increase the maximum number of clients."))
                m.section = 'chapter-optimization'
                m.anchor = 'section-configuration-system-fd'
                self.addMessage(m)

        if 'bandwidth-limit' in properties:
            limit = int(properties['bandwidth-limit'])
            if limit < 1000:
                # The wizard used to set this as being in Mbps, oops.
                self.debug("Bandwidth limit set to unreasonably low %d bps, "
                    "assuming this is meant to be Mbps", limit)
                limit *= 1000000
            self.resource.setBandwidthLimit(limit)

        if 'redirect-on-overflow' in properties:
            self.resource.setRedirectionOnLimits(
                properties['redirect-on-overflow'])

        if 'bouncer' in properties:
            self.httpauth.setBouncerName(properties['bouncer'])

        if 'issuer-class' in properties:
            self.httpauth.setIssuerClass(properties['issuer-class'])

        if 'duration' in properties:
            self.httpauth.setDefaultDuration(
                float(properties['duration']))

        if 'domain' in properties:
            self.httpauth.setDomain(properties['domain'])

        if 'avatarId' in self.config:
            self.httpauth.setRequesterId(self.config['avatarId'])

        if 'ip-filter' in properties:
            logFilter = http.LogFilter()
            for f in properties['ip-filter']:
                logFilter.addIPFilter(f)
            self.resource.setLogFilter(logFilter)

        self.type = properties.get('type', 'master')
        if self.type == 'slave':
            # already checked for these in do_check
            self._porterPath = properties['porter-socket-path']
            self._porterUsername = properties['porter-username']
            self._porterPassword = properties['porter-password']

        self.port = int(properties.get('port', 8800))
예제 #8
0
    def have_properties(self, props):
        desc = props.get("description", None)
        if desc:
            self._description = desc

        # always make sure the mount point starts with /
        mountPoint = props.get("mount-point", "/")
        if not mountPoint.startswith("/"):
            mountPoint = "/" + mountPoint
        self.mountPoint = mountPoint
        self.hostname = props.get("hostname", None)
        if not self.hostname:
            self.hostname = netutils.guess_public_hostname()

        self.type = props.get("type", "master")
        self.port = props.get("port", 8801)
        self._allowBrowsing = props.get("allow-browsing", False)
        if self.type == "slave":
            # already checked for these in do_check
            self._porterPath = props["porter-socket-path"]
            self._porterUsername = props["porter-username"]
            self._porterPassword = props["porter-password"]
        socket = "flumotion.component.plugs.request.RequestLoggerPlug"
        self._loggers = self.plugs.get(socket, [])
        socket = "flumotion.component.plugs.requestmodifier.RequestModifierPlug"
        self._requestModifiers = self.plugs.get(socket, [])

        self.httpauth = httpbase.HTTPAuthentication(self)
        if "avatarId" in self.config:
            self.httpauth.setRequesterId(self.config["avatarId"])
        if "bouncer" in props:
            self.httpauth.setBouncerName(props["bouncer"])
        if "issuer-class" in props:
            self.warning("The component property 'issuer-class' has been" "deprecated.")
            msg = messages.Warning(T_(N_("The component property 'issuer-class' has " "been deprecated.")))
            self.addMessage(msg)

        if "allow-default" in props:
            self.httpauth.setAllowDefault(props["allow-default"])
        if "ip-filter" in props:
            logFilter = http.LogFilter()
            for f in props["ip-filter"]:
                logFilter.addIPFilter(f)
            self._logfilter = logFilter
        socket = "flumotion.component.misc.httpserver.ratecontrol.RateControllerPlug"
        plugs = self.plugs.get(socket, [])
        if plugs:
            # Rate controller factory plug; only one supported.
            self._rateControlPlug = self.plugs[socket][-1]

        plugs = self.plugs.get(FILEPROVIDER_SOCKET, [])
        if plugs:
            # FileProvider factory plug; only one supported.
            self._fileProviderPlug = plugs[-1]
        else:
            # Create a default local provider using path property
            # Delegate the property checks to the plug
            plugProps = {"properties": {"path": props.get("path", None)}}
            self._fileProviderPlug = localprovider.FileProviderLocalPlug(plugProps)

        socket = "flumotion.component.misc.httpserver" ".metadataprovider.MetadataProviderPlug"
        plugs = self.plugs.get(socket, [])
        if plugs:
            self._metadataProviderPlug = plugs[-1]

        # Update uiState
        self.uiState.set("stream-url", self.getUrl())
        self.uiState.set("allow-browsing", self._allowBrowsing)