openstacksdk fails to provision openstack server

Asked by samvaran kashyap on 2021-01-13

While running the following script using openstcak sdk 0.52.0 version it fails on nova api error. However, It does not while using openstackcli.

import os
import sys

import openstack
from openstack.config import loader

openstack.enable_logging(True, stream=sys.stdout)

#: Defines the OpenStack Config cloud key in your config file,
#: typically in $HOME/.config/openstack/clouds.yaml. That configuration
#: will determine where the examples will be run and what resource defaults
#: will be used to run the examples.
TEST_CLOUD = os.getenv('OS_TEST_CLOUD', 'openstack')
EXAMPLE_CONFIG_KEY = os.getenv('OPENSTACKSDK_EXAMPLE_CONFIG_KEY', 'clouds.yaml')
config = loader.OpenStackConfig()
cloud = openstack.connect(cloud=TEST_CLOUD)

def create_connection_from_config():
    return openstack.connect(cloud=TEST_CLOUD)

def list_servers(conn):
    print("List Servers:")
    for server in conn.compute.servers():
        print(server)

conn = create_connection_from_config()
list_servers(conn)
The following output is observed is as follows:

List Servers:
REQ: curl -g -i -X GET https://x.x.x.x.x.com:13000 -H "Accept: application/json" -H "User-Agent: openstacksdk/0.52.0 keystoneauth1/4.3.0 python-requests/2.22.0 CPython/3.8.6"
RESP: [300] Content-Length: 298 Content-Type: application/json Date: Wed, 13 Jan 2021 14:55:06 GMT Location: https://x.x.x.x.x.com:13000/v3/ Server: Apache Vary: X-Auth-Token x-openstack-request-id: req-387880f5-b09a-4a86-8e4a-b2d49f619172
RESP BODY: {"versions": {"values": [{"id": "v3.13", "status": "stable", "updated": "2019-07-19T00:00:00Z", "links": [{"rel": "self", "href": "https://x.x.x.x.x.com:13000/v3/"}], "media-types": [{"base": "application/json", "type": "application/vnd.openstack.identity-v3+json"}]}]}}
GET call to https://x.x.x.x.x.com:13000/ used request id req-387880f5-b09a-4a86-8e4a-b2d49f619172
Making authentication request to https://x.x.x.x.x.com:13000/v3/auth/tokens
{"token": {"methods": ["password"], "user": {"domain": {"id": "62cf1b5ec006489db99e2b0ebfb55f57", "name": "redhat.com"}, "id": "4a7bfd5a9fa25181f9a8fc6f3d4f4a623807e8737e9fb29ad64792d21df97e3c", "name": "xxxxxx", "password_expires_at": null}, "audit_ids": ["DZ6x8bbbS_qAlJDrJsIa4g"], "expires_at": "2021-01-14T02:55:06.000000Z", "issued_at": "2021-01-13T14:55:06.000000Z", "project": {"domain": {"id": "62cf1b5ec006489db99e2b0ebfb55f57", "name": "redhat.com"}, "id": "4679176b5d5647cdbb530553c35bf840", "name": "xxxx"}, "is_domain": false, "roles": [{"id": "9fe2ff9ee4384b1894a90878d3e92bab", "name": "_member_"}], "catalog": [{"endpoints": [{"id": "7e51926755004c999e955f5bf67f6a3e", "interface": "internal", "region_id": "regionOne", "url": "http://x.x.x.x:9876", "region": "regionOne"}, {"id": "8c4b14e0705045599addcfefd8c28e4c", "interface": "public", "region_id": "regionOne", "url": "https://x.x.x.x.x.com:13876", "region": "regionOne"}, {"id": "f0ab449b775a46e5b68a9a557e6b4fd3", "interface": "admin", "region_id": "regionOne", "url": "http://x.x.x.x:9876", "region": "regionOne"}], "id": "195742853db84a7a91cf9ee7c86b1527", "type": "load-balancer", "name": "octavia"}, {"endpoints": [{"id": "100e27a6663f4a668dfb4b54331f422a", "interface": "public", "region_id": "regionOne", "url": "https://x.x.x.x.x.com:13000", "region": "regionOne"}, {"id": "171878bb917f46cf8f0be10b967d2308", "interface": "admin", "region_id": "regionOne", "url": "https://x.x.x.x.x.com:35357", "region": "regionOne"}, {"id": "db169bc8049d460aaa8153535385b795", "interface": "internal", "region_id": "regionOne", "url": "http://x.x.x.x:5000", "region": "regionOne"}], "id": "1dd87b2d2f3c48f8b2efb6ec05114244", "type": "identity", "name": "keystone"}, {"endpoints": [{"id": "663d14235c7f4d669ed6a867d2cc44c4", "interface": "admin", "region_id": "regionOne", "url": "http://x.x.x.x:8776/v3/4679176b5d5647cdbb530553c35bf840", "region": "regionOne"}, {"id": "b0b0f2a6c48f40f9b02d5a24e055dddf", "interface": "public", "region_id": "regionOne", "url": "https://x.x.x.x.x.com:13776/v3/4679176b5d5647cdbb530553c35bf840", "region": "regionOne"}, {"id": "b626dda26c4644fbad561f518aea36d9", "interface": "internal", "region_id": "regionOne", "url": "http://x.x.x.x:8776/v3/4679176b5d5647cdbb530553c35bf840", "region": "regionOne"}], "id": "52f9be8a2b474bb78da2ba2d8075da8d", "type": "volumev3", "name": "cinderv3"}, {"endpoints": [{"id": "42bb3d9b14e4485181391555e59a2108", "interface": "admin", "region_id": "regionOne", "url": "http://x.x.x.x:8786/v2/4679176b5d5647cdbb530553c35bf840", "region": "regionOne"}, {"id": "54e23eafffb843fa9f96d2bf35bdd7d7", "interface": "public", "region_id": "regionOne", "url": "https://x.x.x.x.x.com:13786/v2/4679176b5d5647cdbb530553c35bf840", "region": "regionOne"}, {"id": "e3d44588ac794221a4b8cbfc77af1d89", "interface": "internal", "region_id": "regionOne", "url": "http://x.x.x.x:8786/v2/4679176b5d5647cdbb530553c35bf840", "region": "regionOne"}], "id": "57791433325c4534965fa3aa2d261efc", "type": "sharev2", "name": "manilav2"}, {"endpoints": [{"id": "5b3051eaadae4bb0a3b4782b7156fa3f", "interface": "public", "region_id": "regionOne", "url": "https://x.x.x.x.x.com:13808/v1/AUTH_4679176b5d5647cdbb530553c35bf840", "region": "regionOne"}, {"id": "6430fefe62a94337970f7d31de27bb4d", "interface": "admin", "region_id": "regionOne", "url": "http://172.16.4.1:8080", "region": "regionOne"}, {"id": "d203f3796d024fb3a24de86cad765d11", "interface": "internal", "region_id": "regionOne", "url": "http://172.16.4.1:8080/v1/AUTH_4679176b5d5647cdbb530553c35bf840", "region": "regionOne"}], "id": "7965291ffa6541a6b994ac35090f65c1", "type": "object-store", "name": "swift"}, {"endpoints": [{"id": "0d3275bc1aeb4b34be24409bbf2edc78", "interface": "admin", "region_id": "regionOne", "url": "http://x.x.x.x:8786/v1/4679176b5d5647cdbb530553c35bf840", "region": "regionOne"}, {"id": "0e73f32a92394c1db3d5eb263c3028d2", "interface": "public", "region_id": "regionOne", "url": "https://x.x.x.x.x.com:13786/v1/4679176b5d5647cdbb530553c35bf840", "region": "regionOne"}, {"id": "a3c78f22c4e34299a542b366ed12de8a", "interface": "internal", "region_id": "regionOne", "url": "http://x.x.x.x:8786/v1/4679176b5d5647cdbb530553c35bf840", "region": "regionOne"}], "id": "7b6fd0b1b13c4686af2164703351e82f", "type": "share", "name": "manila"}, {"endpoints": [{"id": "5ee7ebd29b2c4c8d8942492b2af4deb0", "interface": "public", "region_id": "regionOne", "url": "https://x.x.x.x.x.com:13776/v3/4679176b5d5647cdbb530553c35bf840", "region": "regionOne"}, {"id": "6bce3e081cba47e5a6527f716a72f820", "interface": "admin", "region_id": "regionOne", "url": "http://x.x.x.x:8776/v3/4679176b5d5647cdbb530553c35bf840", "region": "regionOne"}, {"id": "9cd502392b174761b6ce2ca967dba7f5", "interface": "internal", "region_id": "regionOne", "url": "http://x.x.x.x:8776/v3/4679176b5d5647cdbb530553c35bf840", "region": "regionOne"}], "id": "82165c21b98a41e38f37ebe22ec531c4", "type": "volume", "name": "cinderv3"}, {"endpoints": [{"id": "1231edc7b0c248b981e41db15a98b1d9", "interface": "admin", "region_id": "regionOne", "url": "http://x.x.x.x:8776/v2/4679176b5d5647cdbb530553c35bf840", "region": "regionOne"}, {"id": "5d97dfe3ffb841cbbdc333be5d1596eb", "interface": "internal", "region_id": "regionOne", "url": "http://x.x.x.x:8776/v2/4679176b5d5647cdbb530553c35bf840", "region": "regionOne"}, {"id": "8c304efe816e42a7b5451fb974d0c62e", "interface": "public", "region_id": "regionOne", "url": "https://x.x.x.x.x.com:13776/v2/4679176b5d5647cdbb530553c35bf840", "region": "regionOne"}], "id": "92bbbbc605f84bac85570bf5f580debc", "type": "volumev2", "name": "cinderv2"}, {"endpoints": [{"id": "20d5c89370584fd49a58a779f9648476", "interface": "internal", "region_id": "regionOne", "url": "http://x.x.x.x:9292", "region": "regionOne"}, {"id": "a125c8f6cc7a4d8b93296928a97e6b43", "interface": "admin", "region_id": "regionOne", "url": "http://x.x.x.x:9292", "region": "regionOne"}, {"id": "b5b286d1a8784ee995d21f8c9d959b82", "interface": "public", "region_id": "regionOne", "url": "https://x.x.x.x.x.com:13292", "region": "regionOne"}], "id": "a110cd3ee1c241818967b6a7686a6b0a", "type": "image", "name": "glance"}, {"endpoints": [{"id": "1f64c481a37d44708483f79eb1c629a1", "interface": "public", "region_id": "regionOne", "url": "https://x.x.x.x.x.com:13005/v1", "region": "regionOne"}, {"id": "3019cee56463428e9af2bda9e0838d14", "interface": "internal", "region_id": "regionOne", "url": "http://x.x.x.x:8000/v1", "region": "regionOne"}, {"id": "f92a0d175e354235a346e08d3a44fc74", "interface": "admin", "region_id": "regionOne", "url": "http://x.x.x.x:8000/v1", "region": "regionOne"}], "id": "a1e61f9ed9844aeb9e6f35ef22f8a805", "type": "cloudformation", "name": "heat-cfn"}, {"endpoints": [{"id": "7e4fa9f2a6894ed6813653b0cb421935", "interface": "admin", "region_id": "regionOne", "url": "http://x.x.x.x:8004/v1/4679176b5d5647cdbb530553c35bf840", "region": "regionOne"}, {"id": "a9671ee6b35543f9827e2bb0d14d1952", "interface": "public", "region_id": "regionOne", "url": "https://x.x.x.x.x.com:13004/v1/4679176b5d5647cdbb530553c35bf840", "region": "regionOne"}, {"id": "c5326b5fcc054401a9998ad3f2ad264f", "interface": "internal", "region_id": "regionOne", "url": "http://x.x.x.x:8004/v1/4679176b5d5647cdbb530553c35bf840", "region": "regionOne"}], "id": "ac44d609d9784fc792271dedc36572c5", "type": "orchestration", "name": "heat"}, {"endpoints": [{"id": "145063f862904cdf9840aaf2a9e4e3b9", "interface": "internal", "region_id": "regionOne", "url": "http://x.x.x.x:8778/placement", "region": "regionOne"}, {"id": "37f42c9d47b4472ea78c1707c02d1d8e", "interface": "admin", "region_id": "regionOne", "url": "http://x.x.x.x:8778/placement", "region": "regionOne"}, {"id": "68aebfd675444d7e9642868e07863e99", "interface": "public", "region_id": "regionOne", "url": "https://x.x.x.x.x.com:13778/placement", "region": "regionOne"}], "id": "cb194ff480f64df88a0adb01cbdfcbac", "type": "placement", "name": "placement"}, {"endpoints": [{"id": "51b105226c4446aa856f595091517bed", "interface": "admin", "region_id": "regionOne", "url": "http://x.x.x.x:9696", "region": "regionOne"}, {"id": "9b462bda336a4a12aed30301763103b6", "interface": "public", "region_id": "regionOne", "url": "https://x.x.x.x.x.com:13696", "region": "regionOne"}, {"id": "c75bf03f0b9c4afdba110db74669f5bd", "interface": "internal", "region_id": "regionOne", "url": "http://x.x.x.x:9696", "region": "regionOne"}], "id": "cd676416d1924c25a0b25b0204d2dfad", "type": "network", "name": "neutron"}, {"endpoints": [{"id": "74ab9f3494da417db04287f6ad6f672c", "interface": "public", "region_id": "regionOne", "url": "https://x.x.x.x.x.com:13774/v2.1", "region": "regionOne"}, {"id": "a83faf53b6ea40bdb0a84207cd29b524", "interface": "internal", "region_id": "regionOne", "url": "http://x.x.x.x:8774/v2.1", "region": "regionOne"}, {"id": "a8f71ac09bed45c5a1a4c102163b8576", "interface": "admin", "region_id": "regionOne", "url": "http://x.x.x.x:8774/v2.1", "region": "regionOne"}], "id": "e263f59a0dc04f29a11e1e4cb53008f2", "type": "compute", "name": "nova"}, {"endpoints": [], "id": "f2a331bced1d4854acf8e2516a805c4b", "type": "volume", "name": "cinder"}]}}
REQ: curl -g -i -X GET https://x.x.x.x.x.com:13774/v2.1 -H "Accept: application/json" -H "User-Agent: openstacksdk/0.52.0 keystoneauth1/4.3.0 python-requests/2.22.0 CPython/3.8.6"
RESP: [200] Content-Encoding: gzip Content-Type: application/json Date: Wed, 13 Jan 2021 14:55:06 GMT OpenStack-API-Version: compute 2.1 Server: Apache Transfer-Encoding: chunked Vary: OpenStack-API-Version,X-OpenStack-Nova-API-Version,Accept-Encoding X-OpenStack-Nova-API-Version: 2.1 x-compute-request-id: req-a76f45ec-13bb-42c9-b558-8104c6093667 x-openstack-request-id: req-a76f45ec-13bb-42c9-b558-8104c6093667
RESP BODY: {"version": {"id": "v2.1", "status": "CURRENT", "version": "2.79", "min_version": "2.1", "updated": "2013-07-23T11:33:21Z", "links": [{"rel": "self", "href": "https://x.x.x.x.x.com:13774/v2.1/"}, {"rel": "describedby", "type": "text/html", "href": "http://docs.openstack.org/"}], "media-types": [{"base": "application/json", "type": "application/vnd.openstack.compute+json;version=2.1"}]}}
GET call to https://x.x.x.x.x.com:13774/v2.1 used request id req-a76f45ec-13bb-42c9-b558-8104c6093667
REQ: curl -g -i -X GET https://x.x.x.x.x.com:13774/v2.1/servers/detail -H "Accept: application/json" -H "OpenStack-API-Version: compute 2.72" -H "User-Agent: openstacksdk/0.52.0 keystoneauth1/4.3.0 python-requests/2.22.0 CPython/3.8.6" -H "X-Auth-Token: {SHA256}ad1a939abdfa2d63ef80bd1b170b5e1be65a5b70ddad960c5e5320d7d728479f" -H "X-OpenStack-Nova-API-Version: 2.72"
RESP: [500] Content-Length: 208 Content-Type: application/json; charset=UTF-8 Date: Wed, 13 Jan 2021 14:55:06 GMT OpenStack-API-Version: compute 2.72 Server: Apache Vary: OpenStack-API-Version,X-OpenStack-Nova-API-Version X-OpenStack-Nova-API-Version: 2.72 x-compute-request-id: req-464cf57e-cf56-4ea5-8df0-ac216a6ea5b1 x-openstack-request-id: req-464cf57e-cf56-4ea5-8df0-ac216a6ea5b1
RESP BODY: {"computeFault": {"code": 500, "message": "Unexpected API Error. Please report this at http://bugs.launchpad.net/nova/ and attach the Nova API log if possible.\n<class 'nova.exception.OrphanedObjectError'>"}}
GET call to compute for https://x.x.x.x.x.com:13774/v2.1/servers/detail used request id req-464cf57e-cf56-4ea5-8df0-ac216a6ea5b1
Traceback (most recent call last):
  File "connect.py", line 95, in <module>
    list_servers(conn)
  File "connect.py", line 93, in list_servers
    for server in conn.compute.servers():
  File "/home/xxxxxx/.local/lib/python3.8/site-packages/openstack/resource.py", line 1745, in list
    exceptions.raise_from_response(response)
  File "/home/xxxxxx/.local/lib/python3.8/site-packages/openstack/exceptions.py", line 233, in raise_from_response
    raise cls(
openstack.exceptions.HttpException: HttpException: 500: Server Error for url: https://x.x.x.x.x.com:13774/v2.1/servers/detail, Unexpected API Error. Please report this at http://bugs.launchpad.net/nova/ and attach the Nova API log if possible.
<class 'nova.exception.OrphanedObjectError'>

surprisingly the OpenStack CLI with the same credentials works for provisioning the instances.
Any help is appreciated.

Question information

Language:
English Edit question
Status:
Open
For:
OpenStack SDK Edit question
Assignee:
No assignee Edit question
Last query:
2021-01-13
Last reply:

Can you help with this problem?

Provide an answer of your own, or ask samvaran kashyap for more information if necessary.

To post a message you must log in.