In many Contrail setups today, in order to log in to a Contrail node (for example a controller node or a compute node), you need to first log in to an intermediate host to prepare the login environment, and from there you may need to log in to another server (for example an undercloud server). Only after that can you log in to a target Contrail node.
Repeating these steps each time just to log in to multiple Contrail nodes in a cluster is tedious and inefficient. However, there are many tools that can be used to simplify this process, such as the open source tool tmux. Tmux is a lightweight and powerful screen multiplexer tool that is typically used for this very scenario.
In this article, we demonstrate how to initiate a tmux session in Contrail environments.
Before starting tmux, execute the following steps:
Log in to the RHOST13 host (the first SSH session).
SSH into the undercloud server (the second SSH session).
Source the stackrc environmental file.
stackrc
Type " openstack server list " to list all Contrail nodes.
openstack server list
Type " tmux ls " to list existing tmux sessions. This is also to make sure that tmux is available.
tmux ls
Type " tmux new -s jtac " to start a (new) tmux session named " jtac " in the undercloud server.
tmux new -s jtac
jtac
SSH into any of the Contrail nodes (the third SSH session).
Some example outputs in the lab environment are given as follows:
$ ssh 10.85.32.44 Last login: Sat Jun 12 18:55:22 2021 from pings-t490.jnpr.net [root@global-intel4 ~]# ssh stack@undercloud Last login: Sat Jun 12 21:55:31 2021 from 192.168.122.1 [stack@queensa ~]$ source stackrc (undercloud) [stack@queensa ~]$ openstack server list +--------------------------------------+--------------------------------+--------+------------------------+----------------+---------------------+ | ID | Name | Status | Networks | Image | Flavor | +--------------------------------------+--------------------------------+--------+------------------------+----------------+---------------------+ | 30ebd697-c756-4ee4-a09c-dec1eb37fd50 | overcloud-contrailcontroller-0 | ACTIVE | ctlplane=192.168.24.12 | overcloud-full | contrail-controller | | 1b7f2838-f950-4ae1-885e-d111a9c673be | overcloud-novacompute-0 | ACTIVE | ctlplane=192.168.24.8 | overcloud-full | compute | | 74280d13-99d6-47fa-94fd-953eaf22ef0f | overcloud-contrailcontroller-1 | ACTIVE | ctlplane=192.168.24.23 | overcloud-full | contrail-controller | | a65e70c7-ef77-4cc3-864b-1989302aa28f | overcloud-controller-0 | ACTIVE | ctlplane=192.168.24.15 | overcloud-full | control | | ef531c6b-5773-4973-a302-1082279db354 | overcloud-contrailcontroller-2 | ACTIVE | ctlplane=192.168.24.10 | overcloud-full | contrail-controller | +--------------------------------------+--------------------------------+--------+------------------------+----------------+---------------------+ (undercloud) [stack@queensa ~]$ tmux -V tmux 1.8 (undercloud) [stack@queensa ~]$ tmux ls (undercloud) [stack@queensa ~]$
From the undercloud server, Contrail nodes can be listed with the openstack server list command. From the output, you see five nodes:
Contrail Controller0 (cc0)
Contrail Controller1 (cc1)
Contrail Controller2 (cc2)
Contrail Compute0 (cp0)
Openstack Controller (oc0)
If the Contrail nodes are listed and tmux prints the version, you are ready to start the tmux session.
Now start a tmux session:
(undercloud) [stack@queensa ~]$ tmux new -s jtac
From this time on, you are working in a tmux session.
Inside the tmux session, you can proceed with the Contrail login process, which is to start an SSH session (the third) toward a Contrail node.
In this article, you will log in to the first Contrail node "cc0," as shown below:
(undercloud) [stack@queensa ~]$ ssh [email protected] Last login: Sun Jun 13 02:09:31 2021 from 192.168.24.1 [heat-admin@overcloud-contrailcontroller-0 ~]$ sudo -i [root@overcloud-contrailcontroller-0 ~]# docker ps | head | less -XES CONTAINER ID IMAGE 7f388cdaf74f 192.168.24.1:8787/contrail/contrail-provisioner:2011.138 ffd83cf89aba 192.168.24.1:8787/contrail/contrail-provisioner:2011.138 1c5a6803d3c0 192.168.24.1:8787/contrail/contrail-provisioner:2011.138 b498e91f9708 192.168.24.1:8787/contrail/contrail-provisioner:2011.138 1732472343c8 192.168.24.1:8787/contrail/contrail-provisioner:2011.138 2358bc22c88e 192.168.24.1:8787/contrail/contrail-nodemgr:2011.138 879e0119e6a1 192.168.24.1:8787/contrail/contrail-nodemgr:2011.138 1dd204307ea6 192.168.24.1:8787/contrail/contrail-controller-control-named:2011.138 f9304d8c1fc1 192.168.24.1:8787/contrail/contrail-controller-control-dns:2011.138
One well-known benefit of running login sessions in tmux is that even when a login session to the remote server gets lost, all sessions started on the remote server within tmux will persist. In this case, assume that you are experiencing some temporary Internet issues, and the first SSH session toward the RHOST13 host gets lost. Naturally the second SSH session from the RHOST13 host to the undercloud server will be disconnected too. However, the third SSH session initiated from the undercloud server to the target Contrail node will remain up and connected.
When you reconnect, you only need to rebuild the first and second SSH sessions, and then you can "attach" the target session with tmux again. This usage case is demonstrated with a detailed example in KB37201- [Contrail] How to detach and reattach a tmux session in Contrail [juniper.net] .