cancel
Showing results for 
Search instead for 
Did you mean: 
cancel
2338
Views
1
Helpful
1
Replies

tail-f NCS Python MAAPI Documentation

achenampara
Level 1
Level 1

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      


1 Reply 1

Geevarghese Cheria
Cisco Employee
Cisco Employee

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