Skip to content

Commit d219736

Browse files
committed
Added setup reset capability
1 parent 6c2a2d1 commit d219736

3 files changed

Lines changed: 159 additions & 0 deletions

File tree

Lines changed: 59 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,59 @@
1+
!! IOS XR Configuration version = 6.4.1
2+
!! Last configuration change at Sat Jul 28 02:39:47 2018 by ZTP
3+
!
4+
hostname r1
5+
banner motd ;
6+
--------------------------------------------------------------------------
7+
Router 1 (Cisco IOS XR Sandbox)
8+
--------------------------------------------------------------------------
9+
;
10+
service timestamps log datetime msec
11+
service timestamps debug datetime msec
12+
username admin
13+
group root-lr
14+
group cisco-support
15+
secret 5 $1$A4C9$oaNorr6BXDruE4gDd086L.
16+
!
17+
line console
18+
timestamp disable
19+
exec-timeout 0 0
20+
!
21+
vty-pool default 0 4 line-template VTY-TEMPLATE
22+
call-home
23+
service active
24+
contact smart-licensing
25+
profile CiscoTAC-1
26+
active
27+
destination transport-method http
28+
!
29+
!
30+
interface MgmtEth0/RP0/CPU0/0
31+
description *** MANAGEMENT INTERFACE ***
32+
ipv4 address dhcp
33+
!
34+
interface GigabitEthernet0/0/0/0
35+
shutdown
36+
!
37+
interface GigabitEthernet0/0/0/1
38+
shutdown
39+
!
40+
interface GigabitEthernet0/0/0/2
41+
shutdown
42+
!
43+
interface GigabitEthernet0/0/0/3
44+
shutdown
45+
!
46+
interface GigabitEthernet0/0/0/4
47+
shutdown
48+
!
49+
router static
50+
address-family ipv4 unicast
51+
0.0.0.0/0 192.168.122.1
52+
!
53+
!
54+
netconf-yang agent
55+
ssh
56+
!
57+
ssh server v2
58+
ssh server netconf vrf default
59+
end
Lines changed: 58 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,58 @@
1+
!! IOS XR Configuration version = 6.4.1
2+
!! Last configuration change at Sat Jul 28 02:38:41 2018 by ZTP
3+
!
4+
hostname r2
5+
banner motd ;
6+
--------------------------------------------------------------------------
7+
Router 2 (Cisco IOS XR Sandbox)
8+
--------------------------------------------------------------------------
9+
;
10+
service timestamps log datetime msec
11+
service timestamps debug datetime msec
12+
username admin
13+
group root-lr
14+
group cisco-support
15+
secret 5 $1$A4C9$oaNorr6BXDruE4gDd086L.
16+
!
17+
line console
18+
timestamp disable
19+
exec-timeout 0 0
20+
!
21+
call-home
22+
service active
23+
contact smart-licensing
24+
profile CiscoTAC-1
25+
active
26+
destination transport-method http
27+
!
28+
!
29+
interface MgmtEth0/RP0/CPU0/0
30+
description *** MANAGEMENT INTERFACE ***
31+
ipv4 address dhcp
32+
!
33+
interface GigabitEthernet0/0/0/0
34+
shutdown
35+
!
36+
interface GigabitEthernet0/0/0/1
37+
shutdown
38+
!
39+
interface GigabitEthernet0/0/0/2
40+
shutdown
41+
!
42+
interface GigabitEthernet0/0/0/3
43+
shutdown
44+
!
45+
interface GigabitEthernet0/0/0/4
46+
shutdown
47+
!
48+
router static
49+
address-family ipv4 unicast
50+
0.0.0.0/0 192.168.122.1
51+
!
52+
!
53+
netconf-yang agent
54+
ssh
55+
!
56+
ssh server v2
57+
ssh server netconf vrf default
58+
end

reset_setup/reset_setup.sh

Lines changed: 42 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,42 @@
1+
#!/bin/bash
2+
3+
r1_user="admin"
4+
r1_port=2222
5+
r1_ip="10.10.20.170"
6+
7+
r2_user="admin"
8+
r2_port=2232
9+
r2_ip="10.10.20.170"
10+
11+
function reset_config() {
12+
13+
router=$1
14+
r_user=$2
15+
r_port=$3
16+
r_ip=$4
17+
18+
# Transfer file to the router
19+
scp -P $r_port -o StrictHostKeyChecking=no ./configs/router_reset_$router.conf ${r_user}@$r_ip:/home/admin/router_reset.conf
20+
21+
source_library="source /pkg/bin/ztp_helper.sh"
22+
bash_cmd="$source_library && xrapply /home/admin/router_reset.conf"
23+
priv_escalate="sudo -i /bin/bash -c"
24+
25+
timeout 45 ssh -t -o StrictHostKeyChecking=no -p $r_port ${r_user}@$r_ip "$priv_escalate '$bash_cmd'"
26+
27+
echo "Configuration done!"
28+
29+
xrcmd_cmd="show running-config"
30+
bash_cmd="$source_library && xrcmd $xrcmd_cmd"
31+
32+
echo "Verifying loopback1 configuration..."
33+
ssh -t -o StrictHostKeyChecking=no -p $r_port ${r_user}@$r_ip "$priv_escalate '$bash_cmd'"
34+
35+
}
36+
37+
38+
# Reset Configuration
39+
reset_config "r1" $r1_user $r1_port $r1_ip
40+
41+
reset_config "r2" $r2_user $r2_port $r2_ip
42+

0 commit comments

Comments
 (0)