Python optparse.OptionParser() Examples

The following are code examples for showing how to use optparse.OptionParser(). They are extracted from open source Python projects. You can vote up the examples you like or vote down the exmaples you don't like. You can also save this page to your account.

Example 1
Project: Adafruit_Python_PureIO   Author: adafruit   File: ez_setup.py    (MIT License) View Source Project 7 votes vote down vote up
def _parse_args():
    """
    Parse the command line for options
    """
    parser = optparse.OptionParser()
    parser.add_option(
        '--user', dest='user_install', action='store_true', default=False,
        help='install in user site package (requires Python 2.6 or later)')
    parser.add_option(
        '--download-base', dest='download_base', metavar="URL",
        default=DEFAULT_URL,
        help='alternative URL from where to download the setuptools package')
    parser.add_option(
        '--insecure', dest='downloader_factory', action='store_const',
        const=lambda: download_file_insecure, default=get_best_downloader,
        help='Use internal, non-validating downloader'
    )
    parser.add_option(
        '--version', help="Specify which version to download",
        default=DEFAULT_VERSION,
    )
    options, args = parser.parse_args()
    # positional arguments are ignored
    return options 
Example 2
Project: heerkat   Author: Roche   File: run_test_suite.py    (Apache License 2.0) View Source Project 6 votes vote down vote up
def parse_args():
    parser = OptionParser()
    parser.add_option('--detailed_output', nargs=1,
                      help='specify path where detailed logs can be found')
    parser.add_option('--monitored_output', nargs=1,
                      help='specify path where monitored logs can be found')
    parser.add_option('--test_suite', nargs=1, choices=['availability.service_tests', ],
                      help='specify the test suite (python module) that you wish to execute')

    (options, args) = parser.parse_args()

    if not options.test_suite:  # Python 2.6 strikes again! Use argparse after Python upgrade
        parser.error('test_suite not given')
    if not options.monitored_output:
        parser.error('monitored_output not given')
    if not options.detailed_output:
        parser.error('detailed_output not given')

    return options 
Example 3
Project: python-   Author: secondtonone1   File: req_file.py    (license) View Source Project 6 votes vote down vote up
def build_parser():
    """
    Return a parser for parsing requirement lines
    """
    parser = optparse.OptionParser(add_help_option=False)

    option_factories = SUPPORTED_OPTIONS + SUPPORTED_OPTIONS_REQ
    for option_factory in option_factories:
        option = option_factory()
        parser.add_option(option)

    # By default optparse sys.exits on parsing errors. We want to wrap
    # that in our own exception.
    def parser_exit(self, msg):
        raise RequirementsFileParseError(msg)
    parser.exit = parser_exit

    return parser 
Example 4
Project: py_find_1st   Author: roebel   File: ez_setup.py    (GNU General Public License v3.0) View Source Project 6 votes vote down vote up
def _parse_args():
    """
    Parse the command line for options
    """
    parser = optparse.OptionParser()
    parser.add_option(
        '--user', dest='user_install', action='store_true', default=False,
        help='install in user site package (requires Python 2.6 or later)')
    parser.add_option(
        '--download-base', dest='download_base', metavar="URL",
        default=DEFAULT_URL,
        help='alternative URL from where to download the setuptools package')
    parser.add_option(
        '--insecure', dest='downloader_factory', action='store_const',
        const=lambda: download_file_insecure, default=get_best_downloader,
        help='Use internal, non-validating downloader'
    )
    parser.add_option(
        '--version', help="Specify which version to download",
        default=DEFAULT_VERSION,
    )
    options, args = parser.parse_args()
    # positional arguments are ignored
    return options 
Example 5
Project: Adafruit_Python_PCA9685   Author: adafruit   File: ez_setup.py    (MIT License) View Source Project 6 votes vote down vote up
def _parse_args():
    """
    Parse the command line for options
    """
    parser = optparse.OptionParser()
    parser.add_option(
        '--user', dest='user_install', action='store_true', default=False,
        help='install in user site package (requires Python 2.6 or later)')
    parser.add_option(
        '--download-base', dest='download_base', metavar="URL",
        default=DEFAULT_URL,
        help='alternative URL from where to download the setuptools package')
    parser.add_option(
        '--insecure', dest='downloader_factory', action='store_const',
        const=lambda: download_file_insecure, default=get_best_downloader,
        help='Use internal, non-validating downloader'
    )
    parser.add_option(
        '--version', help="Specify which version to download",
        default=DEFAULT_VERSION,
    )
    options, args = parser.parse_args()
    # positional arguments are ignored
    return options 
Example 6
Project: cbapi-examples   Author: cbcommunity   File: feed_cert.py    (MIT License) View Source Project 6 votes vote down vote up
def build_cli_parser():
    parser = optparse.OptionParser(usage="%prog [options]", description="Configure SSL client certificate authentication for feeds")

    # for each supported output type, add an option
    #
    parser.add_option("-c", "--cburl", action="store", default=None, dest="server_url",
                      help="CB server's URL.  e.g., http://127.0.0.1 ")
    parser.add_option("-a", "--apitoken", action="store", default=None, dest="token",
                      help="API Token for Carbon Black server")
    parser.add_option("-n", "--no-ssl-verify", action="store_false", default=True, dest="ssl_verify",
                      help="Do not verify server SSL certificate.")
    parser.add_option("-i", "--id", action="store", default=None, dest="id",
                      help="Feed Id")
    parser.add_option("-r", "--remove", action="store_true", default=False, dest="remove",
                      help="Remove SSL client certificate authentication for the feed specified with -i")
    parser.add_option("-C", "--certificate", action="store", default=None, dest="certificate",
                      help="SSL client certificate filename; expected to begin with \"-----BEGIN CERTIFICATE-----\"")
    parser.add_option("-K", "--key", action="store", default=None, dest="key",
                      help="SSL client key filename; expected to begin with \"-----BEGIN RSA PRIVATE KEY-----\"") 
    return parser 
Example 7
Project: cbapi-examples   Author: cbcommunity   File: bit9_platform_server_config.py    (MIT License) View Source Project 6 votes vote down vote up
def build_cli_parser():
    parser = optparse.OptionParser(usage="%prog [options]", description="Get and set Bit9 Platform Server Configuration")

    # for each supported output type, add an option
    #
    parser.add_option("-c", "--cburl", action="store", default=None, dest="url",
                      help="CB server's URL.  e.g., http://127.0.0.1 ")
    parser.add_option("-a", "--apitoken", action="store", default=None, dest="token",
                      help="API Token for Carbon Black server")
    parser.add_option("-n", "--no-ssl-verify", action="store_false", default=True, dest="ssl_verify",
                      help="Do not verify server SSL certificate.")
    parser.add_option("-u", "--server-url", action="store", default=None, dest="server_url",
                      help="Specify the URL of the configured Bit9 Platform Server")
    parser.add_option("-s", "--ssl-cert-verify", action="store", default=None, dest="ssl_cert_verify",
                      help="Specify if the SSL certificate of the Bit9 Platform Server should be verified; should be 'True' or 'False'")
    parser.add_option("-w", "--watchlist-enable", action="store", default=None, dest="watchlist_enable",
                      help="Enable export of CB Watchlists to Bit9 Platform Server; should be 'True' or 'False'")
    parser.add_option("-t", "--authtoken", action="store", default=None, dest="auth_token",
                      help="Bit9 Platform Server Auth Token used by CB server to send watchlist hits")
    return parser 
Example 8
Project: cbapi-examples   Author: cbcommunity   File: check_ioc.py    (MIT License) View Source Project 6 votes vote down vote up
def build_cli_parser():
    parser = OptionParser(usage="%prog [options]", description="check Cb index for provided IOCs")

    # for each supported output type, add an option
    parser.add_option("-c", "--cburl", action="store", default=None, dest="url",
                      help="CB server's URL.  e.g., http://127.0.0.1 ")
    parser.add_option("-a", "--apitoken", action="store", default=None, dest="token",
                      help="API Token for Carbon Black server")
    parser.add_option("-f", "--file", action="store", default=None, dest="fname",
                      help="Filename with CRLF-delimited list of IOCs")
    parser.add_option("-t", "--type", action="store", default=None, dest="type",
                      help="Type of IOCs in the file.  Must be one of md5, domain or ipaddr")
    parser.add_option("-d", "--detail", action="store_true", default=False, dest="detail",
                      help="Get full detail about each IOC hit.")
    parser.add_option("-n", "--no-ssl-verify", action="store_false", default=True, dest="ssl_verify",
                      help="Do not verify server SSL certificate.")
    return parser 
Example 9
Project: cbapi-examples   Author: cbcommunity   File: process_cmdline_regex.py    (MIT License) View Source Project 6 votes vote down vote up
def build_cli_parser():
    parser = OptionParser(usage="%prog [options]", description="Parse the command line using a regular expression (includes the options to count matches & leverage reference groups to define output). NOTE: Given that this script parses all command line data stored in Carbon Black, this script can take from several minutes to several hours to run depending upon the size of your Carbon Black ER datastore & the CbER server's hardware. It is reccomended to use output redirection as then you can tail as well as monitor the output file's size to check the status of long running queries.")

    # for each supported output type, add an option
    parser.add_option("-c", "--cburl", action="store", default=None, dest="url",
                      help="CB server's URL.  e.g., https://127.0.0.1:443")
    parser.add_option("-a", "--apitoken", action="store", default=None, dest="token",
                      help="API Token for Carbon Black server")
    parser.add_option("-n", "--no-ssl-verify", action="store_false", default=True, dest="ssl_verify",
                      help="Do not verify server SSL certificate.")
    parser.add_option("-r", "--regex", action="store", default=None, dest="regex",
                      help="Regular Expression for parsing cmdline")
    parser.add_option("-i", "--ignore-case", action="store", default=None, dest="ignore_case",
                      help="Flag to force regex to ignore character case when matching")
    parser.add_option("-G", "--group-reference-to-match", action="store", default=None, dest="group_reference_to_match",
                      help="User an integer to specify which parenthesized reference group in the regex to match")
    parser.add_option("-C", "--count", action="store_true", default=False, dest="count_flag",
                      help="Count instances of matched regex hits (in some cases, enabling this function may cause this script to run for a long time)")
    parser.add_option("-M", "--matches-only", action="store_true", default=False, dest="matches_only_flag",
                      help="Match MUST begin at the 1st character of the command line string (ASSUME ^ at start of regex)")


    return parser 
Example 10
Project: cbapi-examples   Author: cbcommunity   File: feed_action_del.py    (MIT License) View Source Project 6 votes vote down vote up
def build_cli_parser():
    parser = optparse.OptionParser(usage="%prog [options]", description="Delete a certain action of a specified feed from the server")

    # for each supported output type, add an option
    #
    parser.add_option("-c", "--cburl", action="store", default=None, dest="server_url",
                      help="CB server's URL.  e.g., http://127.0.0.1 ")
    parser.add_option("-a", "--apitoken", action="store", default=None, dest="token",
                      help="API Token for Carbon Black server")
    parser.add_option("-n", "--no-ssl-verify", action="store_false", default=True, dest="ssl_verify",
                      help="Do not verify server SSL certificate.")
    parser.add_option("-i", "--id", action = "store", default = None, dest = "id",
                      help = "id of the feed")
    parser.add_option("-d", "--action_id", action = "store", default = None, dest = "action_id",
                      help = "id of the action to be deleted")
    return parser 
Example 11
Project: cbapi-examples   Author: cbcommunity   File: watchlist_edit.py    (MIT License) View Source Project 6 votes vote down vote up
def build_cli_parser():
    parser = optparse.OptionParser(usage="%prog [options]", description="Edit the Query of an Existing Watchlist")

    # for each supported output type, add an option
    #
    parser.add_option("-c", "--cburl", action="store", default=None, dest="url",
                      help="CB server's URL.  e.g., http://127.0.0.1 ")
    parser.add_option("-a", "--apitoken", action="store", default=None, dest="token",
                      help="API Token for Carbon Black server")
    parser.add_option("-n", "--no-ssl-verify", action="store_false", default=True, dest="ssl_verify",
                      help="Do not verify server SSL certificate.")
    parser.add_option("-i", "--id", action="store", default=None, dest="id",
                      help="Watchlist ID to modify")
    parser.add_option("-q", "--query", action="store", default=None, dest="query",
                      help="New search query, e.g. process_name:notepad.exe")
    return parser 
Example 12
Project: cbapi-examples   Author: cbcommunity   File: sensor_backlog_aggregate.py    (MIT License) View Source Project 6 votes vote down vote up
def build_cli_parser():
    parser = optparse.OptionParser(usage="%prog [options]", description="Display, and optionally log to UDP, global sensor backlog statistics")

    # for each supported output type, add an option
    #
    parser.add_option("-c", "--cburl", action="store", default=None, dest="url",
                      help="CB server's URL.  e.g., http://127.0.0.1 ")
    parser.add_option("-a", "--apitoken", action="store", default=None, dest="token",
                      help="API Token for Carbon Black server")
    parser.add_option("-n", "--no-ssl-verify", action="store_false", default=True, dest="ssl_verify",
                      help="Do not verify server SSL certificate.")
    parser.add_option("-i", "--interval", action="store", default=0, dest="interval",
                      help="period, in seconds, in whicy to requery to use this script as a monitoring agent")
    parser.add_option("-u", "--udp", action="store", default=None, dest="udp",
                      help="ip:port or name:port to which do deliver output via UDP, e.g. splunk.my.org:514  only applicable with -i")
    return parser 
Example 13
Project: cbapi-examples   Author: cbcommunity   File: group_datasharing_add.py    (MIT License) View Source Project 6 votes vote down vote up
def build_cli_parser():
    parser = optparse.OptionParser(usage="%prog [options]", description="Add a new datasharing configuration for a sensor group in the server")

    # for each supported output type, add an option
    #
    parser.add_option("-c", "--cburl", action="store", default=None, dest="server_url",
                      help="CB server's URL.  e.g., http://127.0.0.1 ")
    parser.add_option("-a", "--apitoken", action="store", default=None, dest="token",
                      help="API Token for Carbon Black server")
    parser.add_option("-n", "--no-ssl-verify", action="store_false", default=True, dest="ssl_verify",
                      help="Do not verify server SSL certificate.")
    parser.add_option("-i", "--group_id", action="store", default=True, dest= "group_id",
                      help = "id of sensor group whose datasharing configs to enumerate")
    parser.add_option("-w", "--who", action="store", default=None, dest = "who",
                      help = "who to datashare with")
    parser.add_option("-d", "--what", action="store", default=None, dest = "what",
                      help = "what type of data to share")
    return parser 
Example 14
Project: cbapi-examples   Author: cbcommunity   File: feed_report_stats.py    (MIT License) View Source Project 6 votes vote down vote up
def build_cli_parser():
    parser = optparse.OptionParser(usage="%prog [options]", description="Get the a report's info from a configured feed")

    # for each supported output type, add an option
    #
    parser.add_option("-c", "--cburl", action="store", default=None, dest="server_url",
                      help="CB server's URL.  e.g., http://127.0.0.1 ")
    parser.add_option("-a", "--apitoken", action="store", default=None, dest="token",
                      help="API Token for Carbon Black server")
    parser.add_option("-n", "--no-ssl-verify", action="store_false", default=True, dest="ssl_verify",
                      help="Do not verify server SSL certificate.")
    parser.add_option("-i", "--id", action="store", default=None, dest="id",
                      help="Feed id")
    parser.add_option("-r", "--report_id", action = "store", default = None, dest = "reportid",
                      help = "Report id")
    return parser 
Example 15
Project: cbapi-examples   Author: cbcommunity   File: group_datasharing_del.py    (MIT License) View Source Project 6 votes vote down vote up
def build_cli_parser():
    parser = optparse.OptionParser(usage="%prog [options]", description="Delete a specific datasharing configuration for a sensor group")

    # for each supported output type, add an option
    #
    parser.add_option("-c", "--cburl", action="store", default=None, dest="server_url",
                      help="CB server's URL.  e.g., http://127.0.0.1 ")
    parser.add_option("-a", "--apitoken", action="store", default=None, dest="token",
                      help="API Token for Carbon Black server")
    parser.add_option("-n", "--no-ssl-verify", action="store_false", default=True, dest="ssl_verify",
                      help="Do not verify server SSL certificate.")
    parser.add_option("-i", "--group_id", action="store", default=True, dest= "group_id",
                      help = "id of sensor group whose datasharing configs to enumerate")
    parser.add_option("-d", "--config_id", action = "store", default=True, dest="config_id",
                      help = "id of specific configuration to delete")

    return parser 
Example 16
Project: cbapi-examples   Author: cbcommunity   File: binary_export.py    (MIT License) View Source Project 6 votes vote down vote up
def build_cli_parser():
    parser = optparse.OptionParser(usage="%prog [options]", description="Dump All MD5s from the binary index")

    # for each supported output type, add an option
    #
    parser.add_option("-c", "--cburl", action="store", default=None, dest="url",
                      help="CB server's URL.  e.g., http://127.0.0.1 ")
    parser.add_option("-a", "--apitoken", action="store", default=None, dest="token",
                      help="API Token for Carbon Black server")
    parser.add_option("-n", "--no-ssl-verify", action="store_false", default=True, dest="ssl_verify",
                      help="Do not verify server SSL certificate.")
    parser.add_option("-p", "--pagesize", action="store", default=128, dest="pagesize",
                      help="Number of MD5s to retrieve during each API invocation")
    parser.add_option("-f", "--file", action="store", default=None, dest="filename",
                      help="filename of file to write all md5s to")
    return parser 
Example 17
Project: cbapi-examples   Author: cbcommunity   File: sensors_not_checked_in.py    (MIT License) View Source Project 6 votes vote down vote up
def build_cli_parser():
    parser = optparse.OptionParser(usage="%prog [options]", description="Dump sensor list")

    # for each supported output type, add an option
    #
    parser.add_option("-c", "--cburl", action="store", default=None, dest="url",
                      help="CB server's URL.  e.g., http://127.0.0.1 ")
    parser.add_option("-a", "--apitoken", action="store", default=None, dest="token",
                      help="API Token for Carbon Black server")
    parser.add_option("-n", "--no-ssl-verify", action="store_false", default=True, dest="ssl_verify",
                      help="Do not verify server SSL certificate.")
    parser.add_option("-f", "--format", action="store", default='plain', dest="format",
                      help="Output in pipe-delimited ('pipe'), plaintext ('plain') format or csv ('csv'); plain by default")
    parser.add_option("-g", "--group", action="store", default=None, dest="groupid",
                      help="Limit sensor listing to just those specified by the sensor group id provided")
    parser.add_option("-t", "--hours", action="store", default="6", dest="hours",
                      help="Number of hours since last checked in")
    return parser 
Example 18
Project: cbapi-examples   Author: cbcommunity   File: binary_download.py    (MIT License) View Source Project 6 votes vote down vote up
def build_cli_parser():
    parser = optparse.OptionParser(usage="%prog [options]", description="Download a binary")

    # for each supported output type, add an option
    #
    parser.add_option("-c", "--cburl", action="store", default=None, dest="url",
                      help="CB server's URL.  e.g., http://127.0.0.1 ")
    parser.add_option("-a", "--apitoken", action="store", default=None, dest="token",
                      help="API Token for Carbon Black server")
    parser.add_option("-n", "--no-ssl-verify", action="store_false", default=True, dest="ssl_verify",
                      help="Do not verify server SSL certificate.")
    parser.add_option("-m", "--md5", action="store", default=None, dest="md5",
                      help="binary query")
    parser.add_option("-f", "--filename", action="store", default=None, dest="filename",
                      help="local filename to save the binary as")
    return parser 
Example 19
Project: cbapi-examples   Author: cbcommunity   File: process_report.py    (MIT License) View Source Project 6 votes vote down vote up
def build_cli_parser():
    parser = optparse.OptionParser(usage="%prog [options]", description="Dump a \"report\" package for a given process")

    # for each supported output type, add an option
    parser.add_option("-c", "--cburl", action="store", default=None, dest="url",
                      help="CB server's URL.  e.g., http://127.0.0.1 ")
    parser.add_option("-a", "--apitoken", action="store", default=None, dest="token",
                      help="API Token for Carbon Black server")
    parser.add_option("-n", "--no-ssl-verify", action="store_false", default=True, dest="ssl_verify",
                      help="Do not verify server SSL certificate.")
    parser.add_option("-f", "--file", action="store", default=None, dest="fname",
                      help="Filename where the retrieved report is written.")
    parser.add_option("-i", "--id", action="store", default=None, dest="id",
                      help="Carbon Black process identifier")
    parser.add_option("-s", "--segment", action="store", default=0, dest="segment",
                      help="Carbon Black process segment identifier")
    return parser 
Example 20
Project: cbapi-examples   Author: cbcommunity   File: feed_del.py    (MIT License) View Source Project 6 votes vote down vote up
def build_cli_parser():
    parser = optparse.OptionParser(usage="%prog [options]", description="Delete an existing feed")

    # for each supported output type, add an option
    #
    parser.add_option("-c", "--cburl", action="store", default=None, dest="server_url",
                      help="CB server's URL.  e.g., http://127.0.0.1 ")
    parser.add_option("-a", "--apitoken", action="store", default=None, dest="token",
                      help="API Token for Carbon Black server")
    parser.add_option("-n", "--no-ssl-verify", action="store_false", default=True, dest="ssl_verify",
                      help="Do not verify server SSL certificate.")
    parser.add_option("-f", "--feedname", action="store", default=None, dest="feedname",
                      help="Feed Name")
    parser.add_option("-i", "--id", action="store", default=None, dest="feedid",
                      help="Feed Id")
    return parser 
Example 21
Project: cbapi-examples   Author: cbcommunity   File: feed_modify.py    (MIT License) View Source Project 6 votes vote down vote up
def build_cli_parser():
    parser = optparse.OptionParser(usage="%prog [options]", description="Modify an existing feed")

    # for each supported output type, add an option
    #
    parser.add_option("-c", "--cburl", action="store", default=None, dest="server_url",
                      help="CB server's URL.  e.g., http://127.0.0.1 ")
    parser.add_option("-a", "--apitoken", action="store", default=None, dest="token",
                      help="API Token for Carbon Black server")
    parser.add_option("-n", "--no-ssl-verify", action="store_false", default=True, dest="ssl_verify",
                      help="Do not verify server SSL certificate.")
    parser.add_option("-f", "--feedname", action="store", default=None, dest="feedname",
                      help="Feed Name")
    parser.add_option("-i", "--id", action="store", default=None, dest="feedid",
                      help="Feed Id")
    return parser 
Example 22
Project: cbapi-examples   Author: cbcommunity   File: sensor_backlog_individual.py    (MIT License) View Source Project 6 votes vote down vote up
def build_cli_parser():
    parser = optparse.OptionParser(usage="%prog [options]", description="Output information sensor backlog state on a sensor-by-sensor basis")

    # for each supported output type, add an option
    #
    parser.add_option("-c", "--cburl", action="store", default=None, dest="url",
                      help="CB server's URL.  e.g., http://127.0.0.1 ")
    parser.add_option("-a", "--apitoken", action="store", default=None, dest="token",
                      help="API Token for Carbon Black server")
    parser.add_option("-n", "--no-ssl-verify", action="store_false", default=True, dest="ssl_verify",
                      help="Do not verify server SSL certificate.")
    parser.add_option("-i", "--interval", action="store", default=0, dest="interval",
                      help="period, in seconds, in whicy to requery to use this script as a monitoring agent")
    parser.add_option("-u", "--udp", action="store", default=None, dest="udp",
                      help="ip:port or name:port to which do deliver output via UDP, e.g. splunk.my.org:514  only applicable with -i")
    return parser 
Example 23
Project: cbapi-examples   Author: cbcommunity   File: feed_info.py    (MIT License) View Source Project 6 votes vote down vote up
def build_cli_parser():
    parser = optparse.OptionParser(usage="%prog [options]", description="Display information about an existing feed")

    # for each supported output type, add an option
    #
    parser.add_option("-c", "--cburl", action="store", default=None, dest="server_url",
                      help="CB server's URL.  e.g., http://127.0.0.1 ")
    parser.add_option("-a", "--apitoken", action="store", default=None, dest="token",
                      help="API Token for Carbon Black server")
    parser.add_option("-n", "--no-ssl-verify", action="store_false", default=True, dest="ssl_verify",
                      help="Do not verify server SSL certificate.")
    parser.add_option("-f", "--feedname", action="store", default=None, dest="feedname",
                      help="Feed Name")
    parser.add_option("-i", "--id", action="store", default=None, dest="feedid",
                      help="Feed Id")
    return parser 
Example 24
Project: cbapi-examples   Author: cbcommunity   File: group_datasharing_info.py    (MIT License) View Source Project 6 votes vote down vote up
def build_cli_parser():
    parser = optparse.OptionParser(usage="%prog [options]", description="Retrieve info of a specific datasharing configuration for a sensor group")

    # for each supported output type, add an option
    #
    parser.add_option("-c", "--cburl", action="store", default=None, dest="server_url",
                      help="CB server's URL.  e.g., http://127.0.0.1 ")
    parser.add_option("-a", "--apitoken", action="store", default=None, dest="token",
                      help="API Token for Carbon Black server")
    parser.add_option("-n", "--no-ssl-verify", action="store_false", default=True, dest="ssl_verify",
                      help="Do not verify server SSL certificate.")
    parser.add_option("-i", "--group_id", action="store", default=True, dest= "group_id",
                      help = "id of sensor group whose datasharing configs to enumerate")
    parser.add_option("-d", "--config_id", action = "store", default=True, dest="config_id",
                      help = "id of specific configuration to delete")

    return parser 
Example 25
Project: cbapi-examples   Author: cbcommunity   File: event_update.py    (MIT License) View Source Project 6 votes vote down vote up
def build_cli_parser():
    parser = optparse.OptionParser(usage="%prog [options]", description="Update a tagged_event's description")

    # for each supported output type, add an option
    #
    parser.add_option("-c", "--cburl", action="store", default=None, dest="server_url",
                      help="CB server's URL.  e.g., http://127.0.0.1 ")
    parser.add_option("-a", "--apitoken", action="store", default=None, dest="token",
                      help="API Token for Carbon Black server")
    parser.add_option("-n", "--no-ssl-verify", action="store_false", default=True, dest="ssl_verify",
                      help="Do not verify server SSL certificate.")
    parser.add_option("-i", "--id", action = "store", default = None, dest = "id",
                      help = "id of the investigation this event is for")
    parser.add_option("-d", "--description", action = "store", default = "", dest = "description",
                      help = "Updated description for the event")
    return parser 
Example 26
Project: cbapi-examples   Author: cbcommunity   File: feed_action_add.py    (MIT License) View Source Project 6 votes vote down vote up
def build_cli_parser():
    parser = optparse.OptionParser(usage="%prog [options]", description="Add an action to a feed on the CB server")

    # for each supported output type, add an option
    #
    parser.add_option("-c", "--cburl", action="store", default=None, dest="server_url",
                      help="CB server's URL.  e.g., http://127.0.0.1 ")
    parser.add_option("-a", "--apitoken", action="store", default=None, dest="token",
                      help="API Token for Carbon Black server")
    parser.add_option("-n", "--no-ssl-verify", action="store_false", default=True, dest="ssl_verify",
                      help="Do not verify server SSL certificate.")
    parser.add_option("-i", "--id", action = "store", default = None, dest = "id",
                      help = "id of the feed")
    parser.add_option("-t", "--action_type", action = "store", default = None, dest = "action_type_id",
                      help = "id for the type of action to enable: Type 0 for email, 1 to write to "
                             "syslog, and 3 to create alert")
    parser.add_option("-e", "--email_recipients", action = "store", default = None, dest = "email_recipients",
                      help = "list of user ids of email recipients")
    return parser 
Example 27
Project: cbapi-examples   Author: cbcommunity   File: event_add.py    (MIT License) View Source Project 6 votes vote down vote up
def build_cli_parser():
    parser = optparse.OptionParser(usage="%prog [options]", description="Add a tagged_event to the server")

    # for each supported output type, add an option
    #
    parser.add_option("-c", "--cburl", action="store", default=None, dest="server_url",
                      help="CB server's URL.  e.g., http://127.0.0.1 ")
    parser.add_option("-a", "--apitoken", action="store", default=None, dest="token",
                      help="API Token for Carbon Black server")
    parser.add_option("-n", "--no-ssl-verify", action="store_false", default=True, dest="ssl_verify",
                      help="Do not verify server SSL certificate.")
    parser.add_option("-i", "--investigation_id", action = "store", default = None, dest = "investigation_id",
                      help = "ID of investigation to add this event to")
    parser.add_option("-d", "--description", action = "store", default="", dest="description",
                      help="Description of the event, use quotes")
    parser.add_option("-s", "--start_date", action= "store", default = None, dest = "start_date",
                      help = "start date for the event")
    return parser 
Example 28
Project: cbapi-examples   Author: cbcommunity   File: download_sensor_installer.py    (MIT License) View Source Project 6 votes vote down vote up
def build_cli_parser():
    parser = optparse.OptionParser(usage="%prog [options]", description="Dump Binary Info")

    # for each supported output type, add an option
    #
    parser.add_option("-c", "--cburl", action="store", default=None, dest="url",
                      help="CB server's URL.  e.g., http://127.0.0.1 ")
    parser.add_option("-a", "--apitoken", action="store", default=None, dest="token",
                      help="API Token for Carbon Black server")
    parser.add_option("-n", "--no-ssl-verify", action="store_false", default=True, dest="ssl_verify",
                      help="Do not verify server SSL certificate.")
    parser.add_option("-t", "--installer-type", action="store", default=None, dest="type",
                      help="Installer type; must be one of [WindowsEXE|WindowsMSI]")
    parser.add_option("-f", "--filename", action="store", default=None, dest="filename",
                      help="Filename to save the installer package to")
    parser.add_option("-g", "--sensor-group", action="store", default="1", dest="group",
                      help="Sensor group ID of the group to download an installer for")
    return parser 
Example 29
Project: cbapi-examples   Author: cbcommunity   File: feed_report_info.py    (MIT License) View Source Project 6 votes vote down vote up
def build_cli_parser():
    parser = optparse.OptionParser(usage="%prog [options]", description="Display information about a particular feed report")

    # for each supported output type, add an option
    #
    parser.add_option("-c", "--cburl", action="store", default=None, dest="server_url",
                      help="CB server's URL.  e.g., http://127.0.0.1 ")
    parser.add_option("-a", "--apitoken", action="store", default=None, dest="token",
                      help="API Token for Carbon Black server")
    parser.add_option("-n", "--no-ssl-verify", action="store_false", default=True, dest="ssl_verify",
                      help="Do not verify server SSL certificate.")
    parser.add_option("-i", "--id", action="store", default=None, dest="feedid",
                      help="Id of feed of which the specified report is a part of")
    parser.add_option("-r", "--reportid", action="store", default=None, dest="reportid",
                      help="Id of report to query; this may be alphanumeric")
    return parser 
Example 30
Project: cbapi-examples   Author: cbcommunity   File: sensor_list.py    (MIT License) View Source Project 6 votes vote down vote up
def build_cli_parser():
    parser = optparse.OptionParser(usage="%prog [options]", description="Dump sensor list")

    # for each supported output type, add an option
    #
    parser.add_option("-c", "--cburl", action="store", default=None, dest="url",
                      help="CB server's URL.  e.g., http://127.0.0.1 ")
    parser.add_option("-a", "--apitoken", action="store", default=None, dest="token",
                      help="API Token for Carbon Black server")
    parser.add_option("-n", "--no-ssl-verify", action="store_false", default=True, dest="ssl_verify",
                      help="Do not verify server SSL certificate.")
    parser.add_option("-f", "--format", action="store", default='plain', dest="format",
                      help="Output in pipe-delimited ('pipe'), plaintext ('plain') format or csv ('csv'); plain by default")
    parser.add_option("-g", "--group", action="store", default=None, dest="groupid",
                      help="Limit sensor listing to just those specified by the sensor group id provided")
    return parser 
Example 31
Project: my-first-blog   Author: AnkurBegining   File: req_file.py    (license) View Source Project 6 votes vote down vote up
def build_parser():
    """
    Return a parser for parsing requirement lines
    """
    parser = optparse.OptionParser(add_help_option=False)

    option_factories = SUPPORTED_OPTIONS + SUPPORTED_OPTIONS_REQ
    for option_factory in option_factories:
        option = option_factory()
        parser.add_option(option)

    # By default optparse sys.exits on parsing errors. We want to wrap
    # that in our own exception.
    def parser_exit(self, msg):
        raise RequirementsFileParseError(msg)
    parser.exit = parser_exit

    return parser 
Example 32
Project: cbapi-python   Author: carbonblack   File: feed_cert.py    (license) View Source Project 6 votes vote down vote up
def build_cli_parser():
    parser = optparse.OptionParser(usage="%prog [options]", description="Configure SSL client certificate authentication for feeds")

    # for each supported output type, add an option
    #
    parser.add_option("-c", "--cburl", action="store", default=None, dest="server_url",
                      help="CB server's URL.  e.g., http://127.0.0.1 ")
    parser.add_option("-a", "--apitoken", action="store", default=None, dest="token",
                      help="API Token for Carbon Black server")
    parser.add_option("-n", "--no-ssl-verify", action="store_false", default=True, dest="ssl_verify",
                      help="Do not verify server SSL certificate.")
    parser.add_option("-i", "--id", action="store", default=None, dest="id",
                      help="Feed Id")
    parser.add_option("-r", "--remove", action="store_true", default=False, dest="remove",
                      help="Remove SSL client certificate authentication for the feed specified with -i")
    parser.add_option("-C", "--certificate", action="store", default=None, dest="certificate",
                      help="SSL client certificate filename; expected to begin with \"-----BEGIN CERTIFICATE-----\"")
    parser.add_option("-K", "--key", action="store", default=None, dest="key",
                      help="SSL client key filename; expected to begin with \"-----BEGIN RSA PRIVATE KEY-----\"") 
    return parser 
Example 33
Project: cbapi-python   Author: carbonblack   File: bit9_platform_server_config.py    (license) View Source Project 6 votes vote down vote up
def build_cli_parser():
    parser = optparse.OptionParser(usage="%prog [options]", description="Get and set Bit9 Platform Server Configuration")

    # for each supported output type, add an option
    #
    parser.add_option("-c", "--cburl", action="store", default=None, dest="url",
                      help="CB server's URL.  e.g., http://127.0.0.1 ")
    parser.add_option("-a", "--apitoken", action="store", default=None, dest="token",
                      help="API Token for Carbon Black server")
    parser.add_option("-n", "--no-ssl-verify", action="store_false", default=True, dest="ssl_verify",
                      help="Do not verify server SSL certificate.")
    parser.add_option("-u", "--server-url", action="store", default=None, dest="server_url",
                      help="Specify the URL of the configured Bit9 Platform Server")
    parser.add_option("-s", "--ssl-cert-verify", action="store", default=None, dest="ssl_cert_verify",
                      help="Specify if the SSL certificate of the Bit9 Platform Server should be verified; should be 'True' or 'False'")
    parser.add_option("-w", "--watchlist-enable", action="store", default=None, dest="watchlist_enable",
                      help="Enable export of CB Watchlists to Bit9 Platform Server; should be 'True' or 'False'")
    parser.add_option("-t", "--authtoken", action="store", default=None, dest="auth_token",
                      help="Bit9 Platform Server Auth Token used by CB server to send watchlist hits")
    return parser 
Example 34
Project: cbapi-python   Author: carbonblack   File: watchlist_add.py    (license) View Source Project 6 votes vote down vote up
def build_cli_parser():
    parser = optparse.OptionParser(usage="%prog [options]", description="Add a watchlist")

    # for each supported output type, add an option
    #
    parser.add_option("-c", "--cburl", action="store", default=None, dest="url",
                      help="CB server's URL.  e.g., http://127.0.0.1 ")
    parser.add_option("-a", "--apitoken", action="store", default=None, dest="token",
                      help="API Token for Carbon Black server")
    parser.add_option("-n", "--no-ssl-verify", action="store_false", default=True, dest="ssl_verify",
                      help="Do not verify server SSL certificate.")
    parser.add_option("-q", "--query", action="store", default=None, dest="query",
                      help="Watchlist query string, e.g. process_name:notepad.exe")
    parser.add_option("-t", "--type", action="store", default=None, dest="type",
                      help="Watchlist type 'events' or 'modules'")
    parser.add_option("-N", "--name", action="store", default=None, dest="name",
                      help="Watchlist name")
    parser.add_option("-i", "--id", action="store", default=None, dest="id",
                      help="Watchlist ID (optional)")
    parser.add_option("-r", "--readonly", action="store_true", default=False, dest="readonly",
                      help="When set, marks the new watchlist as 'read-only' so that it cannot be deleted from the console")
    return parser 
Example 35
Project: cbapi-python   Author: carbonblack   File: check_ioc.py    (license) View Source Project 6 votes vote down vote up
def build_cli_parser():
    parser = OptionParser(usage="%prog [options]", description="check Cb index for provided IOCs")

    # for each supported output type, add an option
    parser.add_option("-c", "--cburl", action="store", default=None, dest="url",
                      help="CB server's URL.  e.g., http://127.0.0.1 ")
    parser.add_option("-a", "--apitoken", action="store", default=None, dest="token",
                      help="API Token for Carbon Black server")
    parser.add_option("-f", "--file", action="store", default=None, dest="fname",
                      help="Filename with CRLF-delimited list of IOCs")
    parser.add_option("-t", "--type", action="store", default=None, dest="type",
                      help="Type of IOCs in the file.  Must be one of md5, domain or ipaddr")
    parser.add_option("-d", "--detail", action="store_true", default=False, dest="detail",
                      help="Get full detail about each IOC hit.")
    parser.add_option("-n", "--no-ssl-verify", action="store_false", default=True, dest="ssl_verify",
                      help="Do not verify server SSL certificate.")
    return parser 
Example 36
Project: cbapi-python   Author: carbonblack   File: feed_action_update.py    (license) View Source Project 6 votes vote down vote up
def build_cli_parser():
    parser = optparse.OptionParser(usage="%prog [options]", description="Update a certain feed action (Change to a different"
                                                                        "type of action")

    # for each supported output type, add an option
    #
    parser.add_option("-c", "--cburl", action="store", default=None, dest="server_url",
                      help="CB server's URL.  e.g., http://127.0.0.1 ")
    parser.add_option("-a", "--apitoken", action="store", default=None, dest="token",
                      help="API Token for Carbon Black server")
    parser.add_option("-n", "--no-ssl-verify", action="store_false", default=True, dest="ssl_verify",
                      help="Do not verify server SSL certificate.")
    parser.add_option("-i", "--id", action = "store", default = None, dest = "id",
                      help = "id of the feed")
    parser.add_option("-d", "--action_id", action = "store", default = None, dest = "action_id",
                      help = "id of the action to be deleted")
    parser.add_option("-t", "--action_type", action = "store", type = int, default = None, dest = "action_type_id",
                      help = "new type of action, type 0 for email, 1 for write to syslog, 3 for create alert")
    return parser 
Example 37
Project: cbapi-python   Author: carbonblack   File: feed_action_del.py    (license) View Source Project 6 votes vote down vote up
def build_cli_parser():
    parser = optparse.OptionParser(usage="%prog [options]", description="Delete a certain action of a specified feed from the server")

    # for each supported output type, add an option
    #
    parser.add_option("-c", "--cburl", action="store", default=None, dest="server_url",
                      help="CB server's URL.  e.g., http://127.0.0.1 ")
    parser.add_option("-a", "--apitoken", action="store", default=None, dest="token",
                      help="API Token for Carbon Black server")
    parser.add_option("-n", "--no-ssl-verify", action="store_false", default=True, dest="ssl_verify",
                      help="Do not verify server SSL certificate.")
    parser.add_option("-i", "--id", action = "store", default = None, dest = "id",
                      help = "id of the feed")
    parser.add_option("-d", "--action_id", action = "store", default = None, dest = "action_id",
                      help = "id of the action to be deleted")
    return parser 
Example 38
Project: cbapi-python   Author: carbonblack   File: alert_bulk_resolve.py    (license) View Source Project 6 votes vote down vote up
def build_cli_parser():
    parser = optparse.OptionParser(usage="%prog [options]", description="Set status to Resolved for a set of alerts.")

    # for each supported output type, add an option
    #
    parser.add_option("-c", "--cburl", action="store", default=None, dest="server_url",
                      help="CB server's URL.  e.g., http://127.0.0.1 ")
    parser.add_option("-a", "--apitoken", action="store", default=None, dest="token",
                      help="API Token for Carbon Black server")
    parser.add_option("-n", "--no-ssl-verify", action="store_false", default=True, dest="ssl_verify",
                      help="Do not verify server SSL certificate.")
    parser.add_option("-q", "--query", action="store", default=None, dest="query",
                      help="The query string of alerts to resolve. All matching alerts will be resolved.")
    parser.add_option("-y", "--yes", action="store_true", default=False, dest="answered",
                      help="Automatically answer yes to any question.")
    return parser 
Example 39
Project: cbapi-python   Author: carbonblack   File: watchlist_edit.py    (license) View Source Project 6 votes vote down vote up
def build_cli_parser():
    parser = optparse.OptionParser(usage="%prog [options]", description="Edit the Query of an Existing Watchlist")

    # for each supported output type, add an option
    #
    parser.add_option("-c", "--cburl", action="store", default=None, dest="url",
                      help="CB server's URL.  e.g., http://127.0.0.1 ")
    parser.add_option("-a", "--apitoken", action="store", default=None, dest="token",
                      help="API Token for Carbon Black server")
    parser.add_option("-n", "--no-ssl-verify", action="store_false", default=True, dest="ssl_verify",
                      help="Do not verify server SSL certificate.")
    parser.add_option("-i", "--id", action="store", default=None, dest="id",
                      help="Watchlist ID to modify")
    parser.add_option("-q", "--query", action="store", default=None, dest="query",
                      help="New search query, e.g. process_name:notepad.exe")
    return parser 
Example 40
Project: cbapi-python   Author: carbonblack   File: platform_agent_report.py    (license) View Source Project 6 votes vote down vote up
def build_cli_parser():
    parser = optparse.OptionParser(usage="%prog [options]", description="Dump sensor list")

    # for each supported output type, add an option
    #
    parser.add_option("-c", "--cburl", action="store", default=None, dest="url",
                      help="CB server's URL.  e.g., http://127.0.0.1 ")
    parser.add_option("-a", "--apitoken", action="store", default=None, dest="token",
                      help="API Token for Carbon Black server")
    parser.add_option("-n", "--no-ssl-verify", action="store_false", default=True, dest="ssl_verify",
                      help="Do not verify server SSL certificate")
    parser.add_option("-d", "--details", action="store_true", default=False, dest="detail",
                      help="Show detailed endpoint-by-endpoint listing")
    parser.add_option("-w", "--without-agent", action="store_true", default=False, dest="withoutagent",
                      help="When ouputting detailed report, only output endpoints without an installed platform agent")
    return parser 
Example 41
Project: cbapi-python   Author: carbonblack   File: sensor_backlog_aggregate.py    (license) View Source Project 6 votes vote down vote up
def build_cli_parser():
    parser = optparse.OptionParser(usage="%prog [options]", description="Display, and optionally log to UDP, global sensor backlog statistics")

    # for each supported output type, add an option
    #
    parser.add_option("-c", "--cburl", action="store", default=None, dest="url",
                      help="CB server's URL.  e.g., http://127.0.0.1 ")
    parser.add_option("-a", "--apitoken", action="store", default=None, dest="token",
                      help="API Token for Carbon Black server")
    parser.add_option("-n", "--no-ssl-verify", action="store_false", default=True, dest="ssl_verify",
                      help="Do not verify server SSL certificate.")
    parser.add_option("-i", "--interval", action="store", default=0, dest="interval",
                      help="period, in seconds, in whicy to requery to use this script as a monitoring agent")
    parser.add_option("-u", "--udp", action="store", default=None, dest="udp",
                      help="ip:port or name:port to which do deliver output via UDP, e.g. splunk.my.org:514  only applicable with -i")
    return parser 
Example 42
Project: cbapi-python   Author: carbonblack   File: feed_report_stats.py    (license) View Source Project 6 votes vote down vote up
def build_cli_parser():
    parser = optparse.OptionParser(usage="%prog [options]", description="Get the a report's info from a configured feed")

    # for each supported output type, add an option
    #
    parser.add_option("-c", "--cburl", action="store", default=None, dest="server_url",
                      help="CB server's URL.  e.g., http://127.0.0.1 ")
    parser.add_option("-a", "--apitoken", action="store", default=None, dest="token",
                      help="API Token for Carbon Black server")
    parser.add_option("-n", "--no-ssl-verify", action="store_false", default=True, dest="ssl_verify",
                      help="Do not verify server SSL certificate.")
    parser.add_option("-i", "--id", action="store", default=None, dest="id",
                      help="Feed id")
    parser.add_option("-r", "--report_id", action = "store", default = None, dest = "reportid",
                      help = "Report id")
    return parser 
Example 43
Project: cbapi-python   Author: carbonblack   File: group_datasharing_del.py    (license) View Source Project 6 votes vote down vote up
def build_cli_parser():
    parser = optparse.OptionParser(usage="%prog [options]", description="Delete a specific datasharing configuration for a sensor group")

    # for each supported output type, add an option
    #
    parser.add_option("-c", "--cburl", action="store", default=None, dest="server_url",
                      help="CB server's URL.  e.g., http://127.0.0.1 ")
    parser.add_option("-a", "--apitoken", action="store", default=None, dest="token",
                      help="API Token for Carbon Black server")
    parser.add_option("-n", "--no-ssl-verify", action="store_false", default=True, dest="ssl_verify",
                      help="Do not verify server SSL certificate.")
    parser.add_option("-i", "--group_id", action="store", default=True, dest= "group_id",
                      help = "id of sensor group whose datasharing configs to enumerate")
    parser.add_option("-d", "--config_id", action = "store", default=True, dest="config_id",
                      help = "id of specific configuration to delete")

    return parser 
Example 44
Project: cbapi-python   Author: carbonblack   File: binary_export.py    (license) View Source Project 6 votes vote down vote up
def build_cli_parser():
    parser = optparse.OptionParser(usage="%prog [options]", description="Dump All MD5s from the binary index")

    # for each supported output type, add an option
    #
    parser.add_option("-c", "--cburl", action="store", default=None, dest="url",
                      help="CB server's URL.  e.g., http://127.0.0.1 ")
    parser.add_option("-a", "--apitoken", action="store", default=None, dest="token",
                      help="API Token for Carbon Black server")
    parser.add_option("-n", "--no-ssl-verify", action="store_false", default=True, dest="ssl_verify",
                      help="Do not verify server SSL certificate.")
    parser.add_option("-p", "--pagesize", action="store", default=128, dest="pagesize",
                      help="Number of MD5s to retrieve during each API invocation")
    parser.add_option("-f", "--file", action="store", default=None, dest="filename",
                      help="filename of file to write all md5s to")
    return parser 
Example 45
Project: cbapi-python   Author: carbonblack   File: sensors_not_checked_in.py    (license) View Source Project 6 votes vote down vote up
def build_cli_parser():
    parser = optparse.OptionParser(usage="%prog [options]", description="Dump sensor list")

    # for each supported output type, add an option
    #
    parser.add_option("-c", "--cburl", action="store", default=None, dest="url",
                      help="CB server's URL.  e.g., http://127.0.0.1 ")
    parser.add_option("-a", "--apitoken", action="store", default=None, dest="token",
                      help="API Token for Carbon Black server")
    parser.add_option("-n", "--no-ssl-verify", action="store_false", default=True, dest="ssl_verify",
                      help="Do not verify server SSL certificate.")
    parser.add_option("-f", "--format", action="store", default='plain', dest="format",
                      help="Output in pipe-delimited ('pipe'), plaintext ('plain') format or csv ('csv'); plain by default")
    parser.add_option("-g", "--group", action="store", default=None, dest="groupid",
                      help="Limit sensor listing to just those specified by the sensor group id provided")
    parser.add_option("-t", "--hours", action="store", default="6", dest="hours",
                      help="Number of hours since last checked in")
    return parser 
Example 46
Project: cbapi-python   Author: carbonblack   File: binary_download.py    (license) View Source Project 6 votes vote down vote up
def build_cli_parser():
    parser = optparse.OptionParser(usage="%prog [options]", description="Download a binary")

    # for each supported output type, add an option
    #
    parser.add_option("-c", "--cburl", action="store", default=None, dest="url",
                      help="CB server's URL.  e.g., http://127.0.0.1 ")
    parser.add_option("-a", "--apitoken", action="store", default=None, dest="token",
                      help="API Token for Carbon Black server")
    parser.add_option("-n", "--no-ssl-verify", action="store_false", default=True, dest="ssl_verify",
                      help="Do not verify server SSL certificate.")
    parser.add_option("-m", "--md5", action="store", default=None, dest="md5",
                      help="binary query")
    parser.add_option("-f", "--filename", action="store", default=None, dest="filename",
                      help="local filename to save the binary as")
    return parser 
Example 47
Project: cbapi-python   Author: carbonblack   File: process_report.py    (license) View Source Project 6 votes vote down vote up
def build_cli_parser():
    parser = optparse.OptionParser(usage="%prog [options]", description="Dump a \"report\" package for a given process")

    # for each supported output type, add an option
    parser.add_option("-c", "--cburl", action="store", default=None, dest="url",
                      help="CB server's URL.  e.g., http://127.0.0.1 ")
    parser.add_option("-a", "--apitoken", action="store", default=None, dest="token",
                      help="API Token for Carbon Black server")
    parser.add_option("-n", "--no-ssl-verify", action="store_false", default=True, dest="ssl_verify",
                      help="Do not verify server SSL certificate.")
    parser.add_option("-f", "--file", action="store", default=None, dest="fname",
                      help="Filename where the retrieved report is written.")
    parser.add_option("-i", "--id", action="store", default=None, dest="id",
                      help="Carbon Black process identifier")
    parser.add_option("-s", "--segment", action="store", default=0, dest="segment",
                      help="Carbon Black process segment identifier")
    return parser 
Example 48
Project: cbapi-python   Author: carbonblack   File: feed_del.py    (license) View Source Project 6 votes vote down vote up
def build_cli_parser():
    parser = optparse.OptionParser(usage="%prog [options]", description="Delete an existing feed")

    # for each supported output type, add an option
    #
    parser.add_option("-c", "--cburl", action="store", default=None, dest="server_url",
                      help="CB server's URL.  e.g., http://127.0.0.1 ")
    parser.add_option("-a", "--apitoken", action="store", default=None, dest="token",
                      help="API Token for Carbon Black server")
    parser.add_option("-n", "--no-ssl-verify", action="store_false", default=True, dest="ssl_verify",
                      help="Do not verify server SSL certificate.")
    parser.add_option("-f", "--feedname", action="store", default=None, dest="feedname",
                      help="Feed Name")
    parser.add_option("-i", "--id", action="store", default=None, dest="feedid",
                      help="Feed Id")
    return parser 
Example 49
Project: cbapi-python   Author: carbonblack   File: feed_modify.py    (license) View Source Project 6 votes vote down vote up
def build_cli_parser():
    parser = optparse.OptionParser(usage="%prog [options]", description="Modify an existing feed")

    # for each supported output type, add an option
    #
    parser.add_option("-c", "--cburl", action="store", default=None, dest="server_url",
                      help="CB server's URL.  e.g., http://127.0.0.1 ")
    parser.add_option("-a", "--apitoken", action="store", default=None, dest="token",
                      help="API Token for Carbon Black server")
    parser.add_option("-n", "--no-ssl-verify", action="store_false", default=True, dest="ssl_verify",
                      help="Do not verify server SSL certificate.")
    parser.add_option("-f", "--feedname", action="store", default=None, dest="feedname",
                      help="Feed Name")
    parser.add_option("-i", "--id", action="store", default=None, dest="feedid",
                      help="Feed Id")
    return parser 
Example 50
Project: cbapi-python   Author: carbonblack   File: sensor_backlog_individual.py    (license) View Source Project 6 votes vote down vote up
def build_cli_parser():
    parser = optparse.OptionParser(usage="%prog [options]", description="Output information sensor backlog state on a sensor-by-sensor basis")

    # for each supported output type, add an option
    #
    parser.add_option("-c", "--cburl", action="store", default=None, dest="url",
                      help="CB server's URL.  e.g., http://127.0.0.1 ")
    parser.add_option("-a", "--apitoken", action="store", default=None, dest="token",
                      help="API Token for Carbon Black server")
    parser.add_option("-n", "--no-ssl-verify", action="store_false", default=True, dest="ssl_verify",
                      help="Do not verify server SSL certificate.")
    parser.add_option("-i", "--interval", action="store", default=0, dest="interval",
                      help="period, in seconds, in whicy to requery to use this script as a monitoring agent")
    parser.add_option("-u", "--udp", action="store", default=None, dest="udp",
                      help="ip:port or name:port to which do deliver output via UDP, e.g. splunk.my.org:514  only applicable with -i")
    return parser