private void GetDiscoveryConfig(ITemplateContext templateContext, TemplateInputConfig templateConfig) { foreach (var discovery in SDKHelper.GetFolderItems <ManagementPackDiscovery>(this, templateContext.OutputFolder)) { var discoveryConfig = discovery.DataSource.Configuration; if (discovery.Name.StartsWith(ClustersDiscoveryNamePrefix, StringComparison.OrdinalIgnoreCase)) { if (WatcherNodesListNodeRegex.IsMatch(discoveryConfig)) { templateConfig.WatcherNodesList = WatcherNodesListNodeRegex.Match(discoveryConfig).Groups[1].Value; } } else if (discovery.Name.StartsWith(SeedDiscoveryNamePrefix, StringComparison.OrdinalIgnoreCase)) { if (SeedComputerNameNodeRegex.IsMatch(discoveryConfig)) { templateConfig.SeedComputerName = SeedComputerNameNodeRegex.Match(discoveryConfig).Groups[1].Value; } if (AmbariUriNodeRegex.IsMatch(discoveryConfig)) { templateConfig.AmbariUri = AmbariUriNodeRegex.Match(discoveryConfig).Groups[1].Value; } } } }
private string GetTemplateIdString(ITemplateContext templateContext) { foreach (var mpClass in SDKHelper.GetFolderItems <ManagementPackClass>(this, templateContext.OutputFolder)) { if (mpClass.Name.StartsWith(ClassNamePrefix, StringComparison.OrdinalIgnoreCase)) { return(mpClass.Name.Remove(0, ClassNamePrefix.Length)); } } throw new ObjectNotFoundException("No Hadoop Cluster class found in the template. Template instance may be corrupted. Try to remove and recreate the template."); }
private string GetRunAsAccounts(ITemplateContext templateContext) { var folderItems = SDKHelper.GetFolderItems <ManagementPackSecureReferenceOverride>(this, templateContext.OutputFolder); foreach (var @override in folderItems) { if (@override.Name.StartsWith(AccountOverrideNamePrefix, StringComparison.OrdinalIgnoreCase)) { return(@override.Value); } } return(String.Empty); }
private string GetTemplateIdString(ITemplateContext templateContext) { if (templateContext == null) { throw new ArgumentNullException("templateContext"); } foreach (ManagementPackClass class2 in SDKHelper.GetFolderItems <ManagementPackClass>(this, templateContext.OutputFolder)) { if (class2.Name.StartsWith(ClassNamePrefix, StringComparison.OrdinalIgnoreCase)) { return(class2.Name.Remove(0, ClassNamePrefix.Length)); } } throw new ObjectNotFoundException(); }
private void GetDiscoveryConfig(ITemplateContext templateContext, ref TemplateInputConfig templateConfig) { if (templateContext == null) { throw new ArgumentNullException("templateContext"); } foreach (ManagementPackDiscovery discovery in SDKHelper.GetFolderItems <ManagementPackDiscovery>(this, templateContext.OutputFolder)) { if (discovery.Name.StartsWith(DiscoveryNamePrefix, StringComparison.OrdinalIgnoreCase)) { MatchCollection matchs = new Regex(ValueNodeRegex, RegexOptions.CultureInvariant | RegexOptions.Compiled).Matches(discovery.DataSource.Configuration); templateConfig.ASBNamespaceName = matchs[0].Groups[1].Value; templateConfig.ProxyAgentComputerPrincipalName = matchs[2].Groups[1].Value; return; } } throw new ObjectNotFoundException("my message"); }
private void GetDiscoveryConfig(ITemplateContext templateContext, ref TemplateInputConfig templateConfig) { if (templateContext == null) { throw new ArgumentNullException("templateContext"); } foreach (ManagementPackDiscovery discovery in SDKHelper.GetFolderItems <ManagementPackDiscovery>(this, templateContext.OutputFolder)) { if (discovery.Name.StartsWith(DiscoveryNamePrefix, StringComparison.OrdinalIgnoreCase)) { MatchCollection matchs = new Regex(ValueNodeRegex, RegexOptions.CultureInvariant | RegexOptions.Compiled).Matches(discovery.DataSource.Configuration); templateConfig.TemplateIdString = GetTemplateIdString(templateContext);// matchs[0].Groups[1].Value; templateConfig.UniqueID = matchs[0].Groups[1].Value; templateConfig.Instance = matchs[1].Groups[1].Value; templateConfig.Database = matchs[2].Groups[1].Value; templateConfig.QueryName = matchs[3].Groups[1].Value; templateConfig.StartDay = matchs[4].Groups[1].Value; templateConfig.EndDay = matchs[5].Groups[1].Value; templateConfig.SyncTime = matchs[6].Groups[1].Value; templateConfig.IntervalSeconds = int.Parse(matchs[7].Groups[1].Value); templateConfig.Query = matchs[8].Groups[1].Value; templateConfig.DaysOfWeekMask = int.Parse(matchs[9].Groups[1].Value); templateConfig.GroupName = matchs[10].Groups[1].Value; templateConfig.Direction = matchs[11].Groups[1].Value; templateConfig.ErrorMessage = matchs[12].Groups[1].Value; templateConfig.MetricType = matchs[13].Groups[1].Value; templateConfig.Samples = int.Parse(matchs[14].Groups[1].Value); templateConfig.Threshold = double.Parse(matchs[15].Groups[1].Value); templateConfig.PrincipalName = matchs[16].Groups[1].Value; return; } } throw new ObjectNotFoundException("my message"); }
private void GetConnectionString(ITemplateContext templateContext, ref TemplateInputConfig templateConfig) { if (templateContext == null) { throw new ArgumentNullException("templateContext"); } MatchCollection matchs = null; ManagementPackElementCollection <ManagementPackUnitMonitor> folderItems = SDKHelper.GetFolderItems <ManagementPackUnitMonitor>(this, templateContext.OutputFolder); foreach (ManagementPackUnitMonitor monitor in folderItems) { if (monitor.Name.StartsWith(MonitorUnitNamePrefix, StringComparison.OrdinalIgnoreCase)) { matchs = new Regex(ConnectionStringRegex, RegexOptions.CultureInvariant | RegexOptions.Compiled).Matches(monitor.Configuration); templateConfig.ConnectionString = matchs[0].Groups[1].Value; break; } } }
private void GetRunAsAccounts(ITemplateContext templateContext, ref TemplateInputConfig templateConfig) { if (templateContext == null) { throw new ArgumentNullException("templateContext"); } ManagementPackElementCollection <ManagementPackSecureReferenceOverride> folderItems = SDKHelper.GetFolderItems <ManagementPackSecureReferenceOverride>(this, templateContext.OutputFolder); templateConfig.RunAsAccount = string.Empty; foreach (ManagementPackSecureReferenceOverride @override in folderItems) { if (@override.Name.StartsWith(AccountOverrideNamePrefix, StringComparison.OrdinalIgnoreCase)) { templateConfig.RunAsAccount = @override.Value; break; } } }