本文整理匯總了Golang中github.com/aws/amazon-ssm-agent/agent/log.T.Debug方法的典型用法代碼示例。如果您正苦於以下問題:Golang T.Debug方法的具體用法?Golang T.Debug怎麽用?Golang T.Debug使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類github.com/aws/amazon-ssm-agent/agent/log.T
的用法示例。
在下文中一共展示了T.Debug方法的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Golang代碼示例。
示例1: SendCommand
func (svc *sdkService) SendCommand(log log.T,
documentName string,
instanceIDs []string,
parameters map[string][]*string,
timeoutSeconds *int64,
outputS3BucketName *string,
outputS3KeyPrefix *string) (response *ssm.SendCommandOutput, err error) {
params := ssm.SendCommandInput{
DocumentName: aws.String(documentName),
InstanceIds: makeAwsStrings(instanceIDs),
Comment: aws.String("Comment"),
OutputS3BucketName: outputS3BucketName,
OutputS3KeyPrefix: outputS3KeyPrefix,
Parameters: parameters,
TimeoutSeconds: timeoutSeconds,
}
log.Debug("SendCommand params:", params)
response, err = svc.sdk.SendCommand(¶ms)
if err != nil {
sdkutil.HandleAwsError(log, err, ssmStopPolicy)
return
}
log.Debug("SendCommand Response", response)
return
}
示例2: UpdateInstanceInformation
//UpdateInstanceInformation calls the UpdateInstanceInformation SSM API.
func (svc *sdkService) UpdateInstanceInformation(
log log.T,
agentVersion string,
agentStatus string,
) (response *ssm.UpdateInstanceInformationOutput, err error) {
params := ssm.UpdateInstanceInformationInput{
AgentStatus: aws.String(agentStatus),
AgentVersion: aws.String(agentVersion),
}
goOS := runtime.GOOS
switch goOS {
case "windows":
params.PlatformType = aws.String(ssm.PlatformTypeWindows)
case "linux":
params.PlatformType = aws.String(ssm.PlatformTypeLinux)
default:
return nil, fmt.Errorf("Cannot report platform type of unrecognized OS. %v", goOS)
}
if ip, err := platform.IP(); err == nil {
params.IPAddress = aws.String(ip)
} else {
log.Warn(err)
}
if h, err := platform.Hostname(); err == nil {
params.ComputerName = aws.String(h)
} else {
log.Warn(err)
}
if instID, err := platform.InstanceID(); err == nil {
params.InstanceId = aws.String(instID)
} else {
log.Warn(err)
}
if n, err := platform.PlatformName(log); err == nil {
params.PlatformName = aws.String(n)
} else {
log.Warn(err)
}
if v, err := platform.PlatformVersion(log); err == nil {
params.PlatformVersion = aws.String(v)
} else {
log.Warn(err)
}
log.Debug("Calling UpdateInstanceInformation with params", params)
response, err = svc.sdk.UpdateInstanceInformation(¶ms)
if err != nil {
sdkutil.HandleAwsError(log, err, ssmStopPolicy)
return
}
log.Debug("UpdateInstanceInformation Response", response)
return
}
示例3: NewCoreManager
// NewCoreManager creates a new core plugin manager.
func NewCoreManager(instanceIdPtr *string, regionPtr *string, log logger.T) (cm *CoreManager, err error) {
// initialize appconfig
var config appconfig.SsmagentConfig
if config, err = appconfig.Config(false); err != nil {
log.Errorf("Could not load config file: %v", err)
return
}
// initialize region
if *regionPtr != "" {
if err = platform.SetRegion(*regionPtr); err != nil {
log.Errorf("error occured setting the region, %v", err)
return
}
}
var region string
if region, err = platform.Region(); err != nil {
log.Errorf("error fetching the region, %v", err)
return
}
log.Debug("Using region:", region)
// initialize instance ID
if *instanceIdPtr != "" {
if err = platform.SetInstanceID(*instanceIdPtr); err != nil {
log.Errorf("error occured setting the instance ID, %v", err)
return
}
}
var instanceId string
if instanceId, err = platform.InstanceID(); err != nil {
log.Errorf("error fetching the instanceID, %v", err)
return
}
log.Debug("Using instanceID:", instanceId)
if err = fileutil.HardenDataFolder(); err != nil {
log.Errorf("error initializing SSM data folder with hardened ACL, %v", err)
return
}
//Initialize all folders where interim states of executing commands will be stored.
if !initializeBookkeepingLocations(log, instanceId) {
log.Error("unable to initialize. Exiting")
return
}
context := context.Default(log, config).With("[instanceID=" + instanceId + "]")
corePlugins := coreplugins.RegisteredCorePlugins(context)
return &CoreManager{
context: context,
corePlugins: *corePlugins,
}, nil
}
示例4: killProcessOnTimeout
// killProcessOnTimeout waits for a timeout.
// When the timeout is reached, this method kills the underlying
// process of the command. This will unblock the command.Wait() call.
// If the task completed successfully this method returns with no action.
func killProcessOnTimeout(log log.T, command *exec.Cmd, timer *time.Timer) {
<-timer.C
log.Debug("Process exceeded timeout. Attempting to stop process.")
// task has been exceeded the allowed execution timeout, kill process
if err := killProcess(command.Process); err != nil {
log.Error(err)
return
}
log.Debug("Process stopped successfully")
}
示例5: killProcessOnTimeout
func killProcessOnTimeout(log log.T, command *exec.Cmd, timer *time.Timer) {
<-timer.C
log.Debug("Process exceeded timeout. Attempting to kill process!")
// task has been exceeded the allowed execution timeout, kill process
if err := command.Process.Kill(); err != nil {
log.Error(err)
return
}
log.Debug("Done kill process!")
}
示例6: DeleteMessage
// DeleteMessage calls the DeleteMessage MDS API.
func (mds *sdkService) DeleteMessage(log log.T, messageID string) (err error) {
params := &ssmmds.DeleteMessageInput{
MessageId: aws.String(messageID), // Required
}
log.Debug("Calling DeleteMessage with params", params)
req, resp := mds.sdk.DeleteMessageRequest(params)
if err = mds.sendRequest(req); err != nil {
err = fmt.Errorf("DeleteMessage Error: %v", err)
log.Debug(err)
} else {
log.Debug("DeleteMessage Response", resp)
}
return
}
示例7: killProcessOnCancel
// killProcessOnCancel waits for a cancel request.
// If a cancel request is received, this method kills the underlying
// process of the command. This will unblock the command.Wait() call.
// If the task completed successfully this method returns with no action.
func killProcessOnCancel(log log.T, command *exec.Cmd, cancelFlag task.CancelFlag) {
cancelFlag.Wait()
if cancelFlag.Canceled() {
log.Debug("Process cancelled. Attempting to stop process.")
// task has been asked to cancel, kill process
if err := killProcess(command.Process); err != nil {
log.Error(err)
return
}
log.Debug("Process stopped successfully.")
}
}
示例8: processParams
// processParams smartly divides the input parameter string into valid string blocks
func processParams(log log.T, str string) []string {
// Sample transformation:
// str = "/v value "some path" myproperty=value"
// result: []string{"/v", "value", "some path", "myproperty=value"}
// contains the last split location of the string
lastbit := 0
params := []string{}
// true if first quote was encountered else false
quoteInit := false
// Iterate through each character in str
for i, c := range str {
// Look for quotes or spaces
// By default we split a string using space as a delimiter
// If a quote(") is encountered then wait for the next quote irrespective of any spaces in between
if c == '"' {
if quoteInit {
quoteInit = false
params = append(params, str[lastbit:i+1])
lastbit = i + 1
} else {
quoteInit = true
lastbit = i
}
} else if c == ' ' && !quoteInit {
if lastbit != i {
params = append(params, str[lastbit:i])
}
lastbit = i + 1
}
}
// This handles the last word in str
if lastbit < len(str) {
params = append(params, str[lastbit:len(str)])
}
log.Debug("Parameters after processing...")
for _, param := range params {
log.Debug(param)
}
return params
}
示例9: FailMessage
// FailMessage calls the FailMessage MDS API.
func (mds *sdkService) FailMessage(log log.T, messageID string, failureType FailureType) (err error) {
params := &ssmmds.FailMessageInput{
FailureType: aws.String(string(failureType)), // Required
MessageId: aws.String(messageID), // Required
}
log.Debug("Calling FailMessage with params", params)
req, resp := mds.sdk.FailMessageRequest(params)
if err = mds.sendRequest(req); err != nil {
err = fmt.Errorf("FailMessage Error: %v", err)
log.Debug(err)
} else {
log.Debug("FailMessage Response", resp)
}
return
}
示例10: CancelCommand
func (svc *sdkService) CancelCommand(log log.T, commandID string, instanceIDs []string) (response *ssm.CancelCommandOutput, err error) {
params := ssm.CancelCommandInput{
CommandId: aws.String(commandID),
}
if len(instanceIDs) > 0 {
params.InstanceIds = makeAwsStrings(instanceIDs)
}
log.Debug("CancelCommand params:", params)
response, err = svc.sdk.CancelCommand(¶ms)
if err != nil {
sdkutil.HandleAwsError(log, err, ssmStopPolicy)
return
}
log.Debug("CancelCommand Response", response)
return
}
示例11: SendReply
// SendReply calls the SendReply MDS API.
func (mds *sdkService) SendReply(log log.T, messageID string, payload string) (err error) {
uuid.SwitchFormat(uuid.CleanHyphen)
replyID := uuid.NewV4().String()
params := &ssmmds.SendReplyInput{
MessageId: aws.String(messageID), // Required
Payload: aws.String(payload), // Required
ReplyId: aws.String(replyID), // Required
}
log.Debug("Calling SendReply with params", params)
req, resp := mds.sdk.SendReplyRequest(params)
if err = mds.sendRequest(req); err != nil {
err = fmt.Errorf("SendReply Error: %v", err)
log.Debug(err)
} else {
log.Info("SendReply Response", resp)
}
return
}
示例12: DeleteDocument
func (svc *sdkService) DeleteDocument(log log.T, docName string) (response *ssm.DeleteDocumentOutput, err error) {
params := ssm.DeleteDocumentInput{
Name: aws.String(docName), // Required
}
response, err = svc.sdk.DeleteDocument(¶ms)
if err != nil {
sdkutil.HandleAwsError(log, err, ssmStopPolicy)
return
}
log.Debug("DeleteDocument Response", response)
return
}
示例13: CreateDocument
func (svc *sdkService) CreateDocument(log log.T, docName string, docContent string) (response *ssm.CreateDocumentOutput, err error) {
params := ssm.CreateDocumentInput{
Content: aws.String(docContent),
Name: aws.String(docName),
}
response, err = svc.sdk.CreateDocument(¶ms)
if err != nil {
sdkutil.HandleAwsError(log, err, ssmStopPolicy)
return
}
log.Debug("CreateDocument Response", response)
return
}
示例14: GetMessages
// GetMessages calls the GetMessages MDS API.
func (mds *sdkService) GetMessages(log log.T, instanceID string) (messages *ssmmds.GetMessagesOutput, err error) {
uuid.SwitchFormat(uuid.CleanHyphen)
uid := uuid.NewV4().String()
params := &ssmmds.GetMessagesInput{
Destination: aws.String(instanceID), // Required
MessagesRequestId: aws.String(uid), // Required
VisibilityTimeoutInSeconds: aws.Int64(10),
}
log.Debug("Calling GetMessages with params", params)
requestTime := time.Now()
req, messages := mds.sdk.GetMessagesRequest(params)
if requestErr := mds.sendRequest(req); requestErr != nil {
log.Debug(requestErr)
if isErrorUnexpected(log, requestErr, requestTime, time.Now()) {
//GetMessages api responded with unexpected errors - we must return this as error
err = fmt.Errorf("GetMessages Error: %v", requestErr)
log.Debug(err)
}
} else {
log.Debug("GetMessages Response", messages)
}
return
}
示例15: setMsiExecStatus
// setMsiExecStatus sets the exit status and output to be returned to the user based on exit code
func setMsiExecStatus(log log.T, pluginInput ApplicationPluginInput, cancelFlag task.CancelFlag, out *ApplicationPluginOutput) {
out.Stdout = pluginInput.Source
out.Stderr = ""
out.Status = contracts.ResultStatusFailed
isUnKnownError := false
switch out.ExitCode {
case appconfig.SuccessExitCode:
out.Status = contracts.ResultStatusSuccess
case ErrorUnknownProduct:
if pluginInput.Action == UNINSTALL {
// Uninstall will skip, if product is not currently installed.
// This is needed to support idempotent behavior.
out.Status = contracts.ResultStatusSuccess
}
case ErrorSuccessRebootInitiated:
fallthrough
case appconfig.RebootExitCode:
out.Status = contracts.ResultStatusSuccessAndReboot
case pluginutil.CommandStoppedPreemptivelyExitCode:
if cancelFlag.ShutDown() {
out.Status = contracts.ResultStatusFailed
}
if cancelFlag.Canceled() {
out.Status = contracts.ResultStatusCancelled
}
out.Status = contracts.ResultStatusTimedOut
default:
isUnKnownError = true
}
if isUnKnownError {
// Note: Sample Stderr:
// Action:{Installed}; Status:{Failed};
// ErrorCode:{1620}; ErrorMsg:{ERROR_INSTALL_PACKAGE_INVALID};
// Description:{This installation package could not be opened. Contact the application vendor to verify that this is a valid Windows Installer package.};
// Source:{https:///}
// Construct stderr in above format using StandardMsiErrorCodes
out.Stderr = fmt.Sprintf("Action:{%v}; Status:{%v}; ErrorCode:{%v}; %v Source:{%v};", pluginInput.Action, out.Status, out.ExitCode, getExitCodeDescription(out.ExitCode), pluginInput.Source)
}
// Logging msiexec.Result
log.Debug("logging stdouts & errors after setting final status for msiexec")
log.Debugf("resultCode: %v", out.ExitCode)
log.Debugf("stdout: %v", out.Stdout)
log.Debugf("stderr: %v", out.Stderr)
}