Exemplo n.º 1
0
import json
from pyntc import ntc_device as NTC
site2 = NTC(host='102.1.1.100', username='******', password='******', device_type='cisco_ios_ssh')
site2.open()
site2_output = site2.facts
print (json.dumps(site2_output, indent=4))
site2.config_list(['crypto isakmp policy 1',
                   'authentication pre-share',
                   'encryption aes',
                   'hash sha',
                   'group 5',
                   'lifetime 1800',
                   'exit',
                   'crypto isakmp key shiva address 101.1.1.100',
                   'crypto ipsec transform-set t-set esp-aes esp-sha-hmac',
                   'mode tunnel',
                   'exit',
                   'crypto ipsec security-association lifetime seconds 1800',
                   'access-list 101 permit ip 192.168.102.0 0.0.0.255 192.168.122.0 0.0.0.255', 
                   'crypto map test 10 ipsec-isakmp',
                   'set transform-set t-set',
                   'set peer 101.1.1.100',
                   'match address 101',
                   'int g0/0',
                   'crypto map test',
                   'ip access-list extended natacl',
                   '1 deny ip 192.168.102.0 0.0.0.255 192.168.122.0 0.0.0.255',
                   'exit'])
site2.close()
Exemplo n.º 2
0
print(json.dumps(router6.facts,indent=2))



print(router6.show('show ip arp'))

print(router6.show_list(['show ip inte bri','sho clock','show ip arp']))


print(router6.running_config)







router6.config('hostname test-Router6')
router6.config_list(['interface loop 111','ip address 111.11.11.11 255.255.255.255','description test loopback','no shut'])

print(router6.show('show run | in hostname'))
print(router6.show('show run interface loop 111'))
router6.save()


router6.backup_running_config('Router6.cfg')

router6.close()

##################################
#Get(retrive) configuration
import json
from pyntc import ntc_device as NTC
iosvl2 = NTC(host='XXXXXX',
             username='******',
             password='******',
             device_type='cisco_ios_ssh')
iosvl2.open()

ios_run = iosvl2.running_config
print ios_run

iosvl2.close()
Exemplo n.º 4
0
import json
from pyntc import ntc_device as NTC
site1 = NTC(host='192.168.122.56',
            username='******',
            password='******',
            device_type='cisco_ios_ssh')
site1.open()
site1_output = site1.facts
print(json.dumps(site1_output, indent=4))
site1.config_list([
    'crypto isakmp policy 1', 'authentication pre-share', 'encryption aes',
    'hash sha', 'group 5', 'lifetime 1800', 'exit',
    'crypto isakmp key shiva address 102.1.1.100',
    'crypto ipsec transform-set t-set esp-aes esp-sha-hmac', 'mode tunnel',
    'exit', 'crypto ipsec security-association lifetime seconds 1800',
    'access-list 101 permit ip 192.168.122.0 0.0.0.255 192.168.102.0 0.0.0.255',
    'crypto map test 10 ipsec-isakmp', 'set transform-set t-set',
    'set peer 102.1.1.100', 'match address 101', 'int g0/0', 'crypto map test',
    'ip access-list extended natacl',
    '1 deny ip 192.168.122.0 0.0.0.255 192.168.102.0 0.0.0.255', 'exit'
])
site1.close()
    DEVICE = NTC(host=str(IP),
                 username='******',
                 password='******',
                 device_type='cisco_ios_ssh')
    DEVICE.open()

    print("Connected to " + str(IP))

    # ------------------------------------
    print("Facts - " + str(IP))
    OUTPUT = DEVICE.facts
    OUTPUT = json.dumps(OUTPUT, indent=4)
    print(OUTPUT)

    # ------------------------------------
    print("Running Config - " + str(IP))
    OUTPUT = DEVICE.running_config
    print(OUTPUT)

    # ------------------------------------
    print("Backup of Running Config - " + str(IP))
    if not os.path.exists("Configuration Backup"):
        os.makedirs("Configuration Backup")
    FILENAME = "Configuration Backup\\device " + str(IP) + ".cfg"
    DEVICE.backup_running_config(FILENAME)
    print("Backup Completed for " + str(IP))

    # ------------------------------------

    DEVICE.close()
#!/usr/bin/env python

import json
from pyntc import ntc_device as NTC

rtr = NTC(host='192.168.122.26', username='******', password='******', device_type='cisco_ios_ssh')
rtr.open()

ios_output = rtr.facts
print (json.dumps(ios_output, indent=4))

rtr.config_list(['router ospf 1', 
                 'no network 0.0.0.0 255.255.255.255 area 0', 
                 'network 10.2.2.1 255.255.255.255 area 0', 
                 'network 192.168.122.0 255.255.255.0 area 0',
                 'network 10.3.3.1 255.255.255.255 area 0'])
                 
rtr.close()
Exemplo n.º 7
0
import json
from pyntc import ntc_device as NTC

SW = NTC(host='192.168.2.11',
         username='******',
         password='******',
         device_type='cisco_ios_ssh')
SW.open()

#print (json.dumps(SW.facts, indent=4))
SW.config('hostname pyntc_S1')
SW.config_list(['router ospf 1', 'network 192.168.2.0 0.0.0.255 area 0'])

SW.close()
Exemplo n.º 8
0
import json
from pyntc import ntc_device as NTC

iosv_l2 = NTC(host='192.168.122.242',username='******',password='******',device_$
iosv_l2.open()

iosv_output = iosv_l2.facts
print json.dumps(iosv_output, indent=4)

iosv_l2.close()