-
Notifications
You must be signed in to change notification settings - Fork 0
/
importNetxms.py
executable file
·32 lines (30 loc) · 963 Bytes
/
importNetxms.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
file_mappa="Dispositivi.csv";
root_netxms="test";
f = open(file_mappa,'r')
#CODE
azienda = session.findObjectByName(root_netxms.strip())
azienda_map = session.findObjectByName(root_netxms.strip()+" Maps")
if ( azienda ):
devices = csv.reader(f,delimiter=',',quotechar='"')
for row in devices:
nodeId=-1
nome=row[1]
ip=row[2]
mappastr=row[5]
print "Nome:",nome,"IP:",ip,"Mappa:",mappastr
mappa = session.findObjectByName(mappastr.strip())
if ( not mappa ):
m = NXCObjectCreationData(objects.GenericObject.OBJECT_CONTAINER, mappastr.strip(), azienda.getObjectId());
mappa = session.createObject(m)
else:
mappa = mappa.getObjectId()
try:
# cd = NXCObjectCreationData(objects.GenericObject.OBJECT_NODE, nome, mappa);
# cd.setPrimaryName(ip)
# nodeId = session.createObject(cd)
# print '"%s" created, id=%d' % (nome, nodeId)
pass
except:
print "Errore"
else:
print "Errore lettura mappa TOP"