protected Collection<InputEndpointContext> GetInputEndpoints() { PersistentVM instance = base.VM.GetInstance(); NetworkConfigurationSet networkConfigurationSet = instance.ConfigurationSets.OfType<NetworkConfigurationSet>().SingleOrDefault<NetworkConfigurationSet>(); if (networkConfigurationSet == null) { networkConfigurationSet = new NetworkConfigurationSet(); instance.ConfigurationSets.Add(networkConfigurationSet); } if (networkConfigurationSet.InputEndpoints == null) { networkConfigurationSet.InputEndpoints = new Collection<InputEndpoint>(); } Collection<InputEndpoint> inputEndpoints = networkConfigurationSet.InputEndpoints; Collection<InputEndpointContext> inputEndpointContexts = new Collection<InputEndpointContext>(); foreach (InputEndpoint inputEndpoint in inputEndpoints) { InputEndpointContext inputEndpointContext = new InputEndpointContext(); inputEndpointContext.LBSetName = inputEndpoint.LoadBalancedEndpointSetName; inputEndpointContext.LocalPort = inputEndpoint.LocalPort; inputEndpointContext.Name = inputEndpoint.Name; inputEndpointContext.Port = inputEndpoint.Port; inputEndpointContext.Protocol = inputEndpoint.Protocol; inputEndpointContext.Vip = inputEndpoint.Vip; if (inputEndpoint.LoadBalancerProbe != null && !string.IsNullOrEmpty(inputEndpointContext.LBSetName)) { inputEndpointContext.ProbePath = inputEndpoint.LoadBalancerProbe.Path; inputEndpointContext.ProbePort = inputEndpoint.LoadBalancerProbe.Port; inputEndpointContext.ProbeProtocol = inputEndpoint.LoadBalancerProbe.Protocol; } inputEndpointContexts.Add(inputEndpointContext); } return inputEndpointContexts; }
public bool CheckInputEndpointContext(InputEndpointContext context) { bool ret = context.Protocol == this.EndpointProtocol.ToString() && context.LocalPort == this.EndpointLocalPort && context.Port == this.EndpointPublicPort && context.Name == this.EndpointName; if (ParamSet == ParameterSet.LoadBalanced) { ret = ret && context.LBSetName == this.LBSetName; } if (ParamSet == ParameterSet.LoadBalancedProbe) { ret = ret && context.LBSetName == this.LBSetName && context.ProbePort == this.ProbePort && context.ProbeProtocol == this.ProbeProtocol.ToString(); ret = ret && ( this.ProbeInterval.HasValue ? context.ProbeIntervalInSeconds == this.ProbeInterval : context.ProbeIntervalInSeconds == 15 ); ret = ret && ( this.ProbeTimeout.HasValue ? context.ProbeTimeoutInSeconds == this.ProbeTimeout : context.ProbeTimeoutInSeconds == 31 ); } return ret; }
public bool CheckInputEndpointContext(InputEndpointContext context) { bool ret = false; if (ParamSet == ParameterSet.NoLB) { ret = (context.Name == this.EndpointName); } else { ret = (context.LBSetName == this.LBSetName); } ret = ret && context.Protocol == this.EndpointProtocol.ToString() && context.LocalPort == this.EndpointLocalPort && context.Port == this.EndpointPublicPort && context.EnableDirectServerReturn == this.DirectServerReturn; if(context.Acl == null) { if(this.Acl != null && this.Acl != new NetworkAclObject()) { ret = false; } } else if (this.Acl != null) { foreach (var rule in this.Acl) { if(!context.Acl.Rules.Contains(rule)) { ret = false; } } } else { ret = false; } if (ParamSet == ParameterSet.CustomProbe) { ret = ret && context.LBSetName == this.LBSetName && context.ProbePort == this.ProbePort && context.ProbeProtocol == this.ProbeProtocol.ToString(); ret = ret && ( this.ProbeInterval.HasValue ? context.ProbeIntervalInSeconds == this.ProbeInterval : context.ProbeIntervalInSeconds == 15 ); ret = ret && ( this.ProbeTimeout.HasValue ? context.ProbeTimeoutInSeconds == this.ProbeTimeout : context.ProbeTimeoutInSeconds == 31 ); } return ret; }