Exemple #1
0
    if not host:
        host = sync['server']
    if not port:
        port = sync.get('port', None)
    user = sync['auth_user']

    logger.info("Start")
    client = WinRMClient(host=host,
                         port=port,
                         encrypted=encrypted,
                         logger=logger)
    # TODO: add ca, client_key and client_cert
    client._winrs_skip_cmd_shell = False
    #client._winrs_consolemode_stdin = False
    client.add_credentials(username=user,
                           password=unicode(read_password(user, host),
                                            'utf-8'))

    for opt, val in opts:
        if opt == '--delete-shell':
            logger.info("Deleting shell with ShellId: %s", val)
            client.wsman_delete(val)
            logger.info("Finished")
            sys.exit()

    # Get server identification:
    logger.info("Identifying server")
    ident = client.wsman_identify()
    # TODO: doesn't work now
    for key in ('ProtocolVersion', 'ProductVendor', 'ProductVersion'):
        for event, elem in ident.iterfind(
Exemple #2
0
        print "Need either --type or --host to connect to"
        usage(1)

    if not host:
        host = sync['server']
    if not port:
        port = sync.get('port', None)
    user = sync['auth_user']

    logger.info("Start")
    client = WinRMClient(host=host, port=port, encrypted=encrypted,
                         logger=logger)
    # TODO: add ca, client_key and client_cert
    client._winrs_skip_cmd_shell = False
    #client._winrs_consolemode_stdin = False
    client.add_credentials(username=user,
                           password=unicode(read_password(user, host), 'utf-8'))


    for opt, val in opts:
        if opt == '--delete-shell':
            logger.info("Deleting shell with ShellId: %s", val)
            client.wsman_delete(val)
            logger.info("Finished")
            sys.exit()


    # Get server identification:
    logger.info("Identifying server")
    ident = client.wsman_identify()
    # TODO: doesn't work now
    for key in ('ProtocolVersion', 'ProductVendor', 'ProductVersion'):
Exemple #3
0
    if not args:
        print "Command to run is required"
        usage(1)

    if not host:
        host = sync['server']
    if not port:
        port = sync.get('port', None)
    user = sync['auth_user']

    client = WinRMClient(host=host, port=port, encrypted=encrypted,
                         logger=logger)
    # TODO: add ca, client_key and client_cert
    client._winrs_skip_cmd_shell = False
    #client._winrs_consolemode_stdin = False
    client.add_credentials(username=user,
                           password=read_password(user, host))
    client.connect()

    code = ' '.join(args)
    logger.debug("Running code: %s" % code)

    try:
        out = client.run(code)
    finally:
        client.close()
    for outtype in ('stderr', 'stdout'):
        data = out.get(outtype)
        if data:
            print '%s:' % outtype.upper()
            print data
            print