scripts/cloudfsd.py | 14 ++---
scripts/wwwcfgmain.py | 108 +++++------------------------------------
scripts/wwwcfgroot.py | 104 +++++----------------------------------
scripts/wwwconfirmprovision.py | 32 ++++++------
scripts/wwwcss.py | 79 +++++++++++++++++++++++++++++
scripts/wwwdoinitcluster.py | 16 +++---
scripts/wwwdoprovision.py | 46 ++++++++---------
scripts/wwwinitcluster.py | 39 ++++++--------
scripts/wwwprovision.py | 93 ++++++++++++++++-------------------
scripts/wwwroot.py | 21 +++----
10 files changed, 230 insertions(+), 322 deletions(-)
New commits:
commit 0d1a9f4cc5a7aa2074cb34efcdea8bf0c1517f09
Author: Kaleb S. KEITHLEY <kkeithle(a)cloudfs-node01.kkeithle.redhat.com>
Date: Tue May 3 12:51:46 2011 -0400
checkpoint wip
flow from page to page in www gui works
things remaining:
+ use curl loopback to start volumes, i.e. including creating the
cloudified config files (versus using gluster)
+ switch os.popen and os.system to use subprocess.Popen
but that's enough for today — I need to work on other things.
diff --git a/scripts/cloudfsd.py b/scripts/cloudfsd.py
index 82324db..f68d76e 100755
--- a/scripts/cloudfsd.py
+++ b/scripts/cloudfsd.py
@@ -1,6 +1,6 @@
#!/usr/bin/python
-from bottle import route, post, run
+from bottle import route, post, run, request
import paths
import volstart
@@ -60,18 +60,16 @@ def www_cfgmain():
@route("/wwwprovision")
def www_provision():
- print "www provision"
return wwwprovision.www_provision()
+@post("/wwwconfirmprovision")
+def www_confirmprovision():
+ return wwwconfirmprovision.www_confirmprovision(request.body)
+
@post("/wwwdoprovision")
def www_doprovision():
print "www doprovision"
- return wwwdoprovision.www_doprovision()
-
-@post("/wwwconfirmprovision")
-def www_confirmprovision():
- print "www confirmprovision"
- return wwwconfirmprovision.www_confirmprovision()
+ return wwwdoprovision.www_doprovision(request.body)
@route("/wwwinitcluster")
def www_initcluster():
diff --git a/scripts/wwwcfgmain.py b/scripts/wwwcfgmain.py
index 23f019e..b577a4a 100644
--- a/scripts/wwwcfgmain.py
+++ b/scripts/wwwcfgmain.py
@@ -1,97 +1,19 @@
-import fileinput
+import wwwcss
-def www_cfgroot() :
- fileinput.close()
+def www_cfgmain() :
- print "<!DOCTYPE html PUBLIC \"-//W3C//DTD XHTML 1.1//EN\"
\"http://www.w3.org/TR/xhtml11/DTD/xhtml11.dtd\">"
- print "<html><head>"
- print "<title>_Red Hat CloudFS Configuration_</title>"
- print "<meta http-equiv=\"Content-Type\" content=\"text/html;
charset=UTF-8\" />"
- print "<meta http-equiv=\"Pragma\" content=\"no-cache\"
/>"
- print "<style type=\"text/css\">"
- print "/*<![CDATA[*/"
- print "body {"
- print "background-color: #fff;"
- print "color: #000;"
- print "font-size: 0.9em;"
- print "font-family: sans-serif,helvetica;"
- print "margin: 0;"
- print "padding: 0;"
- print "}"
- print ":link {"
- print "color: #c00;"
- print "}"
- print ":visited {"
- print "color: #c00;"
- print "}"
- print "a:hover {"
- print "color: #f50;"
- print "}"
- print "h1 {"
- print "text-align: center;"
- print "margin: 0;"
- print "padding: 0.6em 2em 0.4em;"
- print "background-color: #900;"
- print "color: #fff;"
- print "font-weight: normal;"
- print "font-size: 1.75em;"
- print "border-bottom: 2px solid #000;"
- print "}"
- print "h1 strong {"
- print "font-weight: bold;"
- print "}"
- print "h2 {"
- print "font-size: 1.1em;"
- print "font-weight: bold;"
- print "}"
- print "hr {"
- print "display: none;"
- print "}"
- print ".content {"
- print "padding: 1em 5em;"
- print "}"
- print ".content-columns {"
- print "/* Setting relative positioning allows for "
- print "absolute positioning for sub-classes */"
- print "position: relative;"
- print "padding-top: 1em;"
- print "}"
- print ".content-column-left {"
- print "/* Value for IE/Win; will be overwritten for other browsers */"
- print "width: 47%;"
- print "padding-right: 3%;"
- print "float: left;"
- print "padding-bottom: 2em;"
- print "}"
- print ".content-column-left hr {"
- print "display: none;"
- print "}"
- print ".content-column-right {"
- print "/* Values for IE/Win; will be overwritten for other browsers */"
- print "width: 47%;"
- print "padding-left: 3%;"
- print "float: left;"
- print "padding-bottom: 2em;"
- print "}"
- print ".content-columns>.content-column-left,
.content-columns>.content-column-right {"
- print "/* Non-IE/Win */"
- print "}"
- print "img {"
- print "border: 2px solid #fff;"
- print "padding: 2px;"
- print "margin: 2px;"
- print "}"
- print "a:hover img {"
- print "border: 2px solid #f50;"
- print "}"
- print "/*]]>*/"
- print "</style>"
- print "<meta http-equiv=\"Refresh\" content=\"0;
url=https:/cfg/main\" />"
- print "</head><body>"
- print "<h1>Red Hat CloudFS Configuration Main<h1/>"
- print "<p><a href=\"http:8080/wwwinitcluster\">Initialize
Cluster</a></p>"
- print "<p><a href=\"http:8080/wwwlisttenants\">Tenant
Management</a></p>"
- print "<p><a href=\"http:8080/wwwprovision\">Provision
Storage</a></p>"
- print "</body></html>"
+ ret = "<!DOCTYPE html PUBLIC \"-//W3C//DTD XHTML 1.1//EN\"
\"http://www.w3.org/TR/xhtml11/DTD/xhtml11.dtd\">"
+ ret = ret + "<html><head>"
+ ret = ret + "<title>_Red Hat CloudFS Configuration_</title>"
+ ret = ret + "<meta http-equiv=\"Content-Type\"
content=\"text/html; charset=UTF-8\" />"
+ ret = ret + "<meta http-equiv=\"Pragma\"
content=\"no-cache\" />"
+ ret = ret + wwwcss.css
+ ret = ret + "</head><body>"
+ ret = ret + "<h1>Red Hat CloudFS Configuration Main<h1/>"
+ ret = ret + "<p><a href=\"wwwinitcluster\">Initialize
Cluster</a></p>"
+ ret = ret + "<p><a href=\"wwwlisttenants\">Tenant
Management</a></p>"
+ ret = ret + "<p><a href=\"wwwprovision\">Provision
Storage</a></p>"
+ ret = ret + "</body></html>"
+ return ret
diff --git a/scripts/wwwcfgroot.py b/scripts/wwwcfgroot.py
index 2f130cc..b9faede 100644
--- a/scripts/wwwcfgroot.py
+++ b/scripts/wwwcfgroot.py
@@ -1,95 +1,17 @@
-import fileinput
+import wwwcss
def www_cfgroot() :
- fileinput.close()
- print "<!DOCTYPE html PUBLIC \"-//W3C//DTD XHTML 1.1//EN\"
\"http://www.w3.org/TR/xhtml11/DTD/xhtml11.dtd\">"
- print "<html><head>"
- print "<title>_Red Hat CloudFS Configuration_</title>"
- print "<meta http-equiv=\"Content-Type\" content=\"text/html;
charset=UTF-8\" />"
- print "<meta http-equiv=\"Pragma\" content=\"no-cache\"
/>"
- print "<style type=\"text/css\">"
- print "/*<![CDATA[*/"
- print "body {"
- print "background-color: #fff;"
- print "color: #000;"
- print "font-size: 0.9em;"
- print "font-family: sans-serif,helvetica;"
- print "margin: 0;"
- print "padding: 0;"
- print "}"
- print ":link {"
- print "color: #c00;"
- print "}"
- print ":visited {"
- print "color: #c00;"
- print "}"
- print "a:hover {"
- print "color: #f50;"
- print "}"
- print "h1 {"
- print "text-align: center;"
- print "margin: 0;"
- print "padding: 0.6em 2em 0.4em;"
- print "background-color: #900;"
- print "color: #fff;"
- print "font-weight: normal;"
- print "font-size: 1.75em;"
- print "border-bottom: 2px solid #000;"
- print "}"
- print "h1 strong {"
- print "font-weight: bold;"
- print "}"
- print "h2 {"
- print "font-size: 1.1em;"
- print "font-weight: bold;"
- print "}"
- print "hr {"
- print "display: none;"
- print "}"
- print ".content {"
- print "padding: 1em 5em;"
- print "}"
- print ".content-columns {"
- print "/* Setting relative positioning allows for "
- print "absolute positioning for sub-classes */"
- print "position: relative;"
- print "padding-top: 1em;"
- print "}"
- print ".content-column-left {"
- print "/* Value for IE/Win; will be overwritten for other browsers */"
- print "width: 47%;"
- print "padding-right: 3%;"
- print "float: left;"
- print "padding-bottom: 2em;"
- print "}"
- print ".content-column-left hr {"
- print "display: none;"
- print "}"
- print ".content-column-right {"
- print "/* Values for IE/Win; will be overwritten for other browsers */"
- print "width: 47%;"
- print "padding-left: 3%;"
- print "float: left;"
- print "padding-bottom: 2em;"
- print "}"
- print ".content-columns>.content-column-left,
.content-columns>.content-column-right {"
- print "/* Non-IE/Win */"
- print "}"
- print "img {"
- print "border: 2px solid #fff;"
- print "padding: 2px;"
- print "margin: 2px;"
- print "}"
- print "a:hover img {"
- print "border: 2px solid #f50;"
- print "}"
- print "/*]]>*/"
- print "</style>"
- print "<meta http-equiv=\"Refresh\" content=\"0;
url=http:8080/cfgmain\" />"
- print "</head><body>"
- print "<h1>Red Hat CloudFS Configuration<h1/>"
+ ret = "<!DOCTYPE html PUBLIC \"-//W3C//DTD XHTML 1.1//EN\"
\"http://www.w3.org/TR/xhtml11/DTD/xhtml11.dtd\">"
+ ret = ret + "<html><head>"
+ ret = ret + "<title>_Red Hat CloudFS Configuration_</title>"
+ ret = ret + "<meta http-equiv=\"Content-Type\"
content=\"text/html; charset=UTF-8\" />"
+ ret = ret + "<meta http-equiv=\"Pragma\"
content=\"no-cache\" />"
+ ret = ret + wwwcss.css
+ ret = ret + "<meta http-equiv=\"Refresh\" content=\"0;
url=/cfgmain\" />"
+ ret = ret + "</head><body>"
+ ret = ret + "<h1>Red Hat CloudFS Configuration<h1/>"
# authentication disabled for now
# <h2>Sign On<h2/>
# <form method="post" action="/cgi-bin/authenticate">
@@ -105,6 +27,8 @@ def www_cfgroot() :
# <input type="submit" name="signon" value="Sign
On">
# </p>
# </form>
- print "<p>Please follow <a
href=\"http:8080/cfgmain\">link</a>!</p>"
- print "</body></html>"
+ ret = ret + "<p>Please follow <a
href=\"/cfgmain\">link</a>!</p>"
+ ret = ret + "</body></html>"
+
+ return ret
diff --git a/scripts/wwwconfirmprovision.py b/scripts/wwwconfirmprovision.py
index 801a5c3..8b3ccba 100644
--- a/scripts/wwwconfirmprovision.py
+++ b/scripts/wwwconfirmprovision.py
@@ -3,13 +3,11 @@ import fileinput
import re
import os
-def www_confirmprovision():
- print "Content-type: text/html"
- print
+def www_confirmprovision(body):
- f = fileinput.input()
- line = f.readline()
- fileinput.close()
+ # f = fileinput.input()
+ line = body.readline()
+ # fileinput.close()
tokens = re.split('&', line)
@@ -39,11 +37,12 @@ def www_confirmprovision():
volumes.append(scratch[1])
continue
- print "<html><head>"
- print "<meta http-equiv=\"pragma\"
content=\"no-cache\">"
- print "<title>Confirm Provision Volume</title>"
- print "</head><body>"
- print "<h2>Confirm Provision Volume</h2>"
+ ret = "Content-type: text/html\n"
+ ret = ret + "<html><head>"
+ ret = ret + "<meta http-equiv=\"pragma\"
content=\"no-cache\">"
+ ret = ret + "<title>Confirm Provision Volume</title>"
+ ret = ret + "</head><body>"
+ ret = ret + "<h2>Confirm Provision Volume</h2>"
cmd = "/usr/sbin/gluster volume create " + volume_id
if volume_type != "plain" :
cmd = cmd + " " + volume_type + " " + replica_or_stripe_count
@@ -51,9 +50,10 @@ def www_confirmprovision():
for volume in volumes :
cmd = cmd + " " + volume.replace("%3A",
":").replace("%2F", "/")
- print "<form method=\"post\" name=\"provision\"
action=\"wwwdoprovision\">"
- print ("<input type=\"hidden\" name=\"COMMAND\"
value=\"%s\" />") % (cmd)
- print ("%s <br><input type=\"submit\"
name=\"PROVISION\" value=\"Confirm\" />") % (cmd)
- print "</form>"
- print "</body></html>"
+ ret = ret + "<form method=\"post\" name=\"provision\"
action=\"wwwdoprovision\">"
+ ret = ret + "<input type=\"hidden\" name=\"COMMAND\"
value=\"" + cmd + "\" />"
+ ret = ret + cmd + " <br><input type=\"submit\"
name=\"PROVISION\" value=\"Confirm\" />"
+ ret = ret + "</form>"
+ ret = ret + "</body></html>"
+ return ret
diff --git a/scripts/wwwcss.py b/scripts/wwwcss.py
new file mode 100644
index 0000000..af378a8
--- /dev/null
+++ b/scripts/wwwcss.py
@@ -0,0 +1,79 @@
+
+css = """<style type=\"text/css\">
+/*<![CDATA[*/
+body {
+background-color: #fff;
+color: #000;
+font-size: 0.9em;
+font-family: sans-serif,helvetica;
+margin: 0;
+padding: 0;
+}
+:link {
+color: #fff;" + +
+}
+:visited {
+color: #fff;
+}
+a:hover {
+color: #f50;
+}
+h1 {
+text-align: center;
+margin: 0;
+padding: 0.6em 2em 0.4em;
+background-color: #900;
+color: #fff;
+font-weight: normal;
+font-size: 1.75em;
+border-bottom: 2px solid #000;
+}
+h1 strong {
+font-weight: bold;
+}
+h2 {
+font-size: 1.1em;
+font-weight: bold;
+}
+hr {
+display: none;
+}
+.content {
+padding: 1em 5em;
+}
+.content-columns {
+/* Setting relative positioning allows for
+absolute positioning for sub-classes */
+position: relative;
+padding-top: 1em;
+}
+.content-column-left {
+/* Value for IE/Win; will be overwritten for other browsers */
+width: 47%;
+padding-right: 3%;
+float: left;
+padding-bottom: 2em;
+}
+.content-column-left hr {
+display: none;
+}
+.content-column-right {
+/* Values for IE/Win; will be overwritten for other browsers */
+width: 47%;
+padding-left: 3%;
+float: left;
+padding-bottom: 2em;
+}
+.content-columns>.content-column-left, .content-columns>.content-column-right {
+/* Non-IE/Win */
+}
+img {
+border: 2px solid #fff;
+padding: 2px;
+margin: 2px;
+}
+a:hover img {
+border: 2px solid #f50;
+}
+/*]]>*/
+</style>"""
diff --git a/scripts/wwwdoinitcluster.py b/scripts/wwwdoinitcluster.py
index 615911b..29526a5 100644
--- a/scripts/wwwdoinitcluster.py
+++ b/scripts/wwwdoinitcluster.py
@@ -5,8 +5,6 @@ import os
import socket
def www_doinitcluster():
- print "Content-type: text/html"
- print
f = fileinput.input()
line = f.readline()
@@ -51,9 +49,11 @@ def www_doinitcluster():
clean_cmd = cmd.replace("|", "").replace("&",
"").replace(">", "")
sts = os.system(clean_cmd + " > /dev/null 2>&1");
- print "<html><head>"
- print "<meta http-equiv=\"pragma\"
content=\"no-cache\">"
- print "<meta http-equiv=\"Refresh\" content=\"0;
url=http:8080/wwwinitcluster\" />"
- print "</head><body>"
- print "<p>Please follow <a
href=\"http:8080/wwwinitcluster\">link</a>!</p>"
- print "</body></html>"
+ ret = "Content-type: text/html\n"
+ ret = ret + "<html><head>"
+ ret = ret + "<meta http-equiv=\"pragma\"
content=\"no-cache\">"
+ ret = ret + "<meta http-equiv=\"Refresh\" content=\"0;
url=wwwinitcluster\" />"
+ ret = ret + "</head><body>"
+ ret = ret + "<p>Please follow <a
href=\"wwwinitcluster\">link</a>!</p>"
+ ret = ret + "</body></html>"
+ return ret
diff --git a/scripts/wwwdoprovision.py b/scripts/wwwdoprovision.py
index d76e451..6535c50 100644
--- a/scripts/wwwdoprovision.py
+++ b/scripts/wwwdoprovision.py
@@ -3,13 +3,11 @@ import fileinput
import re
import os
-def www_doprovision():
- print "Content-type: text/html"
- print
+def www_doprovision(body):
- f = fileinput.input()
- line = f.readline()
- fileinput.close()
+ # f = fileinput.input()
+ line = body.readline()
+ # fileinput.close()
tokens = re.split('&', line)
@@ -27,11 +25,12 @@ def www_doprovision():
command = scratch[1]
continue
- print "<html><head>"
- print "<meta http-equiv=\"pragma\"
content=\"no-cache\">"
- print "<title>Provisioned Volume</title>"
- print "</head><body>"
- print "<h2>Provisioned Volume</h2>"
+ ret = "Content-type: text/html\n"
+ ret = ret + "<html><head>"
+ ret = ret + "<meta http-equiv=\"pragma\"
content=\"no-cache\">"
+ ret = ret + "<title>Provisioned Volume</title>"
+ ret = ret + "</head><body>"
+ ret = ret + "<h2>Provisioned Volume</h2>"
## make the underlying volume with gluster
decode_cmd = command.replace("%3A", ":").replace("%2F",
"/").replace("+", " ")
clean_cmd = decode_cmd.replace("|", "").replace("&",
"").replace(">", "")
@@ -65,7 +64,7 @@ def www_doprovision():
clean_cmd = mkdir_cmd.replace("|", "").replace("&",
"").replace(">", "")
mkdir_sts = os.system(clean_cmd + " > /dev/null 2>&1")
if mkdir_sts != 0 :
- print "<br> fail: " + clean_cmd
+ ret = ret + "<br> fail: " + clean_cmd
# copy the modified vol files to the peers
unique_nodes = set(nodes)
this_ip = ""
@@ -89,26 +88,27 @@ def www_doprovision():
scp_cmd = "/usr/bin/sudo /usr/bin/ssh " + node + " 'cd
/var/lib/glusterd/vols/" + vol_name + " && /usr/bin/scp -q -r " +
this_ip + ":/var/lib/glusterd/vols/" + vol_name + "/* .'"
scp_sts = os.system(scp_cmd)
if scp_sts != 0 :
- print "<br>fail: " + scp_cmd
+ ret = ret + "<br>fail: " + scp_cmd
# now start the volume
start_cmd = "/usr/bin/sudo /usr/sbin/gluster volume start " + vol_name
start_sts = os.system(start_cmd + " > /dev/null 2>&1")
if start_sts != 0 :
- print "<br> fail: " + start_cmd
+ ret = ret + "<br> fail: " + start_cmd
else :
- print("<br> %s started") % (vol_name)
+ ret = ret + "<br> started " + vol_name
# list FUSE volume specs for download
- mkdir_sts = os.system("/usr/bin/sudo /bin/mkdir -p
/var/www/html/cfg/scratch")
- cp_sts = os.system("/usr/bin/sudo /bin/cp /var/lib/glusterd/vols/" + vol_name
+ "/" + vol_name + "-fuse.vol.* /var/www/html/cfg/scratch/")
- print "<hr><br> client/tenant volume files (right-click to
save-as):"
+ mkdir_sts = os.system("/usr/bin/sudo /bin/mkdir -p scratch")
+ cp_sts = os.system("/usr/bin/sudo /bin/cp /var/lib/cloudfs/vols/" + vol_name
+ "/" + vol_name + "-fuse.vol.* /var/www/html/cfg/scratch/")
+ ret = ret + "<hr><br> client/tenant volume files (right-click to
save-as):"
for tenant in tenants :
if tenant != "junk" :
- print("<br><a
href=\"/cfg/scratch/%s-fuse.vol.%s\">%s</a>") % (vol_name, tenant,
tenant)
- print "<hr>"
- print "<form method=\"post\" action=\"cfgmain\">"
- print "<input type=\"submit\" name=\"DONE\"
value=\"Done\"></form>"
+ ret = ret + "<br><a
href=\"/cfg/scratch/%s-fuse.vol.%s\">%s</a>" % (vol_name, tenant,
tenant)
+ ret = ret + "<hr>"
+ ret = ret + "<form method=\"post\"
action=\"cfgmain\">"
+ ret = ret + "<input type=\"submit\" name=\"DONE\"
value=\"Done\"></form>"
- print "</body></html>"
+ ret = ret + "</body></html>"
+ return ret
diff --git a/scripts/wwwinitcluster.py b/scripts/wwwinitcluster.py
index 44f9f5f..2858d6a 100644
--- a/scripts/wwwinitcluster.py
+++ b/scripts/wwwinitcluster.py
@@ -1,6 +1,5 @@
import datetime
-import fileinput
import os
import re
import string
@@ -8,7 +7,6 @@ import socket
import sys
def www_initcluster():
- fileinput.close()
hostname = socket.gethostname()
@@ -21,23 +19,22 @@ def www_initcluster():
node_ips.append(socket.gethostbyname(string.strip(tokens[1])))
peer_ips.close()
- print "Content-type: text/html"
- print
- print "<html><head>"
- print "<meta http-equiv=\"pragma\"
content=\"no-cache\"><title>Initialize CloudFS
Cluster</title>"
- print "</head><body>"
- print "<h2>Initialize CloudFS Cluster</h2>"
- print "<hr>"
- print "<h2>Cluster Nodes</h2>"
+ ret = "Content-type: text/html\n"
+ ret = ret + "<html><head>"
+ ret = ret + "<meta http-equiv=\"pragma\"
content=\"no-cache\"><title>Initialize CloudFS
Cluster</title>"
+ ret = ret + "</head><body>"
+ ret = ret + "<h2>Initialize CloudFS Cluster</h2>"
+ ret = ret + "<hr>"
+ ret = ret + "<h2>Cluster Nodes</h2>"
for node_ip in node_ips :
- print node_ip + "<br>"
- print "<hr><br>"
- print "Enter the hostname of a node to add to the cluster"
- print "<form method=\"post\"
action=\"wwwdoinitcluster\">"
- print "Node Name: <input type=\"text\"
name=\"NODENAME\">"
- print "<input type=\"submit\" name=\"ADDNODE\"
value=\"Add Node\"></form>"
- print "<hr>"
- print "<form method=\"post\" action=\"/cfgmain.\">"
- print "<input type=\"submit\" name=\"DONE\"
value=\"Done\"></form>"
-
- print "</body></html>"
+ ret = ret + node_ip + "<br>"
+ ret = ret + "<hr><br>"
+ ret = ret + "Enter the hostname of a node to add to the cluster"
+ ret = ret + "<form method=\"post\"
action=\"wwwdoinitcluster\">"
+ ret = ret + "Node Name: <input type=\"text\"
name=\"NODENAME\">"
+ ret = ret + "<input type=\"submit\" name=\"ADDNODE\"
value=\"Add Node\"></form>"
+ ret = ret + "<hr>"
+ ret = ret + "<form method=\"post\"
action=\"/cfgmain\">"
+ ret = ret + "<input type=\"submit\" name=\"DONE\"
value=\"Done\"></form>"
+ ret = ret + "</body></html>"
+ return ret
diff --git a/scripts/wwwprovision.py b/scripts/wwwprovision.py
index c4e2910..72dada3 100644
--- a/scripts/wwwprovision.py
+++ b/scripts/wwwprovision.py
@@ -1,14 +1,13 @@
import datetime
-import fileinput
import os
import re
import string
import socket
import sys
-def brick_used(needle) :
- for vol in bricks_by_vol :
+def brick_used(needle, haystack) :
+ for vol in haystack :
for brick in vol :
if brick == needle :
return True
@@ -16,14 +15,8 @@ def brick_used(needle) :
def www_provision() :
- fileinput.close()
-
hostname = socket.gethostname()
- print "Content-type: text/html"
- print
- print "<html><head><meta http-equiv=\"pragma\"
content=\"no-cache\"><title>Provision CloudFS
Volume</title>"
-
existing_vols = []
bricks_by_vol = []
bbv_index = -1
@@ -63,7 +56,7 @@ def www_provision() :
volumes_on_nodes = []
for node_ip in node_ips :
- # print("<p>%s</p>") % (node_ip)
+ # ret = ret +("<p>%s</p>") % (node_ip)
cmd = "/usr/bin/sudo /usr/bin/ssh " + node_ip + " df -H"
volumes_on_node = os.popen(cmd)
scratch = []
@@ -74,53 +67,53 @@ def www_provision() :
volumes_on_node.close()
volumes_on_nodes.append(scratch)
- print "<style type=\"text/css\">"
- print ".colmask{ position: relative; overflow: hidden; margin: 0px auto; width:
100%; background-color: #b4d2f7 }"
- print ".header{ float: left; width: 100%; background-color: #f4f4f4}"
- print ".wrapper{ position: relative; float: left; left: 0.00%; width: 100.00%;
background-color: #cccccc}"
- #for node_ip in node_ips :
- # print(".col%s{ position: relative; float: left; width: %d%%; left: 1%%;
background-color: #b4d2f7}") % (node_ip.replace(".", "_"),
100/len(node_ips)-1)
- print "tr.d0 td { background-color: #CC9999; color: black; }"
- print "tr.d1 td { background-color: #9999CC; color: black; }"
- print ".footer{ float: left; width: 100%; background-color: #f4f4f4}"
- print "body { border-width: 0px; padding: 0px; margin: 0px; font-size: 90%;
background-color: #e7e7de}"
- print "</style></head><body>"
- print "<h1>Provision CloudFS Volume</h1>"
- print "<h2>Existing Volumes:</h2>"
+ ret = "Content-type: text/html\n"
+ ret = ret + "<html><head><meta http-equiv=\"pragma\"
content=\"no-cache\"><title>Provision CloudFS
Volume</title>"
+ ret = ret + "<style type=\"text/css\">"
+ ret = ret + ".colmask{ position: relative; overflow: hidden; margin: 0px auto;
width: 100%; background-color: #b4d2f7 }"
+ ret = ret + ".header{ float: left; width: 100%; background-color: #f4f4f4}"
+ ret = ret + ".wrapper{ position: relative; float: left; left: 0.00%; width:
100.00%; background-color: #cccccc}"
+ ret = ret + "tr.d0 td { background-color: #CC9999; color: black; }"
+ ret = ret + "tr.d1 td { background-color: #9999CC; color: black; }"
+ ret = ret + ".footer{ float: left; width: 100%; background-color: #f4f4f4}"
+ ret = ret + "body { border-width: 0px; padding: 0px; margin: 0px; font-size: 90%;
background-color: #e7e7de}"
+ ret = ret + "</style></head><body>"
+ ret = ret + "<h1>Provision CloudFS Volume</h1>"
+ ret = ret + "<h2>Existing Volumes:</h2>"
bbv_index = 0
for existing_vol in existing_vols :
- print "<p>" + existing_vol + ":"
+ ret = ret + "<p>" + existing_vol + ":"
for brick in bricks_by_vol[bbv_index] :
- print "<br> " + brick
+ ret = ret + "<br> " + brick
bbv_index = bbv_index + 1
- print "</p>"
- print "<hr>"
- print "<h2>Provision a Volume From Available Bricks:</h2>"
- print "<form method=\"post\" name=\"provision\"
action=\"wwwconfirmprovision\">"
- print "<div class=\"header\"><hr></div>"
- print "<div class=\"wrapper\">"
- print "<table>"
+ ret = ret + "</p>"
+ ret = ret + "<hr>"
+ ret = ret + "<h2>Provision a Volume From Available Bricks:</h2>"
+ ret = ret + "<form method=\"post\" name=\"provision\"
action=\"wwwconfirmprovision\">"
+ ret = ret + "<div class=\"header\"><hr></div>"
+ ret = ret + "<div class=\"wrapper\">"
+ ret = ret + "<table>"
node_index = 0
for node_ip in node_ips :
- print("<tr class=\"d%d\">") % (node_index % 2)
- print("<td>%s</td>") % (node_ip)
+ ret = ret + "<tr class=\"d%d\">" % (node_index % 2)
+ ret = ret + "<td>%s</td>" % (node_ip)
for volumes_on_node in volumes_on_nodes[node_index] :
tokens = volumes_on_node.rpartition(" ")
- if brick_used(node_ip + ":" + tokens[2]) == True :
- print("<td><input type=\"checkbox\" name=\"VOLUME\"
value=\"%s:%s\" disabled />%s</td>") % (node_ip, tokens[2],
tokens[2])
+ if brick_used(node_ip + ":" + tokens[2], bricks_by_vol) == True :
+ ret = ret + "<td><input type=\"checkbox\"
name=\"VOLUME\" value=\"%s:%s\" disabled />%s</td>" %
(node_ip, tokens[2], tokens[2])
else :
- print("<td><input type=\"checkbox\" name=\"VOLUME\"
value=\"%s:%s\" />%s</td>") % (node_ip, tokens[2], tokens[2])
- print "</tr>"
+ ret = ret + "<td><input type=\"checkbox\"
name=\"VOLUME\" value=\"%s:%s\" />%s</td>" % (node_ip,
tokens[2], tokens[2])
+ ret = ret + "</tr>"
node_index = node_index + 1
- print "</table>"
- print "</div>"
- print "<div class=\"footer\"><hr></div>"
- print "Volume Type: <input type=\"radio\" name=\"TYPE\"
value=\"plain\" checked />Plain"
- print "<input type=\"radio\" name=\"TYPE\"
value=\"replica\" />Replicated"
- print "<input type=\"radio\" name=\"TYPE\"
value=\"stripe\" />Striped"
- print "<br>Replica or Stripe count: <input type=\"text\"
name=\"COUNT\" size=\"2\" />"
- print "<br>Volume ID: <input type=\"text\"
name=\"VOLUMEID\" />"
- print "<input type=\"submit\" name=\"PROVISION\"
value=\"Provision\" />"
- print "</form>"
-
- print "</body></html>"
+ ret = ret + "</table>"
+ ret = ret + "</div>"
+ ret = ret + "<div class=\"footer\"><hr></div>"
+ ret = ret + "Volume Type: <input type=\"radio\"
name=\"TYPE\" value=\"plain\" checked />Plain"
+ ret = ret + "<input type=\"radio\" name=\"TYPE\"
value=\"replica\" />Replicated"
+ ret = ret + "<input type=\"radio\" name=\"TYPE\"
value=\"stripe\" />Striped"
+ ret = ret + "<br>Replica or Stripe count: <input type=\"text\"
name=\"COUNT\" size=\"2\" />"
+ ret = ret + "<br>Volume ID: <input type=\"text\"
name=\"VOLUMEID\" />"
+ ret = ret + "<input type=\"submit\" name=\"PROVISION\"
value=\"Provision\" />"
+ ret = ret + "</form>"
+ ret = ret + "</body></html>"
+ return ret
diff --git a/scripts/wwwroot.py b/scripts/wwwroot.py
index 5990022..6e9a910 100644
--- a/scripts/wwwroot.py
+++ b/scripts/wwwroot.py
@@ -1,15 +1,10 @@
-import fileinput
-
def www_root() :
- fileinput.close()
-
- print "Content-type: text/html"
- print
- print "<html><head>"
- print "<meta http-equiv=\"pragma\"
content=\"no-cache\">"
-# print "<meta http-equiv=\"Refresh\" content=\"0;
url=https:/cfg/\" />"
- print "<meta http-equiv=\"Refresh\" content=\"0;
url=http:8080/cfg/\" />"
- print "</head><body>"
- print "<p>Please follow <a
href=\"https:/cfg/\">link</a>!</p>"
- print "</body></html>"
+ ret = "Content-type: text/html\n"
+ ret = ret + "<html><head>"
+ ret = ret + "<meta http-equiv=\"pragma\"
content=\"no-cache\">"
+ ret = ret + "<meta http-equiv=\"Refresh\" content=\"0;
url=/cfg\" />"
+ ret = ret + "</head><body>"
+ ret = ret + "<p>Please follow <a
href=\"/cfg\">link</a>!</p>"
+ ret = ret + "</body></html>"
+ return ret