Beispiel #1
0
 def _validate_args(self):
     CliCommand._validate_args(self)
     source_ids = []
     if self.args.sources:
         # check for existence of sources
         not_found, source_ids = get_source_ids(self.parser,
                                                self.args.sources)
         if not_found is True:
             sys.exit(1)
     self.source_ids = source_ids
Beispiel #2
0
    def _validate_args(self):
        """Validate the edit arguments."""
        CliCommand._validate_args(self)
        # Check to see if args were provided
        if not (self.args.sources or self.args.max_concurrency or
                (self.args.disabled_optional_products
                 or self.args.disabled_optional_products == []) or
                (self.args.enabled_ext_product_search
                 or self.args.enabled_ext_product_search == []) or
                (self.args.ext_product_search_dirs
                 or self.args.ext_product_search_dirs == [])):
            print(_(messages.SCAN_EDIT_NO_ARGS % (self.args.name)))
            self.parser.print_help()
            sys.exit(1)

        # check for existence of scan
        exists = False
        response = request(parser=self.parser,
                           method=GET,
                           path=scan.SCAN_URI,
                           params={'name': self.args.name},
                           payload=None)
        if response.status_code == codes.ok:  # pylint: disable=no-member
            json_data = response.json()
            count = json_data.get('count', 0)
            results = json_data.get('results', [])
            if count >= 1:
                for result in results:
                    if result['name'] == self.args.name:
                        scan_entry = result
                        self.req_path \
                            = self.req_path + str(scan_entry['id']) + '/'
                        exists = True
            if not exists or count == 0:
                print(_(messages.SCAN_DOES_NOT_EXIST % self.args.name))
                sys.exit(1)
        else:
            print(_(messages.SCAN_DOES_NOT_EXIST % self.args.name))
            sys.exit(1)

        # check for valid source values
        source_ids = []
        if self.args.sources:
            # check for existence of sources
            not_found, source_ids = get_source_ids(self.parser,
                                                   self.args.sources)
            if not_found is True:
                sys.exit(1)
        self.source_ids = source_ids