Esempio n. 1
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)
 def __init__(self, path):
     plugProps = {"properties": {"path": path}}
     self._fileProviderPlug = localprovider.FileProviderLocalPlug(plugProps)