def main(): parser = OptionParser('%prog [options] [DB_URL]') parser.add_option('-v', '--verbose', action='store_true', help='make sqlalchemy noisy') parser.add_option('-C', '--config', help="override config file") parser.add_option('-c', '--command', help="execute command and quit") options, args = parser.parse_args() logger.configure(log_to_console=True, capture_stdio=False) # Attempt to load a config conf = load_conf(options, args) # Create the session used to connect to the database session = db.configure(conf) banner = "session object 'db' connected to %s" % session.bind.url share = { 'db': session, 'func': func, 'Query': Query, 'helpers': helpers, } # add all models for model in models.ModelBase.__subclasses__(): share[model.__name__] = model if options.command: exec options.command in globals(), share else: c = DBConsole(banner=banner, locals=share) return c()
def logging_file_config(self, config_file): if getattr(self.options, 'daemon', False): logger.configure(config_file, self.name) else: logger.configure(config_file, self.name, log_to_console=True, lunr_log_level=logger.DEBUG, level=logger.WARNING)
def main(argv=sys.argv[1:]): logger.configure(log_to_console=True, level=logger.DEBUG, lunr_log_level=logger.DEBUG, capture_stdio=False) # Create the top-level parser parser = SubCommandParser([ TypeConsole(), NodeConsole(), AccountConsole(), VolumeConsole(), BackupConsole(), ExportConsole(), ToolConsole(), ], desc=__doc__.strip()) # execute the command requested try: return parser.run(argv) except HTTPClientError, e: print str(e) return 1
def main(argv=sys.argv[1:]): logger.configure(log_to_console=True, level=logger.DEBUG, lunr_log_level=logger.DEBUG, capture_stdio=False) # Create the top-level parser parser = SubCommandParser([VolumeConsole(), ExportConsole(), BackupConsole(), ToolsConsole()], desc=__doc__.strip()) # execute the command requested try: return parser.run(argv) except StorageError, e: if parser.command.verbose: raise return '%s: %s' % (e.__class__.__name__, e)
def main(argv=sys.argv[1:]): logger.configure(log_to_console=True, level=logger.DEBUG, lunr_log_level=logger.DEBUG, capture_stdio=False) # Create the top-level parser parser = SubCommandParser( [VolumeConsole(), ExportConsole(), BackupConsole(), ToolsConsole()], desc=__doc__.strip()) # execute the command requested try: return parser.run(argv) except StorageError, e: if parser.command.verbose: raise return '%s: %s' % (e.__class__.__name__, e)
from lunr.storage.helper.utils.scrub import Scrub from lunr.common.config import LunrConfig from testlunr.integration import IetTest from lunr.common import logger from tempfile import mkdtemp from uuid import uuid4 from os import path import unittest import shutil import time import sys import re # configure logging to log to console if nose was called with -s logger.configure(log_to_console=('-s' in sys.argv), capture_stdio=False) class MockResourceLock(object): def remove(self): pass class TestBackupHelper(IetTest): def setUp(self): IetTest.setUp(self) self.tempdir = mkdtemp() self.conf = self.config(self.tempdir) self.volume = VolumeHelper(self.conf) self.backup = BackupHelper(self.conf)
return 1 if not re.match('(start|foreground)', options.command): return parser.print_help() if options.command == 'start': if daemon.alive(): print "-- Orbit Already running" return 1 try: log.info("Starting Orbit..") with daemon: # load the logging config and get our log handle detach = conf.bool('orbit', 'foreground', False) logger.configure(conf.file, log_to_console=detach) # Connect to the database session = db.configure(conf) # TODO(thrawn): make this configurable # Pass in a list of jobs cron should run cron = Cron([ AuditSuspects(conf, session), BackupSuspects(conf, session), RestoreSuspects(conf, session), ScrubSuspects(conf, session), PruneSuspects(conf, session), Detach(conf, session) ]) # Run the cron return cron.run() except (DaemonError, CronError), e:
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or # implied. # See the License for the specific language governing permissions and # limitations under the License. from lunr.storage.helper.volume import VolumeHelper from lunr.storage.helper.utils import ServiceUnavailable from testlunr.integration import IetTest from lunr.common import logger from tempfile import mkdtemp from uuid import uuid4 import shutil import sys # configure logging to log to console if nose was called with -s logger.configure(log_to_console=('-s' in sys.argv), capture_stdio=False) class TestVolumeHelper(IetTest): def setUp(self): IetTest.setUp(self) self.tempdir = mkdtemp() self.conf = self.config(self.tempdir) self.volume = VolumeHelper(self.conf) def tearDown(self): # Remove the temp dir where backups are created shutil.rmtree(self.tempdir) IetTest.tearDown(self) @classmethod
return 1 if not re.match('(start|foreground)', options.command): return parser.print_help() if options.command == 'start': if daemon.alive(): print "-- Orbit Already running" return 1 try: log.info("Starting Orbit..") with daemon: # load the logging config and get our log handle detach = conf.bool('orbit', 'foreground', False) logger.configure(conf.file, log_to_console=detach) # Connect to the database session = db.configure(conf) # TODO(thrawn): make this configurable # Pass in a list of jobs cron should run cron = Cron([AuditSuspects(conf, session), BackupSuspects(conf, session), RestoreSuspects(conf, session), ScrubSuspects(conf, session), PruneSuspects(conf, session), Detach(conf, session)]) # Run the cron return cron.run() except (DaemonError, CronError), e: log.error(str(e)) return 1