source/Tools Integration/CE-Integration/CE-automation-scripts/0-Prerequisites-checks.py [81:153]:
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
def check_ssh_connectivity(ip, user_name, pass_key, is_key, s_result):
    ssh, error = open_ssh(ip, user_name, pass_key, is_key)
    if ssh is None or len(error) > 0:
        s_result["error"] = error
        s_result["SSH22"] = "Fail"
        if "final_result" in s_result:
            s_result["final_result"] = s_result["final_result"] + "SSH22,"
        else:
            s_result["final_result"] = "SSH22,"
        print(" SSH 22 to source server : Fail")
        return None
    else:
        s_result["SSH22"] = "Pass"
        print(" SSH 22 to source server : Pass")
        return ssh


def check_sudo_permissions(ssh, s_result):
    stderr = None
    stdout = None
    ssh_err = ''
    if ssh is not None:
        try:
            stdin, stdout, stderr = ssh.exec_command("sudo -n -l")
        except paramiko.SSHException as e:
            ssh_err = "Got exception! " + str(e)
    else:
        ssh_err = 'Unable to connect! SSH is null'

    if stderr:
        for err in stderr.readlines():
            ssh_err = ssh_err + err
    if 'password is required' in ssh_err:
            s_result["error"] = ssh_err
            s_result["SUDO"] = "Fail"
            if "final_result" in s_result:
                s_result["final_result"] = s_result["final_result"] + "SUDO,"
            else:
                s_result["final_result"] = "SUDO,"
            print(" SUDO permission         : Fail")
    else:
        s_result["SUDO"] = "Pass"
        print(" SUDO permission         : Pass")

def check_tcp_connectivity(ssh, host, port, s_result):
    stderr = None
    stdout = None
    check = "TCP" + str(port)
    ssh_err = ''
    if ssh is not None:
        cmd = "sudo timeout 2 bash -c '</dev/tcp/" + host + "/" + port + " && echo port is open || echo port is closed' || echo connection timeout"
        try:
            stdin, stdout, stderr = ssh.exec_command(cmd)
            str_output = ''
            for output in stdout.readlines():
                str_output = str_output + output
            if len(str_output) > 0:
                str_output = str_output.strip()
                if "open" in str(str_output):
                    s_result[check] = "Pass"
                else:
                    s_result[check] = "Fail"
            else:
                s_result[check] = "Fail"
        except paramiko.SSHException as e:
            ssh_err = "Got exception! while executing the command " + cmd + \
                      " due to " + str(e)
    else:
        ssh_err = 'Unable to connect! SSH is null'

    if port == '1500':
        message = " TCP 1500 to Rep Server  : "
    elif port == '443':
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -



source/Tools Integration/MGN-Integration/MGN-automation-scripts/0-Prerequisites-checks.py [173:245]:
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
def check_ssh_connectivity(ip, user_name, pass_key, is_key, s_result):
    ssh, error = open_ssh(ip, user_name, pass_key, is_key)
    if ssh is None or len(error) > 0:
        s_result["error"] = error
        s_result["SSH22"] = "Fail"
        if "final_result" in s_result:
            s_result["final_result"] = s_result["final_result"] + "SSH22,"
        else:
            s_result["final_result"] = "SSH22,"
        print(" SSH 22 to source server : Fail")
        return None
    else:
        s_result["SSH22"] = "Pass"
        print(" SSH 22 to source server : Pass")
        return ssh


def check_sudo_permissions(ssh, s_result):
    stderr = None
    stdout = None
    ssh_err = ''
    if ssh is not None:
        try:
            stdin, stdout, stderr = ssh.exec_command("sudo -n -l")
        except paramiko.SSHException as e:
            ssh_err = "Got exception! " + str(e)
    else:
        ssh_err = 'Unable to connect! SSH is null'

    if stderr:
        for err in stderr.readlines():
            ssh_err = ssh_err + err
    if 'password is required' in ssh_err:
            s_result["error"] = ssh_err
            s_result["SUDO"] = "Fail"
            if "final_result" in s_result:
                s_result["final_result"] = s_result["final_result"] + "SUDO,"
            else:
                s_result["final_result"] = "SUDO,"
            print(" SUDO permission         : Fail")
    else:
        s_result["SUDO"] = "Pass"
        print(" SUDO permission         : Pass")

def check_tcp_connectivity(ssh, host, port, s_result):
    stderr = None
    stdout = None
    check = "TCP" + str(port)
    ssh_err = ''
    if ssh is not None:
        cmd = "sudo timeout 2 bash -c '</dev/tcp/" + host + "/" + port + " && echo port is open || echo port is closed' || echo connection timeout"
        try:
            stdin, stdout, stderr = ssh.exec_command(cmd)
            str_output = ''
            for output in stdout.readlines():
                str_output = str_output + output
            if len(str_output) > 0:
                str_output = str_output.strip()
                if "open" in str(str_output):
                    s_result[check] = "Pass"
                else:
                    s_result[check] = "Fail"
            else:
                s_result[check] = "Fail"
        except paramiko.SSHException as e:
            ssh_err = "Got exception! while executing the command " + cmd + \
                      " due to " + str(e)
    else:
        ssh_err = 'Unable to connect! SSH is null'

    if port == '1500':
        message = " TCP 1500 to Rep Server  : "
    elif port == '443':
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -



