Access to openstack instance using python sdk

asked 2018-12-14 06:05:19 -0500

najeh gravatar image

updated 2018-12-15 05:22:56 -0500

How can i access to openstack instances using python sdk?

import paramiko

def runSshCmd(hostname, username, password, cmd, timeout=None):

client = paramiko.SSHClient()


client.connect(hostname, username=username, password=password,
        allow_agent=False, look_for_keys=False, timeout=timeout)

stdin, stdout, stderr = client.exec_command(cmd)

data =

print data

print client


runSshCmd("192.168.x.x", "controller", "mypass", "uname -a")

edit retag flag offensive close merge delete

1 answer

Sort by » oldest newest most voted

answered 2018-12-14 06:24:44 -0500

The SDK is for managing OpenStack objects - launch and delete instances, attach volumes, upload images etc. Access to instances is normally via network protocols such as ssh, http, etc, not via the SDK.

edit flag offensive delete link more


I tried to access to instance using paramika python library but i failed.

Have you any other suggestion?

najeh gravatar imagenajeh ( 2018-12-14 15:16:05 -0500 )edit

I misread your question as “OpenStack SDK”, sorry. Paramiko is a library that implements SSH. If you can access the instance with SSH from the command line, it should also work with Paramiko.

Bernd Bausch gravatar imageBernd Bausch ( 2018-12-14 16:46:11 -0500 )edit

@Bernd Bausch This the last line of above code.

I tried the code to connect to the controller and this the result Linux controller 4.15.0-42-generic #45-Ubuntu SMP Thu Nov 15 19:32:57 UTC 2018 x86_64 x86_64 x86_64 GNU/Linux <paramiko.client.sshclient object="" at="" 0x7f584453b550="">

am i connected now

najeh gravatar imagenajeh ( 2018-12-15 04:25:30 -0500 )edit

But for the openstack instance i couldn't access i think because i created without a password

the message error is: paramiko.ssh_exception.SSHException: No authentication methods available

najeh gravatar imagenajeh ( 2018-12-15 05:53:35 -0500 )edit

Get to know Ask OpenStack

Resources for moderators

Question Tools

1 follower


Asked: 2018-12-14 06:05:19 -0500

Seen: 211 times

Last updated: Dec 15 '18