Esempio n. 1
0
    def rvitals(self, nodesinfo, args):

        # 1, parse agrs
        if not args or (len(args) == 1 and args[0] in ['-V', '--verbose']):
            args.append('all')

        rvitals_usage = """
        Usage:
            rvitals [-V|--verbose] [all|altitude|fanspeed|leds|power|temp|voltage|wattage]

        Options:
            -V --verbose   rvitals verbose mode.
        """

        try:
            opts = docopt(rvitals_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 rvitals: %s" % args)
            return

        # 2, validate the args
        if action not in VITALS_OPTIONS:
            self.messager.error("Not supported subcommand for rvitals: %s" % action)
            return

        # 3, run the subcommands
        runner = OpenBMCSensorTask(nodesinfo, callback=self.messager, debugmode=self.debugmode, verbose=self.verbose)
        if action == 'leds':
            DefaultSensorManager().get_beacon_info(runner)
        else:
            DefaultSensorManager().get_sensor_info(runner, action)
Esempio n. 2
0
    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)