winrm

package module
v0.0.0-...-bb4ba34 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Nov 20, 2014 License: Apache-2.0 Imports: 11 Imported by: 0

README

Unsupported Go lang WinRM client library

This was originally forked from masterzen. There are some bug fixes in here and a bunch of other ideas that I was toying with, but ultimately these should get back upstream. If you want to help do that, great! I use this library currently for my Packer WinRM communicator.

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Http_post

func Http_post(client *Client, request *soap.SoapMessage) (response string, err error)

func NewDeleteShellRequest

func NewDeleteShellRequest(uri string, shellId string, params *Parameters) (message *soap.SoapMessage)

func NewExecuteCommandRequest

func NewExecuteCommandRequest(uri string, shellId string, command string, params *Parameters) (message *soap.SoapMessage)

func NewGetOutputRequest

func NewGetOutputRequest(uri string, shellId string, commandId string, streams string, params *Parameters) (message *soap.SoapMessage)

func NewOpenShellRequest

func NewOpenShellRequest(uri string, params *Parameters) (message *soap.SoapMessage)

func NewSendInputRequest

func NewSendInputRequest(uri string, shellId string, commandId string, input []byte, params *Parameters) (message *soap.SoapMessage)

func NewSignalRequest

func NewSignalRequest(uri string, shellId string, commandId string, params *Parameters) (message *soap.SoapMessage)

func ParseExecuteCommandResponse

func ParseExecuteCommandResponse(response string) (commandId string, err error)

func ParseOpenShellResponse

func ParseOpenShellResponse(response string) (shellId string, err error)

func ParseSlurpOutputErrResponse

func ParseSlurpOutputErrResponse(response string, stdout io.Writer, stderr io.Writer) (finished bool, exitCode int, err error)

func ParseSlurpOutputResponse

func ParseSlurpOutputResponse(response string, stream io.Writer, streamType string) (finished bool, exitCode int, err error)

func Powershell

func Powershell(psCmd string) string

Wraps a PowerShell script and prepares it for execution by the winrm client

Types

type Client

type Client struct {
	Parameters
	// contains filtered or unexported fields
}

func NewClient

func NewClient(host string, user string, password string) (client *Client)

NewClient will create a new remote client on url, connecting with user and password This function doesn't connect (connection happens only when CreateShell is called)

func NewClientWithParameters

func NewClientWithParameters(host string, user string, password string, params *Parameters) (client *Client)

NewClient will create a new remote client on url, connecting with user and password This function doesn't connect (connection happens only when CreateShell is called)

func (*Client) CreateShell

func (client *Client) CreateShell() (shell *Shell, err error)

CreateShell will create a WinRM Shell, which is required before running commands.

type Command

type Command struct {
	Stdout io.Writer
	Stderr io.Writer
	// contains filtered or unexported fields
}

Command represents a given command running on a Shell. This structure allows to get access to the various stdout, stderr and stdin pipes.

func (*Command) Close

func (command *Command) Close() (err error)

Close will terminate the running command

func (*Command) ExitCode

func (command *Command) ExitCode() int

ExitCode returns command exit code when it is finished. Before that the result is always 0.

func (*Command) Wait

func (command *Command) Wait()

Calling this function will block the current goroutine until the remote command terminates.

type HttpPost

type HttpPost func(*Client, *soap.SoapMessage) (string, error)

type Parameters

type Parameters struct {
	Timeout      string
	Locale       string
	EnvelopeSize int
	// contains filtered or unexported fields
}

func DefaultParameters

func DefaultParameters() *Parameters

func NewParameters

func NewParameters(timeout string, locale string, envelopeSize int) *Parameters

type Shell

type Shell struct {
	ShellId string
	// contains filtered or unexported fields
}

Shell is the local view of a WinRM Shell of a given Client

func (*Shell) Close

func (shell *Shell) Close() (err error)

Close will terminate this shell. No commands can be issued once the shell is closed.

func (*Shell) Execute

func (shell *Shell) Execute(command string, stdout io.Writer, stderr io.Writer) (cmd *Command, err error)

Execute command on the given Shell, returning either an error or a Command

Directories

Path Synopsis

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL