79
def _option_get(cls, options, param):
80
result = options.get(param)
82
msg = ("Could not find %s in configuration options." % param)
84
raise glance.store.BackendException(msg)
79
88
def add(cls, id, data, options):
81
90
Stores image data to Swift and returns a location that the image was
101
110
from swift.common import client as swift_client
102
111
container = options.get('swift_store_container',
103
112
DEFAULT_SWIFT_CONTAINER)
104
auth_address = options.get('swift_store_auth_address')
105
user = options.get('swift_store_user')
106
key = options.get('swift_store_key')
108
114
# TODO(jaypipes): This needs to be checked every time
109
115
# because of the decision to make glance.store.Backend's
110
116
# interface all @classmethods. This is inefficient. Backend
111
117
# should be a stateful object with options parsed once in
114
msg = ("Could not find swift_store_auth_address in configuration "
117
raise glance.store.BackendException(msg)
119
full_auth_address = auth_address
120
if not full_auth_address.startswith('http'):
121
full_auth_address = 'https://' + full_auth_address
124
msg = ("Could not find swift_store_user in configuration "
127
raise glance.store.BackendException(msg)
130
msg = ("Could not find swift_store_key in configuration "
133
raise glance.store.BackendException(msg)
119
auth_address = cls._option_get(options, 'swift_store_auth_address')
120
user = cls._option_get(options, 'swift_store_user')
121
key = cls._option_get(options, 'swift_store_key')
123
full_auth_address = auth_address
124
if not full_auth_address.startswith('http'):
125
full_auth_address = 'https://' + full_auth_address
135
127
swift_conn = swift_client.Connection(
136
128
authurl=full_auth_address, user=user, key=key, snet=False)