コード例 #1
0
class ManagedDomain:
    def __init__(self):
        self.cr = ConfigReader()
        self.sh = StateHandler()

    def readConfig(self, confFiles=[], confContent=''):
        self.cr.setFilenames(confFiles)
        self.cr.setContentList(confContent)
        self.cr.open()
        if 'cdm' not in self.cr.cp:
            self.cr.cp['cdm'] = {}
        self.cr.interprete(self.sh)
        self.sh.registerConfig(self.cr.config['cdm'])

    def run(self, confFile=None, forcePhase='next', confContent=''):
        if confFile is not None or 0 < len(confContent):
            self.readConfig(confFile, confContent)
        self.sh.load()
        self.sh.delete()  # --next starts with prepare, if failed
        self.sh.resetOpStateRecursive()
        currentPhase = getCurrentPhase(self.sh, forcePhase)
        log.info('Running phase: {}'.format(currentPhase))
        runPhase(self.cr, self.sh, currentPhase)
        nextphase = getNextPhase(currentPhase)
        self.sh.registerResult({'nextphase': nextphase})
        self.sh.save()
コード例 #2
0
 def testSetFilenames(self):
     cr = ConfigReader()
     cr.addFilenames(['a', 'b', 'c'])
     cr.addFilenames(['d', 'e', 'f'])
     cr.setFilenames(['g', 'h', 'i'])
     self.assertEqual(cr.filenameList, ['g', 'h', 'i'])