示例#1
0
        public IList <string> GetManagementAgentRunProfileNamesForPartition(Guid managementAgentID, Guid partitionID, bool includeMultiStep)
        {
            List <string> items = new List <string>();

            try
            {
                ManagementAgent ma = ManagementAgent.GetManagementAgent(managementAgentID);

                foreach (KeyValuePair <string, RunConfiguration> i in ma.RunProfiles.Where(t => includeMultiStep || t.Value.RunSteps.Count == 1))
                {
                    if (partitionID != Guid.Empty)
                    {
                        if (i.Value.RunSteps.Any(t => t.Partition == partitionID))
                        {
                            items.Add(i.Key);
                        }
                    }
                    else
                    {
                        items.Add(i.Key);
                    }
                }
            }
            catch (Exception ex)
            {
                logger.Error(ex, "A request to get the run profile names failed");
            }

            return(items);
        }
示例#2
0
        internal void ResolveManagementAgent()
        {
            try
            {
                Guid?id = Global.FindManagementAgent(this.ManagementAgentName, this.ManagementAgentID);

                if (id.HasValue)
                {
                    ManagementAgent ma = ManagementAgent.GetManagementAgent(id.Value);
                    this.ManagementAgentName = ma.Name;
                    this.ManagementAgentID   = ma.ID;
                    this.IsMissing           = false;
                    this.ResolvePartitions(ma);
                    return;
                }
            }
            catch (Exception ex)
            {
                logger.Error(ex, $"Exception finding management agent {this.ManagementAgentID}/{this.ManagementAgentName}");
            }

            logger.Warn($"Management agent could not be found. Name: '{this.ManagementAgentName}'. ID: '{this.ManagementAgentID}'");

            this.IsMissing = true;
        }
示例#3
0
        public IMAExecutionTrigger CreateTriggerForManagementAgent(string type, Guid managementAgentID)
        {
            ManagementAgent ma = ManagementAgent.GetManagementAgent(managementAgentID);
            Type            t  = Type.GetType(type);

            if (t == null)
            {
                throw new InvalidOperationException($"Could not create trigger for management agent {ma.Name} because the type {type} was unknown");
            }

            IMAExecutionTrigger instance = (IMAExecutionTrigger)Activator.CreateInstance(t, ma);

            return(instance);
        }
        internal static ManagementAgent GetManagementAgent(string name, bool reload)
        {
            if (reload || !maCache.ContainsKey(name))
            {
                ManagementAgent ma = ManagementAgent.GetManagementAgent(name);

                if (!maCache.ContainsKey(name))
                {
                    maCache.Add(ma.Name, ma);
                }
                else
                {
                    maCache[ma.Name] = ma;
                }
            }

            return(maCache[name]);
        }
示例#5
0
        public IList <string> GetAllowedTriggerTypesForMA(Guid managementAgentID)
        {
            List <string> allowedTypes = new List <string>();

            ManagementAgent ma = ManagementAgent.GetManagementAgent(managementAgentID);

            foreach (Type t in Assembly.GetExecutingAssembly().GetTypes()
                     .Where(mytype => mytype.GetInterfaces().Contains(typeof(IMAExecutionTrigger))))
            {
                MethodInfo i = t.GetMethod("CanCreateForMA");

                if (i != null)
                {
                    if ((bool)i.Invoke(null, new object[] { ma }))
                    {
                        allowedTypes.Add(t.FullName);
                    }
                }
            }

            return(allowedTypes);
        }
示例#6
0
        public string GetMAData(Guid managementAgentID)
        {
            ManagementAgent ma = ManagementAgent.GetManagementAgent(managementAgentID);

            return(ma.GetOuterXml());
        }
示例#7
0
        private bool DoSchemaUpdatev1(string file)
        {
            logger.Info("Configuration file upgrade in progress");

            XmlDocument d   = new XmlDocument();
            var         mgr = new XmlNamespaceManager(d.NameTable);

            mgr.AddNamespace("a", "http://schemas.datacontract.org/2004/07/Lithnet.Miiserver.AutoSync");
            d.Load(file);

            foreach (XmlNode node in d.SelectNodes("/a:lithnet-autosync/a:management-agents/a:management-agent", mgr))
            {
                string maName  = node.SelectSingleNode("a:name", mgr)?.InnerText;
                string maidstr = node.SelectSingleNode("a:id", mgr)?.InnerText;
                Guid   maID    = maidstr == null ? Guid.Empty : new Guid(maidstr);

                Guid?id = Global.FindManagementAgent(maName, maID);

                if (id == null)
                {
                    continue;
                }

                ManagementAgent ma = ManagementAgent.GetManagementAgent(id.Value);

                logger.Info($"Processing management agent controller {ma.Name}");

                MAControllerConfiguration c = this.ManagementAgents.GetItemOrDefault(id.Value);

                foreach (PartitionConfiguration p in c.Partitions.ActiveConfigurations)
                {
                    p.AutoImportEnabled         = node.SelectSingleNode("a:auto-import-scheduling", mgr)?.InnerText == "enabled";
                    p.AutoImportIntervalMinutes = int.Parse(node.SelectSingleNode("a:auto-import-interval", mgr)?.InnerText ?? "0");
                }

                string rpName = node.SelectSingleNode("a:run-profile-confirming-import", mgr)?.InnerText;
                Guid?  pid    = this.GetPartitionFromRunProfile(rpName, ma);

                if (pid != null)
                {
                    PartitionConfiguration partition = c.Partitions.GetItemOrNull(pid.Value);

                    if (partition != null)
                    {
                        partition.ConfirmingImportRunProfileName = rpName;
                        logger.Trace($"Migrating run profile {nameof(partition.ConfirmingImportRunProfileName)}-{partition.ConfirmingImportRunProfileName} to partition {partition.Name}");
                    }
                }

                rpName = node.SelectSingleNode("a:run-profile-delta-import", mgr)?.InnerText;
                pid    = this.GetPartitionFromRunProfile(rpName, ma);
                if (pid != null)
                {
                    PartitionConfiguration partition = c.Partitions.GetItemOrNull(pid.Value);

                    if (partition != null)
                    {
                        partition.DeltaImportRunProfileName = rpName;
                        logger.Trace($"Migrating run profile {nameof(partition.DeltaImportRunProfileName)}-{partition.DeltaImportRunProfileName} to partition {partition.Name}");
                    }
                }

                rpName = node.SelectSingleNode("a:run-profile-delta-sync", mgr)?.InnerText;
                pid    = this.GetPartitionFromRunProfile(rpName, ma);
                if (pid != null)
                {
                    PartitionConfiguration partition = c.Partitions.GetItemOrNull(pid.Value);

                    if (partition != null)
                    {
                        partition.DeltaSyncRunProfileName = rpName;
                        logger.Trace($"Migrating run profile {nameof(partition.DeltaSyncRunProfileName)}-{partition.DeltaSyncRunProfileName} to partition {partition.Name}");
                    }
                }

                rpName = node.SelectSingleNode("a:run-profile-export", mgr)?.InnerText;
                pid    = this.GetPartitionFromRunProfile(rpName, ma);
                if (pid != null)
                {
                    PartitionConfiguration partition = c.Partitions.GetItemOrNull(pid.Value);

                    if (partition != null)
                    {
                        partition.ExportRunProfileName = rpName;
                        logger.Trace($"Migrating run profile {nameof(partition.ExportRunProfileName)}-{partition.ExportRunProfileName} to partition {partition.Name}");
                    }
                }

                rpName = node.SelectSingleNode("a:run-profile-full-import", mgr)?.InnerText;
                pid    = this.GetPartitionFromRunProfile(rpName, ma);
                if (pid != null)
                {
                    PartitionConfiguration partition = c.Partitions.GetItemOrNull(pid.Value);

                    if (partition != null)
                    {
                        partition.FullImportRunProfileName = rpName;
                        logger.Trace($"Migrating run profile {nameof(partition.FullImportRunProfileName)}-{partition.FullImportRunProfileName} to partition {partition.Name}");
                    }
                }

                rpName = node.SelectSingleNode("a:run-profile-full-sync", mgr)?.InnerText;
                pid    = this.GetPartitionFromRunProfile(rpName, ma);
                if (pid != null)
                {
                    PartitionConfiguration partition = c.Partitions.GetItemOrNull(pid.Value);

                    if (partition != null)
                    {
                        partition.FullSyncRunProfileName = rpName;
                        logger.Trace($"Migrating run profile {nameof(partition.FullSyncRunProfileName)}-{partition.FullSyncRunProfileName} to partition {partition.Name}");
                    }
                }

                rpName = node.SelectSingleNode("a:run-profile-scheduled-import", mgr)?.InnerText;
                pid    = this.GetPartitionFromRunProfile(rpName, ma);
                if (pid != null)
                {
                    PartitionConfiguration partition = c.Partitions.GetItemOrNull(pid.Value);

                    if (partition != null)
                    {
                        partition.ScheduledImportRunProfileName = rpName;
                        logger.Trace($"Migrating run profile {nameof(partition.ScheduledImportRunProfileName)}-{partition.ScheduledImportRunProfileName} to partition {partition.Name}");
                    }
                }
            }

            this.SchemaVersion = 1;
            return(true);
        }