Ask Your Question

Revision history [back]

click to hide/show revision 1
initial version

unable to upload image using python-glanceclient

I'm using Python API v2 and I'm unable to upload images to Glance.Here's the code snippet I'm using to upload images to Glance:

from keystoneauth1 import loading
from keystoneauth1 import session
from glanceclient import Client

loader = loading.get_plugin_loader('password')
auth = loader.load_from_options(
    auth_url="http://xx.yy.zz.aa:5000/v2.0/",
    username='admin',
    password='password',
    tenant_name='admin')
glance_session = session.Session(auth=auth)
glance = Client('2', session=glance_session)

for image in glance.images.list():  # This works
    print image

image = glance.images.create(name="my_image")
glance.images.upload(image.id, open('/tmp/image.qcow2', 'rb'))

It got stuck here:

-> image = glance.images.create(name="my_image")
(Pdb) p image.id
u'4944dc0f-35d2-4c81-8bf5-df0792abf9d5'
(Pdb) n
> /virtualenv/cfme_tests/scripts/glane_api.py(38)<module>()
-> glance.images.upload(image.id, open('/tmp/image.qcow2', 'rb'))
(Pdb) n
> /virtualenv/lib/python2.7/site-packages/glanceclient/v2/images.py(233)upload()
-> resp, body = self.http_client.put(url, headers=hdrs, data=body)
(Pdb) p url
u'/v2/images/4944dc0f-35d2-4c81-8bf5-df0792abf9d5/file'

When I interrupted from the keyboard, this was the backtrace:

 Pdb) n
Traceback (most recent call last):
  File "./scripts/glane_api.py", line 39, in <module>
    glance.images.upload(image.id, open('/tmp/image.qcow2', 'rb'))
  File "/virtualenv/lib/python2.7/site-packages/glanceclient/common/utils.py", line 545, in inner
    return RequestIdProxy(wrapped(*args, **kwargs))
  File "/virtualenv/lib/python2.7/site-packages/glanceclient/v2/images.py", line 231, in upload
    resp, body = self.http_client.put(url, headers=hdrs, data=body)
  File "/virtualenv/lib/python2.7/site-packages/keystoneauth1/adapter.py", line 232, in put
    return self.request(url, 'PUT', **kwargs)
  File "/virtualenv/lib/python2.7/site-packages/glanceclient/common/http.py", line 338, in request
    **kwargs)
  File "/virtualenv/lib/python2.7/site-packages/keystoneauth1/adapter.py", line 148, in request
    return self.session.request(url, method, **kwargs)
  File "/virtualenv/lib/python2.7/site-packages/positional/__init__.py", line 101, in inner
    return wrapped(*args, **kwargs)
  File "/virtualenv/lib/python2.7/site-packages/keystoneauth1/session.py", line 616, in request
    resp = send(**kwargs)
  File "/virtualenv/lib/python2.7/site-packages/keystoneauth1/session.py", line 674, in _send_request
    resp = self.session.request(method, url, **kwargs)
  File "/virtualenv/lib/python2.7/site-packages/requests/sessions.py", line 513, in request
    resp = self.send(prep, **send_kwargs)
  File "/virtualenv/lib/python2.7/site-packages/requests/sessions.py", line 623, in send
    r = adapter.send(request, **kwargs)
  File "/virtualenv/lib/python2.7/site-packages/requests/adapters.py", line 463, in send
    low_conn.send(i)
  File "/usr/lib64/python2.7/httplib.py", line 826, in send
    self.sock.sendall(data)
  File "/usr/lib64/python2.7/socket.py", line 224, in meth
    return getattr(self._sock,name)(*args)
KeyboardInterrupt

unable to upload image using python-glanceclient

I'm using Python API v2 and I'm unable to upload images to Glance.Here's the code snippet I'm using to upload images to Glance:Glance.

I'd appreciate any pointers.

from keystoneauth1 import loading
from keystoneauth1 import session
from glanceclient import Client

loader = loading.get_plugin_loader('password')
auth = loader.load_from_options(
    auth_url="http://xx.yy.zz.aa:5000/v2.0/",
    username='admin',
    password='password',
    tenant_name='admin')
glance_session = session.Session(auth=auth)
glance = Client('2', session=glance_session)

for image in glance.images.list():  # This works
    print image

image = glance.images.create(name="my_image")
glance.images.upload(image.id, open('/tmp/image.qcow2', 'rb'))

It got stuck here:

-> image = glance.images.create(name="my_image")
(Pdb) p image.id
u'4944dc0f-35d2-4c81-8bf5-df0792abf9d5'
(Pdb) n
> /virtualenv/cfme_tests/scripts/glane_api.py(38)<module>()
-> glance.images.upload(image.id, open('/tmp/image.qcow2', 'rb'))
(Pdb) n
> /virtualenv/lib/python2.7/site-packages/glanceclient/v2/images.py(233)upload()
-> resp, body = self.http_client.put(url, headers=hdrs, data=body)
(Pdb) p url
u'/v2/images/4944dc0f-35d2-4c81-8bf5-df0792abf9d5/file'

When I interrupted from the keyboard, this was the backtrace:

 Pdb) n
Traceback (most recent call last):
  File "./scripts/glane_api.py", line 39, in <module>
    glance.images.upload(image.id, open('/tmp/image.qcow2', 'rb'))
  File "/virtualenv/lib/python2.7/site-packages/glanceclient/common/utils.py", line 545, in inner
    return RequestIdProxy(wrapped(*args, **kwargs))
  File "/virtualenv/lib/python2.7/site-packages/glanceclient/v2/images.py", line 231, in upload
    resp, body = self.http_client.put(url, headers=hdrs, data=body)
  File "/virtualenv/lib/python2.7/site-packages/keystoneauth1/adapter.py", line 232, in put
    return self.request(url, 'PUT', **kwargs)
  File "/virtualenv/lib/python2.7/site-packages/glanceclient/common/http.py", line 338, in request
    **kwargs)
  File "/virtualenv/lib/python2.7/site-packages/keystoneauth1/adapter.py", line 148, in request
    return self.session.request(url, method, **kwargs)
  File "/virtualenv/lib/python2.7/site-packages/positional/__init__.py", line 101, in inner
    return wrapped(*args, **kwargs)
  File "/virtualenv/lib/python2.7/site-packages/keystoneauth1/session.py", line 616, in request
    resp = send(**kwargs)
  File "/virtualenv/lib/python2.7/site-packages/keystoneauth1/session.py", line 674, in _send_request
    resp = self.session.request(method, url, **kwargs)
  File "/virtualenv/lib/python2.7/site-packages/requests/sessions.py", line 513, in request
    resp = self.send(prep, **send_kwargs)
  File "/virtualenv/lib/python2.7/site-packages/requests/sessions.py", line 623, in send
    r = adapter.send(request, **kwargs)
  File "/virtualenv/lib/python2.7/site-packages/requests/adapters.py", line 463, in send
    low_conn.send(i)
  File "/usr/lib64/python2.7/httplib.py", line 826, in send
    self.sock.sendall(data)
  File "/usr/lib64/python2.7/socket.py", line 224, in meth
    return getattr(self._sock,name)(*args)
KeyboardInterrupt