DEV Community

Shubham Fulbandhe
Shubham Fulbandhe

Posted on • Updated on

Connecting Windows Servers and mainframe

Hello readers, my name is Shubham and I am working as a Senior Engineer in Luxoft India. I am primarily working as a Hogan Mainframe Developer having 7 years of experience in the Banking and Finance Domain.

Introduction and Luxoft’s contribution to this article:

In my role as a Senior Engineer at Luxoft, I had the privilege of leveraging the extensive knowledge resources of the Luxoft’s Banking and Finance Team to develop the connectivity solution for mainframe.

In this article, we will be exploring the high-level information about the open connectivity solution I have developed at Luxoft and which can be used to make daily developments tasks easier.
We will discuss how it helped me and my team to significantly connect Windows servers and Unix on the mainframe using Python. By leveraging Python power, we can achieve remarkable advancements, improve data integration, and optimize code operations.

Mainframe and its connection importance with the Windows Server:

The Connectivity and Integration between different systems play a pivotal role in driving efficiency, productivity, and innovation in the many technological environment. Especially in the banking and financial industry, where seamless communication between Windows servers and Unix on the mainframe is essential for streamlining operations, enhancing product offerings, and ensuring regulatory compliance for the customers.

The importance of having efficient connection between Mainframe and Windows systems:
a) Streamlining Operations: The banking and financial industry heavily relies on a different range of systems, including Windows servers and Unix on the mainframe. Connecting these systems enables seamless data exchange, streamlined workflows, and automated processes, reducing manual effort and improving operational efficiency.

b) Enhancing Product Offerings: Connecting Windows servers and Unix on the mainframe allows banks and financial institutions to enhance their product offerings. By integrating data and functionalities across platforms, they can provide customers with comprehensive and cohesive solutions, such as real-time account information, personalized financial recommendations, and advanced reporting capabilities.

c) Regulatory Compliance: The banking and financial industry operates in a highly regulated environment. Connecting Windows servers and Unix on the mainframe facilitates efficient data management, ensuring compliance with stringent regulations, including data privacy, security, and auditability requirements.

d) Simplified Development Process: Python's simplicity and readability significantly ease the development process. Its concise syntax, along with powerful libraries like Paramiko for SSH connections, enables developers to create efficient and maintainable code, reducing development time and effort.

Let us directly go through the example of Python Code and its descriptions which can be used to connect a Windows remote server and Unix on the mainframe.

Please do note that these scripts are basic syntax for connecting the windows server with Unix system on mainframe and need to be developed in little complex way considering your data to be transferred. However, this example can be taken as skeleton for our Systems.

import paramiko

# Establish SSH connection to Windows remote server
def connect_to_windows_server():
    windows_host = '198.172.10.1'
    username = 'your_username'
    password = 'your_password'

    # Create SSH client
    client = paramiko.SSHClient()
    client.set_missing_host_key_policy(paramiko.AutoAddPolicy())

    # Connect to the Windows remote server
    client.connect(windows_host, username=username, password=password)

    return client

# Execute Unix command on the mainframe
def execute_unix_command(client):
    unix_command = 'ls -l'

    # Execute command on the Unix on the mainframe
    stdin, stdout, stderr = client.exec_command(unix_command)

    # Print command output
    print(stdout.read().decode())

# Close SSH connection
def close_connection(client):
    client.close()

# Main function
def main():
    try:
        # Connect to the Windows remote server
        windows_client = connect_to_windows_server()

        # Execute Unix command on the mainframe
        execute_unix_command(windows_client)

    except paramiko.AuthenticationException:
        print("Authentication failed. Please check your credentials.")

    except paramiko.SSHException as ssh_err:
        print("Unable to establish SSH connection:", str(ssh_err))

    finally:
        # Close the SSH connection
        close_connection(windows_client)

# Call the main function
if __name__ == '__main__':
    main()

Enter fullscreen mode Exit fullscreen mode

Here's a detailed description of the provided Python code, highlighting why it is specifically written for mainframe connection:
The Python code presented here is specifically designed to establish a connection between a Windows remote server and a mainframe system running Unix. It leverages the paramiko module, which is widely used for SSH connections, to facilitate secure communication and command execution.

Let us break down the code and explore its main components:

1) Importing the Required Modules:
The paramiko module is imported to handle SSH connections. It provides the necessary classes and methods to establish an SSH connection to the Windows remote server and execute commands on the mainframe.

2) Establishing SSH Connection to the Windows Remote Server:
The connect_to_windows_server() function is responsible for establishing an SSH connection to the Windows remote server. It takes the IP address of the remote server, along with the username and password credentials, as parameters. Within this function, an instance of the paramiko.SSHClient class is created to represent the SSH client.
The set_missing_host_key_policy() method is called to automatically add the remote server's host key to the client's known hosts. This ensures a smooth and secure connection.
Finally, the connect() method of the SSH client is used to establish the SSH connection to the Windows remote server.

3) Executing Unix Command on the mainframe:
The execute_unix_command() function is responsible for executing a Unix command on the mainframe system.
It takes the SSH client as a parameter, which represents the established connection to the Windows remote server. Within this function, a Unix command (in this case, "ls -l") is defined as the unix_command variable.
The exec_command() method of the SSH client is called, passing the Unix command as an argument. This method executes the command on the mainframe system.
The command output is then obtained by reading from the stdout stream and printed to the console.

4) Closing the SSH Connection:
The close_connection() function is responsible for closing the SSH connection to the Windows remote server.
It takes the SSH client as a parameter.
Within this function, the close() method of the SSH client is called to gracefully close the SSH connection.

5) Main Function:
The main() function serves as the entry point of the script.
It wraps the entire process of connecting to the Windows remote server, executing the Unix command on the mainframe, and closing the SSH connection.
Any exceptions that may occur during the SSH connection establishment or command execution are caught and handled appropriately, ensuring a smooth execution flow.

In Summary, this Python code is specifically written for connecting a Windows remote server and a mainframe system running Unix. It utilizes the paramiko module's capabilities to establish an SSH connection, execute commands remotely, and retrieve the command output. By employing this code, organizations can streamline their operations by enabling seamless communication and interaction between these two distinct environments, thereby maximizing productivity and efficiency in mainframe-related tasks.

Advancements can be achieved in the Banking and Financial Industry by connecting Windows server with mainframe:

- Enhanced Data Integration: Connecting Windows servers and Unix on the mainframe using Python allows banks and financial institutions to integrate vast amounts of data from different systems. This enables real-time access to critical information, empowering decision-makers with actionable insights for risk management, fraud detection, and customer analytics.

- Improved Operational Efficiency: Python-based connectivity automates manual processes, reducing human errors, and increasing operational efficiency. Tasks such as data synchronization, batch processing, and report generation can be streamlined, saving time and resources while improving accuracy and reliability.

- Cost Optimization: By leveraging Python's capabilities, organizations can achieve substantial cost savings. Python-based connectivity minimizes the reliance on manual interventions and expensive mainframe resources, optimizing CPU usage and reducing operational costs.

- Enhanced Customer Experience: Seamless connectivity between Windows servers and Unix on the mainframe enables banks and financial institutions to deliver a superior customer experience. It allows for real-time updates on account balances, transaction history, and personalized recommendations, fostering customer loyalty and satisfaction.

Takeaways:
The utilization of Python for connecting Windows remote servers and Unix on the mainframe presents immense benefits for organizations. This article demonstrated how Python's versatility and power can bridge the gap between disparate systems, enhancing products, streamlining operations, and achieving substantial cost savings by optimizing mainframe CPU usage. By automating processes and enabling seamless communication between Windows remote servers and Unix on the mainframe, organizations can unlock new opportunities for collaboration, data integration, and cost-effective operations.
This connectivity solution has enabled me and my team to efficiently analyse system changes and their important features, showcasing the invaluable contribution Luxoft has made to my professional growth and the overall success of our projects.

Thank you for reading this article!

Top comments (0)