# Path: opsmgr/common/exceptions.py
# class OpsException(Exception):
# class ConnectionException(OpsException):
# class AuthenticationException(OpsException):
# class DeviceException(OpsException):
# class InvalidDeviceException(DeviceException):
# class ProviderException(OpsException):
# 
# Path: opsmgr/common/utils.py
# def entry_exit(exclude_index=None, exclude_name=None, log_name=None, level=logging.INFO):
#     """
#     it's a decorator that to add entry and exit log for a function
# 
#     input:
#     excludeIndex -- the index of params that you don't want to be record
#     excludeName -- the name of dictionary params that you don't wnat to be record
#     log_name -- name of the log to write the logging to.
#     level -- the logging level to log the entry/exit with.  default is INFO level
#     """
# 
#     def f(func):
#         @functools.wraps(func)
#         def wrapper(*args, **kwargs):
# 
#             args_for_print = []
#             tmp_index = 0
#             arg_len = len(args)
#             while tmp_index < arg_len:
#                 if tmp_index not in exclude_index:
#                     args_for_print.append(args[tmp_index])
#                 tmp_index += 1
# 
#             kwargs_for_print = {}
#             for a in kwargs:
#                 if a in exclude_name:
#                     continue
#                 else:
#                     kwargs_for_print[a] = kwargs[a]
# 
#             logging.getLogger(log_name).log(level,
#                                             "%s::Entry params %s %s", func.__name__, "{}".format(
#                                                 args_for_print), "{}".format(kwargs_for_print))
#             result = func(*args, **kwargs)
#             logging.getLogger(log_name).log(level,
#                                             "%s::Exit %s ", func.__name__, "{}".format(result))
#             return result
#         return wrapper
#     return f


import logging
import socket
import time
import paramiko
    from StringIO import StringIO
    from io import StringIO
from opsmgr.common import constants
from opsmgr.common import exceptions
from opsmgr.common.utils import entry_exit
from opsmgr.inventory.interfaces import IManagerDevicePlugin
        output = client_shell.recv(500).decode()
        for line in output.splitlines():
            if line.startswith(self.VERSION_TAG):
                version = line.split()[2]
                break
        return version

    @entry_exit(exclude_index=[0], exclude_name=["self"])
    def get_architecture(self):
        return None

    @entry_exit(exclude_index=[0, 1], exclude_name=["self", "new_password"])
    def change_device_password(self, new_password):
        _method_ = "MLNXOSPlugin.change_device_password"
        logging.info("ENTER %s::host=%s userid=%s", _method_, self.host, self.userid)
        client_shell = self.client.invoke_shell()
        client_shell.send(self.ENABLE_COMMAND)
        client_shell.send(self.CONFIGURE_TERMINAL_COMMAND)
        client_shell.send("username " + self.userid + " password 0 " + new_password + "\n")
        time.sleep(5)
        client_shell.close()
        test_connect = MLNXOSPlugin()
        try:
            test_connect.connect(self.host, self.userid, new_password)
        except exceptions.DeviceException as e:
            logging.exception(e)
            logging.error("%s::Failed to login with new password, login exception was thrown: "
                          "%s", _method_, str(e))
            raise e


# Path: opsmgr/common/exceptions.py
# class OpsException(Exception):
# class ConnectionException(OpsException):
# class AuthenticationException(OpsException):
# class DeviceException(OpsException):
# class InvalidDeviceException(DeviceException):
# class ProviderException(OpsException):
# 
# Path: opsmgr/common/utils.py
# def entry_exit(exclude_index=None, exclude_name=None, log_name=None, level=logging.INFO):
#     """
#     it's a decorator that to add entry and exit log for a function
# 
#     input:
#     excludeIndex -- the index of params that you don't want to be record
#     excludeName -- the name of dictionary params that you don't wnat to be record
#     log_name -- name of the log to write the logging to.
#     level -- the logging level to log the entry/exit with.  default is INFO level
#     """
# 
#     def f(func):
#         @functools.wraps(func)
#         def wrapper(*args, **kwargs):
# 
#             args_for_print = []
#             tmp_index = 0
#             arg_len = len(args)
#             while tmp_index < arg_len:
#                 if tmp_index not in exclude_index:
#                     args_for_print.append(args[tmp_index])
#                 tmp_index += 1
# 
#             kwargs_for_print = {}
#             for a in kwargs:
#                 if a in exclude_name:
#                     continue
#                 else:
#                     kwargs_for_print[a] = kwargs[a]
# 
#             logging.getLogger(log_name).log(level,
#                                             "%s::Entry params %s %s", func.__name__, "{}".format(
#                                                 args_for_print), "{}".format(kwargs_for_print))
#             result = func(*args, **kwargs)
#             logging.getLogger(log_name).log(level,
#                                             "%s::Exit %s ", func.__name__, "{}".format(result))
#             return result
#         return wrapper
#     return f


# Path: plugins/devices/mellanox/opsmgr/plugins/devices/mellanox/MLNXOSManagerPlugin.py
import logging
import socket
import time
import paramiko
    from StringIO import StringIO
    from io import StringIO
from opsmgr.common import constants
from opsmgr.common import exceptions
from opsmgr.common.utils import entry_exit
from opsmgr.inventory.interfaces import IManagerDevicePlugin

        output = client_shell.recv(500).decode()
        for line in output.splitlines():
            if line.startswith(self.VERSION_TAG):
                version = line.split()[2]
                break
        return version

    @entry_exit(exclude_index=[0], exclude_name=["self"])
    def get_architecture(self):
        return None

    @entry_exit(exclude_index=[0, 1], exclude_name=["self", "new_password"])
    def change_device_password(self, new_password):
        _method_ = "MLNXOSPlugin.change_device_password"
        logging.info("ENTER %s::host=%s userid=%s", _method_, self.host, self.userid)
        client_shell = self.client.invoke_shell()
        client_shell.send(self.ENABLE_COMMAND)
        client_shell.send(self.CONFIGURE_TERMINAL_COMMAND)
        client_shell.send("username " + self.userid + " password 0 " + new_password + "\n")
        time.sleep(5)
        client_shell.close()
        test_connect = MLNXOSPlugin()
        try:
            test_connect.connect(self.host, self.userid, new_password)
        except exceptions.DeviceException as e:
            logging.exception(e)
            logging.error("%s::Failed to login with new password, login exception was thrown: "
                          "%s", _method_, str(e))
            raise e


    @entry_exit(exclude_index=[0], exclude_name=["self"])