Esempio n. 1
0
def main():
    parser = optparse.OptionParser()
    parser.add_option('-o', '--output', dest='output', help=OUTHELP)
    parser.add_option('-c', '--cert' , dest='cert', help=CERTHELP)
    parser.add_option('-k', '--key', dest='key', help=KEYHELP)
    parser.add_option('-v', '--valid', dest='valid', help=VALIDHELP)
    parser.add_option('-l', '--limited', action="store_true", 
                      default=False, dest='limited', help=VALIDHELP)
    (opts, args) = parser.parse_args()
    kw = {} 
    kw['cert'] = opts.cert
    kw['key'] = opts.key
    if opts.valid is None:
        valid_tuple = (12, 0)
    else:
        valid = opts.valid.split(':') 
        valid_tuple = tuple(map(int, valid))
    kw['valid'] = valid_tuple 
    kw['full'] = not opts.limited
    try:
        proxy_factory = proxylib.ProxyFactory(kw)
    except IOError:
        print "Can't find usercert or userkey. Use the -c or -k arguments"
        sys.exit(0)
    proxy_factory.generate()
    proxy_cert = proxy_factory.getproxy()
    if opts.output is None:
        proxy_cert.write(proxylib.get_proxy_filename())
    else:
        proxy_cert.write(opts.output)
Esempio n. 2
0
def main():
    parser = optparse.OptionParser()
    parser.add_option('-o', '--output', dest='output', help=OUTHELP)
    parser.add_option('-c', '--cert', dest='cert', help=CERTHELP)
    parser.add_option('-k', '--key', dest='key', help=KEYHELP)
    parser.add_option('-v', '--valid', dest='valid', help=VALIDHELP)
    parser.add_option('-l',
                      '--limited',
                      action="store_true",
                      default=False,
                      dest='limited',
                      help=VALIDHELP)
    (opts, args) = parser.parse_args()
    kw = {}
    kw['cert'] = opts.cert
    kw['key'] = opts.key
    if opts.valid is None:
        valid_tuple = (12, 0)
    else:
        valid = opts.valid.split(':')
        valid_tuple = tuple(map(int, valid))
    kw['valid'] = valid_tuple
    kw['full'] = not opts.limited
    try:
        proxy_factory = proxylib.ProxyFactory(kw)
    except IOError:
        print "Can't find usercert or userkey. Use the -c or -k arguments"
        sys.exit(0)
    proxy_factory.generate()
    proxy_cert = proxy_factory.getproxy()
    if opts.output is None:
        proxy_cert.write(proxylib.get_proxy_filename())
    else:
        proxy_cert.write(opts.output)
Esempio n. 3
0
def main():
    parser = optparse.OptionParser()
    parser.set_usage(USAGEHELP)
    opts, args = parser.parse_args()
    if len(args) is 0:
        proxy_file = proxylib.get_proxy_filename()
        scrub_file(proxy_file)

    for proxy_file in args:
        scrub_file(proxy_file)
Esempio n. 4
0
def main():
    parser = optparse.OptionParser()
    parser.add_option("-f", "--file", dest="filename", help=FILEHELP)
    (opts, args) = parser.parse_args()
    filename = opts.filename
    if filename is None:
        proxyfile = proxylib.get_proxy_filename()
    else:
        proxyfile = filename
    proxy_cert = proxylib.Proxy()
    try:
        proxy_cert.read(proxyfile)
    except IOError:
        print "The file: " + proxyfile + " does not exist."
        sys.exit(0)
    print_info(proxy_cert)
Esempio n. 5
0
def main(): 
    parser = optparse.OptionParser()
    parser.add_option("-f", "--file", dest="filename", help=FILEHELP)
    (opts, args) = parser.parse_args()
    filename = opts.filename 
    if filename is None:   
        proxyfile = proxylib.get_proxy_filename()
    else:
        proxyfile = filename
    proxy_cert = proxylib.Proxy()
    try:
        proxy_cert.read(proxyfile)
    except IOError:
        print "The file: " + proxyfile + " does not exist."
        sys.exit(0)
    print_info(proxy_cert)
Esempio n. 6
0
def default_option_parser():
    u"""
    Возвращает OptionParser, содержащий опции, общие для всех
    программ: proxy, output, verbose, debug, log

    @rtype:  OptionParser
    @return: OptionParser instance
    """
    try:
        from pkg_resources import get_distribution
        pkg_version = get_distribution('pilot-client').version
    except ImportError:
        pkg_version = 'UNKNOWN'
    parser = optparse.OptionParser(usage="%prog [options] ...", version="%prog " + pkg_version)
    parser.add_option("--help-exit-codes", action="store_true",
                      help="Display help on CLI utilities exit codes",
                      dest="help_exit_codes")
    
    group = optparse.OptionGroup(parser, 'Security options')
    group.add_option("-c", "--cert", "--usercert", metavar="FILE",
                     help="User certificate filename (default: %default)",
                     dest="usercert", default=os.path.expanduser("~/.globus/usercert.pem"))
    group.add_option("-k", "--key", "--userkey", metavar="FILE",
                     help="User certificate key filename (default: %default)",
                     dest="userkey", default=os.path.expanduser("~/.globus/userkey.pem"))
    group.add_option("-p", "--password", "--userkeypass", metavar="XXX",
                     help="Password for user key (default: read from stdin)",
                     dest="userkey_password", default=None)
    group.add_option("-P", "--proxy", metavar="FILE",
                     help="Proxy certificate chain filename (default: %default)",
                     dest="proxy", default=proxylib.get_proxy_filename())
    group.add_option("--noproxy", action="store_false",
                     help="Do not use proxy certificate, use user certificate instead (default: use proxy certificate).",
                     dest="use_proxy", default=True)
    group.add_option("--capath", "-C", metavar="PATH",
                     help="Path to CA certificates, CRLs and signing policies (default: %default)",
                     dest="capath", default="/etc/grid-security/certificates")
    parser.add_option_group(group)
    
    group = optparse.OptionGroup(parser, "Common options")
    group.add_option("-u", "--url", metavar='URL',
                     help="Pilot server to use if not obvious from other arguments. May be specified as a full URL or just a host/host:port combination. (default: $PILOT_SERVER)",
		     dest="pilot_url", default=os.environ.get("PILOT_SERVER", None))
    group.add_option("-D", "--delegation", metavar="NAME",
                     help="Delegation to use (default: \"%default\").",
                     dest="delegation_id", default="default")
    group.add_option("-t", "--timeout", metavar="SECONDS", type="int",
                     help="Command execution timeout, in seconds (default: infinite)",
                     dest="timeout", default=None)
    group.add_option("-j", "--json", action="store_true",
                     help="JSON output. Forces --quiet (default: off)",
                     dest="json")
    group.add_option("-q", "--quiet", action="store_true",
                     help="Do not output any information intended for human beings. (default: off)",
                     dest="quiet")
    group.add_option("-v", "--verbose", action="store_true",
                     help="Be more verbose about what's going on (default: off)",
                     dest="verbose")
    group.add_option("-d", "--debug", type="int", metavar="N",
                     help="Debug level. Available levels are: fatals (0), errors (1), warnings (2), info messages (3), debug messages (4). Default: %default",
                      dest="debug_level", default=1)
    group.add_option("--connection-debug", action="store_true", 
                     dest="connection_debug", default=False,
                     help="Turn on HTTP connection debug logging. (default: off)")
    group.add_option("-r", "--retry", type="int", metavar="N",
                     help="Number of request retries in case of network failures. Default: %default",
                     dest="retries", default=3)
    group.add_option("--log", metavar='FILE',
                     help="Output debug information to file instead of stderr.",
                     dest="debug_filename")
    group.add_option("--encoding", metavar="ENC",
                     help="Input/Output encoding to use (default: %default)",
                     dest="io_encoding", default="UTF-8")
    group.add_option("--software", metavar="SW",
                     help="Add these software requirements to the job. "
                     "Requirements for specific package is added only if "
                     "requirements for this package are missing in job "
                     "definition.")    
    parser.add_option_group(group)

    return parser
Esempio n. 7
0
def default_option_parser():
    u"""
    Возвращает OptionParser, содержащий опции, общие для всех
    программ: proxy, output, verbose, debug, log

    @rtype:  OptionParser
    @return: OptionParser instance
    """
    try:
        from pkg_resources import get_distribution
        pkg_version = get_distribution('pilot-client').version
    except ImportError:
        pkg_version = 'UNKNOWN'
    parser = optparse.OptionParser(usage="%prog [options] ...",
                                   version="%prog " + pkg_version)
    parser.add_option("--help-exit-codes",
                      action="store_true",
                      help="Display help on CLI utilities exit codes",
                      dest="help_exit_codes")

    group = optparse.OptionGroup(parser, 'Security options')
    group.add_option("-c",
                     "--cert",
                     "--usercert",
                     metavar="FILE",
                     help="User certificate filename (default: %default)",
                     dest="usercert",
                     default=os.path.expanduser("~/.globus/usercert.pem"))
    group.add_option("-k",
                     "--key",
                     "--userkey",
                     metavar="FILE",
                     help="User certificate key filename (default: %default)",
                     dest="userkey",
                     default=os.path.expanduser("~/.globus/userkey.pem"))
    group.add_option("-p",
                     "--password",
                     "--userkeypass",
                     metavar="XXX",
                     help="Password for user key (default: read from stdin)",
                     dest="userkey_password",
                     default=None)
    group.add_option(
        "-P",
        "--proxy",
        metavar="FILE",
        help="Proxy certificate chain filename (default: %default)",
        dest="proxy",
        default=proxylib.get_proxy_filename())
    group.add_option(
        "--noproxy",
        action="store_false",
        help=
        "Do not use proxy certificate, use user certificate instead (default: use proxy certificate).",
        dest="use_proxy",
        default=True)
    group.add_option(
        "--capath",
        "-C",
        metavar="PATH",
        help=
        "Path to CA certificates, CRLs and signing policies (default: %default)",
        dest="capath",
        default="/etc/grid-security/certificates")
    parser.add_option_group(group)

    group = optparse.OptionGroup(parser, "Common options")
    group.add_option(
        "-u",
        "--url",
        metavar='URL',
        help=
        "Pilot server to use if not obvious from other arguments. May be specified as a full URL or just a host/host:port combination. (default: $PILOT_SERVER)",
        dest="pilot_url",
        default=os.environ.get("PILOT_SERVER", None))
    group.add_option("-D",
                     "--delegation",
                     metavar="NAME",
                     help="Delegation to use (default: \"%default\").",
                     dest="delegation_id",
                     default="default")
    group.add_option(
        "-t",
        "--timeout",
        metavar="SECONDS",
        type="int",
        help="Command execution timeout, in seconds (default: infinite)",
        dest="timeout",
        default=None)
    group.add_option("-j",
                     "--json",
                     action="store_true",
                     help="JSON output. Forces --quiet (default: off)",
                     dest="json")
    group.add_option(
        "-q",
        "--quiet",
        action="store_true",
        help=
        "Do not output any information intended for human beings. (default: off)",
        dest="quiet")
    group.add_option(
        "-v",
        "--verbose",
        action="store_true",
        help="Be more verbose about what's going on (default: off)",
        dest="verbose")
    group.add_option(
        "-d",
        "--debug",
        type="int",
        metavar="N",
        help=
        "Debug level. Available levels are: fatals (0), errors (1), warnings (2), info messages (3), debug messages (4). Default: %default",
        dest="debug_level",
        default=1)
    group.add_option(
        "--connection-debug",
        action="store_true",
        dest="connection_debug",
        default=False,
        help="Turn on HTTP connection debug logging. (default: off)")
    group.add_option(
        "-r",
        "--retry",
        type="int",
        metavar="N",
        help=
        "Number of request retries in case of network failures. Default: %default",
        dest="retries",
        default=3)
    group.add_option(
        "--log",
        metavar='FILE',
        help="Output debug information to file instead of stderr.",
        dest="debug_filename")
    group.add_option("--encoding",
                     metavar="ENC",
                     help="Input/Output encoding to use (default: %default)",
                     dest="io_encoding",
                     default="UTF-8")
    group.add_option("--software",
                     metavar="SW",
                     help="Add these software requirements to the job. "
                     "Requirements for specific package is added only if "
                     "requirements for this package are missing in job "
                     "definition.")
    parser.add_option_group(group)

    return parser