Exemple #1
0
        protected PSArgument[] CreateVirtualMachineUpdateLoadBalancedEndpointSetParameters()
        {
            string serviceName    = string.Empty;
            string deploymentName = string.Empty;
            VirtualMachineUpdateLoadBalancedSetParameters parameters = new VirtualMachineUpdateLoadBalancedSetParameters();

            return(ConvertFromObjectsToArguments(new string[] { "ServiceName", "DeploymentName", "Parameters" }, new object[] { serviceName, deploymentName, parameters }));
        }
Exemple #2
0
        protected void ExecuteVirtualMachineUpdateLoadBalancedEndpointSetMethod(object[] invokeMethodInputParameters)
        {
            string serviceName    = (string)ParseParameter(invokeMethodInputParameters[0]);
            string deploymentName = (string)ParseParameter(invokeMethodInputParameters[1]);
            VirtualMachineUpdateLoadBalancedSetParameters parameters = (VirtualMachineUpdateLoadBalancedSetParameters)ParseParameter(invokeMethodInputParameters[2]);

            var result = VirtualMachineClient.UpdateLoadBalancedEndpointSet(serviceName, deploymentName, parameters);

            WriteObject(result);
        }
Exemple #3
0
        protected override void ExecuteCommand()
        {
            ServiceManagementProfile.Initialize();

            base.ExecuteCommand();
            if (string.IsNullOrEmpty(this.ServiceName) || this.CurrentDeploymentNewSM == null)
            {
                return;
            }

            var endpoint = this.GetEndpoint();

            if (endpoint == null)
            {
                this.ThrowTerminatingError(
                    new ErrorRecord(
                        new InvalidOperationException(
                            string.Format(
                                CultureInfo.InvariantCulture,
                                Resources.EndpointsCannotBeFoundWithGivenLBSetName,
                                this.LBSetName)),
                        string.Empty,
                        ErrorCategory.InvalidData,
                        null));
            }

            this.UpdateEndpointProperties(endpoint);

            var endpointList = new LoadBalancedEndpointList();

            endpointList.Add(endpoint);

            var endPointParams = new VirtualMachineUpdateLoadBalancedSetParameters
            {
                //TODO: AutoMapper doesn't seem to work for this conversion.
                //LoadBalancedEndpoints = Mapper.Map<IList<VirtualMachineUpdateLoadBalancedSetParameters.InputEndpoint>>(endpointList)
                LoadBalancedEndpoints = new int[1].Select(e => new VirtualMachineUpdateLoadBalancedSetParameters.InputEndpoint
                {
                    EnableDirectServerReturn    = endpoint.EnableDirectServerReturn,
                    LoadBalancedEndpointSetName = endpoint.LoadBalancedEndpointSetName,
                    LoadBalancerProbe           = endpoint.LoadBalancerProbe == null ? null : new NSM.LoadBalancerProbe
                    {
                        IntervalInSeconds = endpoint.LoadBalancerProbe.IntervalInSeconds,
                        Path             = endpoint.LoadBalancerProbe.Path,
                        Port             = endpoint.LoadBalancerProbe.Port,
                        Protocol         = (LoadBalancerProbeTransportProtocol)Enum.Parse(typeof(LoadBalancerProbeTransportProtocol), endpoint.LoadBalancerProbe.Protocol, true),
                        TimeoutInSeconds = endpoint.LoadBalancerProbe.TimeoutInSeconds
                    },
                    LocalPort = endpoint.LocalPort,
                    Name      = endpoint.Name,
                    Port      = endpoint.Port,
                    Protocol  = endpoint.Protocol,
                    Rules     = endpoint.EndpointAccessControlList == null ? null : endpoint.EndpointAccessControlList.Rules == null ? null : endpoint.EndpointAccessControlList.Rules.Select(r => new NSM.AccessControlListRule
                    {
                        Action       = r.Action,
                        Description  = r.Description,
                        Order        = r.Order,
                        RemoteSubnet = r.RemoteSubnet
                    }).ToList(),
                    VirtualIPAddress = endpoint.Vip,
                    LoadBalancerName = this.InternalLoadBalancerName
                }).ToList()
            };

            this.ExecuteClientActionNewSM(
                null,
                this.CommandRuntime.ToString(),
                () => this.ComputeClient.VirtualMachines.UpdateLoadBalancedEndpointSet(this.ServiceName, this.CurrentDeploymentNewSM.Name, endPointParams));
        }