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

CLI optimization #5

Open
wants to merge 2 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 7 additions & 4 deletions show/main.py
Original file line number Diff line number Diff line change
@@ -1,20 +1,20 @@
#! /usr/bin/python -u

import json
import netaddr
#import netaddr
import os
import subprocess
import sys

import click
from natsort import natsorted
import netifaces
from pkg_resources import parse_version
#from pkg_resources import parse_version

import feature
import interfaces
import kube
import mlnx
#import mlnx
import utilities_common.cli as clicommon
import vlan
import system_health
Expand Down Expand Up @@ -55,7 +55,7 @@ def get_routing_stack():


# Global Routing-Stack variable
routing_stack = get_routing_stack()
routing_stack = "frr"

# Read given JSON file
def readJsonFile(fileName):
Expand Down Expand Up @@ -714,6 +714,7 @@ def get_if_master(iface):
@ip.command()
def interfaces():
"""Show interfaces IPv4 address"""
import netaddr
header = ['Interface', 'Master', 'IPv4 address/mask', 'Admin/Oper', 'BGP Neighbor', 'Neighbor IP']
data = []
bgp_peer = get_bgp_peer()
Expand Down Expand Up @@ -1002,6 +1003,7 @@ def platform():

version_info = device_info.get_sonic_version_info()
if (version_info and version_info.get('asic_type') == 'mellanox'):
import mlnx
platform.add_command(mlnx.mlnx)

# 'summary' subcommand ("show platform summary")
Expand Down Expand Up @@ -1381,6 +1383,7 @@ def bgp(verbose):
@click.option('--verbose', is_flag=True, help="Enable verbose output")
def ntp(ctx, verbose):
"""Show NTP information"""
from pkg_resources import parse_version
ntpstat_cmd = "ntpstat"
ntpcmd = "ntpq -p -n"
if is_mgmt_vrf_enabled(ctx) is True:
Expand Down
3 changes: 2 additions & 1 deletion utilities_common/cli.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@

import click
import json
import netaddr
#import netaddr

from natsort import natsorted

Expand Down Expand Up @@ -195,6 +195,7 @@ def get_interface_naming_mode():

def is_ipaddress(val):
""" Validate if an entry is a valid IP """
import netaddr
if not val:
return False
try:
Expand Down