Exemplo n.º 1
0
        public static RaciEndpointDriver UpdateDriver(string epName, string driverName, string driverType, string descr, bool create = false)
        {
            RaciEndpoint ep = GetEndpointByName(epName);

            if (ep == null)
            {
                string msg = $"Cannot add driver '{driverType}:{driverName}'. Endpoint '{epName}' does not exist";
                logger.LogError(msg);
                throw new KeyNotFoundException(msg);
            }
            RaciEndpointDriver drv = ep.Nodes.WithName(driverName);

            if (drv == null)
            {
                drv = create ? AddDriver(ep?.Name, driverType, driverName, descr):null;
            }
            else
            {
                if (!String.IsNullOrWhiteSpace(driverType))
                {
                    drv.DriverType = driverType;
                }
                if (!String.IsNullOrWhiteSpace(descr))
                {
                    drv.Description = descr;
                }
            }
            return(GetDriverByName(epName, driverName));
        }
Exemplo n.º 2
0
        public static RaciEndpointDriver AddDriver(string epName, string driverType, string driverName, string descr = "")
        {
            if (String.IsNullOrWhiteSpace(driverName))
            {
                logger?.LogWarning($"Unable to add endpoint: Invalid driverName '{driverName}'");
                return(null);
            }
            RaciEndpoint       ep  = GetEndpointByName(epName);
            RaciEndpointDriver drv = null;

            if (ep != null)
            {
                drv = GetDrivers(ep).WithName(driverName);
                if (drv == null)
                {
                    drv = new RaciEndpointDriver(driverName, descr)
                    {
                        DriverType          = driverType,
                        ParentProfileNodeId = ep.ProfileNodeId,
                        Parent = ep
                    };
                    ep.Nodes.Add(drv);
                }
            }
            else
            {
                logger?.LogWarning($"Unable to add endpoint: No service named '{epName}' found");
            }
            return(drv);
        }
Exemplo n.º 3
0
        public static bool RemoveDriver(string epName, string driverName)
        {
            RaciEndpoint       ep  = GetEndpointByName(epName);
            RaciEndpointDriver drv = ep.Nodes.WithName(driverName);

            if (drv != null)
            {
                ep.Nodes.Remove(drv);
            }
            return(ep.Nodes.WithName(driverName) == null);
        }
Exemplo n.º 4
0
        public static RaciEndpointDriver AddDriver(string epName, RaciEndpointDriver drv)
        {
            if (drv?.Name == null || String.IsNullOrWhiteSpace(epName) || !HasEndpointName(epName))
            {
                return(null);
            }

            RaciEndpoint ep = GetEndpointByName(epName);

            var d = ep.Nodes.WithName(drv?.Name);

            if (d != null)
            {
                ep.Nodes.Remove(d);
            }
            drv.Parent = ep;
            ep.Nodes.Add(drv);
            return(drv);
        }