06-05-2015 09:26 AM - edited 03-01-2019 02:48 AM
Hello,
I'm trying to use the Python MAAPI to add a CSV list of "cisco-ios" devices to NCS. I am struggling to find documentation as to how to do this. Here is where I am stuck :
def addCiscoIOS(t, name, ipAddress):
24 ''' All Cisco IOS devices use device-type of CLI and port 22
25 This function will simply take row[0] and row[1] of the device_list csv (Name and IP)
26 and add it to NCS, to an existing authgroup (for now, xxxxxx)
27 '''
28 port = "22"
29 authgroup = "xxxxxx"
30 print( 'Adding CiscoIOS Device %s @ %s:%s authgroup: %s' % (name, ipAddress, port,authgroup))
31 path = '/ncs:devices/device{"' + name + '"}'
32 #print path
33 if (t.exists(path)):
34 #print t.keys(path)
35 print('Device [%s] exists skipping!' % (name))
36
39 else :
40 t.create(path)
41 print type(ipAddress)
42 t.set_elem(ipAddress, path + '/address')
43 _V1 = ncs.types.Value
44 vport = _V1(int(port), _V1.C_UINT16)
45 t.set_elem(vport, path + '/port/')
46 t.create(path + '/device-type/cli')
47 #_N = ncs.types.Value
48 #ned_type = _N('ned-id')
49 #t.set_elem(ned_type, path + '/device-type/cli/')
50 t.create(path + '/device-type/cli/{ned-id cisco-ios}') >>>> STUCK <<<<<<
51 #_V0 = ncs.types
52 #ios_device = _V0("cisco-ios", _V0.C_IDENTITYREF)
53 #t.set_elem('/ned-id/ cisco-ios', path + '/device-type/cli/')
54 _V = ncs.types.Value
55 venum = _V(1, _V.C_ENUM_HASH)
56 t.set_elem(venum, path + '/state/admin-state')
57 t.set_elem(authgroup, path + '/authgroup')
58
01-06-2016 12:34 AM
Hi Ajay,
Request to post your question under ConfD User Community. Did you had any chance to check-Cisco DevNet: ConfD
Thanks and Regards,
Geevarghese
Discover and save your favorite ideas. Come back to expert answers, step-by-step guides, recent topics, and more.
New here? Get started with these tips. How to use Community New member guide