Container for the parameters to the RegisterInstancesWithLoadBalancer operation.

Adds new instances to the LoadBalancer.

Once the instance is registered, it starts receiving traffic and requests from the LoadBalancer. Any instance that is not in any of the Availability Zones registered for the LoadBalancer will be moved to the OutOfService state. It will move to the InService state when the Availability Zone is added to the LoadBalancer.

NOTE: In order for this call to be successful, the client must have created the LoadBalancer. The client must provide the same account credentials as those that were used to create the LoadBalancer.

NOTE: Completion of this API does not guarantee that operation has completed. Rather, it means that the request has been registered and the changes will happen shortly.

Inheritance: Amazon.Runtime.AmazonWebServiceRequest
 protected override void ProcessRecord()
 {
     AmazonElasticLoadBalancing client = base.GetClient();
     Amazon.ElasticLoadBalancing.Model.RegisterInstancesWithLoadBalancerRequest request = new Amazon.ElasticLoadBalancing.Model.RegisterInstancesWithLoadBalancerRequest();
     request.LoadBalancerName = this._LoadBalancerName;
     request.Instances.Add(new Instance(){InstanceId=this.InstanceId});
     Amazon.ElasticLoadBalancing.Model.RegisterInstancesWithLoadBalancerResponse response = client.RegisterInstancesWithLoadBalancer(request);
     base.WriteObject(response.RegisterInstancesWithLoadBalancerResult, true);
 }
        public object Execute(ExecutorContext context)
        {
            var cmdletContext = context as CmdletContext;
            // create request
            var request = new Amazon.ElasticLoadBalancing.Model.RegisterInstancesWithLoadBalancerRequest();

            if (cmdletContext.Instance != null)
            {
                request.Instances = cmdletContext.Instance;
            }
            if (cmdletContext.LoadBalancerName != null)
            {
                request.LoadBalancerName = cmdletContext.LoadBalancerName;
            }

            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);
        }
コード例 #3
0
        internal RegisterInstancesWithLoadBalancerResponse RegisterInstancesWithLoadBalancer(RegisterInstancesWithLoadBalancerRequest request)
        {
            var marshaller = new RegisterInstancesWithLoadBalancerRequestMarshaller();
            var unmarshaller = RegisterInstancesWithLoadBalancerResponseUnmarshaller.Instance;

            return Invoke<RegisterInstancesWithLoadBalancerRequest,RegisterInstancesWithLoadBalancerResponse>(request, marshaller, unmarshaller);
        }
コード例 #4
0
        /// <summary>
        /// Initiates the asynchronous execution of the RegisterInstancesWithLoadBalancer operation.
        /// </summary>
        /// 
        /// <param name="request">Container for the necessary parameters to execute the RegisterInstancesWithLoadBalancer 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<RegisterInstancesWithLoadBalancerResponse> RegisterInstancesWithLoadBalancerAsync(RegisterInstancesWithLoadBalancerRequest request, System.Threading.CancellationToken cancellationToken = default(CancellationToken))
        {
            var marshaller = new RegisterInstancesWithLoadBalancerRequestMarshaller();
            var unmarshaller = RegisterInstancesWithLoadBalancerResponseUnmarshaller.Instance;

            return InvokeAsync<RegisterInstancesWithLoadBalancerRequest,RegisterInstancesWithLoadBalancerResponse>(request, marshaller, 
                unmarshaller, cancellationToken);
        }
コード例 #5
0
 /// <summary>
 /// Initiates the asynchronous execution of the RegisterInstancesWithLoadBalancer operation.
 /// <seealso cref="Amazon.ElasticLoadBalancing.AmazonElasticLoadBalancing.RegisterInstancesWithLoadBalancer"/>
 /// </summary>
 /// 
 /// <param name="registerInstancesWithLoadBalancerRequest">Container for the necessary parameters to execute the
 ///          RegisterInstancesWithLoadBalancer operation on AmazonElasticLoadBalancing.</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
 ///         EndRegisterInstancesWithLoadBalancer operation.</returns>
 public IAsyncResult BeginRegisterInstancesWithLoadBalancer(RegisterInstancesWithLoadBalancerRequest registerInstancesWithLoadBalancerRequest, AsyncCallback callback, object state)
 {
     return invokeRegisterInstancesWithLoadBalancer(registerInstancesWithLoadBalancerRequest, callback, state, false);
 }
コード例 #6
0
 IAsyncResult invokeRegisterInstancesWithLoadBalancer(RegisterInstancesWithLoadBalancerRequest registerInstancesWithLoadBalancerRequest, AsyncCallback callback, object state, bool synchronized)
 {
     IRequest irequest = new RegisterInstancesWithLoadBalancerRequestMarshaller().Marshall(registerInstancesWithLoadBalancerRequest);
     var unmarshaller = RegisterInstancesWithLoadBalancerResponseUnmarshaller.GetInstance();
     AsyncResult result = new AsyncResult(irequest, callback, state, synchronized, signer, unmarshaller);
     Invoke(result);
     return result;
 }
コード例 #7
0
 /// <summary>
 /// <para> Adds new instances to the LoadBalancer. </para> <para> Once the instance is registered, it starts receiving traffic and requests from
 /// the LoadBalancer. Any instance that is not in any of the Availability Zones registered for the LoadBalancer will be moved to the
 /// <i>OutOfService</i> state. It will move to the <i>InService</i> state when the Availability Zone is added to the LoadBalancer. </para>
 /// <para><b>NOTE:</b> In order for this call to be successful, the client must have created the LoadBalancer. The client must provide the same
 /// account credentials as those that were used to create the LoadBalancer. </para> <para><b>NOTE:</b> Completion of this API does not guarantee
 /// that operation has completed. Rather, it means that the request has been registered and the changes will happen shortly. </para>
 /// </summary>
 /// 
 /// <param name="registerInstancesWithLoadBalancerRequest">Container for the necessary parameters to execute the
 ///          RegisterInstancesWithLoadBalancer service method on AmazonElasticLoadBalancing.</param>
 /// 
 /// <returns>The response from the RegisterInstancesWithLoadBalancer service method, as returned by AmazonElasticLoadBalancing.</returns>
 /// 
 /// <exception cref="InvalidInstanceException"/>
 /// <exception cref="LoadBalancerNotFoundException"/>
 public RegisterInstancesWithLoadBalancerResponse RegisterInstancesWithLoadBalancer(RegisterInstancesWithLoadBalancerRequest registerInstancesWithLoadBalancerRequest)
 {
     IAsyncResult asyncResult = invokeRegisterInstancesWithLoadBalancer(registerInstancesWithLoadBalancerRequest, null, null, true);
     return EndRegisterInstancesWithLoadBalancer(asyncResult);
 }
コード例 #8
0
        /// <summary>
        /// <para> Adds new instances to the load balancer. </para> <para> Once the instance is registered, it starts receiving traffic and requests
        /// from the load balancer. Any instance that is not in any of the Availability Zones registered for the load balancer will be moved to the
        /// <i>OutOfService</i> state. It will move to the <i>InService</i> state when the Availability Zone is added to the load balancer. </para>
        /// <para>When an instance registered with a load balancer is stopped and then restarted, the IP addresses associated with the instance changes.
        /// Elastic Load Balancing cannot recognize the new IP address, which prevents it from routing traffic to the instances. We recommend that you
        /// de-register your Amazon EC2 instances from your load balancer after you stop your instance, and then register the load balancer with your
        /// instance after you've restarted. To de-register your instances from load balancer, use DeregisterInstancesFromLoadBalancer action.</para>
        /// <para>For more information, see <a href="http://docs.aws.amazon.com/ElasticLoadBalancing/latest/DeveloperGuide/US_DeReg_Reg_Instances.html">De-register and Register Amazon EC2 Instances</a> in the <i>Elastic Load Balancing Developer Guide</i> .</para> <para><b>NOTE:</b> In order
        /// for this call to be successful, you must provide the same account credentials as those that were used to create the load balancer. </para>
        /// <para><b>NOTE:</b> Completion of this API does not guarantee that operation has completed. Rather, it means that the request has been
        /// registered and the changes will happen shortly. </para> <para>You can use DescribeLoadBalancers or DescribeInstanceHealth action to check
        /// the state of the newly registered instances.</para>
        /// </summary>
        /// 
        /// <param name="registerInstancesWithLoadBalancerRequest">Container for the necessary parameters to execute the
        /// RegisterInstancesWithLoadBalancer service method on AmazonElasticLoadBalancing.</param>
        /// 
        /// <returns>The response from the RegisterInstancesWithLoadBalancer service method, as returned by AmazonElasticLoadBalancing.</returns>
        /// 
        /// <exception cref="T:Amazon.ElasticLoadBalancing.Model.LoadBalancerNotFoundException" />
        /// <exception cref="T:Amazon.ElasticLoadBalancing.Model.InvalidInstanceException" />
        /// <param name="cancellationToken">
        ///     A cancellation token that can be used by other objects or threads to receive notice of cancellation.
        /// </param>
		public async Task<RegisterInstancesWithLoadBalancerResponse> RegisterInstancesWithLoadBalancerAsync(RegisterInstancesWithLoadBalancerRequest registerInstancesWithLoadBalancerRequest, CancellationToken cancellationToken = default(CancellationToken))
        {
            var marshaller = new RegisterInstancesWithLoadBalancerRequestMarshaller();
            var unmarshaller = RegisterInstancesWithLoadBalancerResponseUnmarshaller.GetInstance();
            var response = await Invoke<IRequest, RegisterInstancesWithLoadBalancerRequest, RegisterInstancesWithLoadBalancerResponse>(registerInstancesWithLoadBalancerRequest, marshaller, unmarshaller, signer, cancellationToken)
                .ConfigureAwait(continueOnCapturedContext: false);
            return response;
        }
コード例 #9
0
		internal RegisterInstancesWithLoadBalancerResponse RegisterInstancesWithLoadBalancer(RegisterInstancesWithLoadBalancerRequest request)
        {
            var task = RegisterInstancesWithLoadBalancerAsync(request);
            try
            {
                return task.Result;
            }
            catch(AggregateException e)
            {
                throw e.InnerException;
            }
        }
 private Amazon.ElasticLoadBalancing.Model.RegisterInstancesWithLoadBalancerResponse CallAWSServiceOperation(IAmazonElasticLoadBalancing client, Amazon.ElasticLoadBalancing.Model.RegisterInstancesWithLoadBalancerRequest request)
 {
     Utils.Common.WriteVerboseEndpointMessage(this, client.Config, "Elastic Load Balancing", "RegisterInstancesWithLoadBalancer");
     try
     {
         #if DESKTOP
         return(client.RegisterInstancesWithLoadBalancer(request));
         #elif CORECLR
         return(client.RegisterInstancesWithLoadBalancerAsync(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;
     }
 }
コード例 #11
0
 /// <summary>
 /// <para> Adds new instances to the LoadBalancer. </para> <para> Once the
 /// instance is registered, it starts receiving traffic and requests from
 /// the LoadBalancer. Any instance that is not in any of the Availability
 /// Zones registered for the LoadBalancer will be moved to the
 /// <i>OutOfService</i> state. It will move to the <i>InService</i> state
 /// when the Availability Zone is added to the LoadBalancer. </para>
 /// <para><b>NOTE:</b> In order for this call to be successful, the client
 /// must have created the LoadBalancer. The client must provide the same
 /// account credentials as those that were used to create the
 /// LoadBalancer. </para> <para><b>NOTE:</b> Completion of this API does
 /// not guarantee that operation has completed. Rather, it means that the
 /// request has been registered and the changes will happen shortly.
 /// </para>
 /// </summary>
 /// 
 /// <param name="registerInstancesWithLoadBalancerRequest">Container for
 ///           the necessary parameters to execute the
 ///           RegisterInstancesWithLoadBalancer service method on
 ///           AmazonElasticLoadBalancing.</param>
 /// 
 /// <returns>The response from the RegisterInstancesWithLoadBalancer
 ///         service method, as returned by AmazonElasticLoadBalancing.</returns>
 /// 
 /// <exception cref="InvalidInstanceException"/>
 /// <exception cref="LoadBalancerNotFoundException"/>
 public RegisterInstancesWithLoadBalancerResponse RegisterInstancesWithLoadBalancer(RegisterInstancesWithLoadBalancerRequest registerInstancesWithLoadBalancerRequest)
 {
     IRequest<RegisterInstancesWithLoadBalancerRequest> request = new RegisterInstancesWithLoadBalancerRequestMarshaller().Marshall(registerInstancesWithLoadBalancerRequest);
     RegisterInstancesWithLoadBalancerResponse response = Invoke<RegisterInstancesWithLoadBalancerRequest, RegisterInstancesWithLoadBalancerResponse> (request, this.signer, RegisterInstancesWithLoadBalancerResponseUnmarshaller.GetInstance());
     return response;
 }
コード例 #12
0
        /// <summary>
        /// Initiates the asynchronous execution of the RegisterInstancesWithLoadBalancer operation.
        /// <seealso cref="Amazon.ElasticLoadBalancing.IAmazonElasticLoadBalancing.RegisterInstancesWithLoadBalancer"/>
        /// </summary>
        /// 
        /// <param name="request">Container for the necessary parameters to execute the RegisterInstancesWithLoadBalancer 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<RegisterInstancesWithLoadBalancerResponse> RegisterInstancesWithLoadBalancerAsync(RegisterInstancesWithLoadBalancerRequest request, CancellationToken cancellationToken = default(CancellationToken))
        {
            var marshaller = new RegisterInstancesWithLoadBalancerRequestMarshaller();
            var unmarshaller = RegisterInstancesWithLoadBalancerResponseUnmarshaller.GetInstance();
            return Invoke<IRequest, RegisterInstancesWithLoadBalancerRequest, RegisterInstancesWithLoadBalancerResponse>(request, marshaller, unmarshaller, signer, cancellationToken);
        }
コード例 #13
0
        /// <summary>
        /// <para> Adds new instances to the load balancer. </para> <para> Once the instance is registered, it starts receiving traffic and requests
        /// from the load balancer. Any instance that is not in any of the Availability Zones registered for the load balancer will be moved to the
        /// <i>OutOfService</i> state. It will move to the <i>InService</i> state when the Availability Zone is added to the load balancer. </para>
        /// <para>When an instance registered with a load balancer is stopped and then restarted, the IP addresses associated with the instance changes.
        /// Elastic Load Balancing cannot recognize the new IP address, which prevents it from routing traffic to the instances. We recommend that you
        /// de-register your Amazon EC2 instances from your load balancer after you stop your instance, and then register the load balancer with your
        /// instance after you've restarted. To de-register your instances from load balancer, use DeregisterInstancesFromLoadBalancer action.</para>
        /// <para>For more information, see <a href="http://docs.aws.amazon.com/ElasticLoadBalancing/latest/DeveloperGuide/US_DeReg_Reg_Instances.html">De-register and Register Amazon EC2 Instances</a> in the <i>Elastic Load Balancing Developer Guide</i> .</para> <para><b>NOTE:</b> In order
        /// for this call to be successful, you must provide the same account credentials as those that were used to create the load balancer. </para>
        /// <para><b>NOTE:</b> Completion of this API does not guarantee that operation has completed. Rather, it means that the request has been
        /// registered and the changes will happen shortly. </para> <para>You can use DescribeLoadBalancers or DescribeInstanceHealth action to check
        /// the state of the newly registered instances.</para>
        /// </summary>
        /// 
        /// <param name="request">Container for the necessary parameters to execute the
        /// RegisterInstancesWithLoadBalancer service method on AmazonElasticLoadBalancing.</param>
        /// 
        /// <returns>The response from the RegisterInstancesWithLoadBalancer service method, as returned by AmazonElasticLoadBalancing.</returns>
        /// 
        /// <exception cref="T:Amazon.ElasticLoadBalancing.Model.LoadBalancerNotFoundException" />
        /// <exception cref="T:Amazon.ElasticLoadBalancing.Model.InvalidInstanceException" />
		public RegisterInstancesWithLoadBalancerResponse RegisterInstancesWithLoadBalancer(RegisterInstancesWithLoadBalancerRequest request)
        {
            var task = RegisterInstancesWithLoadBalancerAsync(request);
            try
            {
                return task.Result;
            }
            catch(AggregateException e)
            {
                ExceptionDispatchInfo.Capture(e.InnerException).Throw();
                return null;
            }
        }
コード例 #14
0
        IAsyncResult invokeRegisterInstancesWithLoadBalancer(RegisterInstancesWithLoadBalancerRequest request, AsyncCallback callback, object state, bool synchronized)
        {
            var marshaller = new RegisterInstancesWithLoadBalancerRequestMarshaller();
            var unmarshaller = RegisterInstancesWithLoadBalancerResponseUnmarshaller.Instance;

            return Invoke(request, callback, state, synchronized, marshaller, unmarshaller, signer);
        }
コード例 #15
0
        /// <summary>
        /// Initiates the asynchronous execution of the RegisterInstancesWithLoadBalancer operation.
        /// <seealso cref="Amazon.ElasticLoadBalancing.IAmazonElasticLoadBalancing"/>
        /// </summary>
        /// 
        /// <param name="request">Container for the necessary parameters to execute the RegisterInstancesWithLoadBalancer operation on AmazonElasticLoadBalancingClient.</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 EndRegisterInstancesWithLoadBalancer
        ///         operation.</returns>
        public IAsyncResult BeginRegisterInstancesWithLoadBalancer(RegisterInstancesWithLoadBalancerRequest request, AsyncCallback callback, object state)
        {
            var marshaller = new RegisterInstancesWithLoadBalancerRequestMarshaller();
            var unmarshaller = RegisterInstancesWithLoadBalancerResponseUnmarshaller.Instance;

            return BeginInvoke<RegisterInstancesWithLoadBalancerRequest>(request, marshaller, unmarshaller,
                callback, state);
        }
コード例 #16
0
            /// <summary>
            /// Adds new instances to the load balancer.
            /// Once the instance is registered, it starts receiving traffic and requests from the load balancer. 
            /// Any instance that is not in any of the Availability Zones registered for the load balancer will be moved to the OutOfService state. 
            /// It will move to the InService state when the Availability Zone is added to the load balancer.
            /// </summary>
            /// <param name="loadBalancer">The name associated with the load balancer.</param>
            /// <param name="instances">A list of instance IDs that should be registered with the load balancer.</param>
            /// <param name="settings">The <see cref="LoadBalancingSettings"/> used during the request to AWS.</param>
            public bool RegisterInstances(string loadBalancer, IList<string> instances, LoadBalancingSettings settings)
            {
                if (String.IsNullOrEmpty(loadBalancer))
                {
                    throw new ArgumentNullException("loadBalancer");
                }
                if ((instances == null) || (instances.Count == 0))
                {
                    throw new ArgumentNullException("instances");
                }



                //Create Request
                AmazonElasticLoadBalancingClient client = this.CreateClient(settings);
                RegisterInstancesWithLoadBalancerRequest request = new RegisterInstancesWithLoadBalancerRequest();

                request.LoadBalancerName = loadBalancer;

                foreach (string instance in instances)
                {
                    request.Instances.Add(new Instance(instance));
                }



                //Check Response
                RegisterInstancesWithLoadBalancerResponse response = client.RegisterInstancesWithLoadBalancer(request);

                if (response.HttpStatusCode == HttpStatusCode.OK)
                {
                    _Log.Verbose("Successfully registered instances '{0}'", string.Join(",", instances));
                    return true;
                }
                else
                {
                    _Log.Error("Failed to register instances '{0}'", string.Join(",", instances));
                    return false;
                }
            }