def main(self, argv): # these need to be available for the help, which gets parsed super # early self.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)) return 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', 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() 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 self.load_ceph_conf_path(cluster_name=args.cluster) try: conf.ceph = configuration.load(conf.path) except exceptions.ConfigurationError as error: is_help = "-h" in subcommand_args or "--help" in subcommand_args if " ".join(subcommand_args[:2]) in IGNORE_CEPH_CONFIG_COMMANDS or is_help: # 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) else: terminal.red(error) raise # dispatch to sub-commands terminal.dispatch(self.mapper, subcommand_args)
def main(self, argv): self.load_ceph_conf_path() # these need to be available for the help, which gets parsed super # early self.load_ceph_conf_path() self.load_log_path() 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)) return parser = argparse.ArgumentParser( prog='ceph-volume-zfs', 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', 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-zfs.log') log.setup() logger = logging.getLogger(__name__) logger.info("Running command: ceph-volume-zfs %s %s", " ".join(main_args), " ".join(subcommand_args)) # set all variables from args and load everything needed according to # them self.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 zfs tags) logger.exception('ignoring inability to load ceph.conf') terminal.red(error) # dispatch to sub-commands terminal.dispatch(self.mapper, subcommand_args)
def stat_ceph_conf(self): try: configuration.load(conf.path) return terminal.green(conf.path) except exceptions.ConfigurationError as error: return terminal.red(error)
def stat_ceph_conf(self): try: configuration.load(conf.path) return terminal.green(conf.path) except exceptions.ConfigurationError as error: return terminal.red(error)