projects
/
snf-image-creator
/ blobdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
|
commitdiff
|
tree
raw
|
inline
| side by side
Fix syntax errors
[snf-image-creator]
/
image_creator
/
dialog_menu.py
diff --git
a/image_creator/dialog_menu.py
b/image_creator/dialog_menu.py
index
c8cfe27
..
55bcd4e
100644
(file)
--- a/
image_creator/dialog_menu.py
+++ b/
image_creator/dialog_menu.py
@@
-110,15
+110,21
@@
class metadata_monitor(object):
def upload_image(session):
d = session["dialog"]
dev = session['device']
def upload_image(session):
d = session["dialog"]
dev = session['device']
+ meta = session['metadata']
size = dev.size
if "account" not in session:
size = dev.size
if "account" not in session:
- d.msgbox("You need to provide your ~okeanos account before you "
+ d.msgbox("You need to provide your ~okeanos credentials before you "
"can upload images to pithos+", width=SMALL_WIDTH)
return False
while 1:
"can upload images to pithos+", width=SMALL_WIDTH)
return False
while 1:
- init = session["upload"] if "upload" in session else ''
+ if 'upload' in session:
+ init = session['upload']
+ elif 'OS' in meta:
+ init = "%s.diskdump" % meta['OS']
+ else:
+ init = ""
(code, answer) = d.inputbox("Please provide a filename:", init=init,
width=WIDTH)
(code, answer) = d.inputbox("Please provide a filename:", init=init,
width=WIDTH)
@@
-185,15
+191,17
@@
def register_image(session):
d = session["dialog"]
dev = session['device']
d = session["dialog"]
dev = session['device']
+ is_public = False
+
if "account" not in session:
if "account" not in session:
- d.msgbox("You need to provide your ~okeanos login username before you "
- "can register an images to cyclades",
+ d.msgbox("You need to provide your ~okeanos credentians before you "
+ "can register an images with cyclades",
width=SMALL_WIDTH)
return False
if "pithos_uri" not in session:
d.msgbox("You need to upload the image to pithos+ before you can "
width=SMALL_WIDTH)
return False
if "pithos_uri" not in session:
d.msgbox("You need to upload the image to pithos+ before you can "
- "register it to cyclades", width=SMALL_WIDTH)
+ "register it with cyclades", width=SMALL_WIDTH)
return False
while 1:
return False
while 1:
@@
-206,6
+214,15
@@
def register_image(session):
if len(name) == 0:
d.msgbox("Registration name cannot be empty", width=SMALL_WIDTH)
continue
if len(name) == 0:
d.msgbox("Registration name cannot be empty", width=SMALL_WIDTH)
continue
+
+ ret = d.yesno("Make the image public?\\nA public image is accessible "
+ "by every user of the service.", defaultno=1,
+ width=WIDTH)
+ if ret not in (0, 1):
+ continue
+
+ is_public = True if ret == 0 else False
+
break
metadata = {}
break
metadata = {}
@@
-214,15
+231,17
@@
def register_image(session):
for key in session['task_metadata']:
metadata[key] = 'yes'
for key in session['task_metadata']:
metadata[key] = 'yes'
+ img_type = "public" if is_public else "private"
gauge = GaugeOutput(d, "Image Registration", "Registering image...")
try:
out = dev.out
out.add(gauge)
try:
gauge = GaugeOutput(d, "Image Registration", "Registering image...")
try:
out = dev.out
out.add(gauge)
try:
- out.output("Registering image with Cyclades...")
+ out.output("Registering %s image with Cyclades..." % img_type)
try:
kamaki = Kamaki(session['account'], out)
try:
kamaki = Kamaki(session['account'], out)
- kamaki.register(name, session['pithos_uri'], metadata)
+ kamaki.register(name, session['pithos_uri'], metadata,
+ is_public)
out.success('done')
except ClientError as e:
d.msgbox("Error in pithos+ client: %s" % e.message)
out.success('done')
except ClientError as e:
d.msgbox("Error in pithos+ client: %s" % e.message)
@@
-232,8
+251,8
@@
def register_image(session):
finally:
gauge.cleanup()
finally:
gauge.cleanup()
- d.msgbox("Image `%s' was successfully registered with Cyclades as `%s'" %
- (session['upload'], name), width=SMALL_WIDTH)
+ d.msgbox("%s image `%s' was successfully registered with Cyclades as `%s'"
+ % (img_type.title(), session['upload'], name), width=SMALL_WIDTH)
return True
return True
@@
-270,7
+289,7
@@
def kamaki_menu(session):
if choice == "Account":
default_item = "Account"
(code, answer) = d.inputbox(
if choice == "Account":
default_item = "Account"
(code, answer) = d.inputbox(
- "Please provide your ~okeanos token:",
+ "Please provide your ~okeanos authentication token:",
init=session["account"]['auth_token'] if "account" in session
else '', width=WIDTH)
if code in (d.DIALOG_CANCEL, d.DIALOG_ESC):
init=session["account"]['auth_token'] if "account" in session
else '', width=WIDTH)
if code in (d.DIALOG_CANCEL, d.DIALOG_ESC):
@@
-286,7
+305,7
@@
def kamaki_menu(session):
else:
del session['account']
d.msgbox("The token you provided is not valid!",
else:
del session['account']
d.msgbox("The token you provided is not valid!",
- width=SMALL_WIDTH)
+ width=SMALL_WIDTH)
elif choice == "Upload":
if upload_image(session):
default_item = "Register"
elif choice == "Upload":
if upload_image(session):
default_item = "Register"
@@
-651,6
+670,10
@@
def main_menu(session):
d.infobox("Resetting snf-image-creator. Please wait...",
width=SMALL_WIDTH)
raise Reset
d.infobox("Resetting snf-image-creator. Please wait...",
width=SMALL_WIDTH)
raise Reset
+ elif choice == "Help":
+ d.msgbox("For help, check the online documentation:\n\nhttp://www"
+ ".synnefo.org/docs/snf-image-creator/latest/",
+ width=WIDTH, title="Help")
elif choice in actions:
actions[choice](session)
elif choice in actions:
actions[choice](session)