Revision ffc64d7c image_creator/dialog_menu.py
b/image_creator/dialog_menu.py | ||
---|---|---|
113 | 113 |
|
114 | 114 |
|
115 | 115 |
def upload_image(session): |
116 |
"""Upload the image to pithos+"""
|
|
116 |
"""Upload the image to the storage service"""
|
|
117 | 117 |
d = session["dialog"] |
118 | 118 |
image = session['image'] |
119 | 119 |
meta = session['metadata'] |
... | ... | |
121 | 121 |
|
122 | 122 |
if "account" not in session: |
123 | 123 |
d.msgbox("You need to select a valid cloud before you can upload " |
124 |
"images to pithos+", width=SMALL_WIDTH)
|
|
124 |
"images to it", width=SMALL_WIDTH)
|
|
125 | 125 |
return False |
126 | 126 |
|
127 | 127 |
while 1: |
... | ... | |
149 | 149 |
overwrite.append(f) |
150 | 150 |
|
151 | 151 |
if len(overwrite) > 0: |
152 |
if d.yesno("The following pithos object(s) already exist(s):\n"
|
|
153 |
"%s\nDo you want to overwrite them?" % |
|
152 |
if d.yesno("The following storage service object(s) already "
|
|
153 |
"exist(s):\n%s\nDo you want to overwrite them?" %
|
|
154 | 154 |
"\n".join(overwrite), width=WIDTH, defaultno=1): |
155 | 155 |
continue |
156 | 156 |
|
... | ... | |
182 | 182 |
out.success("done") |
183 | 183 |
|
184 | 184 |
except ClientError as e: |
185 |
d.msgbox("Error in pithos+ client: %s" % e.message, |
|
186 |
title="Pithos+ Client Error", width=SMALL_WIDTH) |
|
185 |
d.msgbox( |
|
186 |
"Error in storage service client: %s" % e.message, |
|
187 |
title="Storage Service Client Error", width=SMALL_WIDTH) |
|
187 | 188 |
if 'pithos_uri' in session: |
188 | 189 |
del session['pithos_uri'] |
189 | 190 |
return False |
... | ... | |
192 | 193 |
finally: |
193 | 194 |
gauge.cleanup() |
194 | 195 |
|
195 |
d.msgbox("Image file `%s' was successfully uploaded to pithos+" % filename,
|
|
196 |
d.msgbox("Image file `%s' was successfully uploaded" % filename, |
|
196 | 197 |
width=SMALL_WIDTH) |
197 | 198 |
|
198 | 199 |
return True |
199 | 200 |
|
200 | 201 |
|
201 | 202 |
def register_image(session): |
202 |
"""Register image with cyclades"""
|
|
203 |
"""Register image with the compute service"""
|
|
203 | 204 |
d = session["dialog"] |
204 | 205 |
|
205 | 206 |
is_public = False |
206 | 207 |
|
207 | 208 |
if "account" not in session: |
208 | 209 |
d.msgbox("You need to select a valid cloud before you " |
209 |
"can register an images with cyclades", width=SMALL_WIDTH)
|
|
210 |
"can register an images with it", width=SMALL_WIDTH)
|
|
210 | 211 |
return False |
211 | 212 |
|
212 | 213 |
if "pithos_uri" not in session: |
213 |
d.msgbox("You need to upload the image to pithos+ before you can "
|
|
214 |
"register it with cyclades", width=SMALL_WIDTH)
|
|
214 |
d.msgbox("You need to upload the image to the cloud before you can "
|
|
215 |
"register it", width=SMALL_WIDTH) |
|
215 | 216 |
return False |
216 | 217 |
|
217 | 218 |
while 1: |
... | ... | |
248 | 249 |
out.add(gauge) |
249 | 250 |
try: |
250 | 251 |
try: |
251 |
out.output("Registering %s image with Cyclades..." % img_type)
|
|
252 |
out.output("Registering %s image with the cloud..." % img_type)
|
|
252 | 253 |
kamaki = Kamaki(session['account'], out) |
253 | 254 |
result = kamaki.register(name, session['pithos_uri'], metadata, |
254 | 255 |
is_public) |
... | ... | |
266 | 267 |
kamaki.share("%s.md5sum" % session['upload']) |
267 | 268 |
out.success('done') |
268 | 269 |
except ClientError as e: |
269 |
d.msgbox("Error in pithos+ client: %s" % e.message)
|
|
270 |
d.msgbox("Error in storage service client: %s" % e.message)
|
|
270 | 271 |
return False |
271 | 272 |
finally: |
272 | 273 |
out.remove(gauge) |
273 | 274 |
finally: |
274 | 275 |
gauge.cleanup() |
275 | 276 |
|
276 |
d.msgbox("%s image `%s' was successfully registered with Cyclades as `%s'"
|
|
277 |
d.msgbox("%s image `%s' was successfully registered with the cloud as `%s'"
|
|
277 | 278 |
% (img_type.title(), session['upload'], name), width=SMALL_WIDTH) |
278 | 279 |
return True |
279 | 280 |
|
... | ... | |
374 | 375 |
choices = [("Add/Edit", "Add/Edit cloud accounts"), |
375 | 376 |
("Delete", "Delete existing cloud accounts"), |
376 | 377 |
("Cloud", "Select cloud account to use: %s" % cloud), |
377 |
("Upload", "Upload image to pithos+"),
|
|
378 |
("Register", "Register the image to cyclades: %s" % upload)]
|
|
378 |
("Upload", "Upload image to the cloud"),
|
|
379 |
("Register", "Register image with the cloud: %s" % upload)]
|
|
379 | 380 |
|
380 | 381 |
(code, choice) = d.menu( |
381 | 382 |
text="Choose one of the following or press <Back> to go back.", |
... | ... | |
791 | 792 |
text="Choose one of the following or press <Exit> to exit.", |
792 | 793 |
width=WIDTH, choices=choices, cancel="Exit", height=13, |
793 | 794 |
default_item=default_item, menu_height=len(choices), |
794 |
title="Image Creator for ~okeanos (snf-image-creator version %s)" %
|
|
795 |
title="Image Creator for synnefo (snf-image-creator version %s)" %
|
|
795 | 796 |
version) |
796 | 797 |
|
797 | 798 |
if code in (d.DIALOG_CANCEL, d.DIALOG_ESC): |
Also available in: Unified diff