Lately, I’ve been fiddling around with Juniper Contrail (Available as Upstream project: Tungsten Fabric). So, I’ll be posting about different stuff I learn about it, SDN in general, and Openstack as well.
One thing that I find myself doing often is testing connectivity between different network resources, primarily VMs. To do so, sometimes I need to test end-to-end connectivity which requires accessing the VM and initiating something as simple as a ping command to see what happens.
However, VNC Console (Or direct connectivity from my workstation towards Overlay/Virtual Networks that virtual machines are connected to may not be available. For this, I need to connect to the VM using the link-local IP address directly from the vRouter / Compute node.
I wrote a python script that uses Contrail API Introspect service to fetch info about compute nodes, then prints the info for VMs hosted on each one of them. In this example, I need to access a VM called AAP_02, so I use the script to find on which vRouter / Compute node it is hosted, then access it directly from there without needing to source Openstack credentials:
[root@contrail-controller contrail_utils]# python vm_linklocal_info.py +------------------------------+-------------------+----------------+-------------------+---------------------+ | Compute Node | VM Name | VM IP Address | VM MAC Address | VM Metadata Address | +------------------------------+-------------------+----------------+-------------------+---------------------+ | contrail-vrouter02.ameen.lab | XRR_01_Main | 172.16.0.67 | 02:05:94:e1:f0:fd | 169.254.0.4 | | contrail-vrouter02.ameen.lab | XRR_02_Changed | 172.16.0.4 | 02:6b:5e:1a:3c:5b | 169.254.0.3 | | contrail-vrouter02.ameen.lab | AAP_02 | 172.16.0.69 | 02:f2:8c:53:6a:2d | 169.254.0.5 | | contrail-vrouter03.ameen.lab | XRR_01_Fixed | 172.16.0.3 | 02:7a:85:f8:de:a1 | 169.254.0.3 | | contrail-vrouter03.ameen.lab | AAP_01 | 172.16.0.68 | 02:97:bc:7d:bf:79 | 169.254.0.5 | | contrail-vrouter03.ameen.lab | vXRR_CrossProject | 172.16.0.131 | 02:97:f1:03:79:f0 | 169.254.0.4 | +------------------------------+-------------------+----------------+-------------------+---------------------+ [root@contrail-controller contrail_utils]# ssh contrail-vrouter02.ameen.lab root@contrail-vrouter02.ameen.lab's password: [root@contrail-vrouter02 ~]# ssh root@169.254.0.5 root@169.254.0.5's password: [root@AAP_02 ~]# ip address show eth0 2: eth0: <BROADCAST,MULTICAST,UP,LOWER_UP>; mtu 1500 qdisc pfifo_fast state UP qlen 1000 link/ether 02:f2:8c:53:6a:2d brd ff:ff:ff:ff:ff:ff inet 172.16.0.69/26 brd 172.16.0.127 scope global eth0 valid_lft forever preferred_lft forever
Script is available here. Clone it to your Contrail Controller and execute it from there.
Awesome work Bro !
Ahlan Ahlan! Thanks for passing by bro :]