Install/Use Yangsuite by Docker

0

Cisco finally published the YangSuit at Devnet at Feb 2021, that can be downloaded and used by customer, and it is Free! I updated the installation section of the article to use the public version, other section should similar and not update.

Cisco YANG Suite provides a set of tools and plugins to learn, test, and adopt YANG programmable interfaces such as NETCONF, RESTCONF, gNMI and more.

YANG Suite will provides network operators with a common tool to interact with Cisco IOS XE, IOS XR, and the NX-OS Network Operating Systems as they look to modernize their network management and migrate from traditional network management tools.

https://developer.cisco.com/yangsuite/?utm_campaign=yang21&utm_source=social&utm_medium=dntwitter-yang-ww

Install

xxx:~ xxx$ git clone https://github.com/CiscoDevNet/yangsuite
xxx:~ xxx$ cd yangsuite/docker/ ; ./gen_test_certs.sh
xxx:docker xxx$ pwd
/Users/xxx/yangsuite/docker
xxx:docker xxx$ docker-compose up
Creating network "docker_default" with the default driver
Creating volume "docker_static-content" with default driver
Creating volume "docker_uwsgi" with default driver
Building yangsuite
……

Check Status

xxx:docker xxx$ docker ps -a
CONTAINER ID   IMAGE                      COMMAND                  CREATED          STATUS                      PORTS                                                                                                                  NAMES
8fe7fb90305d   backup:latest              "/code/run_cron.sh"      17 minutes ago   Up 43 seconds                                                                                                                                      docker_backup_1
ab964c5132af   nginx:latest               "/docker-entrypoint.…"   17 minutes ago   Up 42 seconds               0.0.0.0:80->80/tcp, 0.0.0.0:443->443/tcp                                                                               docker_nginx_1
288cef902d8a   yangsuite:latest           "/yangsuite/migrate_…"   17 minutes ago   Up 43 seconds               0.0.0.0:9339->9339/tcp, 0.0.0.0:50051-50052->50051-50052/tcp, 0.0.0.0:57344-57345->57344-57345/tcp                     docker_yangsuite_1

Enable External Access

At default, YangSuit only be accessed by localhost, and will have follow alarms if you access from external:

yangsuite_1  | [04/Feb/2021 23:58:33] ERROR [django.security.DisallowedHost:74] Invalid HTTP_HOST header: '10.125.6.211'. You may need to add '10.125.6.211' to ALLOWED_HOSTS.
nginx_1      | 172.21.0.1 - - [04/Feb/2021:23:58:33 +0000] "GET / HTTP/2.0" 400 26 "-" "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/87.0.4280.141 Safari/537.36"
yangsuite_1  | [pid: 41|app: 0|req: 6/37] 172.21.0.1 () {54 vars in 958 bytes} [Thu Feb  4 23:58:32 2021] GET / => generated 26 bytes in 741 msecs (HTTP/2.0 400) 1 headers in 53 bytes (1 switches on core 0)
yangsuite_1  | [04/Feb/2021 23:58:33] ERROR [django.security.DisallowedHost:74] Invalid HTTP_HOST header: '10.125.6.211'. You may need to add '10.125.6.211' to ALLOWED_HOSTS.
yangsuite_1  | [pid: 42|app: 0|req: 17/38] 172.21.0.1 () {54 vars in 897 bytes} [Thu Feb  4 23:58:33 2021] GET /favicon.ico => generated 26 bytes in 251 msecs (HTTP/2.0 400) 1 headers in 53 bytes (1 switches on core 0)
nginx_1      | 172.21.0.1 - - [04/Feb/2021:23:58:34 +0000] "GET /favicon.ico HTTP/2.0" 400 26 "https://10.125.6.211/" "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/87.0.4280.141 Safari/537.36"

How to add my ip to “ALLOWED_HOSTS”? Where is “ALLOWED_HOSTS”? We can find the file that include “ALLOWED_HOSTS” key word in the docker forder by “grep”, as follow:

xxx:yangsuite xxx$ pwd
/Users/xxx/yangsuite
xxx:yangsuite xxx$ grep -rn 'ALLOWED_HOSTS' *
docker/yangsuite/production.py:13:if 'DJANGO_ALLOWED_HOSTS' in os.environ:
docker/yangsuite/production.py:14:    ALLOWED_HOSTS = os.getenv('DJANGO_ALLOWED_HOSTS', 'localhost').split()
docker/yangsuite/production.py:16:    ALLOWED_HOSTS = 'localhost'
docker/docker-compose.yml:11:        - DJANGO_ALLOWED_HOSTS=localhost
docker/ys-data/logs/yangsuite.log:70:Invalid HTTP_HOST header: '127.0.0.1'. You may need to add '127.0.0.1' to ALLOWED_HOSTS.
docker/ys-data/logs/yangsuite.log:298:Invalid HTTP_HOST header: '10.125.6.211'. You may need to add '10.125.6.211' to ALLOWED_HOSTS.
docker/ys-data/logs/yangsuite.log:300:Invalid HTTP_HOST header: '10.125.6.211'. You may need to add '10.125.6.211' to ALLOWED_HOSTS.

Then only change “docker-compose.yml” that is ok:

xxx:yangsuite xxx$ grep -rn 'ALLOWED_HOSTS' *
docker/yangsuite/production.py:13:if 'DJANGO_ALLOWED_HOSTS' in os.environ:
docker/yangsuite/production.py:14:    ALLOWED_HOSTS = os.getenv('DJANGO_ALLOWED_HOSTS', 'localhost').split()
docker/yangsuite/production.py:16:    ALLOWED_HOSTS = 'localhost'
docker/docker-compose.yml:11:        - DJANGO_ALLOWED_HOSTS= *

Open Yangsuit

https://localhost

or

https://IP

Default username and password:

xxx:yangsuite xxx$ grep -Ern 'USER|PASS' *
docker/yangsuite/migrate_and_start.sh:18:USERNAME=${YS_ADMIN_USER:-admin}
docker/yangsuite/migrate_and_start.sh:19:PASSWORD=${YS_ADMIN_PASS:-superuser}
docker/yangsuite/migrate_and_start.sh:22:[ -z "${YS_ADMIN_USER}" ] && echo "No YS_ADMIN_USER set, using username: ${USERNAME}"
docker/yangsuite/migrate_and_start.sh:23:[ -z "${YS_ADMIN_PASS}" ] && echo "No YS_ADMIN_PASS set, using password: ${PASSWORD} [WARNING: Please change this via the admin page]"
docker/yangsuite/migrate_and_start.sh:24:echo "from django.contrib.auth.models import User; User.objects.create_superuser('${USERNAME}', '${EMAIL}', '${PASSWORD}')" | ${PY} ${YS_DIR}/manage.py shell
docker/docker-compose.yml:13:        - YS_ADMIN_USER=admin
docker/docker-compose.yml:15:        - YS_ADMIN_PASS=superuser

Add devices

Ignore or fill profile info (General Info, NETCONF, and SSH) when added devices. After added devices, you will found the devices on the right side.

Get YANG File

Add YANG repositories

Download YANG file

Check file in MacOS

Set YANG Module

Build RPC and Testing Netconf

Build RPC XML

Verified on XRv9k

RP/0/RP0/CPU0:Aug 22 04:28:07.586 UTC: netconf[1116]: %MGBL-CONFIG-6-DB_COMMIT : Configuration committed by user 'cisco'. Use 'show configuration commit changes 1000000010' to view the changes. 

RP/0/RP0/CPU0:iosxrv9000-1#show configuration commit changes 1000000010
Thu Aug 22 04:35:45.486 UTC
Building configuration...
!! IOS XR Configuration version = 6.5.2
interface Loopback0
 description frank-xr
!
end

RP/0/RP0/CPU0:iosxrv9000-1#
本文出自 Frank's Blog

版权声明:


本文链接:Install/Use Yangsuite by Docker
版权声明:本文为原创文章,仅代表个人观点,版权归 Frank Zhao 所有,转载时请注明本文出处及文章链接
你可以留言,或者trackback 从你的网站

留言哦

blonde teen swallows load.xxx videos