Hello Dojo
Im creating service with automation core library and works well, im want to add a logic to update the service if existe but i cant find the funciton to remove elements and add the news
if (dms.ServiceExists(grupoCunico.Key))
{
var serviceExist = dms.GetService(grupoCunico.Key);
}
This is my code working in 10.5.0.0-16294-CU6
ServiceConfiguration serviceConfig = new ServiceConfiguration(dms, grupoCunico.Key);
serviceConfig.Views.Add(dms.GetView(63));
serviceConfig.AdvancedSettings.Protocol = dmsProtocol;
serviceConfig.AdvancedSettings.AlarmTemplate = alarmTemplate;
var gruposTroncales = grupoCunico
.GroupBy(x => new
{
// x.Troncal,
x.HostName,
});
int i = 0;
foreach (var grupo in gruposTroncales)
{
i++;
if (dms.ElementExists(grupo.Key.HostName) )
{
engine.GenerateInformation("=======================================");
//engine.GenerateInformation($"Troncal: {grupo.Key.Troncal}");
engine.GenerateInformation($"Host: {grupo.Key.HostName}");
engine.GenerateInformation("---- Registros del grupo ----");
var filters1 = new List<ElementParamFilterConfiguration>();
var filters2 = new List<ElementParamFilterConfiguration>();
foreach (var item in grupo)
{
engine.GenerateInformation(
$"{item.Itm} | {item.IE_Name} | {item.MAC_IE_Local} | {item.MAC_CajaRemota}"
);
filters1.Add(new ElementParamFilterConfiguration(5003, "*", true));
filters1.Add(new ElementParamFilterConfiguration(5004, "*", true));
filters1.Add(new ElementParamFilterConfiguration(5005, "*", true));
filters1.Add(new ElementParamFilterConfiguration(1407, "*" + item.IE_Name + " * ", true));
filters1.Add(new ElementParamFilterConfiguration(1419, "*" + item.IE_Name + " * ", true));
filters1.Add(new ElementParamFilterConfiguration(1420, "*" + item.IE_Name + " * ", true));
filters1.Add(new ElementParamFilterConfiguration(1407, "*" + item.IE_Name + " * ", true));
filters1.Add(new ElementParamFilterConfiguration(1405, "*" + item.IE_Name + " * ", true));
filters1.Add(new ElementParamFilterConfiguration(1408, "*" + item.IE_Name + " * ", true));
filters1.Add(new ElementParamFilterConfiguration(1427, "*" + item.IE_Name + " * ", true));
filters1.Add(new ElementParamFilterConfiguration(1412, "*" + item.IE_Name + " * ", true));
filters1.Add(new ElementParamFilterConfiguration(1413, "*" + item.IE_Name + " * ", true));
filters1.Add(new ElementParamFilterConfiguration(1417, "*" + item.IE_Name + " * ", true));
filters1.Add(new ElementParamFilterConfiguration(1418, "*" + item.IE_Name + " * ", true));
filters1.Add(new ElementParamFilterConfiguration(1431, "*" + item.IE_Name + " * ", true));
}
var element1 = dms.GetElement(grupo.Key.HostName);
serviceConfig.AddElement(element1.DmsElementId, filters1);
var includedElements = serviceConfig.IncludedElements;
int j = 1;
foreach (var includedElement in includedElements)
{
//includedElement.Alias = "device" + j;
includedElement.IncludedCapped = Skyline.DataMiner.Core.DataMinerSystem.Common.AlarmLevel.Normal;
j++;
}
}
}
agent.CreateService(serviceConfig);
Thanks
Hi Juan,
A newly released version of Skyline.DataMiner.Core.DataMinerSystem (1.2.0.3) now allows you to edit an existing service instead of only creating a new one.
The following methods are available on the service configuration:
dms.GetService(grupoCunico.Key).ParameterSettings
AddElement(elementId, filters)to add an element with parameter filters.AddService(serviceId)to add a sub-service.RemoveByElementId(elementId)to remove an element.RemoveByServiceId(serviceId)to remove a sub-service.RemoveByAlias(alias)to remove an item by alias.Clear()to remove all included elements and services, which can be useful when rebuilding the service contents from scratch.
Via ParameterSettings.IncludedElements, it is possible to loop over all elements in the service and make changes.
Hope this helps!
Hi Juan,
While the IDmsService interface does provide an Update() method that allows you to persist changes after modifying the service object, it is currently not possible to change the ElementParamFilters through the IDmsService object.
So even though you can retrieve the service and update certain properties, you won’t be able to remove, or add ElementParamFilters on existing service elements using that API.
If you would like this functionality to be added, you can submit a request on the feature suggestions page: https://community.dataminer.services/feature-suggestions/
hi thomas, could i use an other way to update the service on the automation?
There is no other way that I'm aware of that doesn't involve reverse engineering the SLNet messages sent between Cube and DataMiner using ClientTest tool follow function. Note, using raw SLNet messages is highly discouraged as the API can change between versions.
correct, creating again the service gets error for existing.