Exemple #1
0
        def verifyExistingComponentState(conf, state):
            # condition (1)
            state.setJobState(self.jobState)
            self.componentState = state

            self.upgradeConfig(state, conf)
            if state.get('config') != conf:
                diff = config.dictDiff(state.get('config'), conf)
                diffMsg = config.dictDiffMessageString(diff, 'internal conf',
                                                       'running conf')
                self.addMessage(messages.WARNING,
                                'stale-config',
                                N_("Component logged in with stale "
                                   "configuration. To fix this, stop "
                                   "this component and then restart "
                                   "the manager."),
                                debug=("Updating internal conf from "
                                       "running conf:\n" + diffMsg))
                self.warning('updating internal component state for %r', state)
                self.debug('changes to conf: %s',
                           config.dictDiffMessageString(diff))
                state.set('config', conf)
Exemple #2
0
        def verifyExistingComponentState(conf, state):
            # condition (1)
            state.setJobState(self.jobState)
            self.componentState = state

            self.upgradeConfig(state, conf)
            if state.get('config') != conf:
                diff = config.dictDiff(state.get('config'), conf)
                diffMsg = config.dictDiffMessageString(diff,
                                                   'internal conf',
                                                   'running conf')
                self.addMessage(messages.WARNING, 'stale-config',
                                N_("Component logged in with stale "
                                   "configuration. To fix this, stop "
                                   "this component and then restart "
                                   "the manager."),
                                debug=("Updating internal conf from "
                                       "running conf:\n" + diffMsg))
                self.warning('updating internal component state for %r',
                             state)
                self.debug('changes to conf: %s',
                           config.dictDiffMessageString(diff))
                state.set('config', conf)
Exemple #3
0
        def checkNotRunning(comp, parentState):
            name = comp.getName()

            comps = dict([(x.get('name'), x)
                          for x in parentState.get('components')])
            runningComps = dict([(x.get('name'), x)
                                  for x in parentState.get('components')
                                  if x.get('mood') != moods.sleeping.value])
            if name not in comps:
                # We don't have it at all; allow it
                return True
            elif name not in runningComps:
                # We have it, but it's not running. Allow it after deleting
                # the old one.
                oldComp = comps[name]
                self.deleteComponent(oldComp)
                return True

            # if we get here, the component is already running; warn if
            # the running configuration is different. Return False in
            # all cases.
            parent = comps[name].get('parent').get('name')
            newConf = c.getConfigDict()
            oldConf = comps[name].get('config')

            if newConf == oldConf:
                self.debug('%s already has component %s running with '
                           'same configuration', parent, name)
                self.clearMessage('loadComponent-%s' % oldConf['avatarId'])
                return False

            self.info('%s already has component %s, but configuration '
                      'not the same -- notifying admin', parent, name)

            diff = config.dictDiff(oldConf, newConf)
            diffMsg = config.dictDiffMessageString(diff, 'existing', 'new')

            self.addMessage(messages.WARNING,
                            'loadComponent-%s' % oldConf['avatarId'],
                            N_('Could not load component %r into %r: '
                               'a component is already running with '
                               'this name, but has a different '
                               'configuration.'), name, parent,
                            debug=diffMsg)
            return False
Exemple #4
0
 def test(d1, d2, s):
     msg = config.dictDiffMessageString(config.dictDiff(d1, d2))
     self.assertEquals(msg, s)
Exemple #5
0
 def test(d1, d2, s):
     msg = config.dictDiffMessageString(config.dictDiff(d1, d2))
     self.assertEquals(msg, s)