def __init__(self, parser, opts, args): super(_HasherServiceOptions, self).__init__() if len(args) != 0: parser.error('extraneous arguments: %s' % (' '.join(args))) # hosts self.hosts = opts.host[:] for f in opts.hosts: self.hosts.extend(_file_lines(f)) if len(self.hosts) == 0: parser.error('at least one target host is required') # auid/url self.auid = opts.auid self.url = opts.url # output_directory/output_prefix self.output_directory = os.path.expanduser(opts.output_directory) if not os.path.isdir(self.output_directory): parser.error('no such directory: %s' % (self.output_directory,)) if opts.output_prefix is None: parser.error('--output-prefix is required') if '/' in opts.output_prefix: parser.error('output prefix cannot contain a slash') self.output_prefix = opts.output_prefix # long_html_line/long_text_line/wait/threads if any([opts.long_html_line, opts.long_text_line]) and self.url is None: parser.error('--long-html-line, --long-text-line only apply to --url') if opts.long_html_line and opts.long_text_line: parser.error('--long-html-line, --long-text-line are incompatible') self.long_html_line = opts.long_html_line self.long_text_line = opts.long_text_line if opts.wait is None: self.wait = 30 if self.url is None else 10 else: self.wait = opts.wait # threads self.threads = opts.threads or len(self.hosts) # auth u = opts.username or getpass.getpass('UI username: '******'UI password: ') self.auth = zsiauth(u, p)
def __init__(self, parser, opts, args): super(_HasherServiceOptions, self).__init__() if len(args) != 0: parser.error('extraneous arguments: %s' % (' '.join(args))) # hosts self.hosts = opts.host[:] for f in opts.hosts: self.hosts.extend(_file_lines(f)) if len(self.hosts) == 0: parser.error('at least one target host is required') # auid/url self.auid = opts.auid self.url = opts.url # output_directory/output_prefix self.output_directory = os.path.expanduser(opts.output_directory) if not os.path.isdir(self.output_directory): parser.error('no such directory: %s' % (self.output_directory,)) if opts.output_prefix is None: parser.error('--output-prefix is required') if '/' in opts.output_prefix: parser.error('output prefix cannot contain a slash') self.output_prefix = opts.output_prefix # long_html_line/long_text_line/wait/threads if any([opts.long_html_line, opts.long_text_line]) and self.url is None: parser.error('--long-html-line, --long-text-line only apply to --url') if opts.long_html_line and opts.long_text_line: parser.error('--long-html-line, --long-text-line are incompatible') if opts.include_weight and self.url: parser.error('--include-weight not compatible with --url') self.include_weight = opts.include_weight self.long_html_line = opts.long_html_line self.long_text_line = opts.long_text_line if opts.wait is None: self.wait = 30 if self.url is None else 10 else: self.wait = opts.wait # threads self.threads = opts.threads or len(self.hosts) # auth u = opts.username or getpass.getpass('UI username: '******'UI password: ') self.auth = zsiauth(u, p)
def __init__(self, parser, opts, args): ''' Constructor. Parameters: - parser (OptionParser instance): the option parser - opts (Options instance): the Options instance returned by the parser - args (list of strings): the remaining command line arguments returned by the parser ''' super(_ContentConfigurationServiceOptions, self).__init__() self.errors = 0 # Special options if opts.copyright: print __copyright__ if opts.license: print __license__ if opts.tutorial: print __tutorial__ if any([opts.copyright, opts.license, opts.tutorial]): sys.exit() # General checks if len(args) > 0: parser.error('unexpected command line arguments: %s' % (' '.join(args),)) if len(filter(None, [opts.add_aus, opts.deactivate_aus, opts.delete_aus, opts.reactivate_aus])) != 1: parser.error('exactly one of --add-aus, --deactivate-aus, --delete-aus, --reactivate-aus is required') if len(filter(None, [opts.table_output, opts.text_output])) > 1: parser.error('at most one of --table-output, --text-output can be specified') # hosts self.hosts = opts.host[:] for f in opts.hosts: self.hosts.extend(_file_lines(f)) if len(self.hosts) == 0: parser.error('at least one target host is required') # auids self.auids = opts.auid[:] for f in opts.auids: self.auids.extend(_file_lines(f)) if len(self.auids) == 0: parser.error('at least one target AUID is required') # au_operation if opts.add_aus: self.au_operation = add_aus_by_id_list elif opts.deactivate_aus: self.au_operation = deactivate_aus_by_id_list elif opts.delete_aus: self.au_operation = delete_aus_by_id_list else: self.au_operation = reactivate_aus_by_id_list # table_output/text_output/keysort/keydisplay/verbose self.table_output = opts.table_output self.text_output = not self.table_output if opts.sort_by_auid: self.keysort = _sort_by_auid else: self.keysort = _sort_by_name # default is --sort-by-name if opts.list_by_auid: self.keydisplay = _list_by_auid elif opts.list_by_name: self.keydisplay = _list_by_name else: self.keydisplay = _list_by_both # default is --list-by-both if self.text_output: self.verbose = opts.verbose elif opts.verbose: parser.error('--verbose can only be specified with --text-output') # pool_class/pool_size/batch_size if opts.process_pool and opts.thread_pool: parser.error('--process-pool and --thread-pool are mutually exclusive') self.pool_class = ProcessPool if opts.process_pool else ThreadPool self.pool_size = opts.pool_size or len(self.hosts) self.batch_size = opts.batch_size # auth u = opts.username or getpass.getpass('UI username: '******'UI password: ') self.auth = zsiauth(u, p)
def __init__(self, parser, opts, args): super(_DaemonStatusServiceOptions, self).__init__() if len(args) > 0: parser.error('extraneous arguments: %s' % (' '.join(args))) if len(filter(None, [opts.get_au_status, opts.get_auids, opts.get_auids_names, opts.get_peer_agreements, opts.get_platform_configuration, opts.is_daemon_ready, opts.is_daemon_ready_quiet, opts.query_aus])) != 1: parser.error('exactly one of --get-au-status, --get-auids, --get-auids-names, --get-peer-agreements, --get-platform-configuration, --is-daemon-ready, --is-daemon-ready-quiet, --query-aus is required') if len(opts.auid) + len(opts.auids) > 0 and not any([opts.get_au_status, opts.get_auids, opts.get_auids_names, opts.get_peer_agreements]): parser.error('--auid, --auids can only be applied to --get-au-status, --get-auids, --get-auids-names, --get-peer-agreements') if opts.select and not any([opts.get_au_status, opts.get_platform_configuration, opts.query_aus]): parser.error('--select can only be applied to --get-au-status, --get-platform-configuration, --query-aus') if opts.where and not any([opts.query_aus]): parser.error('--where can only be applied to --query-aus') if opts.group_by_field and not any([opts.get_au_status, opts.query_aus]): parser.error('--group-by-field can only be applied to --get-au-status, --query-aus') # hosts self.hosts = opts.host[:] for f in opts.hosts: self.hosts.extend(_file_lines(f)) if len(self.hosts) == 0: parser.error('at least one target host is required') # auids self.auids = opts.auid[:] for f in opts.auids: self.auids.extend(_file_lines(f)) # get_auids/get_auids_names/is_daemon_ready/is_daemon_ready_quiet self.get_auids = opts.get_auids self.get_auids_names = opts.get_auids_names self.is_daemon_ready = opts.is_daemon_ready self.is_daemon_ready_quiet = opts.is_daemon_ready_quiet # get_platform_configuration/select self.get_platform_configuration = opts.get_platform_configuration if self.get_platform_configuration: self.select = self.__init_select(parser, opts, _PLATFORM_CONFIGURATION) # get_au_status/get_peer_agreements self.get_au_status = opts.get_au_status if self.get_au_status: if len(self.auids) == 0: parser.error('at least one target AUID is required with --get-au-status') self.select = self.__init_select(parser, opts, _AU_STATUS) self.get_peer_agreements = opts.get_peer_agreements # query_aus/where/select self.where = opts.where self.query_aus = opts.query_aus if self.query_aus: self.select = self.__init_select(parser, opts, _QUERY_AUS) # group_by_field/no_special_output self.group_by_field = opts.group_by_field self.no_special_output = opts.no_special_output # auth u = opts.username or getpass.getpass('UI username: '******'UI password: ') self.auth = zsiauth(u, p)
def __init__(self, parser, opts, args): super(_DaemonStatusServiceOptions, self).__init__() if len(args) > 0: parser.error('extraneous arguments: %s' % (' '.join(args))) if len( filter(None, [ opts.get_au_status, opts.get_auids, opts.get_auids_names, opts.get_peer_agreements, opts.get_platform_configuration, opts.is_daemon_ready, opts.is_daemon_ready_quiet, opts.query_aus ])) != 1: parser.error( 'exactly one of --get-au-status, --get-auids, --get-auids-names, --get-peer-agreements, --get-platform-configuration, --is-daemon-ready, --is-daemon-ready-quiet, --query-aus is required' ) if len(opts.auid) + len(opts.auids) > 0 and not any([ opts.get_au_status, opts.get_auids, opts.get_auids_names, opts.get_peer_agreements ]): parser.error( '--auid, --auids can only be applied to --get-au-status, --get-auids, --get-auids-names, --get-peer-agreements' ) if opts.select and not any([ opts.get_au_status, opts.get_platform_configuration, opts.query_aus ]): parser.error( '--select can only be applied to --get-au-status, --get-platform-configuration, --query-aus' ) if opts.where and not any([opts.query_aus]): parser.error('--where can only be applied to --query-aus') if opts.group_by_field and not any( [opts.get_au_status, opts.query_aus]): parser.error( '--group-by-field can only be applied to --get-au-status, --query-aus' ) # hosts self.hosts = opts.host[:] for f in opts.hosts: self.hosts.extend(_file_lines(f)) if len(self.hosts) == 0: parser.error('at least one target host is required') # auids self.auids = opts.auid[:] for f in opts.auids: self.auids.extend(_file_lines(f)) # get_auids/get_auids_names/is_daemon_ready/is_daemon_ready_quiet self.get_auids = opts.get_auids self.get_auids_names = opts.get_auids_names self.is_daemon_ready = opts.is_daemon_ready self.is_daemon_ready_quiet = opts.is_daemon_ready_quiet # get_platform_configuration/select self.get_platform_configuration = opts.get_platform_configuration if self.get_platform_configuration: self.select = self.__init_select(parser, opts, _PLATFORM_CONFIGURATION) # get_au_status/get_peer_agreements self.get_au_status = opts.get_au_status if self.get_au_status: if len(self.auids) == 0: parser.error( 'at least one target AUID is required with --get-au-status' ) self.select = self.__init_select(parser, opts, _AU_STATUS) self.get_peer_agreements = opts.get_peer_agreements # query_aus/where/select self.where = opts.where self.query_aus = opts.query_aus if self.query_aus: self.select = self.__init_select(parser, opts, _QUERY_AUS) # group_by_field/no_special_output self.group_by_field = opts.group_by_field self.no_special_output = opts.no_special_output # auth u = opts.username or getpass.getpass('UI username: '******'UI password: ') self.auth = zsiauth(u, p)
def __init__(self, parser, opts, args): ''' Constructor. Parameters: - parser (OptionParser instance): the option parser - opts (Options instance): the Options instance returned by the parser - args (list of strings): the remaining command line arguments returned by the parser ''' super(_ContentConfigurationServiceOptions, self).__init__() self.errors = 0 # Special options if opts.copyright: print __copyright__ if opts.license: print __license__ if opts.tutorial: print __tutorial__ if any([opts.copyright, opts.license, opts.tutorial]): sys.exit() # General checks if len(args) > 0: parser.error('unexpected command line arguments: %s' % (' '.join(args), )) if len( filter(None, [ opts.add_aus, opts.deactivate_aus, opts.delete_aus, opts.reactivate_aus ])) != 1: parser.error( 'exactly one of --add-aus, --deactivate-aus, --delete-aus, --reactivate-aus is required' ) if len(filter(None, [opts.table_output, opts.text_output])) > 1: parser.error( 'at most one of --table-output, --text-output can be specified' ) # hosts self.hosts = opts.host[:] for f in opts.hosts: self.hosts.extend(_file_lines(f)) if len(self.hosts) == 0: parser.error('at least one target host is required') # auids self.auids = opts.auid[:] for f in opts.auids: self.auids.extend(_file_lines(f)) if len(self.auids) == 0: parser.error('at least one target AUID is required') # au_operation if opts.add_aus: self.au_operation = add_aus_by_id_list elif opts.deactivate_aus: self.au_operation = deactivate_aus_by_id_list elif opts.delete_aus: self.au_operation = delete_aus_by_id_list else: self.au_operation = reactivate_aus_by_id_list # table_output/text_output/keysort/keydisplay/verbose self.table_output = opts.table_output self.text_output = not self.table_output if opts.sort_by_auid: self.keysort = _sort_by_auid else: self.keysort = _sort_by_name # default is --sort-by-name if opts.list_by_auid: self.keydisplay = _list_by_auid elif opts.list_by_name: self.keydisplay = _list_by_name else: self.keydisplay = _list_by_both # default is --list-by-both if self.text_output: self.verbose = opts.verbose elif opts.verbose: parser.error('--verbose can only be specified with --text-output') # pool_class/pool_size/batch_size if opts.process_pool and opts.thread_pool: parser.error( '--process-pool and --thread-pool are mutually exclusive') self.pool_class = ProcessPool if opts.process_pool else ThreadPool self.pool_size = opts.pool_size or len(self.hosts) self.batch_size = opts.batch_size # auth u = opts.username or getpass.getpass('UI username: '******'UI password: ') self.auth = zsiauth(u, p)