Exemplo n.º 1
0
 /// <inheritdoc/>
 public override int GetHashCode()
 {
     unchecked
     {
         return((SubnetId.GetHashCode() * 397) ^ (IPAddress != null ? IPAddress.GetHashCode() : 0));
     }
 }
Exemplo n.º 2
0
        public override int GetHashCode()
        {
            int hash = 1;

            if (SubnetId.Length != 0)
            {
                hash ^= SubnetId.GetHashCode();
            }
            if (Address.Length != 0)
            {
                hash ^= Address.GetHashCode();
            }
            if (_unknownFields != null)
            {
                hash ^= _unknownFields.GetHashCode();
            }
            return(hash);
        }
Exemplo n.º 3
0
        private void HandleManagedIntegrationRuntime(ManagedIntegrationRuntime integrationRuntime)
        {
            if (!string.IsNullOrWhiteSpace(Location))
            {
                if (integrationRuntime.ComputeProperties == null)
                {
                    integrationRuntime.ComputeProperties = new IntegrationRuntimeComputeProperties();
                }

                integrationRuntime.ComputeProperties.Location = Location;
            }

            if (!string.IsNullOrWhiteSpace(NodeSize))
            {
                if (integrationRuntime.ComputeProperties == null)
                {
                    integrationRuntime.ComputeProperties = new IntegrationRuntimeComputeProperties();
                }

                integrationRuntime.ComputeProperties.NodeSize = NodeSize;
            }

            if (NodeCount.HasValue)
            {
                if (integrationRuntime.ComputeProperties == null)
                {
                    integrationRuntime.ComputeProperties = new IntegrationRuntimeComputeProperties();
                }

                integrationRuntime.ComputeProperties.NumberOfNodes = NodeCount;

                if (integrationRuntime.SsisProperties == null)
                {
                    integrationRuntime.SsisProperties = new IntegrationRuntimeSsisProperties();
                }
            }

            if (MaxParallelExecutionsPerNode.HasValue)
            {
                if (integrationRuntime.ComputeProperties == null)
                {
                    integrationRuntime.ComputeProperties = new IntegrationRuntimeComputeProperties();
                }

                integrationRuntime.ComputeProperties.MaxParallelExecutionsPerNode = MaxParallelExecutionsPerNode;
            }

            if (!string.IsNullOrWhiteSpace(CatalogServerEndpoint))
            {
                if (integrationRuntime.SsisProperties == null)
                {
                    integrationRuntime.SsisProperties = new IntegrationRuntimeSsisProperties()
                    {
                        CatalogInfo = new IntegrationRuntimeSsisCatalogInfo()
                    };
                }
                else if (integrationRuntime.SsisProperties.CatalogInfo == null)
                {
                    integrationRuntime.SsisProperties.CatalogInfo = new IntegrationRuntimeSsisCatalogInfo();
                }

                integrationRuntime.SsisProperties.CatalogInfo.CatalogServerEndpoint = CatalogServerEndpoint;
            }

            if (CatalogAdminCredential != null)
            {
                if (integrationRuntime.SsisProperties == null)
                {
                    integrationRuntime.SsisProperties = new IntegrationRuntimeSsisProperties()
                    {
                        CatalogInfo = new IntegrationRuntimeSsisCatalogInfo()
                    };
                }
                else if (integrationRuntime.SsisProperties.CatalogInfo == null)
                {
                    integrationRuntime.SsisProperties.CatalogInfo = new IntegrationRuntimeSsisCatalogInfo();
                }

                integrationRuntime.SsisProperties.CatalogInfo.CatalogAdminUserName = CatalogAdminCredential.UserName;
                var passWord = ConvertToUnsecureString(CatalogAdminCredential.Password);
                if (passWord != null && passWord.Length > 128)
                {
                    throw new PSArgumentException("The password exceeds maximum length of '128'", "CatalogAdminCredential");
                }
                integrationRuntime.SsisProperties.CatalogInfo.CatalogAdminPassword = new SecureString(passWord);
            }

            if (!string.IsNullOrWhiteSpace(CatalogPricingTier))
            {
                if (integrationRuntime.SsisProperties == null)
                {
                    integrationRuntime.SsisProperties = new IntegrationRuntimeSsisProperties()
                    {
                        CatalogInfo = new IntegrationRuntimeSsisCatalogInfo()
                    };
                }
                else if (integrationRuntime.SsisProperties.CatalogInfo == null)
                {
                    integrationRuntime.SsisProperties.CatalogInfo = new IntegrationRuntimeSsisCatalogInfo();
                }

                integrationRuntime.SsisProperties.CatalogInfo.CatalogPricingTier = CatalogPricingTier;
            }

            if (!string.IsNullOrWhiteSpace(SubnetId))
            {
                // When subnetId as VNet property of Azure - SSIS integration runtime is provided, the other subnet and vnetId properties must be empty.
                if (!string.IsNullOrWhiteSpace(VNetId) || !string.IsNullOrWhiteSpace(Subnet))
                {
                    throw new PSArgumentException(string.Format(
                                                      CultureInfo.InvariantCulture,
                                                      Resources.AzureSSISIRSubnetAndVnetIdMustBeEmpty));
                }

                integrationRuntime.ComputeProperties.VNetProperties = new IntegrationRuntimeVNetProperties
                {
                    SubnetId = SubnetId
                };
            }
            else if (string.IsNullOrWhiteSpace(VNetId) ^ string.IsNullOrWhiteSpace(Subnet))
            {
                // Only one of the two pramaters is set
                throw new PSArgumentException(string.Format(
                                                  CultureInfo.InvariantCulture,
                                                  Resources.IntegrationRuntimeInvalidVnet),
                                              "Type");
            }

            if (integrationRuntime.ComputeProperties?.VNetProperties == null ||
                (string.IsNullOrWhiteSpace(integrationRuntime.ComputeProperties.VNetProperties.VNetId) &&
                 string.IsNullOrWhiteSpace(integrationRuntime.ComputeProperties.VNetProperties.Subnet) &&
                 string.IsNullOrWhiteSpace(integrationRuntime.ComputeProperties.VNetProperties.SubnetId)))
            {
                // When no previous VNet set, subnetId or both VNetId and Subnet must be present
                if (!string.IsNullOrWhiteSpace(SubnetId))
                {
                    integrationRuntime.ComputeProperties.VNetProperties = new IntegrationRuntimeVNetProperties
                    {
                        SubnetId = SubnetId
                    };
                }
                else if (!string.IsNullOrWhiteSpace(VNetId) && !string.IsNullOrWhiteSpace(Subnet))
                {
                    // Both VNetId and Subnet are set
                    if (integrationRuntime.ComputeProperties == null)
                    {
                        integrationRuntime.ComputeProperties = new IntegrationRuntimeComputeProperties();
                    }

                    integrationRuntime.ComputeProperties.VNetProperties = new IntegrationRuntimeVNetProperties()
                    {
                        VNetId = VNetId,
                        Subnet = Subnet
                    };
                }
            }
            else
            {
                // We have VNet properties set, then we are able to change VNetId or Subnet individually now.
                // Could be empty. If user input empty, then convert it to null. If user want to remove VNet settings, input both with empty string.
                if (VNetId != null)
                {
                    integrationRuntime.ComputeProperties.VNetProperties.VNetId = VNetId.IsEmptyOrWhiteSpace() ? null : VNetId;
                }
                if (Subnet != null)
                {
                    integrationRuntime.ComputeProperties.VNetProperties.Subnet = Subnet.IsEmptyOrWhiteSpace() ? null : Subnet;
                }
                if (SubnetId != null)
                {
                    integrationRuntime.ComputeProperties.VNetProperties.SubnetId = SubnetId.IsEmptyOrWhiteSpace() ? null : SubnetId;
                }

                // Make sure both VNetId and Subnet are present, or both null
                if (string.IsNullOrWhiteSpace(integrationRuntime.ComputeProperties.VNetProperties.VNetId)
                    ^ string.IsNullOrWhiteSpace(integrationRuntime.ComputeProperties.VNetProperties.Subnet))
                {
                    throw new PSArgumentException(string.Format(
                                                      CultureInfo.InvariantCulture,
                                                      Resources.IntegrationRuntimeInvalidVnet),
                                                  "Type");
                }
            }

            if (!string.IsNullOrWhiteSpace(DataFlowComputeType) || DataFlowCoreCount != null || DataFlowTimeToLive != null)
            {
                if (integrationRuntime.ComputeProperties == null)
                {
                    integrationRuntime.ComputeProperties = new IntegrationRuntimeComputeProperties();
                }
                if (integrationRuntime.ComputeProperties.DataFlowProperties == null)
                {
                    integrationRuntime.ComputeProperties.DataFlowProperties = new IntegrationRuntimeDataFlowProperties();
                }

                integrationRuntime.ComputeProperties.DataFlowProperties.ComputeType = DataFlowComputeType ?? integrationRuntime.ComputeProperties.DataFlowProperties.ComputeType;
                integrationRuntime.ComputeProperties.DataFlowProperties.CoreCount   = DataFlowCoreCount ?? integrationRuntime.ComputeProperties.DataFlowProperties.CoreCount;
                integrationRuntime.ComputeProperties.DataFlowProperties.TimeToLive  = DataFlowTimeToLive ?? integrationRuntime.ComputeProperties.DataFlowProperties.TimeToLive;
            }

            if (PublicIPs != null)
            {
                if (string.IsNullOrWhiteSpace(VNetId) && string.IsNullOrWhiteSpace(SubnetId))
                {
                    throw new PSArgumentException(string.Format(
                                                      CultureInfo.InvariantCulture,
                                                      Resources.IntegrationRuntimeSubnetNotProvided),
                                                  "SubnetId");
                }

                if (PublicIPs.Length != 2)
                {
                    throw new PSArgumentException(string.Format(
                                                      CultureInfo.InvariantCulture,
                                                      Resources.InvalidPublicIPCount),
                                                  "PublicIPs");
                }

                integrationRuntime.ComputeProperties.VNetProperties.PublicIPs = PublicIPs;
            }

            if (!string.IsNullOrWhiteSpace(LicenseType))
            {
                if (integrationRuntime.SsisProperties == null)
                {
                    integrationRuntime.SsisProperties = new IntegrationRuntimeSsisProperties();
                }

                integrationRuntime.SsisProperties.LicenseType = LicenseType;
            }

            if (!string.IsNullOrEmpty(SetupScriptContainerSasUri))
            {
                if (integrationRuntime.SsisProperties == null)
                {
                    integrationRuntime.SsisProperties = new IntegrationRuntimeSsisProperties();
                }

                int index = SetupScriptContainerSasUri.IndexOf('?');

                integrationRuntime.SsisProperties.CustomSetupScriptProperties = new IntegrationRuntimeCustomSetupScriptProperties()
                {
                    BlobContainerUri = index >= 0 ? SetupScriptContainerSasUri.Substring(0, index) : SetupScriptContainerSasUri,
                    SasToken         = index >= 0 ? new SecureString(SetupScriptContainerSasUri.Substring(index)) : null
                };
            }

            if (ExpressCustomSetup != null && ExpressCustomSetup.ToArray().Length > 0)
            {
                if (integrationRuntime.SsisProperties == null)
                {
                    integrationRuntime.SsisProperties = new IntegrationRuntimeSsisProperties();
                }
                System.Collections.Generic.IList <CustomSetupBase> setups = new System.Collections.Generic.List <CustomSetupBase>();
                foreach (CustomSetupBase setup in ExpressCustomSetup)
                {
                    setups.Add(setup);
                }
                integrationRuntime.SsisProperties.ExpressCustomSetupProperties = setups;
            }

            if (!string.IsNullOrEmpty(DataProxyIntegrationRuntimeName))
            {
                if (integrationRuntime.SsisProperties == null)
                {
                    integrationRuntime.SsisProperties = new IntegrationRuntimeSsisProperties();
                }
                if (integrationRuntime.SsisProperties.DataProxyProperties == null)
                {
                    integrationRuntime.SsisProperties.DataProxyProperties = new IntegrationRuntimeDataProxyProperties();
                }
                integrationRuntime.SsisProperties.DataProxyProperties.ConnectVia = new EntityReference("IntegrationRuntimeReference", DataProxyIntegrationRuntimeName);
            }

            if (!string.IsNullOrEmpty(DataProxyStagingLinkedServiceName))
            {
                if (integrationRuntime.SsisProperties == null)
                {
                    integrationRuntime.SsisProperties = new IntegrationRuntimeSsisProperties();
                }
                if (integrationRuntime.SsisProperties.DataProxyProperties == null)
                {
                    integrationRuntime.SsisProperties.DataProxyProperties = new IntegrationRuntimeDataProxyProperties();
                }
                integrationRuntime.SsisProperties.DataProxyProperties.StagingLinkedService = new EntityReference("LinkedServiceReference", DataProxyStagingLinkedServiceName);
            }

            if (!string.IsNullOrEmpty(DataProxyStagingPath))
            {
                if (integrationRuntime.SsisProperties == null)
                {
                    integrationRuntime.SsisProperties = new IntegrationRuntimeSsisProperties();
                }
                if (integrationRuntime.SsisProperties.DataProxyProperties == null)
                {
                    integrationRuntime.SsisProperties.DataProxyProperties = new IntegrationRuntimeDataProxyProperties();
                }
                integrationRuntime.SsisProperties.DataProxyProperties.Path = DataProxyStagingPath;
            }

            if (!string.IsNullOrEmpty(Edition))
            {
                if (integrationRuntime.SsisProperties == null)
                {
                    integrationRuntime.SsisProperties = new IntegrationRuntimeSsisProperties();
                }

                integrationRuntime.SsisProperties.Edition = Edition;
            }

            integrationRuntime.Validate();
        }