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

feat: adding support to launch MAPDL on remote HPC clusters #3713

Draft
wants to merge 4 commits into
base: main
Choose a base branch
from

Conversation

germa89
Copy link
Collaborator

@germa89 germa89 commented Jan 28, 2025

...

HIGHLY UNDER DEVELOPMENT!!

Description

As the title.

Notes

Example

from ansys.mapdl.core.hpc import launch_on_remote_hpc
import os

from ansys.mapdl.core import LOG

LOG.setLevel("DEBUG")
LOG.log_to_file("mylog.log")

mapdl = launch_on_remote_hpc(
    hostname="myhostname",
    username="user",
    password="mypass",
    exec_file="/ansys_inc/v242/ansys/bin/ansys242",
    run_location="/home/user/simulation",
    # loglevel="DEBUG",
    scheduler_options={"partition": "partition"},
    replace_env_vars={"ANSYS_LOCK": "OFF"},
    nproc=2, # required
    )

mapdl.input("apdl.inp")

print(mapdl.jobid)

print(mapdl.prep7())

mapdl.exit()

print("Ended")

Issue linked

NA

Checklist

@ansys-reviewer-bot
Copy link
Contributor

Thanks for opening a Pull Request. If you want to perform a review write a comment saying:

@ansys-reviewer-bot review

@github-actions github-actions bot added dependencies maintenance General maintenance of the repo (libraries, cicd, etc) new feature Request or proposal for a new feature labels Jan 28, 2025

def __enter__(self):
self.session = SSHClient()
self.session.set_missing_host_key_policy(paramiko.AutoAddPolicy())

Check failure

Code scanning / CodeQL

Accepting unknown SSH host keys when using Paramiko High

Setting missing host key policy to AutoAddPolicy may be unsafe.

Copilot Autofix AI 12 days ago

To fix the problem, we need to change the missing host key policy from AutoAddPolicy to RejectPolicy. This ensures that the SSH connection will only be established if the host key is already known and trusted, thereby preventing potential man-in-the-middle attacks.

  • Change the set_missing_host_key_policy method call to use RejectPolicy instead of AutoAddPolicy.
  • Ensure that the paramiko.RejectPolicy is imported if it is not already.
Suggested changeset 1
src/ansys/mapdl/core/hpc.py

Autofix patch

Autofix patch
Run the following command in your local git repository to apply this patch
cat << 'EOF' | git apply
diff --git a/src/ansys/mapdl/core/hpc.py b/src/ansys/mapdl/core/hpc.py
--- a/src/ansys/mapdl/core/hpc.py
+++ b/src/ansys/mapdl/core/hpc.py
@@ -26,3 +26,3 @@
 import paramiko
-from paramiko.client import SSHClient
+from paramiko.client import SSHClient, RejectPolicy
 
@@ -389,3 +389,3 @@
         self.session = SSHClient()
-        self.session.set_missing_host_key_policy(paramiko.AutoAddPolicy())
+        self.session.set_missing_host_key_policy(paramiko.RejectPolicy())
         self.session.connect(
EOF
@@ -26,3 +26,3 @@
import paramiko
from paramiko.client import SSHClient
from paramiko.client import SSHClient, RejectPolicy

@@ -389,3 +389,3 @@
self.session = SSHClient()
self.session.set_missing_host_key_policy(paramiko.AutoAddPolicy())
self.session.set_missing_host_key_policy(paramiko.RejectPolicy())
self.session.connect(
Copilot is powered by AI and may make mistakes. Always verify output.
Positive Feedback
Negative Feedback

Provide additional feedback

Please help us improve GitHub Copilot by sharing more details about this comment.

Please select one or more of the options
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
dependencies maintenance General maintenance of the repo (libraries, cicd, etc) new feature Request or proposal for a new feature
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants