Bug 810628 - API is instantiatable only once.
API is instantiatable only once.
Status: CLOSED NOTABUG
Product: oVirt
Classification: Community
Component: ovirt-engine-sdk (Show other bugs)
unspecified
All Linux
unspecified Severity high
: ---
: ---
Assigned To: Michael Pasternak
:
Depends On:
Blocks:
  Show dependency treegraph
 
Reported: 2012-04-07 07:08 EDT by Jaroslav Henner
Modified: 2014-01-12 19:37 EST (History)
7 users (show)

See Also:
Fixed In Version:
Doc Type: Bug Fix
Doc Text:
Story Points: ---
Clone Of:
Environment:
Last Closed: 2012-04-07 07:17:48 EDT
Type: Bug
Regression: ---
Mount Type: ---
Documentation: ---
CRM:
Verified Versions:
Category: ---
oVirt Team: ---
RHEL 7.3 requirements from Atomic Host:
Cloudforms Team: ---


Attachments (Terms of Use)

  None (edit)
Description Jaroslav Henner 2012-04-07 07:08:04 EDT
Description of problem:
One cannot instantiate two ovirtsdk.API objects. This prevents failover after bad password supplied.

Version-Release number of selected component (if applicable):
ovirt-engine-sdk-1.6.4-1.fc16.noarch

How reproducible:
Always.


Steps to Reproduce:
In [1]: from ovirtsdk import api

In [2]: apicko=api.API("https://jh-rhsetup.rhev.lab.eng.brq.redhat.com:8443/", "vdcadmin@rhev.lab.eng.brq.redhat.com", "12345", debug=True)

In [3]: apicko.test()
send: 'GET /api HTTP/1.1\r\nHost: jh-rhsetup.rhev.lab.eng.brq.redhat.com:8443\r\nAccept-Encoding: identity\r\nContent-type: application/xml\r\nAuthorization: Basic dmRjYWRtaW5Acmhldi5sYWIuZW5nLmJycS5yZWRoYXQuY29tOjEyMzQ1\r\n\r\n'
reply: 'HTTP/1.1 401 Unauthorized\r\n'
header: Server: Apache-Coyote/1.1
header: Pragma: No-cache
header: Cache-Control: no-cache
header: Expires: Thu, 01 Jan 1970 01:00:00 CET
header: X-Powered-By: Servlet 2.5; JBoss-5.0/JBossWeb-2.1
header: WWW-Authenticate: Basic realm = "RHEVM"
header: Content-Type: text/html;charset=utf-8
header: Content-Length: 970
header: Date: Sat, 07 Apr 2012 11:00:37 GMT
Out[3]: False

In [4]: apicko=api.API("https://jh-rhsetup.rhev.lab.eng.brq.redhat.com:8443/", "vdcadmin@rhev.lab.eng.brq.redhat.com", "123456", debug=True)
---------------------------------------------------------------------------
ImmutableError                            Traceback (most recent call last)
/home/jhenner/work/rest-api-tests/<ipython-input-4-326fcf63bbf2> in <module>()
----> 1 apicko=api.API("https://jh-rhsetup.rhev.lab.eng.brq.redhat.com:8443/", "vdcadmin@rhev.lab.eng.brq.redhat.com", "123456", debug=True)

/usr/lib/python2.7/site-packages/ovirtsdk/api.pyc in __init__(self, url, username, password, key_file, cert_file, port, timeout, debug)
     71                                                  timeout=timeout,
     72                                                  debug=debug)),
---> 73                            Mode.R)
     74 
     75         self.capabilities = Capabilities()

/usr/lib/python2.7/site-packages/ovirtsdk/infrastructure/contextmanager.pyc in add(key, val, mode)
     61     with lock:
     62         if mode is Mode.R and cache.has_key(key):
---> 63             raise ImmutableError(key)
     64         else:
     65             cache[key] = __Item(val, mode)

ImmutableError: [ERROR]::'proxy' is immutable.
Comment 1 Michael Pasternak 2012-04-07 07:17:48 EDT
http://www.ovirt.org/wiki/SDK#sdk
Comment 2 Michael Pasternak 2012-04-07 08:07:23 EDT
this is planned feature for sdk (i'm on it), first item in TODO (Comment 1), 

as about your use-case, use api.disconnect() before creating new
instance of the api proxy.
Comment 3 Carsten Clasohm 2012-09-12 17:29:58 EDT
Even if you call api.disconnect(), you still cannot instantiate another API object.

api.disconnect() only removes "proxy" from the contextmanager, but not "entry_point" and "persistent_auth", which are also marked as immutable.
Comment 4 Carsten Clasohm 2012-09-13 13:19:37 EDT
Ignore my last comment, I was using an older version (rhevm-sdk-3.1.0.5-1.el6ev).

Newer versions of API.disconnect() clear the whole contextmanager cache.

Note You need to log in before you can comment on or make changes to this bug.