glance does not work when working with swift

Asked by Guangya Liu on 2011-08-09

My swift server is working well, and also glance server also works well when using file "default_store = file", but when I change to "default_store = swift", "glance add" will not work, can any of you help check why?

Thanks in advance!

root@glance-node:/tmp# glance add name="swift2" is_public=true < /tmp/test.iso
Failed to add image. Got error:
400 Bad Request

The server could not comply with the request since it is either malformed or otherwise incorrect.

 Error uploading image: global name 'swift_client' is not defined
Note: Your image metadata may still be in the registry, but the image's status will likely be 'killed'.
root@glance-node:/tmp# cat /etc/glance/glance-api.conf
[DEFAULT]
# Show more verbose log output (sets INFO log level output)
verbose = True

# Show debugging output in logs (sets DEBUG log level output)
debug = False

# Which backend store should Glance use by default is not specified
# in a request to add a new image to Glance? Default: 'file'
# Available choices are 'file', 'swift', and 's3'
default_store = swift

# Address to bind the API server
bind_host = 0.0.0.0

# Port the bind the API server to
bind_port = 9292

# Address to find the registry server
registry_host = 0.0.0.0

# Port the registry server is listening on
registry_port = 9191

# Log to this file. Make sure you do not set the same log
# file for both the API and registry servers!
log_file = /var/log/glance/api.log

# ============ Filesystem Store Options ========================

# Directory that the Filesystem backend store
# writes image data to
filesystem_store_datadir = /var/lib/glance/images/

# ============ Swift Store Options =============================

# Address where the Swift authentication service lives
swift_store_auth_address = 172.17.1.125:443/v1.0/

# User to authenticate against the Swift authentication service
swift_store_user = tester

# Auth key for the user authenticating against the
# Swift authentication service
swift_store_key = tk361dc384f1214cae898e8271109dad3f

# Container within the account that the account should use
# for storing images in Swift
swift_store_container = CONTAINER

# Do we create the container if it does not exist?
swift_store_create_container_on_put = True

# Whether to use ServiceNET to communicate with the Swift storage servers.
# (If you aren't RACKSPACE, leave this False!)
#
# To use ServiceNET for authentication, prefix hostname of
# `swift_store_auth_address` with 'snet-'.
# Ex. https://example.com/v1.0/ -> https://snet-example.com/v1.0/
swift_enable_snet = False

# ============ S3 Store Options =============================

# Address where the S3 authentication service lives
s3_store_host = 127.0.0.1:8080/v1.0/

# User to authenticate against the S3 authentication service
s3_store_access_key = <20-char AWS access key>

# Auth key for the user authenticating against the
# S3 authentication service
s3_store_secret_key = <40-char AWS secret key>

# Container within the account that the account should use
# for storing images in S3. Note that S3 has a flat namespace,
# so you need a unique bucket name for your glance images. An
# easy way to do this is append your AWS access key to "glance".
# S3 buckets in AWS *must* be lowercased, so remember to lowercase
# your AWS access key if you use it in your bucket name below!
s3_store_bucket = <lowercased 20-char aws access key>glance

# Do we create the bucket if it does not exist?
s3_store_create_bucket_on_put = False

# ============ Image Cache Options ========================

image_cache_enabled = False

# Directory that the Image Cache writes data to
# Make sure this is also set in glance-pruner.conf
image_cache_datadir = /var/lib/glance/image-cache/

# Number of seconds after which we should consider an incomplete image to be
# stalled and eligible for reaping
image_cache_stall_timeout = 86400

# ============ Delayed Delete Options =============================

# Turn on/off delayed delete
delayed_delete = False

[pipeline:glance-api]
pipeline = versionnegotiation context apiv1app

# To enable Image Cache Management API replace pipeline with below:
# pipeline = versionnegotiation imagecache apiv1app

[pipeline:versions]
pipeline = versionsapp

[app:versionsapp]
paste.app_factory = glance.api.versions:app_factory

[app:apiv1app]
paste.app_factory = glance.api.v1:app_factory

[filter:versionnegotiation]
paste.filter_factory = glance.api.middleware.version_negotiation:filter_factory

[filter:imagecache]
paste.filter_factory = glance.api.middleware.image_cache:filter_factory

[filter:context]
paste.filter_factory = glance.common.context:filter_factory
root@glance-node:/tmp#

Question information

Language:
English Edit question
Status:
Solved
For:
Glance Edit question
Assignee:
No assignee Edit question
Solved by:
Guangya Liu
Solved:
2011-08-10
Last query:
2011-08-10
Last reply:
2011-08-10
DzungVuAnh (anhdungcha) said : #1

- Before you add new image by Glance, you should use Curl to check the operation in Swift Proxy Server.
Check your Swift Store User and Pass in proxy-server.conf

- I think you should consider about the link of swift_store_auth_address = 172.17.1.125:443/v1.0/
check http://172.17.1.125:443/auth/v1.0/ for your result

hope this help!

Dzung Vu Anh

Guangya Liu (gyliu) said : #2

Thanks Dzung for the answer, but I'm still have some trouble to configure. Can you give more help?

On Swift host:
root@saio:/home/swiftdemo# export ST_AUTH=https://172.17.1.125:443/auth/v1.0
root@saio:/home/swiftdemo# export ST_USER=test:tester
root@saio:/home/swiftdemo# export ST_KEY=testing
root@saio:/home/swiftdemo# swift stat -v
StorageURL: https://172.17.1.125:443/v1/AUTH_3852a9fd-b1e5-4498-8aa4-3a557cebff2e
Auth Token: AUTH_tk1a85a0af81364aa3ad104c9e035027c6
   Account: AUTH_3852a9fd-b1e5-4498-8aa4-3a557cebff2e
Containers: 3
   Objects: 1
     Bytes: 0
Accept-Ranges: bytes

On Glance node:
vi /etc/glance/glance-api.conf
=======================
# Which backend store should Glance use by default is not specified
# in a request to add a new image to Glance? Default: 'file'
# Available choices are 'file', 'swift', and 's3'
default_store = swift
# ============ Swift Store Options =============================

# Address where the Swift authentication service lives
swift_store_auth_address = 172.17.1.125:443/v1.0/

# User to authenticate against the Swift authentication service
swift_store_user = test:tester

# Auth key for the user authenticating against the
# Swift authentication service
swift_store_key = AUTH_tk1a85a0af81364aa3ad104c9e035027c6

# Container within the account that the account should use
# for storing images in Swift
swift_store_container = CONTAINER

# Do we create the container if it does not exist?
swift_store_create_container_on_put = True

# Whether to use ServiceNET to communicate with the Swift storage servers.
# (If you aren't RACKSPACE, leave this False!)
#
# To use ServiceNET for authentication, prefix hostname of
# `swift_store_auth_address` with 'snet-'.
# Ex. https://example.com/v1.0/ -> https://snet-example.com/v1.0/
swift_enable_snet = False

Then on glance node, try to add an image.
root@glance-node:~# glance add name="swift2" is_public=true < /tmp/test.iso
Failed to add image. Got error:
400 Bad Request

The server could not comply with the request since it is either malformed or otherwise incorrect.

 Error uploading image: global name 'swift_client' is not defined
Note: Your image metadata may still be in the registry, but the image's status will likely be 'killed'.

Guangya Liu (gyliu) said : #3

Clarify something:
===================================
The "curl" and "swift" command works well on swift node:
root@saio:/home/swiftdemo# export ST_AUTH=https://172.17.1.125:443/auth/v1.0
root@saio:/home/swiftdemo# export ST_USER=test:tester
root@saio:/home/swiftdemo# export ST_KEY=testing
root@saio:/home/swiftdemo# swift list
builders
gholt
myfiles
root@saio:/home/swiftdemo# swift stat -v
StorageURL: https://172.17.1.125:443/v1/AUTH_3852a9fd-b1e5-4498-8aa4-3a557cebff2e
Auth Token: AUTH_tk1a85a0af81364aa3ad104c9e035027c6
   Account: AUTH_3852a9fd-b1e5-4498-8aa4-3a557cebff2e
Containers: 3
   Objects: 1
     Bytes: 0
Accept-Ranges: bytes
root@saio:/home/swiftdemo#
root@saio:/home/swiftdemo# curl -k -v -H 'X-Storage-User: test:tester' -H 'X-Storage-Pass: testing' https://172.17.1.125:443/auth/v1.0
* About to connect() to 172.17.1.125 port 443 (#0)
* Trying 172.17.1.125... connected
* Connected to 172.17.1.125 (172.17.1.125) port 443 (#0)
* successfully set certificate verify locations:
* CAfile: none
  CApath: /etc/ssl/certs
* SSLv3, TLS handshake, Client hello (1):
* SSLv3, TLS handshake, Server hello (2):
* SSLv3, TLS handshake, CERT (11):
* SSLv3, TLS handshake, Server finished (14):
* SSLv3, TLS handshake, Client key exchange (16):
* SSLv3, TLS change cipher, Client hello (1):
* SSLv3, TLS handshake, Finished (20):
* SSLv3, TLS change cipher, Client hello (1):
* SSLv3, TLS handshake, Finished (20):
* SSL connection using AES256-SHA
* Server certificate:
* subject: C=CH; ST=SHANXIN; L=XIAN; O=Platform; OU=DEV; CN=172.17.1.125; <email address hidden>
* start date: 2011-08-08 03:29:29 GMT
* expire date: 2011-09-07 03:29:29 GMT
* common name: 172.17.1.125 (matched)
* issuer: C=CH; ST=SHANXIN; L=XIAN; O=Platform; OU=DEV; CN=172.17.1.125; <email address hidden>
* SSL certificate verify result: self signed certificate (18), continuing anyway.
> GET /auth/v1.0 HTTP/1.1
> User-Agent: curl/7.19.7 (x86_64-pc-linux-gnu) libcurl/7.19.7 OpenSSL/0.9.8k zlib/1.2.3.3 libidn/1.15
> Host: 172.17.1.125
> Accept: */*
> X-Storage-User: test:tester
> X-Storage-Pass: testing
>
< HTTP/1.1 200 OK
< X-Storage-Url: https://172.17.1.125:443/v1/AUTH_3852a9fd-b1e5-4498-8aa4-3a557cebff2e
< X-Storage-Token: AUTH_tk1a85a0af81364aa3ad104c9e035027c6
< X-Auth-Token: AUTH_tk1a85a0af81364aa3ad104c9e035027c6
< Content-Length: 115
< Date: Wed, 10 Aug 2011 08:51:41 GMT
<
* Connection #0 to host 172.17.1.125 left intact
* Closing connection #0
* SSLv3, TLS alert, Client hello (1):
{"storage": {"default": "local", "local": "https://172.17.1.125:443/v1/AUTH_3852a9fd-b1e5-4498-8aa4-3a557cebff2e"}}
============================================

Just make minor change on glance.conf, set log level to DEBUG,

========glance-api.conf==================
default_store = swift
swift_store_auth_address = 172.17.1.125:443/v1.0/
swift_store_user = test:tester
swift_store_key = testing
swift_store_container = glance
swift_store_create_container_on_put = True
swift_enable_snet = False
===================================

root@glance-node:~# glance add name="s2" is_public=true < /tmp/test.iso
Failed to add image. Got error:
400 Bad Request

The server could not comply with the request since it is either malformed or otherwise incorrect.

 Error uploading image: global name 'swift_client' is not defined
Note: Your image metadata may still be in the registry, but the image's status will likely be 'killed'.

Log file of api.log:
2011-08-10 16:44:30 DEBUG [glance-api] ********************************************************************************
2011-08-10 16:44:30 DEBUG [glance-api] Configuration options gathered from config file:
2011-08-10 16:44:30 DEBUG [glance-api] /etc/glance/glance-api.conf
2011-08-10 16:44:30 DEBUG [glance-api] ================================================
2011-08-10 16:44:30 DEBUG [glance-api] bind_host 0.0.0.0
2011-08-10 16:44:30 DEBUG [glance-api] bind_port 9292
2011-08-10 16:44:30 DEBUG [glance-api] debug True
2011-08-10 16:44:30 DEBUG [glance-api] default_store swift
2011-08-10 16:44:30 DEBUG [glance-api] delayed_delete False
2011-08-10 16:44:30 DEBUG [glance-api] filesystem_store_datadir /var/lib/glance/images/
2011-08-10 16:44:30 DEBUG [glance-api] image_cache_datadir /var/lib/glance/image-cache/
2011-08-10 16:44:30 DEBUG [glance-api] image_cache_enabled False
2011-08-10 16:44:30 DEBUG [glance-api] image_cache_stall_timeout 86400
2011-08-10 16:44:30 DEBUG [glance-api] log_file /var/log/glance/api.log
2011-08-10 16:44:30 DEBUG [glance-api] registry_host 0.0.0.0
2011-08-10 16:44:30 DEBUG [glance-api] registry_port 9191
2011-08-10 16:44:30 DEBUG [glance-api] s3_store_access_key <20-char AWS access key>
2011-08-10 16:44:30 DEBUG [glance-api] s3_store_bucket <lowercased 20-char aws access key>glance
2011-08-10 16:44:30 DEBUG [glance-api] s3_store_create_bucket_on_put False
2011-08-10 16:44:30 DEBUG [glance-api] s3_store_host 127.0.0.1:8080/v1.0/
2011-08-10 16:44:30 DEBUG [glance-api] s3_store_secret_key <40-char AWS secret key>
2011-08-10 16:44:30 DEBUG [glance-api] swift_enable_snet False
2011-08-10 16:44:30 DEBUG [glance-api] swift_store_auth_address 172.17.1.125:443/v1.0/
2011-08-10 16:44:30 DEBUG [glance-api] swift_store_container glance
2011-08-10 16:44:30 DEBUG [glance-api] swift_store_create_container_on_put True
2011-08-10 16:44:30 DEBUG [glance-api] swift_store_key testing
2011-08-10 16:44:30 DEBUG [glance-api] swift_store_user test:tester
2011-08-10 16:44:30 DEBUG [glance-api] verbose True
2011-08-10 16:44:30 DEBUG [glance-api] ********************************************************************************
2011-08-10 16:44:30 DEBUG [routes.middleware] Initialized with method overriding = True, and path info altering = True
2011-08-10 16:44:30 DEBUG [eventlet.wsgi.server] (678) wsgi starting up on http://0.0.0.0:9292/
2011-08-10 16:45:34 DEBUG [glance.api.middleware.version_negotiation] Processing request: POST /v1/images Accept:
2011-08-10 16:45:34 DEBUG [glance.api.middleware.version_negotiation] Matched versioned URI. Version: 1.0
2011-08-10 16:45:34 DEBUG [routes.middleware] Matched POST /images
2011-08-10 16:45:34 DEBUG [routes.middleware] Route path: 'images', defaults: {'action': u'create', 'controller': <glance.common.wsgi.Resource object at 0x2999a50>}
2011-08-10 16:45:34 DEBUG [routes.middleware] Match dict: {'action': u'create', 'controller': <glance.common.wsgi.Resource object at 0x2999a50>}
2011-08-10 16:45:34 DEBUG [glance.registry] Adding image metadata...
2011-08-10 16:45:34 DEBUG [glance.registry] container_format: ovf
2011-08-10 16:45:34 DEBUG [glance.registry] disk_format: raw
2011-08-10 16:45:34 DEBUG [glance.registry] is_public: True
2011-08-10 16:45:34 DEBUG [glance.registry] name: s2
2011-08-10 16:45:34 DEBUG [glance.registry] size: 0
2011-08-10 16:45:34 DEBUG [glance.registry] status: queued
2011-08-10 16:45:34 DEBUG [glance.registry] Returned image metadata from call to RegistryClient.add_image():
2011-08-10 16:45:34 DEBUG [glance.registry] checksum: None
2011-08-10 16:45:34 DEBUG [glance.registry] container_format: ovf
2011-08-10 16:45:34 DEBUG [glance.registry] created_at: 2011-08-10T08:45:34.533024
2011-08-10 16:45:34 DEBUG [glance.registry] deleted: False
2011-08-10 16:45:34 DEBUG [glance.registry] deleted_at: None
2011-08-10 16:45:34 DEBUG [glance.registry] disk_format: raw
2011-08-10 16:45:34 DEBUG [glance.registry] id: 16
2011-08-10 16:45:34 DEBUG [glance.registry] is_public: True
2011-08-10 16:45:34 DEBUG [glance.registry] location: None
2011-08-10 16:45:34 DEBUG [glance.registry] name: s2
2011-08-10 16:45:34 DEBUG [glance.registry] owner: None
2011-08-10 16:45:34 DEBUG [glance.registry] size: 0
2011-08-10 16:45:34 DEBUG [glance.registry] status: queued
2011-08-10 16:45:34 DEBUG [glance.registry] updated_at: None
2011-08-10 16:45:34 DEBUG [glance.api.v1.images] Setting image 16 to status 'saving'
2011-08-10 16:45:34 DEBUG [glance.registry] Updating image metadata for image 16...
2011-08-10 16:45:34 DEBUG [glance.registry] status: saving
2011-08-10 16:45:34 DEBUG [glance.registry] Returned image metadata from call to RegistryClient.update_image():
2011-08-10 16:45:34 DEBUG [glance.registry] checksum: None
2011-08-10 16:45:34 DEBUG [glance.registry] container_format: ovf
2011-08-10 16:45:34 DEBUG [glance.registry] created_at: 2011-08-10T08:45:34.533024
2011-08-10 16:45:34 DEBUG [glance.registry] deleted: False
2011-08-10 16:45:34 DEBUG [glance.registry] deleted_at: None
2011-08-10 16:45:34 DEBUG [glance.registry] disk_format: raw
2011-08-10 16:45:34 DEBUG [glance.registry] id: 16
2011-08-10 16:45:34 DEBUG [glance.registry] is_public: True
2011-08-10 16:45:34 DEBUG [glance.registry] location: None
2011-08-10 16:45:34 DEBUG [glance.registry] name: s2
2011-08-10 16:45:34 DEBUG [glance.registry] owner: None
2011-08-10 16:45:34 DEBUG [glance.registry] size: 0
2011-08-10 16:45:34 DEBUG [glance.registry] status: saving
2011-08-10 16:45:34 DEBUG [glance.registry] updated_at: 2011-08-10T08:45:34.629167
2011-08-10 16:45:34 DEBUG [glance.api.v1.images] Uploading image data for image 16 to swift store
2011-08-10 16:45:34 DEBUG [glance.store.swift] Creating Swift connection with (auth_address=https://172.17.1.125:443/v1.0/, user=test:tester, key=testing, snet=False)
2011-08-10 16:45:34 ERROR [glance.api.v1.images] Error uploading image: global name 'swift_client' is not defined
2011-08-10 16:45:34 DEBUG [glance.registry] Updating image metadata for image 16...
2011-08-10 16:45:34 DEBUG [glance.registry] status: killed
2011-08-10 16:45:34 DEBUG [glance.registry] Returned image metadata from call to RegistryClient.update_image():
2011-08-10 16:45:34 DEBUG [glance.registry] checksum: None
2011-08-10 16:45:34 DEBUG [glance.registry] container_format: ovf
2011-08-10 16:45:34 DEBUG [glance.registry] created_at: 2011-08-10T08:45:34.533024
2011-08-10 16:45:34 DEBUG [glance.registry] deleted: False
2011-08-10 16:45:34 DEBUG [glance.registry] deleted_at: None
2011-08-10 16:45:34 DEBUG [glance.registry] disk_format: raw
2011-08-10 16:45:34 DEBUG [glance.registry] id: 16
2011-08-10 16:45:34 DEBUG [glance.registry] is_public: True
2011-08-10 16:45:34 DEBUG [glance.registry] location: None
2011-08-10 16:45:34 DEBUG [glance.registry] name: s2
2011-08-10 16:45:34 DEBUG [glance.registry] owner: None
2011-08-10 16:45:34 DEBUG [glance.registry] size: 0
2011-08-10 16:45:34 DEBUG [glance.registry] status: killed
2011-08-10 16:45:34 DEBUG [glance.registry] updated_at: 2011-08-10T08:45:34.709725
2011-08-10 16:45:34 DEBUG [eventlet.wsgi.server] 127.0.0.1 - - [10/Aug/2011 16:45:34] "POST /v1/images HTTP/1.1" 400 310 0.256314

Can any of you give some help? Thanks in advance!

Guangya Liu (gyliu) said : #4

Even if I set "swift_store_auth_address = https://172.17.1.125:443/auth/v1.0/" still does not work.

Jay Pipes (jaypipes) said : #5

Hi! I think you may need to install python-swift on the Glance box :)

2011-08-10 16:45:34 ERROR [glance.api.v1.images] Error uploading image: global name 'swift_client' is not defined

means that there was an import error. I'll file a bug about the message not being clear...

Cheers!
jay

Guangya Liu (gyliu) said : #6

Thanks Jay, may I ask how can I install python-swift?

I try the command "apt-get install python-swift", but failed.

Thanks.

Jay Pipes (jaypipes) said : #7

jpipes@serialcoder:~/repos/glance$ dpkg -l | grep "swift"
ii python-swift 1.3.0-0ubuntu1 A distributed virtual object store (python libraries)
ii swift 1.3.0-0ubuntu1 A distributed virtual object store (common files)

What version of Debian or Ubuntu are you on?

-jay

Guangya Liu (gyliu) said : #8

Thanks Jay for the quick response ;-), the following are my ubuntu version. Any comments?

root@glance-node:~/test# cat /etc/*release
DISTRIB_ID=Ubuntu
DISTRIB_RELEASE=10.04
DISTRIB_CODENAME=lucid
DISTRIB_DESCRIPTION="Ubuntu 10.04.3 LTS"
root@glance-node:~/test# apt-get install python-swift
Reading package lists... Done
Building dependency tree
Reading state information... Done
E: Couldn't find package python-swift
root@glance-node:~/test#

Jay Pipes (jaypipes) said : #9

Hi again! Can you try this?

sudo easy_install swift

Might be easier than adding a PPA via add-apt-repository...

-jay

Guangya Liu (gyliu) said : #10

Thanaks Jay, after re-install a ubuntu OS and re-install glance, it works well with swift.

You are right, we need to install python-swift in Glance box to make this works.

Thanks for your great help!

root@glance-node2:~# glance show 2
URI: http://0.0.0.0/images/2
Id: 2
Public: Yes
Name: swift1
Status: active
Size: 0
Location: swift+https://test:tester:testing@172.17.1.125:443/auth/v1.0//glance/2
Disk format: raw
Container format: ovf

Jay Pipes (jaypipes) said : #11

Glad to hear you are all set! Don't hesitate to get in touch with us if you have any further questions or issues.

Cheers!
jay

Everett Toews (everett-toews) said : #12

Perhaps you're running into this bug?

https://bugs.launchpad.net/glance/+bug/771849

Everett

On Wed, Aug 10, 2011 at 3:06 AM, Guangya Liu <
<email address hidden>> wrote:

> Question #167442 on OpenStack Object Storage (swift) changed:
> https://answers.launchpad.net/swift/+question/167442
>
> Guangya Liu gave more information on the question:
> Even if I set "swift_store_auth_address =
> https://172.17.1.125:443/auth/v1.0/" still does not work.
>
> --
> You received this question notification because you are an answer
> contact for OpenStack Object Storage (swift).
>

Guangya Liu (gyliu) said : #13

Thanks Everett for the comments, the problem have been resolved with the help of Jay ;-)

What I need do is install python-swift on my Glance Box.