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)); }
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); }
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); }
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); }