Orchastrating Network infra using Cisco NSO 2



# NEDの設定
デバイス管理にNEDの設定が必要になる。
```shell-session

$ cd NSOins/
$ ncs --stop
$ ncs-setup --package /home/username/NSO/packages/neds/cisco-ios-cli-3.8 --dest /home/username/NSOins/
$ cd packages/
$ ls
cisco-ios-cli-3.8

$ source ../NSO/ncsrc

$ ncs
$ ncs_cli -u admin -C
```

# 管理デバイスの設定
```cisco_ios
!追加したパッケージをロードする。
admin@ncs# packages reload
reload-result {
    package cisco-ios-cli-3.8
    result true
}
admin@ncs# 
System message at 2024-12-01 02:33:46...
    Subsystem stopped: ncs-dp-1-cisco-ios-cli-3.8:IOSDp2
admin@ncs# 
System message at 2024-12-01 02:33:46...
    Subsystem stopped: ncs-dp-2-cisco-ios-cli-3.8:IOSDp
admin@ncs# 
System message at 2024-12-01 02:33:46...
    Subsystem started: ncs-dp-3-cisco-ios-cli-3.8:IOSDp2
admin@ncs# 
System message at 2024-12-01 02:33:46...
    Subsystem started: ncs-dp-4-cisco-ios-cli-3.8:IOSDp
admin@ncs# 

!認証グループの設定
admin@ncs# config
Entering configuration mode terminal
admin@ncs(config)# devices authgroups group myauthgroup
admin@ncs(config-group-myauthgroup)# default-map remote-name admin
admin@ncs(config-group-myauthgroup)# default-map remote-password cisco
admin@ncs(config-group-myauthgroup)# exit
admin@ncs(config)# commit
Commit complete.
admin@ncs(config)# 

!管理デバイスの設定
admin@ncs(config)# devices device IOS_XE1
admin@ncs(config-device-IOS_XE1)# authgroup myauthroup
admin@ncs(config-device-IOS_XE1)# address 10.255.1.101
admin@ncs(config-device-IOS_XE1)# ssh host-key-verification none
admin@ncs(config-device-IOS_XE1)# device-type cli ned-id cisco-ios-cli-3.8 
admin@ncs(config-device-IOS_XE1)# device-type cli protocol ssh
admin@ncs(config-device-IOS_XE1)# state admin-state unlocked 
admin@ncs(config-device-IOS_XE1)# commit
Commit complete.
admin@ncs(config-device-IOS_XE1)# end
admin@ncs# show devices list
NAME     ADDRESS       DESCRIPTION  NED ID             ADMIN STATE  
------------------------------------------------------------------
IOS_XE1  10.255.1.101  -            cisco-ios-cli-3.8  unlocked  

```


# 各種コマンド
```cisco_ios
!pingコマンド
admin@ncs# devices device IOS_XE1 ping
result PING 10.255.1.101 (10.255.1.101) 56(84) bytes of data.
64 bytes from 10.255.1.101: icmp_seq=1 ttl=255 time=13.4 ms

--- 10.255.1.101 ping statistics ---
1 packets transmitted, 1 received, 0% packet loss, time 0ms
rtt min/avg/max/mdev = 13.439/13.439/13.439/0.000 ms

!管理デバイスへの接続
admin@ncs# devices device IOS_XE1 connect
result true
info (admin) Connected to IOS_XE1 - 10.255.1.101:22

!管理デバイスからコンフィグを取得
admin@ncs# devices device IOS_XE1 sync-from
result true
admin@ncs# 

!コンフィグの閲覧
admin@ncs# show running-config devices device IOS_XE1
devices device IOS_XE1
 address   10.255.1.101
 ssh host-key-verification none
 authgroup myauthgroup
 device-type cli ned-id cisco-ios-cli-3.8
 device-type cli protocol ssh
 state admin-state unlocked

```

# NSOから設定

```cisco_ios
admin@ncs# 
admin@ncs# config
Entering configuration mode terminal
admin@ncs(config)# devices device IOS_XE1 config
admin@ncs(config-if)# ip address 192.168.10.1 255.255.255.0
admin@ncs(config-if)# description configured by NSO
admin@ncs(config-if)# no shut
admin@ncs(config-if)# top
admin@ncs(config)# show config
devices device IOS_XE1
 config
  interface Loopback10
   description configured by NSO
   ip address 192.168.10.1 255.255.255.0
   no shutdown
  exit
 !
!
admin@ncs(config)# commit
Commit complete.
admin@ncs(config)# 
```

確認するとループバックが追加されてる。
```cisco_ios
IOS-XE1#sh int desc 
Interface                      Status         Protocol Description
Gi1                            up             up       Connect to MGMT
Gi2                            up             up       Connect to IOS-XE2
Gi3                            up             up       Connect to IOS2
Gi4                            up             up       Connect to IOS4
Lo10                           up             up       configured by NSO
IOS-XE1#
```