From 993da54b4a89c32e9c28b6b31ca01751ac3b86c4 Mon Sep 17 00:00:00 2001 From: Evan Broder Date: Sun, 27 Dec 2009 12:29:13 -0500 Subject: [PATCH 01/16] The tag is always empty, so having a separate closing tag is meaningless. svn path=/trunk/packages/invirt-web/; revision=2792 --- code/templates/functions.mako | 2 +- code/templates/list.mako | 6 ++---- 2 files changed, 3 insertions(+), 5 deletions(-) diff --git a/code/templates/functions.mako b/code/templates/functions.mako index 068401f..c57e904 100644 --- a/code/templates/functions.mako +++ b/code/templates/functions.mako @@ -27,7 +27,7 @@ ${databaseList(sorted(database.Autoinstall.query(), key=lambda x: x.description) <%def name="vmTypeList(default=None)"> % for vmtype in (('linux-hvm', 'HVM'), ('linux', 'ParaVM'), ): % endfor diff --git a/code/templates/list.mako b/code/templates/list.mako index 288e44f..99e81cb 100644 --- a/code/templates/list.mako +++ b/code/templates/list.mako @@ -54,18 +54,16 @@ VM List Autoinstall${self.fn.helppopup('Autoinstalls')} + onchange="$('cdromlist').value = ''; $('vmtype-linux').checked = true" /> ${self.fn.autoList(defaults.cdrom, "$('cd_or_auto_auto').checked = true;$('cdromlist').value = '';$('vmtype-linux').checked = true")} (experimental; 2-3 minutes, and you have a machine with empty root password.) - Boot CD + onchange="$('autoinstalllist').value = ''; $('vmtype-linux-hvm').checked = true" /> ${self.fn.cdromList(defaults.cdrom, "$('cd_or_auto_cd').checked = true;$('autoinstalllist').value = '';$('vmtype-linux-hvm').checked = true")} - ${self.fn.errorRow('cdrom', err)} ${self.fn.errorRow('cdrom', err)} -- 1.7.9.5 From 6698c203874b6b49fe661b2f598a905953fb2004 Mon Sep 17 00:00:00 2001 From: Evan Broder Date: Sun, 27 Dec 2009 12:29:17 -0500 Subject: [PATCH 02/16] Nuke an extra tag. svn path=/trunk/packages/invirt-web/; revision=2793 --- code/templates/info.mako | 1 - 1 file changed, 1 deletion(-) diff --git a/code/templates/info.mako b/code/templates/info.mako index 0d1b66b..998b73e 100644 --- a/code/templates/info.mako +++ b/code/templates/info.mako @@ -47,7 +47,6 @@ Info on ${machine.name}
${command_button("Delete VM", "delete", extra='''onclick="return confirm('Are you sure that you want to delete this VM?');"''')}
- <%def name="modifyForm()"> -- 1.7.9.5 From ef93f894aa9ab8d6dccb8a85324d6b2ebc69facf Mon Sep 17 00:00:00 2001 From: Evan Broder Date: Sun, 27 Dec 2009 19:25:09 -0500 Subject: [PATCH 03/16] Add label tags to group tags with their labels. Also add missing tags. svn path=/trunk/packages/invirt-web/; revision=2794 --- code/templates/list.mako | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/code/templates/list.mako b/code/templates/list.mako index 99e81cb..c3167cb 100644 --- a/code/templates/list.mako +++ b/code/templates/list.mako @@ -53,17 +53,18 @@ VM List ${self.fn.errorRow('autoinstall', err)} Autoinstall${self.fn.helppopup('Autoinstalls')} - Boot CD - ${self.fn.errorRow('cdrom', err)} ${self.fn.errorRow('cdrom', err)} -- 1.7.9.5 From 1e99dd0672b15943cdd2234f0243b31f1adb626f Mon Sep 17 00:00:00 2001 From: Evan Broder Date: Sun, 27 Dec 2009 19:49:17 -0500 Subject: [PATCH 04/16] Adjust the Makefile shipped with the website to kill invirt.fcgi, instead of main.fcgi. svn path=/trunk/packages/invirt-web/; revision=2795 --- code/Makefile | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/code/Makefile b/code/Makefile index c406438..5b6a005 100644 --- a/code/Makefile +++ b/code/Makefile @@ -5,4 +5,4 @@ chmod: chmod -R g+w . 2>/dev/null || true kill: - -pkill main.fcgi + -pkill invirt.fcgi -- 1.7.9.5 From 6658211de695c3b138f33ad9d8d39bad1581a316 Mon Sep 17 00:00:00 2001 From: Quentin Smith Date: Sun, 27 Dec 2009 20:13:29 -0500 Subject: [PATCH 05/16] Don't use JavaScript to stripe rows svn path=/trunk/packages/invirt-web/; revision=2796 --- code/static/stripe.js | 18 ------------------ code/templates/list.mako | 19 ++++++++----------- 2 files changed, 8 insertions(+), 29 deletions(-) delete mode 100644 code/static/stripe.js diff --git a/code/static/stripe.js b/code/static/stripe.js deleted file mode 100644 index f1c16de..0000000 --- a/code/static/stripe.js +++ /dev/null @@ -1,18 +0,0 @@ -/* - * The general idea is from the following A List Apart article: - * http://www.alistapart.com/articles/zebratables/ - * - * The structure is inspired by the code fragment they supply, but the - * code here is significantly cleaner. It also colors every two lines - * rather than every line, since XVM uses two rows for each item. - */ - -function stripe(table, darkClass, lightClass) { - for (var i = 0; i < table.rows.length; i++ ) { - /* The header row should be light; the next two are dark. */ - if (i%4 == 1 || i%4 == 2) - table.rows[i].className += ' ' + darkClass; - else if (lightClass) - table.rows[i].className += ' ' + lightClass; - } -} diff --git a/code/templates/list.mako b/code/templates/list.mako index c3167cb..d7d320a 100644 --- a/code/templates/list.mako +++ b/code/templates/list.mako @@ -80,8 +80,12 @@ ${self.fn.cdromList(defaults.cdrom, "$('cd_or_auto_cd').checked = true;$('autoin % endif -<%def name="machineRow(machine)"> - +<%def name="machineRow(machine, dark)"> + % if machine.uptime and installing[machine]: Installing... @@ -139,17 +143,10 @@ ${has_vnc[machine]} Uptime VNC -% for machine in machines: - ${machineRow(machine)} +% for n, machine in enumerate(machines): + ${machineRow(machine, (n%2)==0)} % endfor - -

What is XVM?

-- 1.7.9.5 From 810f5128717fa14957fce60d04d42b15c6b87fe0 Mon Sep 17 00:00:00 2001 From: Quentin Smith Date: Sun, 27 Dec 2009 20:17:03 -0500 Subject: [PATCH 06/16] There's two trs svn path=/trunk/packages/invirt-web/; revision=2797 --- code/templates/list.mako | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/code/templates/list.mako b/code/templates/list.mako index d7d320a..90953f0 100644 --- a/code/templates/list.mako +++ b/code/templates/list.mako @@ -126,7 +126,11 @@ ${has_vnc[machine]} % endif - + ${machine.description|self.fn.module.nl2br} -- 1.7.9.5 From fdda3852e46b9fb9bde623d6dbd4d55752fcbf74 Mon Sep 17 00:00:00 2001 From: Evan Broder Date: Mon, 28 Dec 2009 14:03:33 -0500 Subject: [PATCH 07/16] Add more user-friendly error handling for common errors, so they don't send us e-mail. (LP: #307296) svn path=/trunk/packages/invirt-web/; revision=2803 --- code/controls.py | 13 +++++++++++++ debian/changelog | 7 +++++++ 2 files changed, 20 insertions(+) diff --git a/code/controls.py b/code/controls.py index bbc9f8c..2a86a89 100644 --- a/code/controls.py +++ b/code/controls.py @@ -73,6 +73,19 @@ def bootMachine(machine, cdtype): if 'already running' in err: raise InvalidInput('action', 'create', 'VM %s is already on' % machine.name) + elif 'I need' in err and 'but dom0_min_mem is' in err: + raise InvalidInput('action', 'create', + "We're really sorry, but our servers don't have enough capacity to create your VM right now. Try creating a VM with less RAM, or shutting down another VM of yours. Feel free to ask %s if you would like to know when we plan to have more resources." % (config.contact)) + elif ('Booting VMs is temporarily disabled for maintenance, sorry' in err or + 'LVM operations are temporarily disabled for maintenance, sorry' in err): + raise InvalidInput('action', 'create', + err) + elif "Boot loader didn't return any data!" in err: + raise InvalidInput('action', 'create', + "The ParaVM bootloader was unable to find an operating system to boot. Do you have GRUB configured correctly?") + elif 'xc_dom_find_loader: no loader found' in err: + raise InvalidInput('action', 'create', + "The ParaVM bootloader was unable to boot the kernel you have configured. Are you sure this kernel is capable of running as a Xen ParaVM guest?") elif err: raise CodeError('"%s" on "control %s create %s' % (err, machine.name, cdtype)) diff --git a/debian/changelog b/debian/changelog index f33fb00..acb4e06 100644 --- a/debian/changelog +++ b/debian/changelog @@ -1,3 +1,10 @@ +invirt-web (0.1.3) unstable; urgency=low + + * Add some more user-friendly error handling for common errors. (LP: + #307296) + + -- Evan Broder Mon, 28 Dec 2009 13:03:00 -0600 + invirt-web (0.1.2) unstable; urgency=low * Do some quick config cleanup. -- 1.7.9.5 From 75b32a456c2efa77b7ca33b2275405f3a88bac35 Mon Sep 17 00:00:00 2001 From: Evan Broder Date: Mon, 28 Dec 2009 14:15:30 -0500 Subject: [PATCH 08/16] Stylize the results box a bit more so it's more visible. svn path=/trunk/packages/invirt-web/; revision=2804 --- code/static/style.css | 7 +++++++ code/templates/skeleton.mako | 11 ++++++----- 2 files changed, 13 insertions(+), 5 deletions(-) diff --git a/code/static/style.css b/code/static/style.css index a764e17..9bea2e9 100644 --- a/code/static/style.css +++ b/code/static/style.css @@ -108,3 +108,10 @@ tr.stripedrow { form { display: inline; } + +/* styling for the results box */ +.result { + background-color: #e8e8ff; + border: 1px black solid; + padding: 1ex; +} diff --git a/code/templates/skeleton.mako b/code/templates/skeleton.mako index a53d2bf..aee4769 100644 --- a/code/templates/skeleton.mako +++ b/code/templates/skeleton.mako @@ -66,15 +66,16 @@ You are currently authenticated as an administrator. % endif -
+% if not simple: +

${self.title()} — XVM

+% endif + % if result: +
${result} -% endif
- -% if not simple: -

${self.title()} — XVM

% endif + ${next.body()} % if not simple:
-- 1.7.9.5 From 3c7dbc58af6d9a366f0c26b4f50d2ab57bcfeb2e Mon Sep 17 00:00:00 2001 From: Paul Weaver Date: Wed, 30 Dec 2009 02:46:54 -0500 Subject: [PATCH 09/16] Added a like for kerberos authentication for the website svn path=/trunk/packages/invirt-web/; revision=2807 --- code/templates/unauth.mako | 3 +++ 1 file changed, 3 insertions(+) diff --git a/code/templates/unauth.mako b/code/templates/unauth.mako index 562481f..0cbc4c7 100644 --- a/code/templates/unauth.mako +++ b/code/templates/unauth.mako @@ -20,6 +20,9 @@ href="https://${config.web.hostname}/">

You'll need an MIT personal certificate.

+
Log in to XVM using Kerberos Tickets +

XVM features:

%endif

MIT users:

-- 1.7.9.5 From d8276b5c303ed6bb8e0596e6332bad50f1b7fb71 Mon Sep 17 00:00:00 2001 From: Paul Weaver Date: Wed, 30 Dec 2009 15:42:23 -0500 Subject: [PATCH 14/16] Moved all code for service messages to unauth.make svn path=/trunk/packages/invirt-web/; revision=2814 --- code/main.py | 6 +----- code/templates/unauth.mako | 5 +++-- 2 files changed, 4 insertions(+), 7 deletions(-) diff --git a/code/main.py b/code/main.py index 9f57f84..ecf0305 100755 --- a/code/main.py +++ b/code/main.py @@ -51,11 +51,7 @@ class InvirtUnauthWeb(View): @cherrypy.expose @cherrypy.tools.mako(filename="/unauth.mako") def index(self): - d = dict(simple=True) - if os.path.exists("/etc/invirt/message"): - f = open('/etc/invirt/message') - d['serviceMessage']= f.read() - return d + return dict(simple=True) class InvirtWeb(View): def __init__(self): diff --git a/code/templates/unauth.mako b/code/templates/unauth.mako index 08dd617..ec67c80 100644 --- a/code/templates/unauth.mako +++ b/code/templates/unauth.mako @@ -13,9 +13,10 @@ own complete system on which you can start from our three-minute Debian or Ubuntu install or install the operating system of your choice. The service is free to any Athena account holder.

-%if serviceMessage: + +%if os.path.exists("/etc/invirt/message"):
-

${serviceMessage}

+

${open('/etc/invirt/message').read()}

%endif -- 1.7.9.5 From deb49f12aad253039d9b8907dde04b89321f5e49 Mon Sep 17 00:00:00 2001 From: Evan Broder Date: Wed, 30 Dec 2009 15:55:42 -0500 Subject: [PATCH 15/16] Fix modifying powered-on machines. svn path=/trunk/packages/invirt-web/; revision=2815 --- code/main.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/code/main.py b/code/main.py index ecf0305..7044167 100755 --- a/code/main.py +++ b/code/main.py @@ -520,9 +520,9 @@ def modifyDict(username, state, machine_id, fields): olddisk = {} session.begin() try: - kws = dict([(kw, fields[kw]) for kw in + kws = dict((kw, fields[kw]) for kw in 'owner admin contact name description memory vmtype disksize'.split() - if fields[kw]]) + if fields.get(kw)) kws['machine_id'] = machine_id validate = validation.Validate(username, state, **kws) machine = validate.machine -- 1.7.9.5 From dbc720a8ee1dfdbc48fa3e17e8ef8af4aed7efe4 Mon Sep 17 00:00:00 2001 From: Evan Broder Date: Sun, 3 Jan 2010 16:43:08 -0500 Subject: [PATCH 16/16] Merge invirt-web-iptables into invirt-web and use the new invirt-iptables interface. svn path=/trunk/packages/invirt-web/; revision=2863 --- debian/changelog | 7 ++++++ debian/control | 3 ++- debian/invirt-web.init | 2 +- .../etc/invirt-iptables/rules.d/50-invirt-web.mako | 26 ++++++++++++++++++++ 4 files changed, 36 insertions(+), 2 deletions(-) create mode 100644 files/etc/invirt-iptables/rules.d/50-invirt-web.mako diff --git a/debian/changelog b/debian/changelog index acb4e06..c489ddc 100644 --- a/debian/changelog +++ b/debian/changelog @@ -1,3 +1,10 @@ +invirt-web (0.1.4) unstable; urgency=low + + * Merge invirt-web-iptables into invirt-web and use the new + invirt-iptables interface. + + -- Evan Broder Sun, 03 Jan 2010 16:36:47 -0500 + invirt-web (0.1.3) unstable; urgency=low * Add some more user-friendly error handling for common errors. (LP: diff --git a/debian/control b/debian/control index e22a9ff..f2a3f00 100644 --- a/debian/control +++ b/debian/control @@ -10,7 +10,7 @@ Architecture: all Depends: ${misc:Depends}, # other Invirt invirt-base, invirt-database, - invirt-dns, invirt-vnc-client, invirt-web-iptables, + invirt-dns, invirt-vnc-client, invirt-iptables, # web server apache2, libapache2-mod-fcgid, libapache2-svn, libapache2-mod-auth-sslcert, libapache2-mod-auth-kerb, @@ -26,4 +26,5 @@ Depends: ${misc:Depends}, cron, Provides: ${diverted-files} Conflicts: ${diverted-files} +Replaces: invirt-web-iptables (<= 0.0.2) Description: the Invirt web interface diff --git a/debian/invirt-web.init b/debian/invirt-web.init index e8524ee..ad4c37c 100755 --- a/debian/invirt-web.init +++ b/debian/invirt-web.init @@ -11,7 +11,7 @@ PACKAGE=invirt-web PARENTPACKAGE=apache2 -GEN_FILES=(/etc/apache2/sites-available/{default,ssl,svn}) +GEN_FILES=(/etc/apache2/sites-available/{default,ssl,svn} /etc/invirt-iptables/rules.d/50-invirt-web) . /lib/init/config-init.sh config_init "$1" diff --git a/files/etc/invirt-iptables/rules.d/50-invirt-web.mako b/files/etc/invirt-iptables/rules.d/50-invirt-web.mako new file mode 100644 index 0000000..a8f218b --- /dev/null +++ b/files/etc/invirt-iptables/rules.d/50-invirt-web.mako @@ -0,0 +1,26 @@ +<% + +from invirt.config import structs as cfg +h_port = cfg.vnc.base_port +port = cfg.vnc.base_port + +%>\ +*nat +:PREROUTING ACCEPT [5:300] +:POSTROUTING ACCEPT [8:674] +:OUTPUT ACCEPT [8:674] +% for h in cfg.hosts: +-A PREROUTING -s ! ${h.ip} -i eth0 -p tcp -m tcp --dport ${port} -j DNAT --to-destination ${h.ip}:${h_port} +-A POSTROUTING -d ${h.ip} -o eth0 -p tcp -m tcp --dport ${h_port} -j SNAT --to-source ${cfg.vnc.proxy_ip} +<% port += 1 %> +% endfor +COMMIT + +*filter +:INPUT ACCEPT [366:44912] +:FORWARD ACCEPT [0:0] +:OUTPUT ACCEPT [292:53151] +% for h in cfg.hosts: +-A FORWARD -d ${h.ip} -i eth0 -o eth0 -p tcp -m tcp --dport ${h_port} -j ACCEPT +% endfor +COMMIT -- 1.7.9.5