def _validate_options(self): CliCommand._validate_options(self) if not self.options.report_path: print(_("No report location specified.")) self.parser.print_help() sys.exit(1) normalized_path = os.path.normpath(self.options.report_path) if not os.path.isfile(normalized_path): print(_('Report location is invalid.')) sys.exit(1) # perform fact validation input_facts = self.options.facts if input_facts == [] or input_facts == ['default']: self.facts_to_hash = facts.SENSITIVE_FACTS elif os.path.isfile(input_facts[0]): self.facts_to_hash = set(_read_in_file(input_facts[0])) else: assert isinstance(input_facts, list) self.facts_to_hash = set(input_facts) # check facts_to_hash is subset of facts.ALL_FACTS if not self.facts_to_hash.issubset(facts.ALL_FACTS): invalid_facts = self.facts_to_hash.difference(facts.ALL_FACTS) print( _("Invalid facts were supplied to the command: " + ",".join(invalid_facts))) self.parser.print_help() sys.exit(1)
def _validate_options(self): CliCommand._validate_options(self) if not self.options.report_path: print(_("No report location specified.")) self.parser.print_help() sys.exit(1) normalized_path = os.path.normpath(self.options.report_path) if not os.path.isfile(normalized_path): print(_('Report location is invalid.')) sys.exit(1) # perform fact validation facts = self.options.facts if facts == [] or facts == ['default']: self.facts_to_hash = list(utilities.SENSITIVE_FACTS_TUPLE) elif os.path.isfile(facts[0]): self.facts_to_hash = _read_in_file(facts[0]) else: assert isinstance(facts, list) self.facts_to_hash = facts # check facts_to_hash is subset of utilities.DEFAULT_FACTS all_facts = utilities.DEFAULT_FACTS facts_to_hash_set = set(self.facts_to_hash) if not facts_to_hash_set.issubset(all_facts): invalid_facts = facts_to_hash_set.difference(all_facts) print( _("Invalid facts were supplied to the command: " + ",".join(invalid_facts))) self.parser.print_help() sys.exit(1)
def _validate_options(self): CliCommand._validate_options(self) if not self.options.hosts: self.parser.print_help() sys.exit(1) if not self.options.auth: self.parser.print_help() sys.exit(1) if not self.options.name: self.parser.print_help() sys.exit(1) if hasattr(self.options, 'sshport') \ and self.options.sshport is not None: ssh_port = self.options.sshport try: ssh_port = utilities.validate_port(ssh_port) self.options.sshport = ssh_port except ValueError as port_error: print(str(port_error)) self.parser.print_help() sys.exit(1) else: self.options.sshport = 22
def _validate_options(self): CliCommand._validate_options(self) if not self.options.name: self.parser.print_help() sys.exit(1) if not (self.options.filename or self.options.username or self.options.password or self.options.sudo_password): print(_("Should specify an option to update: " "--username, --password, --sshkeyfile " "or --sudo-password")) sys.exit(1) if self.options.filename and self.options.password: print(_('You must provide either "--password" or a value for ' '"--sshkeyfile". You cannot supply both.')) self.parser.print_help() sys.exit(1) if self.options.filename: keyfile_path = os.path.abspath(os.path.normpath( os.path.expanduser(os.path.expandvars(self.options.filename)))) if os.path.isfile(keyfile_path) is False: print(_('You must provide a valid file path for' ' "--sshkeyfile", "%s" could not be found.' % keyfile_path)) self.parser.print_help() sys.exit(1) else: self.options.filename = keyfile_path
def _validate_options(self): CliCommand._validate_options(self) if not self.options.profile: print(_("No profile specified.")) self.parser.print_help() sys.exit(1) if not self.options.facts: print(_("No facts specified.")) self.parser.print_help() sys.exit(1) if not self.options.report_path: print(_("No report location specified.")) self.parser.print_help() sys.exit(1) if self.options.ansible_forks: try: if int(self.options.ansible_forks) <= 0: print(_("ansible_forks can only be a positive integer.")) self.parser.print_help() sys.exit(1) except ValueError: print(_("ansible_forks can only be a positive integer.")) self.parser.print_help() sys.exit(1)
def _validate_options(self): CliCommand._validate_options(self) if not self.options.name and not self.options.all: self.parser.print_help() sys.exit(1) if self.options.name and self.options.all: self.parser.print_help() sys.exit(1)
def _validate_options(self): CliCommand._validate_options(self) if not self.options.name: self.parser.print_help() sys.exit(1) if not self.options.hosts and not self.options.auth \ and not self.options.sshport: print(_("Specify either hosts, sshport, or auths to update.")) self.parser.print_help() sys.exit(1)
def _validate_options(self): CliCommand._validate_options(self) if not self.options.name: self.parser.print_help() sys.exit(1) if not (self.options.filename or self.options.username or self.options.password): print( _("Should specify an option to update:" " --username, --password or --sshkeyfile")) sys.exit(1)
def _validate_options(self): CliCommand._validate_options(self) if not self.options.name: self.parser.print_help() sys.exit(1) # need to pass in file or username: if not self.options.filename \ and not (self.options.username and self.options.password): self.parser.print_help() sys.exit(1)
def _validate_options(self): CliCommand._validate_options(self) if not self.options.hosts: self.parser.print_help() sys.exit(1) if not self.options.auth: self.parser.print_help() sys.exit(1) if not self.options.name: self.parser.print_help() sys.exit(1)
def _validate_options(self): CliCommand._validate_options(self) if not self.options.profile: print(_("No profile specified.")) self.parser.print_help() sys.exit(1) if not self.options.report_path: print(_("No report location specified.")) self.parser.print_help() sys.exit(1) if self.options.ansible_forks: try: if int(self.options.ansible_forks) <= 0: print(_("--ansible-forks can only be a positive integer.")) self.parser.print_help() sys.exit(1) except ValueError: print(_("--ansible-forks can only be a positive integer.")) self.parser.print_help() sys.exit(1) # perform fact validation input_facts = self.options.facts assert isinstance(input_facts, list) if input_facts and os.path.isfile(input_facts[0]): input_facts = _read_in_file(input_facts[0]) self.facts_to_collect = facts.expand_facts(input_facts) if self.options.scan_dirs == []: self.options.scan_dirs = ['/', '/opt', '/app', '/home', '/usr'] elif os.path.isfile(self.options.scan_dirs[0]): self.options.scan_dirs = \ _read_in_file(self.options.scan_dirs[0]) else: assert isinstance(self.options.scan_dirs, list) # check that all values in scan_dirs are valid abs paths invalid_paths = utilities.check_path_validity(self.options.scan_dirs) if invalid_paths != []: print( _("Invalid paths were supplied to the --scan-dirs option: " + ",".join(invalid_paths))) self.parser.print_help() sys.exit(1)
def _validate_options(self): CliCommand._validate_options(self) if not self.options.name and not self.options.all: print( _('You must provide either "--all" or a value for ' '"--name".')) self.parser.print_help() sys.exit(1) if self.options.name and self.options.all: print( _('You must provide either "--all" or a value for ' '"--name". You cannot supply both.')) self.parser.print_help() sys.exit(1)
def _validate_options(self): CliCommand._validate_options(self) if not self.options.name: self.parser.print_help() sys.exit(1) if not (self.options.filename or self.options.username or self.options.password or self.options.sudo_password): print(_("Should specify an option to update: " "--username, --password, --sshkeyfile " "or --sudo-password")) sys.exit(1) if self.options.filename and self.options.password: print(_('You must provide either "--password" or a value for ' '"--sshkeyfile". You cannot supply both.')) self.parser.print_help() sys.exit(1)
def _validate_options(self): CliCommand._validate_options(self) if not (self.options.name and self.options.username): print(_('You must provide a value for "--name" and "--username".')) self.parser.print_help() sys.exit(1) if not self.options.username: self.parser.print_help() sys.exit(1) # need to pass in file or password: if not (self.options.filename or self.options.password): print( _('You must provide either "--password" or a value for ' '"--sshkeyfile".')) self.parser.print_help() sys.exit(1) if self.options.filename and self.options.password: print( _('You must provide either "--password" or a value for ' '"--sshkeyfile". You cannot supply both.')) self.parser.print_help() sys.exit(1) if self.options.filename: keyfile_path = os.path.abspath( os.path.normpath( os.path.expanduser( os.path.expandvars(self.options.filename)))) if os.path.isfile(keyfile_path) is False: print( _('You must provide a valid file path for' ' "--sshkeyfile", "%s" could not be found.' % keyfile_path)) self.parser.print_help() sys.exit(1) else: self.options.filename = keyfile_path
def _validate_options(self): CliCommand._validate_options(self) if not self.options.name: self.parser.print_help() sys.exit(1) if not self.options.hosts and not self.options.auth \ and not self.options.sshport: print(_("Specify either hosts, sshport, or auths to update.")) self.parser.print_help() sys.exit(1) if hasattr(self.options, 'sshport') \ and self.options.sshport is not None: ssh_port = self.options.sshport try: ssh_port = utilities.validate_port(ssh_port) self.options.sshport = ssh_port except ValueError as port_error: print(str(port_error)) self.parser.print_help() sys.exit(1)
def _validate_options(self): CliCommand._validate_options(self) if not (self.options.name and self.options.username): print(_('You must provide a value for "--name" and "--username".')) self.parser.print_help() sys.exit(1) if not self.options.username: self.parser.print_help() sys.exit(1) # need to pass in file or password: if not (self.options.filename or self.options.password): print(_('You must provide either "--password" or a value for ' '"--sshkeyfile".')) self.parser.print_help() sys.exit(1) if self.options.filename and self.options.password: print(_('You must provide either "--password" or a value for ' '"--sshkeyfile". You cannot supply both.')) self.parser.print_help() sys.exit(1)
def _validate_options(self): CliCommand._validate_options(self) if not self.options.profile: print(_("No profile specified.")) self.parser.print_help() sys.exit(1) if not self.options.report_path: print(_("No report location specified.")) self.parser.print_help() sys.exit(1) if self.options.ansible_forks: try: if int(self.options.ansible_forks) <= 0: print(_("--ansible-forks can only be a positive integer.")) self.parser.print_help() sys.exit(1) except ValueError: print(_("--ansible-forks can only be a positive integer.")) self.parser.print_help() sys.exit(1) # perform fact validation facts = self.options.facts if facts == []: self.facts_to_collect = list(utilities.RHEL_FACTS + utilities.CONNECTION_FACTS_TUPLE) elif facts == ['default'] or facts == ['all']: self.facts_to_collect = list(utilities.DEFAULT_FACTS) elif facts == ['jboss']: self.facts_to_collect = list(utilities.JBOSS_FACTS + utilities.CONNECTION_FACTS_TUPLE) elif facts == ['rhel']: self.facts_to_collect = list(utilities.RHEL_FACTS + utilities.CONNECTION_FACTS_TUPLE) elif os.path.isfile(facts[0]): self.facts_to_collect = _read_in_file(facts[0]) else: assert isinstance(facts, list) self.facts_to_collect = facts # check facts_to_collect is subset of utilities.DEFAULT_FACTS all_facts = utilities.DEFAULT_FACTS facts_to_collect_set = set(self.facts_to_collect) if not facts_to_collect_set.issubset(all_facts): invalid_facts = facts_to_collect_set.difference(all_facts) print(_("Invalid facts were supplied to scan command: " + ",".join(invalid_facts))) self.parser.print_help() sys.exit(1) if self.options.scan_dirs == []: self.options.scan_dirs = ['/', '/opt', '/app', '/home', '/usr'] elif os.path.isfile(self.options.scan_dirs[0]): self.options.scan_dirs = \ _read_in_file(self.options.scan_dirs[0]) else: assert isinstance(self.options.scan_dirs, list) # check that all values in scan_dirs are valid abs paths invalid_paths = utilities.check_path_validity(self.options.scan_dirs) if invalid_paths != []: print(_("Invalid paths were supplied to the --scan-dirs option: " + ",".join(invalid_paths))) self.parser.print_help() sys.exit(1)