def startup(**kwds): global view Globals.chandlerDirectory = Utility.locateChandlerDirectory() if not Globals.chandlerDirectory: print "Please set CHANDLERHOME" return None os.chdir(Globals.chandlerDirectory) Utility.initLocale('en') Globals.options = Utility.initOptions(Globals.chandlerDirectory, **kwds) profileDir = Globals.options.profileDir Utility.initLogging(Globals.options) parcelPath = Utility.initParcelEnv(Globals.chandlerDirectory, Globals.options.parcelPath) view = Utility.initRepository( Utility.locateRepositoryDirectory(profileDir), Globals.options) if not Utility.verifySchema(view): print "Schema mismatch. Try again with startup(create=True)" return None Utility.initCrypto(Globals.options.profileDir) Utility.initParcels(view, parcelPath) if Globals.options.createData: import GenerateItemsFromFile GenerateItemsFromFile.RunScript(view) return view
def startup(**kwds): global view Globals.chandlerDirectory = Utility.locateChandlerDirectory() if not Globals.chandlerDirectory: print "Please set CHANDLERHOME" return None os.chdir(Globals.chandlerDirectory) Utility.initLocale('en') Globals.options = Utility.initOptions(Globals.chandlerDirectory, **kwds) profileDir = Globals.options.profileDir Utility.initLogging(Globals.options) parcelPath = Utility.initParcelEnv(Globals.chandlerDirectory, Globals.options.parcelPath) view = Utility.initRepository(Utility.locateRepositoryDirectory(profileDir), Globals.options) if not Utility.verifySchema(view): print "Schema mismatch. Try again with startup(create=True)" return None Utility.initCrypto(Globals.options.profileDir) Utility.initParcels(view, parcelPath) if Globals.options.createData: import GenerateItemsFromFile GenerateItemsFromFile.RunScript(view) return view
def setUp(self): self.profileDir = os.path.dirname(__file__) Utility.initCrypto(self.profileDir) super(TestSSL, self).setUp(testdir=self.profileDir) self.loadParcel("osaf.framework.certstore") self.loadParcel("osaf.framework.certstore.data")
def startup(chandlerDirectory=None, **kwds): global view, commitOnExit Globals.options = Utility.initOptions(**kwds) if chandlerDirectory is None: Globals.chandlerDirectory = Utility.locateChandlerDirectory() else: Globals.chandlerDirectory = chandlerDirectory os.chdir(Globals.chandlerDirectory) Utility.initI18n(Globals.options) profileDir = Globals.options.profileDir Utility.initLogging(Globals.options) parcelPath = Utility.initParcelEnv(Globals.options, Globals.chandlerDirectory) pluginEnv, pluginEggs = Utility.initPluginEnv(Globals.options, Globals.options.pluginPath) Globals.options.getPassword = getPassword repoDir = Utility.locateRepositoryDirectory(profileDir, Globals.options) view = Utility.initRepository(repoDir, Globals.options) verify, repoVersion, schemaVersion = Utility.verifySchema(view) if not verify: print "Schema mismatch (%s vs %s). Try again with startup(create=True)" % ( repoVersion, schemaVersion) return None Utility.initCrypto(Globals.options.profileDir) Utility.initParcels(Globals.options, view, parcelPath) Utility.initPlugins(Globals.options, view, pluginEnv, pluginEggs) Utility.initTimezone(Globals.options, view) if Globals.options.reload: from osaf import dumpreload dumpreload.reload(view, Globals.options.reload) return view
def startup(chandlerDirectory=None, **kwds): global view, commitOnExit Globals.options = Utility.initOptions(**kwds) if chandlerDirectory is None: Globals.chandlerDirectory = Utility.locateChandlerDirectory() else: Globals.chandlerDirectory = chandlerDirectory os.chdir(Globals.chandlerDirectory) Utility.initI18n(Globals.options) profileDir = Globals.options.profileDir Utility.initLogging(Globals.options) parcelPath = Utility.initParcelEnv(Globals.options, Globals.chandlerDirectory) pluginEnv, pluginEggs = Utility.initPluginEnv(Globals.options, Globals.options.pluginPath) Globals.options.getPassword = getPassword repoDir = Utility.locateRepositoryDirectory(profileDir, Globals.options) view = Utility.initRepository(repoDir, Globals.options) verify, repoVersion, schemaVersion = Utility.verifySchema(view) if not verify: print "Schema mismatch (%s vs %s). Try again with startup(create=True)" %(repoVersion, schemaVersion) return None Utility.initCrypto(Globals.options.profileDir) Utility.initParcels(Globals.options, view, parcelPath) Utility.initPlugins(Globals.options, view, pluginEnv, pluginEggs) Utility.initTimezone(Globals.options, view) if Globals.options.reload: from osaf import dumpreload dumpreload.reload(view, Globals.options.reload) return view
def testCrypto(self): # First time there should not be anything, so load and save 0 r = Utility.initCrypto(self.path) self.assert_(r == 0, 'First time crypto init should return 0, got %d' % r) r = Utility.stopCrypto(self.path) self.assert_(r == 0, 'First time crypto stop should return 0, got %d' % r) # Trick us into thinking we have initialized entropy from osaf.framework.certstore import utils utils.entropyInitialized = True # Now we should save 1k on stop, after that loading and saving 1k r = Utility.initCrypto(self.path) self.assert_( r == 0, 'Entropy initialized, crypto init should return 0 first time, got %d' % r) # Note: the most likely reason why these would fail is if the entropy # file was not created, for example if we failed to create the # directory in setUp() r = Utility.stopCrypto(self.path) self.assert_( r == 1024, 'Entropy initialized, should save 1024 entropy first time, got %d' % r) r = Utility.initCrypto(self.path) self.assert_( r == 1024, 'Entropy initialized, should load 1024 entropy, got %d' % r) r = Utility.stopCrypto(self.path) self.assert_( r == 1024, 'Entropy initialized, should save 1024 entropy, got %d' % r)
def testCrypto(self): # First time there should not be anything, so load and save 0 r = Utility.initCrypto(self.path) self.assert_(r == 0, 'First time crypto init should return 0, got %d' % r) r = Utility.stopCrypto(self.path) self.assert_(r == 0, 'First time crypto stop should return 0, got %d' % r) # Trick us into thinking we have initialized entropy from osaf.framework.certstore import utils utils.entropyInitialized = True # Now we should save 1k on stop, after that loading and saving 1k r = Utility.initCrypto(self.path) self.assert_(r == 0, 'Entropy initialized, crypto init should return 0 first time, got %d' % r) # Note: the most likely reason why these would fail is if the entropy # file was not created, for example if we failed to create the # directory in setUp() r = Utility.stopCrypto(self.path) self.assert_(r == 1024, 'Entropy initialized, should save 1024 entropy first time, got %d' % r) r = Utility.initCrypto(self.path) self.assert_(r == 1024, 'Entropy initialized, should load 1024 entropy, got %d' % r) r = Utility.stopCrypto(self.path) self.assert_(r == 1024, 'Entropy initialized, should save 1024 entropy, got %d' % r)
print Globals.chandlerDirectory print profileDir Utility.initLogging(Globals.options) parcelPath = Utility.initParcelEnv(Globals.options, Globals.chandlerDirectory) pluginEnv, pluginEggs = Utility.initPluginEnv(Globals.options, Globals.options.pluginPath) view = Utility.initRepository(profileDir, Globals.options) verify, repoVersion, schemaVersion = Utility.verifySchema(view) Utility.initCrypto(Globals.options.profileDir) Utility.initParcels(Globals.options, view, parcelPath) Utility.initPlugins(Globals.options, view, pluginEnv, pluginEggs) Utility.initTimezone(Globals.options, view) outputDir = os.path.join(Globals.chandlerDirectory, 'docs') if os.path.isfile('Chandler.py'): if not os.path.isdir(outputDir): _mkdirs(outputDir) generateModelDocs(Globals.chandlerDirectory, view, outputDir) generateDocs(outputDir) else: print "Error: Currently gen_docs.py assumes it is running in the chandler/ directory"