Пример #1
0
    def perspective_authenticate(self, bouncerName, keycard):
        """
        Authenticate the given keycard.
        If no bouncerName given, authenticate against the manager's bouncer.
        If a bouncerName is given, authenticate against the given bouncer
        in the atmosphere.

        @since: 0.3.1

        @param bouncerName: the name of the atmosphere bouncer, or None
        @type  bouncerName: str or None
        @param keycard:     the keycard to authenticate
        @type  keycard:     L{flumotion.common.keycards.Keycard}

        @returns: a deferred, returning the keycard or None.
        """
        if not bouncerName:
            self.debug(
                'asked to authenticate keycard %r using manager bouncer' %
                    keycard)
            return self.vishnu.bouncer.authenticate(keycard)

        self.debug('asked to authenticate keycard %r using bouncer %s' % (
            keycard, bouncerName))
        avatarId = common.componentId('atmosphere', bouncerName)
        if not self.heaven.hasAvatar(avatarId):
            self.warning('No bouncer with id %s registered' % avatarId)
            raise errors.UnknownComponentError(avatarId)

        bouncerAvatar = self.heaven.getAvatar(avatarId)
        return bouncerAvatar.authenticate(keycard)
Пример #2
0
    def perspective_keepAlive(self, bouncerName, issuerName, ttl):
        """
        Resets the expiry timeout for keycards issued by issuerName. See
        L{flumotion.component.bouncers.bouncer} for more information.

        @since: 0.4.3

        @param bouncerName: the name of the atmosphere bouncer, or None
        @type  bouncerName: str or None
        @param issuerName: the issuer for which keycards should be kept
                           alive; that is to say, keycards with the
                           attribute 'issuerName' set to this value will
                           have their ttl values reset.
        @type  issuerName: str
        @param ttl: the new expiry timeout
        @type  ttl: number

        @returns: a deferred which will fire success or failure.
        """
        self.debug('keycards keepAlive on behalf of %s, ttl=%d', issuerName,
                   ttl)

        if not bouncerName:
            return self.vishnu.bouncer.keepAlive(issuerName, ttl)

        self.debug('looking for bouncer %s in atmosphere', bouncerName)
        avatarId = common.componentId('atmosphere', bouncerName)
        if not self.heaven.hasAvatar(avatarId):
            self.warning('No bouncer with id %s registered', avatarId)
            raise errors.UnknownComponentError(avatarId)

        bouncerAvatar = self.heaven.getAvatar(avatarId)
        return bouncerAvatar.keepAlive(issuerName, ttl)
    def __init__(self, parent, name, eaters=None, feeders=None, vfeeds=None,
                 clockMaster=False, worker='localhost', host='127.0.0.1',
                 fport=-1):
        self._parent = parent
        self._name = name
        self._host = host
        if fport == -1:
            fport = FakeComponentAvatar._nextPort
            FakeComponentAvatar._nextPort += 1
        self._fport = fport
        self._worker = worker

        self._eatlog = []
        self._feedlog = []

        if eaters is None:
            eaters = {}
        self._eaters = eaters
        if feeders is None:
            feeders = ['default']
        self._feeders = feeders
        if vfeeds is None:
            vfeeds = {}
        self._vfeeds = dict([(common.fullFeedId(self._parent, vcomp, vfeed),
                              (self, feed))
                             for vcomp, vfeed, feed in vfeeds])

        self.avatarId = common.componentId(parent, name)
        self.componentState = (None, 'componentState_%s' % name)
        self.jobState = (None, 'jobState_%s' % name)
        self._clockmaster = clockMaster
        gp = (lambda: dac(host=self._host))
        self.mind = dac(broker=dac(transport=dac(getPeer=gp)))
Пример #4
0
    def perspective_authenticate(self, bouncerName, keycard):
        """
        Authenticate the given keycard.
        If no bouncerName given, authenticate against the manager's bouncer.
        If a bouncerName is given, authenticate against the given bouncer
        in the atmosphere.

        @since: 0.3.1

        @param bouncerName: the name of the atmosphere bouncer, or None
        @type  bouncerName: str or None
        @param keycard:     the keycard to authenticate
        @type  keycard:     L{flumotion.common.keycards.Keycard}

        @returns: a deferred, returning the keycard or None.
        """
        if not bouncerName:
            self.debug(
                'asked to authenticate keycard %r using manager bouncer' %
                keycard)
            return self.vishnu.bouncer.authenticate(keycard)

        self.debug('asked to authenticate keycard %r using bouncer %s' %
                   (keycard, bouncerName))
        avatarId = common.componentId('atmosphere', bouncerName)
        if not self.heaven.hasAvatar(avatarId):
            self.warning('No bouncer with id %s registered' % avatarId)
            raise errors.UnknownComponentError(avatarId)

        bouncerAvatar = self.heaven.getAvatar(avatarId)
        return bouncerAvatar.authenticate(keycard)
 def __init__(self, name="fake", parent="eve", eaters=[], port=-1, listen_host="127.0.0.1"):
     self.name = name
     self.parent = parent
     self.avatarId = common.componentId(parent, name)
     self.eaters = eaters
     self.port = port
     self.listen_host = listen_host
Пример #6
0
    def perspective_keepAlive(self, bouncerName, issuerName, ttl):
        """
        Resets the expiry timeout for keycards issued by issuerName. See
        L{flumotion.component.bouncers.bouncer} for more information.

        @since: 0.4.3

        @param bouncerName: the name of the atmosphere bouncer, or None
        @type  bouncerName: str or None
        @param issuerName: the issuer for which keycards should be kept
                           alive; that is to say, keycards with the
                           attribute 'issuerName' set to this value will
                           have their ttl values reset.
        @type  issuerName: str
        @param ttl: the new expiry timeout
        @type  ttl: number

        @returns: a deferred which will fire success or failure.
        """
        self.debug('keycards keepAlive on behalf of %s, ttl=%d',
                   issuerName, ttl)

        if not bouncerName:
            return self.vishnu.bouncer.keepAlive(issuerName, ttl)

        self.debug('looking for bouncer %s in atmosphere', bouncerName)
        avatarId = common.componentId('atmosphere', bouncerName)
        if not self.heaven.hasAvatar(avatarId):
            self.warning('No bouncer with id %s registered', avatarId)
            raise errors.UnknownComponentError(avatarId)

        bouncerAvatar = self.heaven.getAvatar(avatarId)
        return bouncerAvatar.keepAlive(issuerName, ttl)
Пример #7
0
 def __init__(self, name='fake', parent='eve', eaters=[], port=-1,
              listen_host='127.0.0.1'):
     self.name = name
     self.parent = parent
     self.avatarId = common.componentId(parent, name)
     self.eaters = eaters
     self.port = port
     self.listen_host = listen_host
Пример #8
0
    def __init__(self, type_, class_, props=None, name=None, plugs=None,
                 cfg=None):
        self.comp = None
        self.comp_class = class_
        if cfg is None:
            cfg = {}
        self.cfg = cfg
        self.auto_link = True
        self.debug_msgs = []

        self.sync = None
        self.sync_master = None

        if ComponentWrapper._registry is None:
            ComponentWrapper._registry = registry.getRegistry()

        cfg['type'] = type_
        reg = ComponentWrapper._registry.getComponent(type_)

        if not 'source' in cfg:
            cfg['source'] = []

        if not 'eater' in cfg:
            cfg['eater'] = dict([(e.getName(), []) for e in reg.getEaters()
                                 if e.getRequired()])

        if not 'feed' in cfg:
            cfg['feed'] = reg.getFeeders()[:]

        if plugs is not None:
            cfg['plugs'] = plugs
        if not 'plugs' in cfg:
            cfg['plugs'] = dict([(s, []) for s in reg.getSockets()])

        if name:
            cfg['name'] = name
        if not 'name' in cfg:
            cfg['name'] = ComponentWrapper.get_unique_name()
        self.name = cfg['name']

        if not 'parent' in cfg:
            cfg['parent'] = 'default'

        if not 'avatarId' in cfg:
            cfg['avatarId'] = common.componentId(cfg['parent'], self.name)

        if props is not None:
            cfg['properties'] = props
        if not 'properties' in cfg:
            cfg['properties'] = {}

        if not 'clock-master' in cfg:
            cfg['clock-master'] = None

        self.sync_master = cfg['clock-master']

        if reg.getNeedsSynchronization():
            self.sync = reg.getClockPriority()
 def loadProducer():
     compType = "pipeline-producer"
     compId = common.componentId("testflow", "producer-video-test")
     compProps = [
         ("pipeline", "videotestsrc ! video/x-raw-yuv,width=320," "height=240,framerate=5/1,format=(fourcc)I420")
     ]
     return self.vishnu.loadComponent(
         manager.LOCAL_IDENTITY, compType, compId, None, compProps, "worker", [], [], False, []
     )
Пример #10
0
 def loadProducer():
     compType = "pipeline-producer"
     compId = common.componentId("testflow", "producer-video-test")
     compProps = [("pipeline",
                   "videotestsrc ! video/x-raw-yuv,width=320,"
                   "height=240,framerate=5/1,format=(fourcc)I420")]
     return self.vishnu.loadComponent(manager.LOCAL_IDENTITY, compType,
                                      compId, None, compProps, "worker",
                                      [], [], False, [])
Пример #11
0
 def perspective_componentsList(self):
     """
     List components in the planet. Returns a list of avatar ids.
     """
     componentStates = self.vishnu.state.getComponents()
     avatar_ids = [common.componentId(c.get('parent').get('name'),
                                      c.get('name'))
                   for c in componentStates]
     return avatar_ids
Пример #12
0
    def getComponentEntries(self):
        """
        Get all component entries from both atmosphere and all flows
        from the configuration.

        @rtype: dictionary of /parent/name -> L{ConfigEntryComponent}
        """
        entries = {}
        if self.atmosphere and self.atmosphere.components:
            for c in self.atmosphere.components.values():
                path = common.componentId('atmosphere', c.name)
                entries[path] = c

        for flowEntry in self.flows:
            for c in flowEntry.components.values():
                path = common.componentId(c.parent, c.name)
                entries[path] = c

        return entries
Пример #13
0
    def getComponentEntries(self):
        """
        Get all component entries from both atmosphere and all flows
        from the configuration.

        @rtype: dictionary of /parent/name -> L{ConfigEntryComponent}
        """
        entries = {}
        if self.atmosphere and self.atmosphere.components:
            for c in self.atmosphere.components.values():
                path = common.componentId('atmosphere', c.name)
                entries[path] = c

        for flowEntry in self.flows:
            for c in flowEntry.components.values():
                path = common.componentId(c.parent, c.name)
                entries[path] = c

        return entries
Пример #14
0
 def __init__(self,
              name='fake',
              parent='eve',
              eaters=[],
              port=-1,
              listen_host='127.0.0.1'):
     self.name = name
     self.parent = parent
     self.avatarId = common.componentId(parent, name)
     self.eaters = eaters
     self.port = port
     self.listen_host = listen_host
Пример #15
0
    def _buildConfig(self, propertyList, plugsList, eatersList, isClockMaster,
                     project, version, virtualFeeds):
        """
        Build a component configuration dictionary.
        """
        # clock-master should be either an avatar id or None.
        # It can temporarily be set to True, and the flow parsing
        # code will change it to the avatar id or None.
        config = {
            'name':
            self.name,
            'parent':
            self.parent,
            'type':
            self.type,
            'config-version':
            CURRENT_VERSION,
            'avatarId':
            common.componentId(self.parent, self.name),
            'project':
            project or configure.PACKAGE,
            'version':
            self._buildVersionTuple(version),
            'clock-master':
            isClockMaster or None,
            'feed':
            self.defs.getFeeders(),
            'properties':
            fluconfig.buildPropertyDict(propertyList,
                                        self.defs.getProperties()),
            'plugs':
            fluconfig.buildPlugsSet(plugsList, self.defs.getSockets()),
            'eater':
            buildEatersDict(eatersList, self.defs.getEaters()),
            'source': [tup[1] for tup in eatersList],
            'virtual-feeds':
            buildVirtualFeeds(virtualFeeds or [], self.defs.getFeeders())
        }

        if self.label:
            # only add a label attribute if it was specified
            config['label'] = self.label

        if not config['source']:
            # preserve old behavior
            del config['source']
        # FIXME: verify that config['project'] matches the defs

        return config
Пример #16
0
    def perspective_removeKeycardId(self, bouncerName, keycardId):
        """
        Remove a keycard on the given bouncer on behalf of a
        component's medium.

        This is requested by a component that created the keycard.

        @type  bouncerName: str
        @param keycardId:   id of keycard to remove
        @type  keycardId:   str
        """
        avatarId = common.componentId('atmosphere', bouncerName)
        if not self.heaven.hasAvatar(avatarId):
            self.warning('No bouncer with id %s registered', avatarId)
            raise errors.UnknownComponentError(avatarId)

        return self.heaven.getAvatar(avatarId).removeKeycardId(keycardId)
Пример #17
0
    def perspective_removeKeycardId(self, bouncerName, keycardId):
        """
        Remove a keycard on the given bouncer on behalf of a
        component's medium.

        This is requested by a component that created the keycard.

        @type  bouncerName: str
        @param keycardId:   id of keycard to remove
        @type  keycardId:   str
        """
        avatarId = common.componentId('atmosphere', bouncerName)
        if not self.heaven.hasAvatar(avatarId):
            self.warning('No bouncer with id %s registered', avatarId)
            raise errors.UnknownComponentError(avatarId)

        return self.heaven.getAvatar(avatarId).removeKeycardId(keycardId)
Пример #18
0
    def _doReceiveFeed(self, fullFeedId):
        t = self.mind.broker.transport

        self.debug('flushing PB write queue')
        t.doWrite()
        self.debug('stop writing to transport')
        t.stopWriting()

        # hand off the fd to the component
        self.debug("Attempting to send FD: %d", t.fileno())

        (flowName, componentName, eaterAlias) = common.parseFullFeedId(
            fullFeedId)
        componentId = common.componentId(flowName, componentName)

        if self.feedServer.eatFromFD(componentId, eaterAlias, t.fileno(),
                                     self.avatarId):
            t.keepSocketAlive = True

        t.loseConnection()
Пример #19
0
    def _doReceiveFeed(self, fullFeedId):
        t = self.mind.broker.transport

        self.debug('flushing PB write queue')
        t.doWrite()
        self.debug('stop writing to transport')
        t.stopWriting()

        # hand off the fd to the component
        self.debug("Attempting to send FD: %d", t.fileno())

        (flowName, componentName,
         eaterAlias) = common.parseFullFeedId(fullFeedId)
        componentId = common.componentId(flowName, componentName)

        if self.feedServer.eatFromFD(componentId, eaterAlias, t.fileno(),
                                     self.avatarId):
            t.keepSocketAlive = True

        t.loseConnection()
Пример #20
0
    def __init__(self,
                 parent,
                 name,
                 eaters=None,
                 feeders=None,
                 vfeeds=None,
                 clockMaster=False,
                 worker='localhost',
                 host='127.0.0.1',
                 fport=-1):
        self._parent = parent
        self._name = name
        self._host = host
        if fport == -1:
            fport = FakeComponentAvatar._nextPort
            FakeComponentAvatar._nextPort += 1
        self._fport = fport
        self._worker = worker

        self._eatlog = []
        self._feedlog = []

        if eaters is None:
            eaters = {}
        self._eaters = eaters
        if feeders is None:
            feeders = ['default']
        self._feeders = feeders
        if vfeeds is None:
            vfeeds = {}
        self._vfeeds = dict([(common.fullFeedId(self._parent, vcomp,
                                                vfeed), (self, feed))
                             for vcomp, vfeed, feed in vfeeds])

        self.avatarId = common.componentId(parent, name)
        self.componentState = (None, 'componentState_%s' % name)
        self.jobState = (None, 'jobState_%s' % name)
        self._clockmaster = clockMaster
        gp = (lambda: dac(host=self._host))
        self.mind = dac(broker=dac(transport=dac(getPeer=gp)))
Пример #21
0
    def _sendFeedReplyCb(self, result, fullFeedId):
        # compare with startStreaming in prototype
        # Remove this from the reactor; we mustn't read or write from it from
        # here on
        t = self.mind.broker.transport
        t.stopReading()
        t.stopWriting()

        # hand off the fd to the component
        self.debug("Attempting to send FD: %d", t.fileno())

        (flowName, componentName, feedName) = common.parseFullFeedId(
            fullFeedId)
        componentId = common.componentId(flowName, componentName)

        if self.feedServer.feedToFD(componentId, feedName, t.fileno(),
                                    self.avatarId):
            t.keepSocketAlive = True

        # We removed the transport from the reactor before sending the
        # FD; now we want the socket cleaned up.
        t.loseConnection()
Пример #22
0
    def _loadComponent(self, componentType, componentName, componentLabel,
                       workerPxy, properties, timeout=None):
        compId = common.componentId(self._state.get('name'), componentName)
        identifier = self.__getComponentUniqueIdByName(componentName)
        workerCtx = workerPxy.getWorkerContext()
        properties.prepare(workerCtx)
        props = properties.asComponentProperties(workerCtx)
        resDef = defer.Deferred()
        initDef = defer.Deferred()
        self._waitCompLoaded[identifier] = initDef

        callDef = self._managerPxy._callRemote('loadComponent', componentType,
                                            compId, componentLabel,
                                            props, workerPxy.getName())
        to = utils.createTimeout(timeout or adminconsts.LOAD_COMPONENT_TIMEOUT,
                                 self.__asyncComponentLoadedTimeout,
                                 callDef, componentLabel)
        args = (identifier, initDef, resDef, to)
        callDef.addCallbacks(self.__cbComponentLoaded,
                             self.__ebComponentLoadingFailed,
                             callbackArgs=args, errbackArgs=args)
        return resDef
Пример #23
0
    def _sendFeedReplyCb(self, result, fullFeedId):
        # compare with startStreaming in prototype
        # Remove this from the reactor; we mustn't read or write from it from
        # here on
        t = self.mind.broker.transport
        t.stopReading()
        t.stopWriting()

        # hand off the fd to the component
        self.debug("Attempting to send FD: %d", t.fileno())

        (flowName, componentName,
         feedName) = common.parseFullFeedId(fullFeedId)
        componentId = common.componentId(flowName, componentName)

        if self.feedServer.feedToFD(componentId, feedName, t.fileno(),
                                    self.avatarId):
            t.keepSocketAlive = True

        # We removed the transport from the reactor before sending the
        # FD; now we want the socket cleaned up.
        t.loseConnection()
Пример #24
0
    def _buildConfig(self, propertyList, plugsList, eatersList,
                     isClockMaster, project, version, virtualFeeds):
        """
        Build a component configuration dictionary.
        """
        # clock-master should be either an avatar id or None.
        # It can temporarily be set to True, and the flow parsing
        # code will change it to the avatar id or None.
        config = {'name': self.name,
                  'parent': self.parent,
                  'type': self.type,
                  'config-version': CURRENT_VERSION,
                  'avatarId': common.componentId(self.parent, self.name),
                  'project': project or configure.PACKAGE,
                  'version': self._buildVersionTuple(version),
                  'clock-master': isClockMaster or None,
                  'feed': self.defs.getFeeders(),
                  'properties': fluconfig.buildPropertyDict(propertyList,
                                                  self.defs.getProperties()),
                  'plugs': fluconfig.buildPlugsSet(plugsList,
                                         self.defs.getSockets()),
                  'eater': buildEatersDict(eatersList,
                                           self.defs.getEaters()),
                  'source': [tup[1] for tup in eatersList],
                  'virtual-feeds': buildVirtualFeeds(virtualFeeds or [],
                                                     self.defs.getFeeders())}

        if self.label:
            # only add a label attribute if it was specified
            config['label'] = self.label

        if not config['source']:
            # preserve old behavior
            del config['source']
        # FIXME: verify that config['project'] matches the defs

        return config
Пример #25
0
 def _getAvatarId(self):
     return common.componentId(self.parent.getName(), self.getName())
Пример #26
0
 def testPath(self):
     self.assertEqual(common.componentId("Adam", "Cain"), "/Adam/Cain")
Пример #27
0
 def testPath(self):
     self.assertEqual(common.componentId('Adam', 'Cain'), '/Adam/Cain')
Пример #28
0
        def loadConverter(_):
            flows = self.vishnu.state.get('flows')
            self.assertEqual(len(flows), 1)
            flow = flows[0]
            self.assertEqual(flow.get('name'), 'testflow')
            components = flow.get('components')
            self.assertEqual(len(components), 1)
            self.assertEqual(components[0].get('name'), "producer-video-test")

            compType = "pipeline-converter"
            compId = common.componentId("testflow", "converter-ogg-theora")
            compEaters = [("default", "producer-video-test")]
            compProps = [("pipeline", "ffmpegcolorspace ! theoraenc "
                          "keyframe-force=5 ! oggmux")]
            compState = self.vishnu.loadComponent(manager.LOCAL_IDENTITY,
                                                  compType, compId, None,
                                                  compProps, "worker", [],
                                                  compEaters, False, [])

            self.assertEqual(
                compState.get('config').get('name'), "converter-ogg-theora")
            self.failIf('label' in compState.get('config'))
            self.assertEqual(len(components), 2)
            self.assertEqual(components[1].get('name'), "converter-ogg-theora")

            # Loading the same component again raises an error
            self.assertRaises(errors.ComponentAlreadyExistsError,
                              self.vishnu.loadComponent,
                              manager.LOCAL_IDENTITY, compType, compId, None,
                              compProps, "worker", [], compEaters, False, [])

            compType = "http-streamer"
            compId = common.componentId("testflow", "streamer-ogg-theora")
            compLabel = "Streamer OGG-Theora/Vorbis"
            compEaters = [("default", "converter-ogg-theora")]
            compProps = [("port", "8800")]
            compState = self.vishnu.loadComponent(manager.LOCAL_IDENTITY,
                                                  compType, compId, compLabel,
                                                  compProps, "streamer", [],
                                                  compEaters, False, [])

            self.assertEqual(
                compState.get('config').get('name'), "streamer-ogg-theora")
            self.assertEqual(
                compState.get('config').get('label'),
                "Streamer OGG-Theora/Vorbis")
            self.assertEqual(len(components), 3)
            self.assertEqual(components[2].get('name'), "streamer-ogg-theora")

            # Load a component to atmosphere
            compType = "ical-bouncer"
            compId = common.componentId("atmosphere", "test-bouncer")
            compProps = [("file", "icalfile")]
            compState = self.vishnu.loadComponent(manager.LOCAL_IDENTITY,
                                                  compType, compId, None,
                                                  compProps, "worker", [], [],
                                                  False, [])

            atmosphere = self.vishnu.state.get('atmosphere')
            components = atmosphere.get('components')
            self.assertEquals(len(components), 1)
            self.failUnlessEqual(components[0].get('name'), 'test-bouncer')
Пример #29
0
    def __init__(self,
                 type_,
                 class_,
                 props=None,
                 name=None,
                 plugs=None,
                 cfg=None):
        self.comp = None
        self.comp_class = class_
        if cfg is None:
            cfg = {}
        self.cfg = cfg
        self.auto_link = True
        self.debug_msgs = []

        self.sync = None
        self.sync_master = None

        if ComponentWrapper._registry is None:
            ComponentWrapper._registry = registry.getRegistry()

        cfg['type'] = type_
        reg = ComponentWrapper._registry.getComponent(type_)

        if not 'source' in cfg:
            cfg['source'] = []

        if not 'eater' in cfg:
            cfg['eater'] = dict([(e.getName(), []) for e in reg.getEaters()
                                 if e.getRequired()])

        if not 'feed' in cfg:
            cfg['feed'] = reg.getFeeders()[:]

        if plugs is not None:
            cfg['plugs'] = plugs
        if not 'plugs' in cfg:
            cfg['plugs'] = dict([(s, []) for s in reg.getSockets()])

        if name:
            cfg['name'] = name
        if not 'name' in cfg:
            cfg['name'] = ComponentWrapper.get_unique_name()
        self.name = cfg['name']

        if not 'parent' in cfg:
            cfg['parent'] = 'default'

        if not 'avatarId' in cfg:
            cfg['avatarId'] = common.componentId(cfg['parent'], self.name)

        if props is not None:
            cfg['properties'] = props
        if not 'properties' in cfg:
            cfg['properties'] = {}

        if not 'clock-master' in cfg:
            cfg['clock-master'] = None

        self.sync_master = cfg['clock-master']

        if reg.getNeedsSynchronization():
            self.sync = reg.getClockPriority()
        def loadConverter(_):
            flows = self.vishnu.state.get("flows")
            self.assertEqual(len(flows), 1)
            flow = flows[0]
            self.assertEqual(flow.get("name"), "testflow")
            components = flow.get("components")
            self.assertEqual(len(components), 1)
            self.assertEqual(components[0].get("name"), "producer-video-test")

            compType = "pipeline-converter"
            compId = common.componentId("testflow", "converter-ogg-theora")
            compEaters = [("default", "producer-video-test")]
            compProps = [("pipeline", "ffmpegcolorspace ! theoraenc " "keyframe-force=5 ! oggmux")]
            compState = self.vishnu.loadComponent(
                manager.LOCAL_IDENTITY, compType, compId, None, compProps, "worker", [], compEaters, False, []
            )

            self.assertEqual(compState.get("config").get("name"), "converter-ogg-theora")
            self.failIf("label" in compState.get("config"))
            self.assertEqual(len(components), 2)
            self.assertEqual(components[1].get("name"), "converter-ogg-theora")

            # Loading the same component again raises an error
            self.assertRaises(
                errors.ComponentAlreadyExistsError,
                self.vishnu.loadComponent,
                manager.LOCAL_IDENTITY,
                compType,
                compId,
                None,
                compProps,
                "worker",
                [],
                compEaters,
                False,
                [],
            )

            compType = "http-streamer"
            compId = common.componentId("testflow", "streamer-ogg-theora")
            compLabel = "Streamer OGG-Theora/Vorbis"
            compEaters = [("default", "converter-ogg-theora")]
            compProps = [("port", "8800")]
            compState = self.vishnu.loadComponent(
                manager.LOCAL_IDENTITY, compType, compId, compLabel, compProps, "streamer", [], compEaters, False, []
            )

            self.assertEqual(compState.get("config").get("name"), "streamer-ogg-theora")
            self.assertEqual(compState.get("config").get("label"), "Streamer OGG-Theora/Vorbis")
            self.assertEqual(len(components), 3)
            self.assertEqual(components[2].get("name"), "streamer-ogg-theora")

            # Load a component to atmosphere
            compType = "ical-bouncer"
            compId = common.componentId("atmosphere", "test-bouncer")
            compProps = [("file", "icalfile")]
            compState = self.vishnu.loadComponent(
                manager.LOCAL_IDENTITY, compType, compId, None, compProps, "worker", [], [], False, []
            )

            atmosphere = self.vishnu.state.get("atmosphere")
            components = atmosphere.get("components")
            self.assertEquals(len(components), 1)
            self.failUnlessEqual(components[0].get("name"), "test-bouncer")
Пример #31
0
 def testPath(self):
     self.assertEqual(common.componentId('Adam', 'Cain'), '/Adam/Cain')