def perspective_upstreamList(self, avatarId): """ List a component and its upstream components along with types and worker hosts. @param avatarId: the component avatar id @type avatarId: str """ def get_eaters_ids(eaters_dic): avatars = [] for flow in eaters_dic.keys(): comps = eaters_dic[flow] for c in comps: (name, what) = c[0].split(':') avatars.append('/%s/%s' % (flow, name)) return avatars def create_response(components, workers): comps = [] for c in components: workerName = c.get('workerName') host = "unknown" for w in workers: if workerName == w.get('name'): host = w.get('host') break comps.append((c.get('name'), c.get('type'), host)) return comps component = util.findComponent(self.vishnu.state, avatarId) if not component: self.warning('No component with avatar id %s' % avatarId) raise errors.UnknownComponentError(avatarId) eaters = component.get('config').get('eater', {}) eaters_id = get_eaters_ids(eaters) comps = [component] while len(eaters_id) > 0: eaters = {} for i in eaters_id: try: compState = util.findComponent(self.vishnu.state, i) comps.append(compState) eaters.update(compState.get('config').get('eater', {})) except Exception, e: self.debug(log.getExceptionMessage(e)) emsg = "Error retrieving component '%s'" % i raise errors.UnknownComponentError(emsg) eaters_id = get_eaters_ids(eaters)
def planet_callback(uistate, self=self): component = util.findComponent(uistate, '/default/producer-firewire') if self.volume_monitor is None: import volume_monitor parent_widget = self.xml.get_object(self.box) self.volume_monitor = volume_monitor.VolumeMonitor(self.flumotion.medium, component, force_channels=1) volume_widget = self.volume_monitor.widget old_parent = volume_widget.get_parent() if old_parent: old_parent.remove(volume_widget) parent_widget.pack_start(volume_widget) if moods.get(component.get('mood')) is not moods.happy: return def component_callback(firewire_uistate, self=self): if self.volume_monitor.state is not None: return self.volume_monitor.setUIState(firewire_uistate) self.assistant.set_page_complete(self.page, True) self.focus_forward() d = self.flumotion.medium.componentCallRemote(component, 'getUIState') d.addCallback(component_callback)
def planet_callback(uistate, self=self): component = util.findComponent(uistate, '/default/producer-firewire') if self.volume_monitor is None: import volume_monitor parent_widget = self.xml.get_object(self.box) self.volume_monitor = volume_monitor.VolumeMonitor( self.flumotion.medium, component, force_channels=1) volume_widget = self.volume_monitor.widget old_parent = volume_widget.get_parent() if old_parent: old_parent.remove(volume_widget) parent_widget.pack_start(volume_widget) if moods.get(component.get('mood')) is not moods.happy: return def component_callback(firewire_uistate, self=self): if self.volume_monitor.state is not None: return self.volume_monitor.setUIState(firewire_uistate) self.assistant.set_page_complete(self.page, True) self.focus_forward() d = self.flumotion.medium.componentCallRemote( component, 'getUIState') d.addCallback(component_callback)
def gotPlanetStateCb(result): self.planetState = result self.debug('gotPlanetStateCb') # only get componentState if we got passed an argument for it if not self.componentId: return try: self.componentState = util.findComponent(result, self.componentId) except Exception, e: self.debug(log.getExceptionMessage(e)) common.errorRaise("Invalid component id '%s'" % self.componentId)
def gotUIState(self, state): p = self.parentCommand dList = [] for f in state.get('feeders'): for c in f['clients']: feeder_id = c['client-id'].split(':')[0] compState = util.findComponent(p.planetState, feeder_id) if compState is None or compState in self.components: continue d = defer.maybeDeferred(self.getUIState, compState) dList.append(d) d = defer.DeferredList(dList) d.addCallback(lambda result: self.components) return d
def gotPlanetStateCb(result): self.planetState = result self.debug('gotPlanetStateCb') # only get componentState if we got passed an argument for it if not self.componentId: return try: self.componentState = util.findComponent( result, self.componentId) except Exception, e: self.debug(log.getExceptionMessage(e)) common.errorRaise("Invalid component id '%s'" % self.componentId)
def gotUIState(self, state): p = self.parentCommand dList = [] for f in state.get('feeders'): for c in f['clients']: feeder_id = c['client-id'].split(':')[0] compState = util.findComponent(p.planetState, feeder_id) if compState is None or compState in self.components: continue d = defer.maybeDeferred(self.getUIState, compState) dList.append(d) d = defer.DeferredList(dList) d.addCallback(lambda result: self.components) return d
def perspective_componentInvoke(self, avatarId, methodName, *args, **kwargs): """ Call a remote method on the component. @param avatarId: the component avatar id @type avatarId: str @param methodName: name of the method to call @type methodName: str """ component = util.findComponent(self.vishnu.state, avatarId) if not component: self.warning('No component with avatar id %s' % avatarId) raise errors.UnknownComponentError(avatarId) return self.perspective_componentCallRemote(component, methodName, *args, **kwargs)
def gotPlanetStateCb(result): self.debug("gotPlanetStateCb") c = util.findComponent(result, self._component) if not c: return util.unknown("Could not find component %s" % self._component) moodValue = c.get("mood") moodName = planet.moods.get(moodValue).name if moodName in self._critical: return util.critical("Component %s is %s" % (self._component, moodName)) if moodName in self._warning: return util.warning("Component %s is %s" % (self._component, moodName)) return util.ok("Component %s is %s" % (self._component, moodName))
def gotPlanetStateCb(result): self.debug('gotPlanetStateCb') c = util.findComponent(result, self._component) if not c: return util.unknown('Could not find component %s' % self._component) moodValue = c.get('mood') moodName = planet.moods.get(moodValue).name if moodName in self._critical: return util.critical('Component %s is %s' % (self._component, moodName)) if moodName in self._warning: return util.warning('Component %s is %s' % (self._component, moodName)) return util.ok('Component %s is %s' % (self._component, moodName))
def doCallback(self, args): p = self.parentCommand s = p.workerHeavenState workers = s.get('workers') if not p.componentId: common.errorRaise("Please specify a component id " "with 'component -i [component-id]'") eaters = p.componentState.get('config').get('eater', {}) eaters_id = self.get_eaters_ids(eaters) comps = [p.componentState] while len(eaters_id) > 0: eaters = {} for i in eaters_id: try: compState = util.findComponent(p.planetState, i) comps.append(compState) eaters.update(compState.get('config').get('eater', {})) except Exception, e: self.debug(log.getExceptionMessage(e)) common.errorRaise("Error retrieving component '%s'" % i) eaters_id = self.get_eaters_ids(eaters)
def doCallback(self, args): p = self.parentCommand s = p.workerHeavenState workers = s.get('workers') if not p.componentId: common.errorRaise("Please specify a component id " "with 'component -i [component-id]'") eaters = p.componentState.get('config').get('eater', {}) eaters_id = self.get_eaters_ids(eaters) comps = [p.componentState] while len(eaters_id) > 0: eaters = {} for i in eaters_id: try: compState = util.findComponent(p.planetState, i) comps.append(compState) eaters.update(compState.get('config').get('eater', {})) except Exception, e: self.debug(log.getExceptionMessage(e)) common.errorRaise("Error retrieving component '%s'" % i) eaters_id = self.get_eaters_ids(eaters)
def _got_planet_state(self, planet_state): c = util.findComponent(planet_state, self.component_id) if not c: return util.unknown('Could not find component %s' % self.component_id) return self._detect_flipflops(c)
def _got_planet_state(self, planet_state): c = util.findComponent(planet_state, self.component_id) if not c: return util.unknown('Could not find component %s' % self.component_id) return self._detect_flipflops(c)