public ConsoleOutput GetConsoleOutput(string instanceId) { try { AWSModel.GetConsoleOutputRequest request = new AWSModel.GetConsoleOutputRequest(); request.InstanceId = instanceId; AWSModel.GetConsoleOutputResponse response = ec2.GetConsoleOutput(request); if (response != null) { return(ModelUtil.CreateInstance(response.GetConsoleOutputResult.ConsoleOutput)); } else { return(null); } } catch (WebException e) { throw new MonoscapeEC2Exception(e.Message, e); } catch (AmazonEC2Exception e) { throw new MonoscapeEC2Exception(e.Message, e); } }
/// <summary> /// The GetConsoleOutput operation retrieves console output for the specified /// instance. /// Instance console output is buffered and posted shortly after instance boot, /// reboot, and termination. Amazon EC2 preserves the most recent 64 KB output /// which will be available for at least one hour after the most recent post. /// /// </summary> /// <param name="service">Instance of AmazonEC2 service</param> /// <param name="request">GetConsoleOutputRequest request</param> public static void InvokeGetConsoleOutput(AmazonEC2 service, GetConsoleOutputRequest request) { try { GetConsoleOutputResponse response = service.GetConsoleOutput(request); Console.WriteLine ("Service Response"); Console.WriteLine ("============================================================================="); Console.WriteLine (); Console.WriteLine(" GetConsoleOutputResponse"); if (response.IsSetResponseMetadata()) { Console.WriteLine(" ResponseMetadata"); ResponseMetadata responseMetadata = response.ResponseMetadata; if (responseMetadata.IsSetRequestId()) { Console.WriteLine(" RequestId"); Console.WriteLine(" {0}", responseMetadata.RequestId); } } if (response.IsSetGetConsoleOutputResult()) { Console.WriteLine(" GetConsoleOutputResult"); GetConsoleOutputResult getConsoleOutputResult = response.GetConsoleOutputResult; if (getConsoleOutputResult.IsSetConsoleOutput()) { Console.WriteLine(" ConsoleOutput"); ConsoleOutput consoleOutput = getConsoleOutputResult.ConsoleOutput; if (consoleOutput.IsSetInstanceId()) { Console.WriteLine(" InstanceId"); Console.WriteLine(" {0}", consoleOutput.InstanceId); } if (consoleOutput.IsSetTimestamp()) { Console.WriteLine(" Timestamp"); Console.WriteLine(" {0}", consoleOutput.Timestamp); } if (consoleOutput.IsSetOutput()) { Console.WriteLine(" Output"); Console.WriteLine(" {0}", consoleOutput.Output); } } } } catch (AmazonEC2Exception ex) { Console.WriteLine("Caught Exception: " + ex.Message); Console.WriteLine("Response Status Code: " + ex.StatusCode); Console.WriteLine("Error Code: " + ex.ErrorCode); Console.WriteLine("Error Type: " + ex.ErrorType); Console.WriteLine("Request ID: " + ex.RequestId); Console.WriteLine("XML: " + ex.XML); } }
protected override void ProcessRecord() { AmazonEC2 client = base.GetClient(); Amazon.EC2.Model.GetConsoleOutputRequest request = new Amazon.EC2.Model.GetConsoleOutputRequest(); request.InstanceId = this._InstanceId; Amazon.EC2.Model.GetConsoleOutputResponse response = client.GetConsoleOutput(request); base.WriteObject(response.GetConsoleOutputResult.ConsoleOutput, true); }
public object Execute(ExecutorContext context) { var cmdletContext = context as CmdletContext; // create request var request = new Amazon.EC2.Model.GetConsoleOutputRequest(); if (cmdletContext.InstanceId != null) { request.InstanceId = cmdletContext.InstanceId; } if (cmdletContext.Latest != null) { request.Latest = cmdletContext.Latest.Value; } CmdletOutput output; // issue call var client = Client ?? CreateClient(_CurrentCredentials, _RegionEndpoint); try { var response = CallAWSServiceOperation(client, request); object pipelineOutput = null; pipelineOutput = cmdletContext.Select(response, this); output = new CmdletOutput { PipelineOutput = pipelineOutput, ServiceResponse = response }; } catch (Exception e) { output = new CmdletOutput { ErrorResponse = e }; } return(output); }
/// <summary> /// Initiates the asynchronous execution of the GetConsoleOutput operation. /// </summary> /// /// <param name="request">Container for the necessary parameters to execute the GetConsoleOutput operation.</param> /// <param name="cancellationToken"> /// A cancellation token that can be used by other objects or threads to receive notice of cancellation. /// </param> /// <returns>The task object representing the asynchronous operation.</returns> public Task<GetConsoleOutputResponse> GetConsoleOutputAsync(GetConsoleOutputRequest request, System.Threading.CancellationToken cancellationToken = default(CancellationToken)) { var marshaller = new GetConsoleOutputRequestMarshaller(); var unmarshaller = GetConsoleOutputResponseUnmarshaller.Instance; return InvokeAsync<GetConsoleOutputRequest,GetConsoleOutputResponse>(request, marshaller, unmarshaller, cancellationToken); }
/// <summary> /// Gets the console output for the specified instance. /// /// /// <para> /// Instances do not have a physical monitor through which you can view their console /// output. They also lack physical controls that allow you to power up, reboot, or shut /// them down. To allow these actions, we provide them through the Amazon EC2 API and /// command line interface. /// </para> /// /// <para> /// Instance console output is buffered and posted shortly after instance boot, reboot, /// and termination. Amazon EC2 preserves the most recent 64 KB output which is available /// for at least one hour after the most recent post. /// </para> /// /// <para> /// For Linux instances, the instance console output displays the exact console output /// that would normally be displayed on a physical monitor attached to a computer. This /// output is buffered because the instance produces it and then posts it to a store where /// the instance's owner can retrieve it. /// </para> /// /// <para> /// For Windows instances, the instance console output includes output from the EC2Config /// service. /// </para> /// </summary> /// <param name="request">Container for the necessary parameters to execute the GetConsoleOutput service method.</param> /// /// <returns>The response from the GetConsoleOutput service method, as returned by EC2.</returns> public GetConsoleOutputResponse GetConsoleOutput(GetConsoleOutputRequest request) { var marshaller = new GetConsoleOutputRequestMarshaller(); var unmarshaller = GetConsoleOutputResponseUnmarshaller.Instance; return Invoke<GetConsoleOutputRequest,GetConsoleOutputResponse>(request, marshaller, unmarshaller); }
/// <summary> /// Initiates the asynchronous execution of the GetConsoleOutput operation. /// </summary> /// /// <param name="request">Container for the necessary parameters to execute the GetConsoleOutput operation on AmazonEC2Client.</param> /// <param name="callback">An AsyncCallback delegate that is invoked when the operation completes.</param> /// <param name="state">A user-defined state object that is passed to the callback procedure. Retrieve this object from within the callback /// procedure using the AsyncState property.</param> /// /// <returns>An IAsyncResult that can be used to poll or wait for results, or both; this value is also needed when invoking EndGetConsoleOutput /// operation.</returns> public IAsyncResult BeginGetConsoleOutput(GetConsoleOutputRequest request, AsyncCallback callback, object state) { var marshaller = new GetConsoleOutputRequestMarshaller(); var unmarshaller = GetConsoleOutputResponseUnmarshaller.Instance; return BeginInvoke<GetConsoleOutputRequest>(request, marshaller, unmarshaller, callback, state); }
IAsyncResult invokeGetConsoleOutput(GetConsoleOutputRequest getConsoleOutputRequest, AsyncCallback callback, object state, bool synchronized) { IRequest irequest = new GetConsoleOutputRequestMarshaller().Marshall(getConsoleOutputRequest); var unmarshaller = GetConsoleOutputResponseUnmarshaller.GetInstance(); AsyncResult result = new AsyncResult(irequest, callback, state, synchronized, signer, unmarshaller); Invoke(result); return result; }
/// <summary> /// Initiates the asynchronous execution of the GetConsoleOutput operation. /// <seealso cref="Amazon.EC2.IAmazonEC2.GetConsoleOutput"/> /// </summary> /// /// <param name="getConsoleOutputRequest">Container for the necessary parameters to execute the GetConsoleOutput operation on AmazonEC2.</param> /// <param name="callback">An AsyncCallback delegate that is invoked when the operation completes.</param> /// <param name="state">A user-defined state object that is passed to the callback procedure. Retrieve this object from within the callback /// procedure using the AsyncState property.</param> /// /// <returns>An IAsyncResult that can be used to poll or wait for results, or both; this value is also needed when invoking EndGetConsoleOutput /// operation.</returns> public IAsyncResult BeginGetConsoleOutput(GetConsoleOutputRequest getConsoleOutputRequest, AsyncCallback callback, object state) { return invokeGetConsoleOutput(getConsoleOutputRequest, callback, state, false); }
/// <summary> /// <para>Gets the console output for the specified instance.</para> <para>Instances do not have a physical monitor through which you can view /// their console output. They also lack physical controls that allow you to power up, reboot, or shut them down. To allow these actions, we /// provide them through the Amazon EC2 API and command line interface.</para> <para>Instance console output is buffered and posted shortly /// after instance boot, reboot, and termination. Amazon EC2 preserves the most recent 64 KB output which is available for at least one hour /// after the most recent post.</para> <para>For Linux/Unix instances, the instance console output displays the exact console output that would /// normally be displayed on a physical monitor attached to a machine. This output is buffered because the instance produces it and then posts /// it to a store where the instance's owner can retrieve it.</para> <para>For Windows instances, the instance console output displays the last /// three system event log errors.</para> /// </summary> /// /// <param name="getConsoleOutputRequest">Container for the necessary parameters to execute the GetConsoleOutput service method on /// AmazonEC2.</param> /// /// <returns>The response from the GetConsoleOutput service method, as returned by AmazonEC2.</returns> /// public GetConsoleOutputResponse GetConsoleOutput(GetConsoleOutputRequest getConsoleOutputRequest) { IAsyncResult asyncResult = invokeGetConsoleOutput(getConsoleOutputRequest, null, null, true); return EndGetConsoleOutput(asyncResult); }
/// <summary> /// <para>Gets the console output for the specified instance.</para> <para>Instances do not have a physical monitor through which you can view /// their console output. They also lack physical controls that allow you to power up, reboot, or shut them down. To allow these actions, we /// provide them through the Amazon EC2 API and command line interface.</para> <para>Instance console output is buffered and posted shortly /// after instance boot, reboot, and termination. Amazon EC2 preserves the most recent 64 KB output which is available for at least one hour /// after the most recent post.</para> <para>For Linux/Unix instances, the instance console output displays the exact console output that would /// normally be displayed on a physical monitor attached to a machine. This output is buffered because the instance produces it and then posts /// it to a store where the instance's owner can retrieve it.</para> <para>For Windows instances, the instance console output displays the last /// three system event log errors.</para> /// </summary> /// /// <param name="getConsoleOutputRequest">Container for the necessary parameters to execute the GetConsoleOutput service method on /// AmazonEC2.</param> /// /// <returns>The response from the GetConsoleOutput service method, as returned by AmazonEC2.</returns> /// <param name="cancellationToken"> /// A cancellation token that can be used by other objects or threads to receive notice of cancellation. /// </param> public Task<GetConsoleOutputResponse> GetConsoleOutputAsync(GetConsoleOutputRequest getConsoleOutputRequest, CancellationToken cancellationToken = default(CancellationToken)) { var marshaller = new GetConsoleOutputRequestMarshaller(); var unmarshaller = GetConsoleOutputResponseUnmarshaller.GetInstance(); return Invoke<IRequest, GetConsoleOutputRequest, GetConsoleOutputResponse>(getConsoleOutputRequest, marshaller, unmarshaller, signer, cancellationToken); }
internal GetConsoleOutputResponse GetConsoleOutput(GetConsoleOutputRequest request) { var task = GetConsoleOutputAsync(request); try { return task.Result; } catch(AggregateException e) { ExceptionDispatchInfo.Capture(e.InnerException).Throw(); return null; } }
/// <summary> /// Initiates the asynchronous execution of the GetConsoleOutput operation. /// <seealso cref="Amazon.EC2.IAmazonEC2.GetConsoleOutput"/> /// </summary> /// /// <param name="request">Container for the necessary parameters to execute the GetConsoleOutput operation.</param> /// <param name="cancellationToken"> /// A cancellation token that can be used by other objects or threads to receive notice of cancellation. /// </param> /// <returns>The task object representing the asynchronous operation.</returns> public async Task<GetConsoleOutputResponse> GetConsoleOutputAsync(GetConsoleOutputRequest request, CancellationToken cancellationToken = default(CancellationToken)) { var marshaller = new GetConsoleOutputRequestMarshaller(); var unmarshaller = GetConsoleOutputResponseUnmarshaller.GetInstance(); var response = await Invoke<IRequest, GetConsoleOutputRequest, GetConsoleOutputResponse>(request, marshaller, unmarshaller, signer, cancellationToken) .ConfigureAwait(continueOnCapturedContext: false); return response; }
/// <summary> /// <para> The GetConsoleOutput operation retrieves console output for the specified instance. </para> <para> Instance console output is /// buffered and posted shortly after instance boot, reboot, and termination. Amazon EC2 preserves the most recent 64 KB output which will be /// available for at least one hour after the most recent post. </para> /// </summary> /// /// <param name="request">Container for the necessary parameters to execute the GetConsoleOutput service method on /// AmazonEC2.</param> /// /// <returns>The response from the GetConsoleOutput service method, as returned by AmazonEC2.</returns> public GetConsoleOutputResponse GetConsoleOutput(GetConsoleOutputRequest request) { var task = GetConsoleOutputAsync(request); try { return task.Result; } catch(AggregateException e) { throw e.InnerException; } }
public ConsoleOutput GetConsoleOutput(string instanceId) { try { AWSModel.GetConsoleOutputRequest request = new AWSModel.GetConsoleOutputRequest(); request.InstanceId = instanceId; AWSModel.GetConsoleOutputResponse response = ec2.GetConsoleOutput(request); if (response != null) return ModelUtil.CreateInstance(response.GetConsoleOutputResult.ConsoleOutput); else return null; } catch (WebException e) { throw new MonoscapeEC2Exception(e.Message, e); } catch (AmazonEC2Exception e) { throw new MonoscapeEC2Exception(e.Message, e); } }
private Amazon.EC2.Model.GetConsoleOutputResponse CallAWSServiceOperation(IAmazonEC2 client, Amazon.EC2.Model.GetConsoleOutputRequest request) { Utils.Common.WriteVerboseEndpointMessage(this, client.Config, "Amazon Elastic Compute Cloud (EC2)", "GetConsoleOutput"); try { #if DESKTOP return(client.GetConsoleOutput(request)); #elif CORECLR return(client.GetConsoleOutputAsync(request).GetAwaiter().GetResult()); #else #error "Unknown build edition" #endif } catch (AmazonServiceException exc) { var webException = exc.InnerException as System.Net.WebException; if (webException != null) { throw new Exception(Utils.Common.FormatNameResolutionFailureMessage(client.Config, webException.Message), webException); } throw; } }