def selectfunction(self, line):
        """ Main select worker function

        :param line: command line input
        :type line: string.
        """
        try:
            (options, args) = self._parse_arglist(line)
        except:
            if ("-h" in line) or ("--help" in line):
                return ReturnCodes.SUCCESS
            else:
                raise InvalidCommandLineErrorOPTS("")

        self.selectvalidation(options)

        try:
            if args:
                if options.ref:
                    LOGGER.warn(
                        "Patches from current selection will be cleared.")
                selector = args[0]
                selections = self._rdmc.app.select(selector=selector,
                                                   rel=options.ref)

                if self._rdmc.opts.verbose and selections:
                    templist = list()
                    sys.stdout.write("Selected option(s): ")

                    for item in selections:
                        if item.type not in templist:
                            templist.append(item.type)

                    sys.stdout.write('%s' % ', '.join(map(str, templist)))
                    sys.stdout.write('\n')
            else:
                selector = self._rdmc.app.get_selector()

                if selector:
                    sellist = [sel for sel in self._rdmc.app.current_client.\
                       monolith.typesadded if selector.lower() in sel.lower()]
                    sys.stdout.write("Current selection: ")
                    sys.stdout.write('%s' % ', '.join(map(str, sellist)))
                    sys.stdout.write('\n')
                else:
                    raise InvalidCommandLineError("No type currently selected."\
                                " Please use the 'types' command to\nget a" \
                                " list of types, or pass your type by using" \
                                " the '--selector' flag.")

        except redfish.ris.InstanceNotFoundError as infe:
            raise redfish.ris.InstanceNotFoundError(infe)
Esempio n. 2
0
    def selectfunction(self, line):
        """ Main select worker function

        :param line: command line input
        :type line: string.
        """
        try:
            (options, args) = self.rdmc.rdmc_parse_arglist(self, line)
        except (InvalidCommandLineErrorOPTS, SystemExit):
            if ("-h" in line) or ("--help" in line):
                return ReturnCodes.SUCCESS
            else:
                raise InvalidCommandLineErrorOPTS("")

        self.selectvalidation(options)

        if args:
            if options.ref:
                LOGGER.warn("Patches from current selection will be cleared.")
            selector = args[0]
            selections = self.rdmc.app.select(selector=selector, path_refresh=options.ref)

            if self.rdmc.opts.verbose and selections:
                templist = list()
                self.rdmc.ui.printer("Selected option(s): ")

                for item in selections:
                    if item.type not in templist:
                        templist.append(item.type)

                self.rdmc.ui.printer('%s\n' % ', '.join(map(str, templist)))

        else:
            selector = self.rdmc.app.selector

            if selector:
                sellist = [sel for sel in self.rdmc.app.\
                   monolith.typesadded if selector.lower() in sel.lower()]
                self.rdmc.ui.printer("Current selection: ")
                self.rdmc.ui.printer('%s' % ', '.join(map(str, sellist)))
            else:
                raise NothingSelectedError

        self.cmdbase.logout_routine(self, options)