Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[devutils] add utilities to handle devices #2645

Merged
merged 1 commit into from
Dec 10, 2020
Merged

Conversation

yxieca
Copy link
Collaborator

@yxieca yxieca commented Dec 10, 2020

Summary:
Add utilities for device related oeprations.

Type of change

  • Bug fix
  • Testbed and Framework(new/improvement)
  • Test case(new/improvement)

Approach

What is the motivation for this PR?

Finding DUT information for access is a chore. Checking device status is not easy especially when comes to multiple devices.0:w

How did you do it?

  • list hosts defined in an inventory.
  • ping hosts defined in an inventory.
  • ssh to host(s) define din an inventory.
    (best executed with limited to one host)
  • console connect to host(s).
    (not implemetned, for future expansion)

Signed-off-by: Ying Xie [email protected]

How did you verify/test it?

yinxi@str-serv-acs-14:~/src/sonic-mgmt/ansible$ ./devutils -h
usage: devutils [-h] [-6] [-a {list,ping,ssh,console}] [-c CATEGORY]
[-i INVENTORY] [-l LIMIT] [-u USER]

Device utilities

optional arguments:
-h, --help show this help message and exit
-6, --ipv6 Include IPv6
-a {list,ping,ssh,console}, --action {list,ping,ssh,console}
Action towards host(s): list, ping, ssh, console,
default list
-c CATEGORY, --category CATEGORY
Categories: all, sonic, ptf, pdu, default all
-i INVENTORY, --inventory INVENTORY
Categories: lab, etc, default lab
-l LIMIT, --limit LIMIT
Host: limit to a single dut host name, default all
-u USER, --user USER User: user account to login to host with, default
admin

yinxi@str-serv-acs-14:~/src/sonic-mgmt/ansible$ ./devutils -a list
type sonic_s6000 host vlab-03 details {'ansible_host': '10.250.0.105', 'ansible_hostv6': 'fec0::ffff:afa:5'}
type sonic_s6000 host lab-s6000-01 details {'ansible_host': '10.251.0.189', 'ansible_hostv6': 'fec0::ffff:afa:9'}
type sonic_s6000 host vlab-01 details {'ansible_host': '10.250.0.101', 'ansible_hostv6': 'fec0::ffff:afa:1'}
type sonic_s6000 host vlab-06 details {'ansible_host': '10.250.0.111', 'ansible_hostv6': 'fec0::ffff:afa:b'}
type sonic_s6000 host vlab-05 details {'ansible_host': '10.250.0.110', 'ansible_hostv6': 'fec0::ffff:afa:a'}
type sonic_s6000 host vlab-04 details {'ansible_host': '10.250.0.107', 'ansible_hostv6': 'fec0::ffff:afa:7'}
type fanout host str-7260-10 details {'ansible_host': '10.251.0.13'}
type fanout host str-7260-11 details {'ansible_host': '10.251.0.234'}
type fanout host str-msn2700-02 details {'os': 'sonic', 'ansible_host': '10.251.0.235'}
type sonic_sn2700_40 host str-msn2700-01 details {'model': 'MSN2700-CS2FO', 'base_mac': '24:8a:07:12:34:56', 'syseeprom_info': {'0x28': 'x86_64-mlnx_x86-r0', '0x29': '2016.11-5.1.0008-9600', '0x22': 'MSN2700-CS2FO', '0x23': 'MT1234X56789', '0x21': 'MSN2700', '0x26': '0', '0x24': '24:8a:07:12:34:56', '0x25': '12/07/2016', '0x2A': '128', '0x2B': 'Mellanox', '0xFE': '0xFBA1E964'}, 'ansible_host': '10.251.0.188', 'serial': 'MT1234X56789'}
type ptf host ptf_vms6-1 details {'ansible_ssh_user': 'root', 'ansible_host': '10.250.0.100', 'ansible_ssh_pass': 'root'}
type ptf host ptf_ptf1 details {'ansible_ssh_user': 'root', 'ansible_host': '10.255.0.188', 'ansible_ssh_pass': 'root'}
type ptf host ptf_vms1-1 details {'ansible_ssh_user': 'root', 'ansible_host': '10.255.0.178', 'ansible_ssh_pass': 'root'}
type sonic_s6100 host vlab-02 details {'ansible_host': '10.250.0.102'}
type sonic_s6100 host lab-s6100-01 details {'ansible_host': '10.251.0.190'}
type sonic_a7260 host lab-a7260-01 details {'hwsku': 'Arista-7260CX3-D108C8', 'ansible_host': '10.251.0.191'}

yinxi@str-serv-acs-14:~/src/sonic-mgmt/ansible$ ./devutils -i str -c sonic -a ping
host str-msn2700-05 (type sonic_mlnx_40) is unreachable at address 10.3.147.48
host str-msn2700-11-3po (type sonic_mlnx_40) is unreachable at address 10.3.147.54
host str-s6000-on-3 (type sonic_dell32_40) is unreachable at address 10.3.146.112
host str-s6000-acs-7 (type sonic_dell32_40) is unreachable at address 10.3.147.195

yinxi@str-serv-acs-14:~/src/sonic-mgmt/ansible$ ./devutils -i str2 -a ssh -l str2-7050cx3-acs-06
[email protected]'s password:
Linux str2-7050cx3-acs-06 4.19.0-9-2-amd64 #1 SMP Debian 4.19.118-2+deb10u1 (2020-06-07) x86_64
You are on


/ | / _ | \ | ()/ |
_
| | | | | | | |
) | || | |\ | | |

|
/ ___/|| _||____|

-- Software for Open Networking in the Cloud --

Unauthorized access and/or use are prohibited.
All access and/or use are subject to monitoring.

Help: http://azure.github.io/SONiC/

Last login: Thu Dec 10 06:23:48 2020 from 10.64.247.30

@yxieca
Copy link
Collaborator Author

yxieca commented Dec 10, 2020

@jleveque, @sujinmkang we can probably add PDU toggling action to this utility too? And any other actions might be useful for you folks?

@lgtm-com
Copy link

lgtm-com bot commented Dec 10, 2020

This pull request introduces 1 alert when merging c932940a50ff847ea7774dd31f9f878ded3495ca into 2c5ff63 - view on LGTM.com

new alerts:

  • 1 for Unused import

- list hosts defined in an inventory.
- ping hosts defined in an inventory.
- ssh to host(s) define din an inventory.
  (best executed with limited to one host)
- console connect to host(s).
  (not implemetned, for future expansion)

Signed-off-by: Ying Xie <[email protected]>
@yxieca
Copy link
Collaborator Author

yxieca commented Dec 10, 2020

retest vsimage please

@jleveque
Copy link
Contributor

@jleveque, @sujinmkang we can probably add PDU toggling action to this utility too? And any other actions might be useful for you folks?

Yes, I think this utility could be extended for many purposes, but none off the top of my head at the moment.

@yxieca yxieca merged commit 4f5abea into sonic-net:master Dec 10, 2020
@yxieca yxieca deleted the devutils branch December 10, 2020 22:53
antoninamelnyk pushed a commit to antoninamelnyk/sonic-mgmt that referenced this pull request Dec 11, 2020
Summary:
Add utilities for device related oeprations.

Approach
What is the motivation for this PR?
Finding DUT information for access is a chore. Checking device status is not easy especially when comes to multiple devices.

How did you do it?
list hosts defined in an inventory.
ping hosts defined in an inventory.
ssh to host(s) define din an inventory.
(best executed with limited to one host)
console connect to host(s).
(not implemetned, for future expansion)
Signed-off-by: Ying Xie [email protected]

How did you verify/test it?
yinxi@str-serv-acs-14:~/src/sonic-mgmt/ansible$ ./devutils -h
usage: devutils [-h] [-6] [-a {list,ping,ssh,console}] [-c CATEGORY]
[-i INVENTORY] [-l LIMIT] [-u USER]

Device utilities

optional arguments:
-h, --help show this help message and exit
-6, --ipv6 Include IPv6
-a {list,ping,ssh,console}, --action {list,ping,ssh,console}
Action towards host(s): list, ping, ssh, console,
default list
-c CATEGORY, --category CATEGORY
Categories: all, sonic, ptf, pdu, default all
-i INVENTORY, --inventory INVENTORY
Categories: lab, etc, default lab
-l LIMIT, --limit LIMIT
Host: limit to a single dut host name, default all
-u USER, --user USER User: user account to login to host with, default
admin
antoninamelnyk added a commit to antoninamelnyk/sonic-mgmt that referenced this pull request Dec 11, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants