Hi,
I've been searching the dojo for hints on how to update IP settings via automation, and this article came close: https://community.dataminer.services/question/change-elements-ip-address-from-automation-script/
Aparantly the "currentElementInfo.PortInfo[0].PollingIPPort" does not contain the IP anymore, it only has the port.
Can someone provide an updated example, or any other ideas on how to approach this?
I'm also looking for a way to enable/disable the SNMP agent (under Advanced element settings) for each device via automation.
We are running version 10.2.0.0-11774-CU3
BR
Jan-Terje Larsen
Hi Jan-Terje,
Below I'm sharing with you an automation script I've created some time ago to change the SNMPv3 credentials for a specific set of elements. Now, I have added also the IP address so you can use it a reference and starting point to reach your goal. Please test it carefully.
Note this is just an idea as I'm note sure if there is a more straightforward way to do it.
Hope it helps.
using System;
using Skyline.DataMiner.Automation;
using Skyline.DataMiner.Net.Messages;
public class Script
{
//------------------------------------------------------------------------------------------------------------------------------------
// these are the input parameters of the script, please make sure they are correct:
//------------------------------------------------------------------------------------------------------------------------------------
const string sUserName = "admin"; // snmpv3 user name
const string sGetComPwd = "password_AAA"; // snmpv3 authentication password
const string sSetComPwd = "password_BBB"; // usually both authentication and encryption passwords are the same
const string sIpAddress = "127.0.0.1"; // Polling IP address
const int iIntervalBetweenChanges = 500; // in miliseconds
String[] elements = { "CMTS#1", "CMTS#2" }; // Names of the elements to be changed
//------------------------------------------------------------------------------------------------------------------------------------
public void Run(Engine engine)
{
engine.GenerateInformation("Change Element Passwords | Starting!");
engine.Timeout = TimeSpan.FromMinutes(60);
int nrElements = 0;
int nrElementsChanged = 0;
foreach (String sElement in elements)
{
nrElements++;
if (ChangeElementCredentials(engine, sElement))
nrElementsChanged++;
engine.Sleep(iIntervalBetweenChanges);
}
engine.GenerateInformation("Total of " + nrElementsChanged + " out of " + nrElements + " elements changed.");
engine.GenerateInformation("Change Element Passwords | Completed!");
}
public bool ChangeElementCredentials(Engine engine, String elementName)
{
try
{
Element eEl = engine.FindElement(elementName);
GetLiteElementInfo glei = new GetLiteElementInfo();
glei.DataMinerID = eEl.DmaId;
glei.ElementID = eEl.ElementId;
LiteElementInfoEvent leie = Engine.SLNet.SendSingleResponseMessage(glei) as LiteElementInfoEvent;
ElementPortInfo[] PortInfo = leie.PortInfo;
bool bChanged = false;
foreach (ElementPortInfo epi in PortInfo)
{
if (epi.ProtocolType.ToString().Equals("SnmpV3"))
{
epi.PollingIPAddress = sIpAddress;
epi.DataBits = sUserName;
epi.GetCommunity = sGetComPwd;
epi.SetCommunity = sSetComPwd;
bChanged = true;
}
}
if (bChanged)
{
engine.GenerateInformation("--> changing " + eEl.ElementName);
AddElementMessage aem = new AddElementMessage();
aem.DataMinerID = eEl.DmaId;
aem.ElementID = eEl.ElementId;
aem.ProtocolName = leie.Protocol;
aem.ProtocolVersion = leie.ProtocolVersion;
aem.Ports = PortInfo;
engine.GenerateInformation("--> changing " + eEl.ElementName + "; Sending AddElement message");
Engine.SLNet.SendSingleResponseMessage(aem);
}
}
catch (Exception ex)
{
engine.GenerateInformation("--> ERR: changing " + elementName + " failed!. Skipping this element. " + ex.ToString());
return false;
}
return true;
}
}
Thanks Paolo, the asnwers the IP address question.
Do you know where/how I can also set the SNMP Agent check-box ?
BR
Jan-Terje