Tungsten Fabric实战:对接vMX虚拟路由平台填坑



  • 要了解Tungsten Fabric的硬件对接机制,不一定真的去购买交换机设备来部署,更现实的方法是使用虚拟机软件版本来做模拟实验,本文使用瞻博网络vMX虚拟路由平台,模拟其MX和QFX系列交换机的对接扩展操作。

    下面做的实验就是基于EVE-NG模拟平台,在CentOS虚拟机上做Tungsten Fabric&k8s集成部署,然后启动vMX来做对接。

    (编者按:本文着眼于能够对接并对vMX下发配置,如有疑问,欢迎加入社区与开源SDN爱好者们一起交流)

    准备

    后续对python文件的修改,都需要进入device-manager这个docker进行修改。
    26888680-da26-448d-adee-ee7cb821eaf5-image.png

    修改前记得先备份,例如:

    #cp juniper_conf.py juniper_conf.py_bak
    

    修改后需要重启device-manager这个docker,修改才会生效。

    [root@master01 ~]# docker restart 001caca78cde
    001caca78cde
    

    log打印最好一直开着,默认只有WARNNING和ERROR的信息会打印出来。

    [root@master01 ~]# tailf /var/log/contrail/contrail-device-manager.log
    

    根据打印信息找到代码位置,是最便捷的定位方法。

    如果要自己向py文件中添加打印信息,下面是个例子。

    self._logger.warning(">>password is %s" % self.user_creds[password])
    

    如果发现修改后docker不停地自动重启,那就抓紧时间进入docker后,将之前修改的py文件恢复,例如:

    #cd  /usr/lib/python2.7/site-packages/device_manager
    #cp juniper_conf.py_bak juniper_conf.py
    

    坑一:

    描述:Tungsten Fabric5.1.0版本默认对接物理交换机的功能是关闭的。

    解决方法:参考微信公众号【TF中文社区】--Tungsten Fabric入门宝典系列文章 ,需要手动添加一项,建议接着删除所有contrail相关的容器后重建。
    cf40639e-6f43-4b5f-9c29-3384a9a2e328-image.png

    坑二:

    描述:Tungsten Fabric的netconf session会去对接交换机的接口值已经被写死(juniper_conf.py),所以在web录入的时候service port填的值不会生效。

    def device_connect(self):
          if not self._nc_manager or not self.is_connected():
              try:
                  self._nc_manager = manager.connect(host=self.management_ip, port=22,
    

    解决方法:物理交换机的netconf port设置为22。

    [edit]
    netops@vMX-3# set system services netconf ssh port 22 ,才好对接
    

    坑三:

    描述:代码传入的netconf password是密文,但是ncclient只能接受密码的原文,导致:

    04/19/2020 08:00:53 PM [contrail-device-manager] [ERROR]: could not establish netconf session with  router 192.168.122.103: AuthenticationException('Authentication failed.',)
    

    例如我设置的密码是"Test123",但是其实传的是:
    b800a1c2-a5b6-4f1f-bb64-03b228bb7c70-image.png

    解决方法(juniper_conf.py):是的,我就直接赋值了。

    ![1fac441f-eec4-4f12-adc6-ecf4b6fe8cc7-image.png](/assets/uploads/files/1589948889529-1fac441f-eec4-4f12-adc6-ecf4b6fe8cc7-image.png)
    

    坑四:

    描述:netconf对接成功后,Tungsten Fabric会取回device model信息,并判断是否是mx或vmx,但是我用的模拟器返回的是olive。

    netops@vMX-3> show version
    Hostname: vMX-3
    Model: olive
    Junos: 18.2R2.6
    

    因此报错。

    04/20/2020 09:02:06 PM [contrail-device-manager] [ERROR]: product model mismatch: device model = olive, plugin mode = ['mx', 'vmx']
    

    解决方法:device_conf.py直接给model赋值。

    def validate_device(self):
           if not self.device_config:
               self.device_config = self.device_get()
           if not self.device_config:
               self.device_config = {}
               return False
           #model = self.device_config.get('product-model')
           model = 'mx'
    

    坑五:

    描述:添加BGP Router后,配置无法下发成功。明明输入的是64512,结果识别为"b’64512’"。
    4c8ac2bc-98dd-418d-a35b-b17e0503b773-image.png

    04/19/2020 09:25:38 PM [contrail-device-manager] [ERROR]: Router 192.168.122.103: error: as_number: 'b'64512'': Use format 'x' or 'x.y' to specify number 'x' (Range 1 .. 4294967295) or number with higher 2 bytes 'x' (Range 0 .. 65535) ay
    error: syntax error, expecting  or 
    

    将conf_str打印出来self._logger.warning(">>config_str is %s" % config_str)。

    d0bda22b-8320-466a-a7d6-b6f4f64a7d67-image.png

    解决方法:经过大神指点,将contrail-controller-config-devicemgr镜像从1912-latest替换为1910-laset。

    在我的deployer节点操作。

    [root@deployer ~]# docker pull opencontrailnightly/contrail-controller-config-devicemgr:1910-latest  
    [root@deployer ~]# docker tag opencontrailnightly/contrail-controller-config-devicemgr:1910-latest 192.168.122.211/contrail-controller-config-devicemgr:1910-latest
    [root@deployer ~]# docker push 192.168.122.211/contrail-controller-config-devicemgr:1910-latest
    [root@deployer ~]#
    [root@deployer ~]# curl -X GET http://localhost/v2/contrail-controller-config-devicemgr/tags/list --cacert /etc/docker/certs.d/dockershare:2333/ca.crt | python -m json.tool
      % Total    % Received % Xferd  Average Speed   Time    Time     Time  Current
                                     Dload  Upload   Total   Spent    Left  Speed
    100    85  100    85    0     0   1072      0 --:--:-- --:--:-- --:--:--  1089
    {
        "name": "contrail-controller-config-devicemgr",
        "tags": [
            "1912-latest",
            "1910-latest"
        ]
    }
    [root@deployer ~]#
    12345678910111213141516
    

    master01节点拉取(hosts文件里面已经将hub.juniper.net设置为deployer IP)。

    [root@master01 ~]# ping hub.juniper.net
    PING deployer (192.168.122.211) 56(84) bytes of data.
    64 bytes from deployer (192.168.122.211): icmp_seq=1 ttl=64 time=1.47 ms
    ^C
    --- deployer ping statistics ---
    1 packets transmitted, 1 received, 0% packet loss, time 0ms
    rtt min/avg/max/mdev = 1.472/1.472/1.472/0.000 ms
    [root@master01 ~]#
    [root@master01 ~]# docker pull hub.juniper.net/contrail-controller-config-devicemgr:1910-latest  
    [root@master01 ~]#
    [root@master01 ~]# docker image list | grep devicemgr
    hub.juniper.net/contrail-controller-config-devicemgr    1912-latest         c08868a27a0a        5 months ago        772MB
    hub.juniper.net/contrail-controller-config-devicemgr    1910-latest         a1b3ab402efc        5 months ago        862MB
    [root@master01 ~]#
    1234567891011121314
    

    修改/etc/contrail/config/docker-compose.yaml文件,将devicemgr的镜像版本从
    1912-latest改为1910-latest。

    devicemgr:
      image: "hub.juniper.net/contrail-controller-config-devicemgr:1910-latest"
    

    将contrail相关的容器删除然后重建。

    [root@master01 config]# docker-compose -f /etc/contrail/config/docker-compose.yaml down
    /usr/lib/python2.7/site-packages/requests/__init__.py:91: RequestsDependencyWarning: urllib3 (1.24.3) or chardet (2.2.1) doesn't match a supported version!
      RequestsDependencyWarning)
    Stopping config_devicemgr_1  ... done
    Stopping config_dnsmasq_1    ... done
    Stopping config_nodemgr_1    ... done
    Stopping config_schema_1     ... done
    Stopping config_svcmonitor_1 ... done
    Stopping config_stats_1      ... done
    Stopping config_api_1        ... done
    Removing config_devicemgr_1  ... done
    Removing config_dnsmasq_1    ... done
    Removing config_nodemgr_1    ... done
    Removing config_schema_1     ... done
    Removing config_svcmonitor_1 ... done
    Removing config_stats_1      ... done
    Removing config_api_1        ... done
    Removing config_node-init_1  ... done
    [root@master01 config]#
    [root@master01 config]# docker-compose -f /etc/contrail/config/docker-compose.yaml up -d
    /usr/lib/python2.7/site-packages/requests/__init__.py:91: RequestsDependencyWarning: urllib3 (1.24.3) or chardet (2.2.1) doesn't match a supported version!
      RequestsDependencyWarning)
    Creating config_node-init_1 ... done
    Creating config_schema_1     ... done
    Creating config_api_1        ... done
    Creating config_svcmonitor_1 ... done
    Creating config_nodemgr_1    ... done
    Creating config_dnsmasq_1    ... done
    Creating config_stats_1      ... done
    Creating config_devicemgr_1  ... done
    [root@master01 config]#
    1234567891011121314151617181920212223242526272829303132
    

    前面提到的坑1-4,需要在新的devicemgr中重新修改一遍。

    验证

    • Physical Router已经添加(role为None)

    54d5dd9d-124e-4bb2-8619-1592d65ed6e3-image.png

    • 添加BGP Router
      ac38687f-7f02-4571-8fab-ba105fc0a861-image.png
      c0fab8e4-a11f-4ffc-a61e-2ad2742957c4-image.png
      8a5986a1-614e-44fb-bdc8-3f277bc07bb8-image.png
    • 查看vMX上新增配置
      5b888532-3035-453a-9fec-2a19e3b3b69f-image.png

    本文为盛科网络刘敬一的原创文章。
    原文链接:
    https://blog.csdn.net/ljyfree/article/details/105652253

    Tungsten Fabric入门宝典系列文章——

    1.首次启动和运行指南
    2.TF组件的七种“武器”
    3.编排器集成
    4.关于安装的那些事(上)
    5.关于安装的那些事(下)
    6.主流监控系统工具的集成
    7.开始第二天的工作
    8. 8个典型故障及排查Tips


Log in to reply