Exemplo n.º 1
0
 def main(self, argv):
     # these need to be available for the help, which gets parsed super
     # early
     configuration.load_ceph_conf_path()
     self.load_log_path()
     self.enable_plugins()
     main_args, subcommand_args = self._get_split_args()
     # no flags where passed in, return the help menu instead of waiting for
     # argparse which will end up complaning that there are no args
     if len(argv) <= 1:
         print(self.help(warning=True))
         raise SystemExit(0)
     parser = argparse.ArgumentParser(
         prog='ceph-volume',
         formatter_class=argparse.RawDescriptionHelpFormatter,
         description=self.help(),
     )
     parser.add_argument(
         '--cluster',
         default='ceph',
         help='Cluster name (defaults to "ceph")',
     )
     parser.add_argument(
         '--log-level',
         default='debug',
         choices=['debug', 'info', 'warning', 'error', 'critical'],
         help='Change the file log level (defaults to debug)',
     )
     parser.add_argument(
         '--log-path',
         default='/var/log/ceph/',
         help='Change the log path (defaults to /var/log/ceph)',
     )
     args = parser.parse_args(main_args)
     conf.log_path = args.log_path
     if os.path.isdir(conf.log_path):
         conf.log_path = os.path.join(args.log_path, 'ceph-volume.log')
     log.setup(log_level=args.log_level)
     log.setup_console()
     logger = logging.getLogger(__name__)
     logger.info("Running command: ceph-volume %s %s", " ".join(main_args),
                 " ".join(subcommand_args))
     # set all variables from args and load everything needed according to
     # them
     configuration.load_ceph_conf_path(cluster_name=args.cluster)
     try:
         conf.ceph = configuration.load(conf.path)
     except exceptions.ConfigurationError as error:
         # we warn only here, because it is possible that the configuration
         # file is not needed, or that it will be loaded by some other means
         # (like reading from lvm tags)
         logger.exception('ignoring inability to load ceph.conf')
         terminal.red(error)
     # dispatch to sub-commands
     terminal.dispatch(self.mapper, subcommand_args)
Exemplo n.º 2
0
 def setup(self):
     self.octpus_and_squid_en = u'octpus and squid'
     self.octpus_and_squid_zh = u'章鱼和鱿鱼'
     self.message = self.octpus_and_squid_en + self.octpus_and_squid_zh
     setup_console()