• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    迪恩网络公众号

C# Extensions.ExtensionConfigurationInput类代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

本文整理汇总了C#中Microsoft.WindowsAzure.Commands.ServiceManagement.Extensions.ExtensionConfigurationInput的典型用法代码示例。如果您正苦于以下问题:C# ExtensionConfigurationInput类的具体用法?C# ExtensionConfigurationInput怎么用?C# ExtensionConfigurationInput使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。



ExtensionConfigurationInput类属于Microsoft.WindowsAzure.Commands.ServiceManagement.Extensions命名空间,在下文中一共展示了ExtensionConfigurationInput类的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的C#代码示例。

示例1: ExecuteCommand

        public void ExecuteCommand()
        {
            InitializeAntimalwareSettings();
            ValidateParameters();

            RemoveAntimalwareExtension();
            RemoveExistingAntimalwareMonitoringConfig();

            ExtensionConfigurationInput[] extConfigInputs = null;
            if (AntimalwareExtensionConfigurationInput != null && AntimalwareMonitoringExtensionConfigurationInput != null)
            {
                extConfigInputs = new ExtensionConfigurationInput[2];
                extConfigInputs[0] = AntimalwareMonitoringExtensionConfigurationInput;
                extConfigInputs[1] = AntimalwareExtensionConfigurationInput;
            }
            else if (AntimalwareExtensionConfigurationInput != null)
            {
                extConfigInputs = new ExtensionConfigurationInput[1];
                extConfigInputs[0] = AntimalwareExtensionConfigurationInput;
            }
            else if (AntimalwareMonitoringExtensionConfigurationInput != null)
            {
                extConfigInputs = new ExtensionConfigurationInput[1];
                extConfigInputs[0] = AntimalwareMonitoringExtensionConfigurationInput;
            }

            // process any pending deployment changes
            if (extConfigInputs != null)
            {
                ExtensionConfiguration newExtConfig = ExtensionManager.Add(Deployment, extConfigInputs, Slot);
                ChangeDeployment(newExtConfig);
            }
        }
开发者ID:kangyangthu,项目名称:azure-sdk-tools,代码行数:33,代码来源:RemoveAzureServiceAntimalwareExtension.cs


示例2: NewAzureDeploymentCmdletInfo

        public NewAzureDeploymentCmdletInfo(string serviceName, string packagePath, string configName, string slot,
            string label, string name, bool doNotStart, bool warning, ExtensionConfigurationInput config)
    {
        cmdletName = Utilities.NewAzureDeploymentCmdletName;

        cmdletParams.Add(new CmdletParam("ServiceName", serviceName));
        cmdletParams.Add(new CmdletParam("Package", packagePath));
        cmdletParams.Add(new CmdletParam("Configuration", configName));
        cmdletParams.Add(new CmdletParam("Slot", slot));

        if (label != null)
        {
            cmdletParams.Add(new CmdletParam("Label", label));
        }
        if (name != null)
        {
            cmdletParams.Add(new CmdletParam("Name", name));
        }
        if (doNotStart)
        {
            cmdletParams.Add(new CmdletParam("DoNotStart"));
        }
        if (warning)
        {
            cmdletParams.Add(new CmdletParam("TreatWarningsAsError"));
        }
        if (config != null)
        {
            cmdletParams.Add(new CmdletParam("ExtensionConfiguration", config));
        }
    }
开发者ID:FrankSiegemund,项目名称:azure-powershell,代码行数:31,代码来源:NewAzureDeploymentCmdletInfo.cs


示例3: SetAzureDeploymentConfigCmdletInfo

        public static SetAzureDeploymentCmdletInfo SetAzureDeploymentConfigCmdletInfo(string serviceName, string slot, string configPath, ExtensionConfigurationInput extConfig = null)
        {
            SetAzureDeploymentCmdletInfo result = new SetAzureDeploymentCmdletInfo(serviceName, slot);

            result.cmdletParams.Add(new CmdletParam("Config"));
            result.cmdletParams.Add(new CmdletParam("Configuration", configPath));

            if (extConfig != null)
            {
                result.cmdletParams.Add(new CmdletParam("ExtensionConfiguration", extConfig));
            }

            return result;
        }
开发者ID:FrankSiegemund,项目名称:azure-powershell,代码行数:14,代码来源:SetAzureDeploymentCmdletInfo.cs


示例4: InstallExtension

        public ExtensionConfiguration InstallExtension(ExtensionConfigurationInput context, string slot,
            DeploymentGetResponse deployment, DeploymentGetResponse peerDeployment)
        {
            Func<DeploymentGetResponse, ExtensionConfiguration> func = (d) => d == null ? null : d.ExtensionConfiguration;

            ExtensionConfiguration extConfig = func(deployment);
            ExtensionConfiguration secondSlotExtConfig = func(peerDeployment);

            return InstallExtension(context, slot, extConfig, secondSlotExtConfig);
        }
开发者ID:rturnage,项目名称:azure-powershell,代码行数:10,代码来源:ExtensionManager.cs


示例5: AddNewAntimalwareMonitoringConfig

 private void AddNewAntimalwareMonitoringConfig()
 {
     // install diagnostics provider with a new antimalware event monitoring config
     InitializeDiagnosticsSettings();
     ExtensionConfigurationInput diagExtConfigInput = new ExtensionConfigurationInput
     {
         ProviderNameSpace = ProviderNamespace,
         Type = ExtensionName,
         CertificateThumbprint = CertificateThumbprint,
         ThumbprintAlgorithm = ThumbprintAlgorithm,
         X509Certificate = X509Certificate,
         PublicConfiguration = PublicConfiguration,
         PrivateConfiguration = PrivateConfiguration,
         Roles = new ExtensionRoleList(Role != null && Role.Any() ? Role.Select(r => new ExtensionRole(r)) : Enumerable.Repeat(new ExtensionRole(), 1))
     };
     AntimalwareMonitoringExtensionConfigurationInput = diagExtConfigInput;
 }
开发者ID:B-Rich,项目名称:azure-sdk-tools,代码行数:17,代码来源:SetAzureServiceAntimalwareExtension.cs


示例6: ExecuteCommand

        public void ExecuteCommand()
        {
            ValidateParameters();

            // set diagnostics extension
            switch (monitoringAction)
            {
                case MonitoringActionType.Enable : EnableMonitoring(); break;
                case MonitoringActionType.Disable : RemoveExistingAntimalwareMonitoringConfig(); break;
                default: break;
            }

            // set antimalware extension 
            InitializeAntimalwareSettings();
            ExtensionConfigurationInput amExtConfigInput = new ExtensionConfigurationInput
            {
                ProviderNameSpace = ProviderNamespace,
                Type = ExtensionName,
                PublicConfiguration = PublicConfiguration,
                PrivateConfiguration = PrivateConfiguration,
                Roles = new ExtensionRoleList(Role != null && Role.Any() ? Role.Select(r => new ExtensionRole(r)) : Enumerable.Repeat(new ExtensionRole(), 1))
            };
            AntimalwareExtensionConfigurationInput = amExtConfigInput;

            ExtensionConfigurationInput[] extConfigInputs = null;
            if (AntimalwareExtensionConfigurationInput != null && AntimalwareMonitoringExtensionConfigurationInput != null)
            {
                extConfigInputs = new ExtensionConfigurationInput[2];
                extConfigInputs[0] = AntimalwareMonitoringExtensionConfigurationInput;
                extConfigInputs[1] = AntimalwareExtensionConfigurationInput;
            }
            else if (AntimalwareExtensionConfigurationInput != null)
            {
                extConfigInputs = new ExtensionConfigurationInput[1];
                extConfigInputs[0] = AntimalwareExtensionConfigurationInput;
            }
            else if (AntimalwareMonitoringExtensionConfigurationInput!=null)
            {
                extConfigInputs = new ExtensionConfigurationInput[1];
                extConfigInputs[0] = AntimalwareMonitoringExtensionConfigurationInput;
            }

            // process any pending deployment changes
            if (extConfigInputs != null)
            {
                ExtensionConfiguration newExtConfig = ExtensionManager.Add(Deployment, extConfigInputs, Slot);
                ChangeDeployment(newExtConfig);
            }
        }
开发者ID:B-Rich,项目名称:azure-sdk-tools,代码行数:49,代码来源:SetAzureServiceAntimalwareExtension.cs


示例7: ExecuteCommand

        public void ExecuteCommand()
        {
            ValidateParameters();
            ExtensionConfigurationInput context = new ExtensionConfigurationInput
            {
                Version = Version,
                ProviderNameSpace = ProviderNamespace,
                Type = ExtensionName,
                CertificateThumbprint = CertificateThumbprint,
                ThumbprintAlgorithm = ThumbprintAlgorithm,
                X509Certificate = X509Certificate,
                PublicConfiguration = PublicConfiguration,
                PrivateConfiguration = PrivateConfiguration,
                Roles = new ExtensionRoleList(Role != null && Role.Any() ? Role.Select(r => new ExtensionRole(r)) : Enumerable.Repeat(new ExtensionRole(), 1))
            };

            var secondSlotDeployment = GetDeployment(this.Slot == DeploymentSlotType.Production ? DeploymentSlotType.Staging : DeploymentSlotType.Production);
            Microsoft.WindowsAzure.Management.Compute.Models.ExtensionConfiguration secondSlotExtensionConfiguration = 
                secondSlotDeployment != null ? secondSlotDeployment.ExtensionConfiguration : null;

            var extConfig = ExtensionManager.InstallExtension(context, Slot, Deployment.ExtensionConfiguration, secondSlotExtensionConfiguration);
            ChangeDeployment(extConfig);
        }
开发者ID:ldattilo,项目名称:azure-powershell,代码行数:23,代码来源:SetAzureServiceDiagnosticsExtension.cs


示例8: Add

 public ExtensionConfigurationBuilder Add(ExtensionConfigurationInput context, string extensionId)
 {
     if (context != null && context.Roles != null)
     {
         context.Roles.ForEach(r => Add(r, extensionId));
     }
     return this;
 }
开发者ID:NordPool,项目名称:azure-sdk-tools,代码行数:8,代码来源:ExtensionConfigurationBuilder.cs


示例9: VerifyExtensionConfigRDP

        private bool VerifyExtensionConfigRDP(ExtensionConfigurationInput resultConfig, string user, string pass, List<string> roles, DateTime exp, string thumbprint = null, string algorithm = null, X509Certificate2 cert = null)
        {
            try
            {
                string resultUserName = GetInnerText(resultConfig.PublicConfiguration, "UserName");
                string resultPassword = GetInnerText(resultConfig.PrivateConfiguration, "Password");
                string resultExpDate = GetInnerText(resultConfig.PublicConfiguration, "Expiration");

                Console.WriteLine("Type: {0}, UserName:{1}, Password: {2}, ExpirationDate: {3}, CertificateThumbprint: {4}, ThumbprintAlgorithm: {5}, X509Certificate: {6}",
                    resultConfig.Type, resultUserName, resultPassword, resultExpDate, resultConfig.CertificateThumbprint, resultConfig.ThumbprintAlgorithm, resultConfig.X509Certificate);

                Assert.AreEqual(resultConfig.Type, "RDP", "Type is not equal!");
                Assert.AreEqual(resultUserName, user);
                Assert.AreEqual(resultPassword, pass);
                Assert.IsTrue(Utilities.CompareDateTime(exp, resultExpDate));

                if (string.IsNullOrWhiteSpace(thumbprint))
                {
                    Assert.IsTrue(string.IsNullOrWhiteSpace(resultConfig.CertificateThumbprint));
                }
                else
                {
                    Assert.AreEqual(resultConfig.CertificateThumbprint, thumbprint, "Certificate thumbprint is not equal!");
                }

                if (string.IsNullOrWhiteSpace(algorithm))
                {
                    Assert.IsTrue(string.IsNullOrWhiteSpace(resultConfig.ThumbprintAlgorithm));
                }
                else
                {
                    Assert.AreEqual(resultConfig.ThumbprintAlgorithm, algorithm, "Thumbprint algorithm is not equal!");
                }
                Assert.AreEqual(resultConfig.X509Certificate, cert, "X509Certificate is not equal!");
                if (resultConfig.Roles.Count == 1 && string.IsNullOrEmpty(resultConfig.Roles[0].RoleName))
                {
                    Assert.IsTrue(roles.Contains(resultConfig.Roles[0].RoleType.ToString()));
                }
                else
                {
                    foreach (ExtensionRole role in resultConfig.Roles)
                    {
                        Assert.IsTrue(roles.Contains(role.RoleName));
                    }
                }

                return true;
            }
            catch
            {
                return false;
            }
        }
开发者ID:khoatle,项目名称:azure-powershell,代码行数:53,代码来源:FunctionalTest.cs


示例10: VerifyExtensionConfigDiag

        private bool VerifyExtensionConfigDiag(ExtensionConfigurationInput resultConfig, string storage, List<string> roles, XmlDocument wadconfig = null, string thumbprint = null, string algorithm = null, X509Certificate2 cert = null)
        {
            try
            {
                string resultStorageAccount = GetInnerText(resultConfig.PublicConfiguration, "StorageAccount");
                string resultWadCfg = Utilities.GetInnerXml(resultConfig.PublicConfiguration, "WadCfg");
                if (string.IsNullOrWhiteSpace(resultWadCfg))
                {
                    resultWadCfg = null;
                }
                string resultStorageKey = GetInnerValue(resultConfig.PrivateConfiguration, "StorageAccount", "key");

                Console.WriteLine("Type: {0}, StorageAccountName:{1}, StorageKey: {2}, WadCfg: {3}, CertificateThumbprint: {4}, ThumbprintAlgorithm: {5}, X509Certificate: {6}",
                    resultConfig.Type, resultStorageAccount, resultStorageKey, resultWadCfg, resultConfig.CertificateThumbprint, resultConfig.ThumbprintAlgorithm, resultConfig.X509Certificate);

                Assert.AreEqual("PaaSDiagnostics", resultConfig.Type, "Type is not equal!");
                Assert.AreEqual(storage, resultStorageAccount);
                Assert.IsTrue(Utilities.CompareWadCfg(resultWadCfg, wadconfig));

                if (string.IsNullOrWhiteSpace(thumbprint))
                {
                    Assert.IsTrue(string.IsNullOrWhiteSpace(resultConfig.CertificateThumbprint));
                }
                else
                {
                    Assert.AreEqual(thumbprint, resultConfig.CertificateThumbprint, "Certificate thumbprint is not equal!");
                }
                if (string.IsNullOrWhiteSpace(algorithm))
                {
                    Assert.IsTrue(string.IsNullOrWhiteSpace(resultConfig.ThumbprintAlgorithm));
                }
                else
                {
                    Assert.AreEqual(algorithm, resultConfig.ThumbprintAlgorithm, "Thumbprint algorithm is not equal!");
                }
                Assert.AreEqual(cert, resultConfig.X509Certificate, "X509Certificate is not equal!");
                if (resultConfig.Roles.Count == 1 && string.IsNullOrEmpty(resultConfig.Roles[0].RoleName))
                {
                    Assert.IsTrue(roles.Contains(resultConfig.Roles[0].RoleType.ToString()));
                }
                else
                {
                    foreach (ExtensionRole role in resultConfig.Roles)
                    {
                        Assert.IsTrue(roles.Contains(role.RoleName));
                    }
                }

                return true;
            }
            catch
            {
                return false;
            }
        }
开发者ID:khoatle,项目名称:azure-powershell,代码行数:55,代码来源:FunctionalTest.cs


示例11: PostProcessExtensionConfigAfterInstallExtension

        /// <summary>
        /// The configuration must be defined in either allRoles or namedRoles.
        /// Otherwise, it will fail for trying to apply the same extension.
        /// We only apply the fix here but not in ExtensionManager, so other commands won't get affected.
        /// </summary>
        /// <param name="configInput">The configuration used for InstallExtension()</param>
        /// <param name="extConfig">The extension config after InstallExtension()</param>
        private Microsoft.WindowsAzure.Management.Compute.Models.ExtensionConfiguration PostProcessExtensionConfigAfterInstallExtension(
            ExtensionConfigurationInput configInput,
            Microsoft.WindowsAzure.Management.Compute.Models.ExtensionConfiguration extConfig)
        {
            ExtensionConfigurationBuilder builder = ExtensionManager.GetBuilder(extConfig);
            if (configInput.Roles.All(r => r.Default))
            {
                // If the configuration applies to all roles, remove the ones defined in each named roles
                foreach (var role in Deployment.Roles)
                {
                    builder.Remove(role.RoleName, ProviderNamespace, ExtensionName);
                }
            }
            else
            {
                // If the configuration applies to some specific roles and there is already extension defined in allRoles,
                // we remove the setting from allRoles and move it to specific namedRoles.
                if (builder.ExistDefault(ProviderNamespace, ExtensionName))
                {
                    var diagnosticExtensionId = extConfig.AllRoles.FirstOrDefault(ext =>
                    {
                        var e = ExtensionManager.GetExtension(ext.Id);
                        return e != null && e.ProviderNamespace == ProviderNamespace && e.Type == ExtensionName;
                    }).Id;
                    builder.RemoveDefault(diagnosticExtensionId);

                    foreach (var role in Deployment.Roles)
                    {
                        // The role is previously configured by allRoles, move it to the namedRole itself
                        if (!configInput.Roles.Exists(r => r.RoleName == role.RoleName))
                        {
                            builder.Add(role.RoleName, diagnosticExtensionId);
                        }
                    }
                }
            }

            return builder.ToConfiguration();
        }
开发者ID:rturnage,项目名称:azure-powershell,代码行数:46,代码来源:SetAzureServiceDiagnosticsExtension.cs


示例12: RemoveExistingAntimalwareMonitoringConfig

        protected void RemoveExistingAntimalwareMonitoringConfig()
        {
            // this does not remove the diagnostics extension entirely, it only removes the portion of the 
            // diagnostics configuration that monitors antimalware events- everything else will remain 
            // in order to avoid doing harm to any other users who may be sharing the diagnostics extension 

            var ext = GetDiagnosticsExtension();
            if (ext != null)
            {
                string tmpXmlString = ext.PublicConfiguration;
                string AntimalwareDataSourceName = "System!*[System[Provider[@Name='Microsoft Antimalware']]]";
                string DiagnosticsConfigXmlNamespace = @"http://schemas.microsoft.com/ServiceHosting/2010/10/DiagnosticsConfiguration";

                // remove the data source element with the antimalware event provider 
                XmlDocument tmpXmlDoc = new XmlDocument();
                tmpXmlDoc.LoadXml(tmpXmlString);

                // retrieve storage account name from public configuration
                string stgAcctNameXPath = string.Format(@"//*[local-name()='{0}' and namespace-uri()='{1}']", StorageAccountElemStr, DiagnosticsConfigXmlNamespace);
                XmlNode stgAcctNameNode = tmpXmlDoc.DocumentElement.SelectSingleNode(stgAcctNameXPath);
                if (stgAcctNameNode != null)
                {
                    StorageAccountName = stgAcctNameNode.InnerText;
                }
                if (string.IsNullOrWhiteSpace(StorageAccountName))
                {
                    // do not modify diagnostics config without including the storage account
                    // throw terminating exception since it is not possible to preserve the 
                    // existing storage account with the configuration if it doesn't have a  
                    // hint to what the last storage account was in the public configuration 
                    ThrowTerminatingError(new ErrorRecord(
                        new Exception(Resources.ServiceExtensionCannotFindStorageAccountName),
                        string.Empty,
                        ErrorCategory.InvalidData,
                        null));

                    return;
                }
                else
                {
                    // check the storage account and initialize for use
                    ValidateStorageAccount();
                }

                // locate the antimalware data source node in the document 
                string antimalwareDataSourceXPath = string.Format(@"//*[local-name()='{0}' and @name=""{1}"" and namespace-uri()='{2}']", "DataSource", AntimalwareDataSourceName, DiagnosticsConfigXmlNamespace);
                XmlNode antimalwareDataSourceNode = tmpXmlDoc.DocumentElement.SelectSingleNode(antimalwareDataSourceXPath);
                if (antimalwareDataSourceNode != null)
                {
                    XmlNode windowsEventLogNode = antimalwareDataSourceNode.ParentNode;
                    if (windowsEventLogNode.RemoveChild(antimalwareDataSourceNode) != null)
                    {
                        // remove the windows event log if there are no other child data sources present
                        // as will be required for schema validation to succeed when sending the new config
                        // any other data sources outside of the windows event log are left untouched 
                        if (!windowsEventLogNode.HasChildNodes)
                        {
                            windowsEventLogNode.ParentNode.RemoveChild(windowsEventLogNode);
                        }
                    }

                    // now reinstall the diagnostics extension with the updated configuration
                    InitializeDiagnosticsSettings();
                    ExtensionConfigurationInput diagExtConfigInput = new ExtensionConfigurationInput
                    {
                        ProviderNameSpace = ProviderNamespace,
                        Type = ExtensionName,
                        CertificateThumbprint = CertificateThumbprint,
                        ThumbprintAlgorithm = ThumbprintAlgorithm,
                        X509Certificate = X509Certificate,
                        PublicConfiguration = tmpXmlDoc.OuterXml,
                        PrivateConfiguration = PrivateConfiguration,
                        Roles = new ExtensionRoleList(Role != null && Role.Any() ? Role.Select(r => new ExtensionRole(r)) : Enumerable.Repeat(new ExtensionRole(), 1))
                    };
                    AntimalwareMonitoringExtensionConfigurationInput = diagExtConfigInput;
                }
                else
                {
                    // no existing antimalware data source was found needing removal
                    return;
                }
            }
        }
开发者ID:B-Rich,项目名称:azure-sdk-tools,代码行数:83,代码来源:BaseAzureServiceAntimalwareExtension.cs


示例13: NewAzureDeployment

        private void NewAzureDeployment(ExtensionConfigurationInput domainJoinExtensionConfig = null)
        {
            //Create a new Azure Iaas VM and set Domain Join extension, get domain join extension and then remove domain join extension
            Console.WriteLine("Creating a new Azure Iaas VM");

            vmPowershellCmdlets.NewAzureService(_serviceName, _serviceName, null, AffinityGroupName);

            Console.WriteLine("Service, {0}, is created.", _serviceName);

            vmPowershellCmdlets.AddAzureCertificate(_serviceName, _rdpCertPath.FullName, password);

            if (domainJoinExtensionConfig == null)
            {
                vmPowershellCmdlets.NewAzureDeployment(_serviceName, _packagePath1.FullName, _configPath1.FullName, DeploymentSlotType.Production, _deploymentLabel, _deploymentName, false, false);
                Console.WriteLine("New deployment created successfully.");
            }
            else
            {
                vmPowershellCmdlets.NewAzureDeployment(_serviceName, _packagePath1.FullName, _configPath1.FullName, DeploymentSlotType.Production, _deploymentLabel, _deploymentName, false, false, domainJoinExtensionConfig);
                Console.WriteLine("{0}:New deployment {1} with domain join {2} created successfully.", DateTime.Now, _serviceName, domainJoinExtensionConfig.Type);
            }
        }
开发者ID:FrankSiegemund,项目名称:azure-powershell,代码行数:22,代码来源:AzureServiceADDomainJoinExtensionTests.cs


示例14: Set

        public ExtensionConfiguration Set(DeploymentGetResponse currentDeployment, DeploymentGetResponse peerDeployment, ExtensionConfigurationInput[] inputs, string slot)
        {
            string errorConfigInput = null;
            if (!Validate(inputs, out errorConfigInput))
            {
                throw new Exception(string.Format(Resources.ServiceExtensionCannotApplyExtensionsInSameType, errorConfigInput));
            }

            ExtensionConfigurationBuilder configBuilder = this.GetBuilder();
            foreach (ExtensionConfigurationInput context in inputs)
            {
                if (context != null)
                {
                    ExtensionConfiguration currentConfig = this.InstallExtension(context, slot, currentDeployment, peerDeployment);

                    foreach (var r in currentConfig.AllRoles)
                    {
                        if (currentDeployment == null || !this.GetBuilder(currentDeployment.ExtensionConfiguration).ExistAny(r.Id))
                        {
                            configBuilder.AddDefault(r.Id);
                        }
                    }
                    foreach (var r in currentConfig.NamedRoles)
                    {
                        foreach (var e in r.Extensions)
                        {
                            if (currentDeployment == null || !this.GetBuilder(currentDeployment.ExtensionConfiguration).ExistAny(e.Id))
                            {
                                configBuilder.Add(r.RoleName, e.Id);
                            }
                        }
                    }
                }
            }

            var extConfig = configBuilder.ToConfiguration();

            return extConfig;
        }
开发者ID:rturnage,项目名称:azure-powershell,代码行数:39,代码来源:ExtensionManager.cs


示例15: Validate

        public static bool Validate(ExtensionConfigurationInput[] inputs, out string errorConfigInput)
        {
            var roleList = (from c in inputs
                            where c != null
                            from r in c.Roles
                            select r).GroupBy(r => r.ToString()).Select(g => g.First());

            foreach (var role in roleList)
            {
                var result = from c in inputs
                             where c != null && c.Roles.Any(r => r.ToString() == role.ToString())
                             select string.Format("{0}.{1}", c.ProviderNameSpace, c.Type);
                foreach (var s in result)
                {
                    if (result.Count(t => t == s) > 1)
                    {
                        errorConfigInput = s;
                        return false;
                    }
                }
            }

            errorConfigInput = null;
            return true;
        }
开发者ID:rturnage,项目名称:azure-powershell,代码行数:25,代码来源:ExtensionManager.cs


示例16: UpdateExtensionState

        public ExtensionConfiguration UpdateExtensionState(ExtensionConfigurationInput input)
        {
            var extConfig = new ExtensionConfiguration();
            if (input.Roles == null || input.Roles.Count == 1 && input.Roles[0].RoleType == ExtensionRoleType.AllRoles)
            {

                extConfig.AllRoles = new List<ExtensionConfiguration.Extension>();
                extConfig.AllRoles.Add(new ExtensionConfiguration.Extension
                {
                    Id = input.Id,
                    State = input.State
                });
            }
            else
            {
                extConfig.NamedRoles = new List<ExtensionConfiguration.NamedRole>();
                foreach (var role in input.Roles)
                {
                    var ext = new List<ExtensionConfiguration.Extension>();
                    ext.Add(new ExtensionConfiguration.Extension
                    {
                        Id = input.Id,
                        State = input.State
                    });
                    extConfig.NamedRoles.Add(new ExtensionConfiguration.NamedRole
                    {
                        RoleName = role.RoleName,
                        Extensions = ext
                    });
                }
            }
            return extConfig;
        }
开发者ID:Azure,项目名称:azure-powershell,代码行数:33,代码来源:ExtensionManager.cs


示例17: MergeAntimalwareMonitoringIntoExistingConfig

        private void MergeAntimalwareMonitoringIntoExistingConfig(string existingConfigXmlStr)
        {
            // prepare a new xml document to hold the merged config
            XmlDocument mergedConfig = new XmlDocument();
            mergedConfig.LoadXml(existingConfigXmlStr);

            // check if old config already contains a WindowsEventLog section
            string targetNode;
            string mergeXmlStr;
            if (existingConfigXmlStr.Contains(DiagnosticsConfigWindowsEventLogNodeName))
            {
                // inject into the existing windows event log section 
                targetNode = DiagnosticsConfigWindowsEventLogNodeName;
                mergeXmlStr = DiagnosticsDefaultConfigMergeXmlWithExistingEventLogNode;
            }
            else
            {
                // inject a windows event log section with antimalware monitoring into the diagnostics config 
                targetNode = DiagnosticsConfigNodeName;
                mergeXmlStr = DiagnosticsDefaultConfigMergeXmlWithoutExistingEventLogNode;
            }

            // locate the desired target using xpath 
            string diagXPathStr = String.Format("//*[local-name()='{0}' and namespace-uri()='{1}']", targetNode, DiagnosticsConfigXmlNamespace);
            XmlNode diagNode = mergedConfig.DocumentElement.SelectSingleNode(diagXPathStr);

            // create an import node and then append to the correct location
            XmlDocument diagnosticsConfigXml = new XmlDocument();
            diagnosticsConfigXml.LoadXml(mergeXmlStr);

            XmlNode importNode = mergedConfig.ImportNode(diagnosticsConfigXml.DocumentElement, true);
            diagNode.AppendChild(importNode);

            // Note : Currently any pre-existing user of the diagnostics configuration will be expected 
            // to follow convention of specifying storage account name in the xml configuration so that 
            // it can be persisted across configuration changes being made by multiple users. 

            // remove any stray xmlns="" attribute from xml string prior to use 
            string mergedConfiguration = mergedConfig.OuterXml.Replace(@"xmlns=""""", "");

            // now reinstall the extension with the new configuration
            InitializeDiagnosticsSettings();
            ExtensionConfigurationInput diagExtConfigInput = new ExtensionConfigurationInput
            {
                ProviderNameSpace = ProviderNamespace,
                Type = ExtensionName,
                CertificateThumbprint = CertificateThumbprint,
                ThumbprintAlgorithm = ThumbprintAlgorithm,
                X509Certificate = X509Certificate,
                PublicConfiguration = mergedConfiguration,
                PrivateConfiguration = PrivateConfiguration,
                Roles = new ExtensionRoleList(Role != null && Role.Any() ? Role.Select(r => new ExtensionRole(r)) : Enumerable.Repeat(new ExtensionRole(), 1))
            };

            // set up for reinstall with new configuration
            AntimalwareMonitoringExtensionConfigurationInput = diagExtConfigInput;
        }
开发者ID:B-Rich,项目名称:azure-sdk-tools,代码行数:57,代码来源:SetAzureServiceAntimalwareExtension.cs


示例18: EnableMonitoring

        protected void EnableMonitoring()
        {
            // retrieve any pre-existing diagnostics extension
            var ext = GetDiagnosticsExtension();

            if ( (ext == null) && 
                 ((monitoringAction==MonitoringActionType.Disable) || (monitoringAction == MonitoringActionType.NoActionRequested)) )
            {
                // if there was no pre-existing diagnostics extension there is 
                // nothing to do in either of these two cases so exit early 

                // note the user may not have provided a storage account either
                // so this check is performed prior to storage account validation                
                return;   
            }

            // establish the storage account name to be associated with monitoring
            if (string.IsNullOrWhiteSpace(StorageAccountName))
            {
                // not specified as a parameter, try to use any value found in config
                StorageAccountName = monitoringStorageAccountName;
            }

            if (string.IsNullOrWhiteSpace(StorageAccountName))
            {
                // unable to find the storage account name as a parameter or as a config
                ThrowTerminatingError(new ErrorRecord(
                            new Exception(Resources.ServiceExtensionCannotFindStorageAccountName),
                            string.Empty,
                            ErrorCategory.InvalidData,
                            null));
            }
            else
            {
                ValidateStorageAccount();
            }

            if (ext != null)
            {
                // save the current configuration of the diagnostics extension
                // in the event we do not end up needing to modify it but need
                // to persist the config in the final call to change deployment 
                InitializeDiagnosticsSettings();
                AntimalwareMonitoringExtensionConfigurationInput = new ExtensionConfigurationInput
                {
                    ProviderNameSpace = ProviderNamespace,
                    Type = ExtensionName,
                    CertificateThumbprint = CertificateThumbprint,
                    ThumbprintAlgorithm = ThumbprintAlgorithm,
                    X509Certificate = X509Certificate,
                    PublicConfiguration = ext.PublicConfiguration,
                    PrivateConfiguration = PrivateConfiguration,
                    Roles = new ExtensionRoleList(Role != null && Role.Any() ? Role.Select(r => new ExtensionRole(r)) : Enumerable.Repeat(new ExtensionRole(), 1))
                };
            }

            switch (monitoringAction)
            {
                case (MonitoringActionType.Enable) :
                    if (ext == null)
                    {
                        AddNewAntimalwareMonitoringConfig();
                    }
                    else
                    {
                        // extension already exists, check to see if it already contains antimalware data source
                        if (!ext.PublicConfiguration.Contains(DiagnosticsConfigAntimalwareProviderToken))
                        {
                            // antimalware data source is not already in the configuration, merge it 
                            // with existing config (tracking perf counters, other event logs, etc.)
                            MergeAntimalwareMonitoringIntoExistingConfig(ext.PublicConfiguration);
                        }
                    }
                    break;

                case (MonitoringActionType.Disable) :
                    if (ext != null)
                    {
                        RemoveExistingAntimalwareMonitoringConfig();
                    }
                    break;

                case (MonitoringActionType.NoActionRequested) :
                    break;

                default: 
                    break;
            }
        }
开发者ID:B-Rich,项目名称:azure-sdk-tools,代码行数:89,代码来源:SetAzureServiceAntimalwareExtension.cs


示例19: ExecuteCommand

 public void ExecuteCommand()
 {
     ValidateParameters();
     ExtensionConfigurationInput context = new ExtensionConfigurationInput
     {
         Id = ExtensionId,
         ProviderNameSpace = ProviderNamespace,
         Type = ExtensionName,
         CertificateThumbprint = CertificateThumbprint,
         ThumbprintAlgorithm = ThumbprintAlgorithm,
         X509Certificate = X509Certificate,
         PublicConfiguration = PublicConfiguration,
         PrivateConfiguration = PrivateConfiguration,
         Version = Version,
         Roles = new ExtensionRoleList(Role != null && Role.Any() ? Role.Select(r => new ExtensionRole(r)) : Enumerable.Repeat(new ExtensionRole(), 1))
     };
     var extConfig = ExtensionManager.InstallExtension(context, Slot, Deployment, PeerDeployment);
     ChangeDeployment(extConfig);
 }
开发者ID:docschmidt,项目名称:azure-powershell,代码行数:19,代码来源:SetAzureServiceExtension.cs


示例20: Add

        public Microsoft.WindowsAzure.Management.Compute.Models.ExtensionConfiguration Add(DeploymentGetResponse deployment, ExtensionConfigurationInput[] inputs, string slot)
        {
            string errorConfigInput = null;
            if (!Validate(inputs, out errorConfigInput))
            {
                throw new Exception(string.Format(Resources.ServiceExtensionCannotApplyExtensionsInSameType, errorConfigInput));
            }

            var oldExtConfig = deploymen 

鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
C# ConfigDataInfo.AzureProvisioningConfigInfo类代码示例发布时间:2022-05-26
下一篇:
C# ScenarioTest.EnvironmentSetupHelper类代码示例发布时间:2022-05-26
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap