def rbeacon(self, nodesinfo, args): # 1, parse args rbeacon_usage = """ Usage: rbeacon [-V|--verbose] [on|off|stat] Options: -V --verbose rbeacon verbose mode. """ try: opts = docopt(rbeacon_usage, argv=args) self.verbose = opts.pop('--verbose') action = [k for k, v in opts.items() if v][0] except Exception as e: self.messager.error("Failed to parse arguments for rbeacon: %s" % args) return # 2, validate the args if action is None: self.messager.error("Subcommand for rbeacon was not specified") return if action not in BEACON_OPTIONS: self.messager.error("Not supported subcommand for rbeacon: %s" % action) return # 3, run the subcommands if action == 'stat': runner = OpenBMCSensorTask(nodesinfo, callback=self.messager, debugmode=self.debugmode, verbose=self.verbose) DefaultSensorManager().get_beacon_info(runner, display_type='compact') else: runner = OpenBMCBeaconTask(nodesinfo, callback=self.messager, debugmode=self.debugmode, verbose=self.verbose) DefaultBeaconManager().set_beacon_state(runner, beacon_state=action)