Ask Your Question

Revision history [back]

click to hide/show revision 1
initial version

unable to stop an instance using python api

I am trying to stop an instance using openstack api with the help of python.

from openstack import connection import os

def auth_args(): d = {} d['username'] = os.environ['OS_USERNAME'] d['password'] = os.environ['OS_PASSWORD'] d['auth_url'] = os.environ['OS_AUTH_URL'] d['project_name'] = os.environ['OS_TENANT_NAME'] d['project_domain_id'] = os.environ['OS_PROJECT_DOMAIN_ID'] d['user_domain_id'] = os.environ['OS_PROJECT_DOMAIN_ID'] return d

conn=connection.Connection(**auth_args()) for server in conn.compute.servers(): if server.name == 'server_test': server.stop(server.id)

i have set a source file then i am trying to run this code, but it gives the below error.

Traceback (most recent call last): File "stop_opsk_srv.py", line 20, in <module> server.stop(server.id) File "/root/.local/lib/python2.7/site-packages/openstack/compute/v2/server.py", line 345, in stop self._action(session, body) File "/root/.local/lib/python2.7/site-packages/openstack/compute/v2/server.py", line 181, in _action return session.post(

I am able to retrieve instance details and meta data using the same conn.compute.servers() method. Please help.

unable to stop an instance using python api

I am trying to stop an instance using openstack api with the help of python.

from openstack import connection connection

import os

def auth_args(): auth_args():

d = {}
  d['username'] = os.environ['OS_USERNAME']
  d['password'] = os.environ['OS_PASSWORD']
  d['auth_url'] = os.environ['OS_AUTH_URL']
  d['project_name'] = os.environ['OS_TENANT_NAME']
  d['project_domain_id'] = os.environ['OS_PROJECT_DOMAIN_ID']
  d['user_domain_id'] = os.environ['OS_PROJECT_DOMAIN_ID']
  return d

conn=connection.Connection(**auth_args()) d

conn=connection.Connection(**auth_args())

for server in conn.compute.servers(): conn.compute.servers():

if server.name == 'server_test': server.stop(server.id)

'server_test':

server.stop(server.id)

i have set a source file then i am trying to run this code, but it gives the below error.

Traceback (most recent call last): last):

File "stop_opsk_srv.py", line 20, in <module> server.stop(server.id) File "/root/.local/lib/python2.7/site-packages/openstack/compute/v2/server.py", line 345, in stop self._action(session, body) File "/root/.local/lib/python2.7/site-packages/openstack/compute/v2/server.py", line 181, in _action return session.post(

I am able to retrieve instance details and meta data using the same conn.compute.servers() method. Please help.

unable to stop an instance using python api

I am trying to stop an instance using openstack api with the help of python.

from openstack import connection

connection import os

os def auth_args():

auth_args():
    d = {}
  d['username'] = os.environ['OS_USERNAME']
  d['password'] = os.environ['OS_PASSWORD']
  d['auth_url'] = os.environ['OS_AUTH_URL']
  d['project_name'] = os.environ['OS_TENANT_NAME']
  d['project_domain_id'] = os.environ['OS_PROJECT_DOMAIN_ID']
  d['user_domain_id'] = os.environ['OS_PROJECT_DOMAIN_ID']
  return d

conn=connection.Connection(**auth_args())

conn=connection.Connection(**auth_args()) for server in conn.compute.servers():

conn.compute.servers(): if server.name == 'server_test':

'server_test':
    server.stop(server.id)

i have set a source file then i am trying to run this code, but it gives the below error.

Traceback (most recent call last):

last): File "stop_opsk_srv.py", line 20, in <module> server.stop(server.id) File "/root/.local/lib/python2.7/site-packages/openstack/compute/v2/server.py", line 345, in stop self._action(session, body) File "/root/.local/lib/python2.7/site-packages/openstack/compute/v2/server.py", line 181, in _action return session.post(

session.post(

I am able to retrieve instance details and meta data using the same conn.compute.servers() method. Please help.