Skip to main content
Question

How to execute a command on Prism Central VM in Blueprint

  • February 15, 2026
  • 9 replies
  • 0 views

In my blueprint, I need to execute a command on Prism Central VM. The command will be a script on Prism Central VM. My blueprint uses the existing Prism Central VM as the substrate. I tried different ways to execute the command but none of them worked. Could you please advise how I could do it? The script I need to run doesn’t have an API counterpart. I can run PC API from the blueprint without problems. Here are the different ways I tried and how they failed.

# SSH Endpoint

PCSSHEndpoint = Endpoint.Linux.ip(

    ["@@{calm_pc_ip}@@"],

    name="PC_SSH_Endpoint",

    port=22,

    cred=SSHCredential,

)

# ============================================================================

# METHOD 1: SSH Endpoint with Target Reference

# ============================================================================

class Method1_SSHEndpointService(Service):

    """

    Method 1: Using SSH endpoint with explicit target reference

   

    Pros: Proper SSH connection setup

    Cons: Failed with "Machine and credential are required for script execution"

          and "ssh: subsystem request failed" errors

    """

    @action

    def RunCommand(name="Method 1 SSH Endpoint"):

        """Execute command via SSH endpoint"""

        Task.Exec.ssh(

            name="SSHWithEndpoint",

            script='echo "=== Method 1: SSH Endpoint ===" \nncli cluster version',

            target=ref(PCSSHEndpoint),

            cred=ref(SSHCredential),

        )

# ============================================================================

# METHOD 2: SSH Without Endpoint (Local Execution)

# ============================================================================

class Method2_SSHLocalService(Service):

    """

    Method 2: SSH task without endpoint (attempting local execution)

   

    Pros: Simpler syntax

    Cons: Still tried to use SSH subsystem, failed with "subsystem request failed"

     """

    @action

    def RunCommand(name="Method 2 SSH Local"):

        """Execute command locally via SSH task"""

        Task.Exec.ssh(

            name="SSHLocal",

            script='#!/bin/bash\necho "=== Method 2: SSH Local ==="\nncli cluster version',

        )

# ============================================================================

# METHOD 3: Escript with Subprocess

# ============================================================================

class Method3_SubprocessService(Service):

    """

    Method 3: Using Python subprocess module in escript

   

    Pros: Standard Python approach for running commands

    Cons: subprocess module not available in Calm escript environment

          Error: "No module named 'subprocess'"

    """

    @action

    def RunCommand(name="Method 3 Subprocess"):

        """Execute command using subprocess"""

        Task.Exec.escript(

            name="SubprocessExec",

            script='import subprocess\n\nprint("=== Method 3: Subprocess ===")\nresult = subprocess.run(["ncli", "cluster", "version"], capture_output=True, text=True)\nprint(result.stdout)',

        )

# ============================================================================

# METHOD 4: Escript with Paramiko

# ============================================================================

class Method4_ParamikoService(Service):

    """

    Method 4: Using paramiko library for SSH in escript

   

    Pros: Full-featured SSH library

    Cons: paramiko not available in Calm escript environment

          Error: "No module named 'paramiko'"

    """

    @action

    def RunCommand(name="Method 4 Paramiko"):

        """Execute command using paramiko"""

        Task.Exec.escript(

            name="ParamikoExec",

            script='import paramiko\n\nprint("=== Method 4: Paramiko ===")\nssh = paramiko.SSHClient()\nssh.set_missing_host_key_policy(paramiko.AutoAddPolicy())\nssh.connect("@@{calm_pc_ip}@@", username="admin", password="Delluser@123")\nstdin, stdout, stderr = ssh.exec_command("ncli cluster version")\nprint(stdout.read().decode())\nssh.close()',

        )

# ============================================================================

# METHOD 5: Escript with os.system()

# ============================================================================

class Method5_OsSystemService(Service):

    """

    Method 5: Using os.system() for direct command execution

   

    Pros: Simple, built-in Python function

    Cons: os module not available in Calm escript environment

          Error: "No module named 'os'" or similar restriction

    """

 

    @action

    def RunCommand(name="Method 5 os_system"):

        """Execute command using os.system()"""

        Task.Exec.escript(

            name="OsSystemExec",

            script='import os\n\nprint("=== Method 5: os.system() ===")\nos.system("ncli cluster version")\nos.system("cluster status")',

        )

# ============================================================================

# METHOD 6: Shell Script with Task.Exec.ssh()

# ============================================================================

class Method6_ShellScriptService(Service):

   

    """

    Method 6: Pure bash script using Task.Exec.ssh() without target

   

    Pros: No Python dependencies, native shell execution

    Cons: Still uses SSH subsystem, failed with "subsystem request failed"

    """

 

    @action

    def RunCommand(name="Method 6 Shell Script"):

        """Execute bash script"""

        Task.Exec.ssh(

            name="ShellScript",

            script='#!/bin/bash\necho "=== Method 6: Shell Script ==="\nncli cluster version\nncli cluster info\ncluster status',

        )

 

9 replies

Forum|alt.badge.img+2
  • Trendsetter
  • February 16, 2026

What are you trying to achieve with the script?


  • Author
  • Adventurer
  • February 16, 2026

This is just to use the simple examples to demonstrate what I have tried for running a command on PC VM and how they failed. 

What I need to do is to call this script in blueprint: /usr/local/nutanix/cluster/.venv/bin/bin/python3 /usr/local/nutanix/cluster/.venv/bin/lib/python3.9/site-packages/reverse_proxy/configure_reverse_proxy.pyc

 


Forum|alt.badge.img+2
  • Trendsetter
  • February 16, 2026

I would encourage finding an alternative solution since nutanix is going to be moving away from SSH access.

https://download.nutanix.com/misc/Nutanix_EOL_SSH_BASH_SHELL_10292025.pdf 

Could you potentially leverage the self-service DSL or ansible for what you are trying to do?

 

What does the script actually do, is there any way you can move it out of running on the PCVMs?


Forum|alt.badge.img+2
  • Trendsetter
  • February 16, 2026

Can you let me know what is the final outcome you are looking for by invoking that script, maybe I can help find a better solution if I understand what the end goals and requirements are. 


  • Author
  • Adventurer
  • February 16, 2026

There is no API alternative unfortunately from what I know. This script is provided by Nutanix to register a reverse proxy for Prism Central which basically will map a Prism Central endpoint to an external URL. 


Forum|alt.badge.img+2
  • Trendsetter
  • February 16, 2026

Okay. What if you made a runbook at could SSH into the PCVM and invoke the script, triggering the playbook as an action? 

 

Here is how you can call a playbook in your BP: https://portal.nutanix.com/page/documents/details?targetId=Self-Service-Admin-Operations-Guide-v4_3_0:nuc-macros-runbook-list-r.html


  • Author
  • Adventurer
  • February 16, 2026

Thank you! We tried runbook as well. But we eventually need to publish to the marketplace. We have yet to see if we can do that with the runbook. 

 


Forum|alt.badge.img+2
  • Trendsetter
  • February 16, 2026

Thank you! We tried runbook as well. But we eventually need to publish to the marketplace. We have yet to see if we can do that with the runbook. 

 

Yes, you can publish playbooks to the marketplace: https://portal.nutanix.com/page/documents/details?targetId=Self-Service-Admin-Operations-Guide-v4_3_0:nuc-runbook-submit-for-publishing-t.html

So if the playbook can execute the script, can you can call that from your BP, then will will do the trick until BASH SSH is deprecated.


  • Author
  • Adventurer
  • February 16, 2026

Thanks!