Minor edits for grammar, spelling and python string operations
git-svn-id: https://svn.apache.org/repos/asf/incubator/tashi/branches/luke-zoni@1351872 13f79535-47bb-0310-9956-ffa450edef68
diff --git a/etc/ZoniDefaults.cfg b/etc/ZoniDefaults.cfg
index 05bbde2..93f36d2 100644
--- a/etc/ZoniDefaults.cfg
+++ b/etc/ZoniDefaults.cfg
@@ -60,7 +60,8 @@
INITRD_ROOT = builds/initrd
KERNEL_ROOT = builds/kernel
# Extensions from MIMOS
-NTPSVR = IP_OF_NTP_SERVER
+# put the IP address of your NTP server here
+NTPSVR = 127.0.0.1
CUSTOM_TEMPLATES_DIR = /var/lib/tftpboot/templates
[www]
diff --git a/src/zoni/client/zoni-cli.py b/src/zoni/client/zoni-cli.py
index eecf158..060ec16 100755
--- a/src/zoni/client/zoni-cli.py
+++ b/src/zoni/client/zoni-cli.py
@@ -202,7 +202,7 @@
# Extensions from MIMOS
group = optparse.OptionGroup(parser, "Zoni MIMOS Extensions", "Special Functions created by MIMOS Lab:")
- group.add_option("--addRole", "--addrole", dest="addRole", help="Create a disk based installation default file for a node based on it's role or function, e.g. one|oned|cc|clc|walrus|sc|nc|preseed|kickstart", default=None, action="store")
+ group.add_option("--addRole", "--addrole", dest="addRole", help="Create a disk based installation default file for a node based on its role or function, e.g. one|oned|cc|clc|walrus|sc|nc|preseed|kickstart", default=None, action="store")
group.add_option("--removeRole", "--removerole", dest="removeRole", help="Remove the default file of a node", action="store_true", default=False)
group.add_option("--showRoleMap", dest="showRoleMap", help="Show Role to Host Mapping", action="store_true", default=False)
group.add_option("--showKernel", dest="showKernelInfo", help="Show Kernel Info", action="store_true", default=False)
@@ -250,7 +250,7 @@
if "drac_name" in host:
hw= dellDrac(configs, options.nodeName, host)
else:
- mesg = "Host (" + options.nodeName + ") does not have a DRAC card!!\n"
+ mesg = "Host (%s) does not have a DRAC card!!\n" % options.nodeName
sys.stdout.write(mesg)
exit(1)
diff --git a/src/zoni/data/resourcequerysql.py b/src/zoni/data/resourcequerysql.py
index 1c8444c..2beafd4 100644
--- a/src/zoni/data/resourcequerysql.py
+++ b/src/zoni/data/resourcequerysql.py
@@ -1137,7 +1137,7 @@
# Extensions from MIMOS - to take care of the addition of kernel_id and initrd_id
#query = "insert into imageinfo (image_name, dist, dist_ver) values(\"" + name + "\", \"" + dist + "\", \"" + dist_ver + "\")"
- query = "insert into imageinfo (image_name, dist, dist_ver, kernel_id, initrd_id) values(\"" + name + "\", \"" + dist + "\", \"" + dist_ver + "\", \"" + kernel_id + "\", \"" + initrd_id + "\")"
+ query = "insert into imageinfo (image_name, dist, dist_ver, kernel_id, initrd_id) values ('%s', '%s', '%s', '%s', '%s')" % (name, dist, dist_ver, kernel_id, initrd_id)
self.insertDb(query)
diff --git a/src/zoni/extensions/convertz-src/convertz b/src/zoni/extensions/convertz-src/convertz
index b212304..2849946 100644
--- a/src/zoni/extensions/convertz-src/convertz
+++ b/src/zoni/extensions/convertz-src/convertz
@@ -27,7 +27,7 @@
#add max_loop=x and loop.max_part=y to the /etc/default/grub and update-grub.
#Version $thisver: Written 2011 by Jing-Yuan Luke at MIMOS
-export PYTHONPATH=/opt/tashi/tashi/branches/luke-zoni/src
+#export PYTHONPATH=/opt/tashi/tashi/branches/luke-zoni/src
export PATH=$PATH:$PYTHONPATH/zoni/extra
thisver="1.0"
@@ -36,7 +36,7 @@
cat << EOF
usage: $0 options
-This script converts an VM image to a live boot image and register it to Zoni.
+This script converts an VM image to a live boot image and registers it to Zoni.
Currently it only support Ubuntu/Debian based VM images using the live-boot,
live-config and live-tools packages.
@@ -376,7 +376,7 @@
MYFREELOOP=`losetup -f`
if [ -z $MYFREELOOP ]
then
- echo "No more loop device."
+ echo "No more loop devices available."
exit 1
else
echo "loop device available: $MYFREELOOP"
@@ -385,11 +385,11 @@
losetup $MYFREELOOP $FORLOOPMNT &> /dev/null
if [ ! $? == "0" ]
then
- echo "Error attach ${FORLOOPMNT} to ${MYFREELOOP}"
+ echo "Error attaching ${FORLOOPMNT} to ${MYFREELOOP}"
clean_tmp
exit 1
else
- echo "losetup attach success."
+ echo "losetup attached successfully."
fi
# Mount the loop device partition assuming image is created with only 2 partitions else user need to determine themselves but first create a temp dir
diff --git a/src/zoni/extensions/convertz-src/convertz.8 b/src/zoni/extensions/convertz-src/convertz.8
index 240da97..99dc2ef 100644
--- a/src/zoni/extensions/convertz-src/convertz.8
+++ b/src/zoni/extensions/convertz-src/convertz.8
@@ -27,7 +27,7 @@
.PP
Currently
.BI convertz
-only supports full Ubuntu based VM images (with vmlinuz and initrd.img in
+only supports full Ubuntu or Debian based VM images (with vmlinuz and initrd.img in
/boot folder) and it assumes that the VM images file system in Non LVM
based and only contains a / or root partition and a swap partition.
.SH OPTIONS
@@ -64,7 +64,7 @@
.SH BUGS
This is still a work in progress. As mentioned earlier,
.BI convertz
-only supports Ubuntu based VM images only. A fair amount of steps had been
+only supports Ubuntu or Debian based VM images only. A fair amount of steps had been
added to try to capture any errors as early as possible, any bugs please
contact the author. Thanks.
.SH AUTHOR
diff --git a/src/zoni/extensions/convertz-src/live-boot-support/README b/src/zoni/extensions/convertz-src/live-boot-support/README
index 8065ed3..abe923c 100644
--- a/src/zoni/extensions/convertz-src/live-boot-support/README
+++ b/src/zoni/extensions/convertz-src/live-boot-support/README
@@ -26,6 +26,6 @@
- live-tools_<version>_all.deb
If you decide to try new versions of the deb files, please remember to
-move the ones in this folder to a save place before downloading the new
+move the ones in this folder to a safe place before downloading the new
ones here.
diff --git a/src/zoni/extensions/install/db/m_extendDbSetup.py b/src/zoni/extensions/install/db/m_extendDbSetup.py
index 85e2459..c7ab259 100644
--- a/src/zoni/extensions/install/db/m_extendDbSetup.py
+++ b/src/zoni/extensions/install/db/m_extendDbSetup.py
@@ -51,7 +51,7 @@
ver = version.split(" ")[0]
rev = revision
- parser = optparse.OptionParser(usage="%prog -u username ", version="%prog " + ver + " " + rev)
+ parser = optparse.OptionParser(usage="prog -u username ", version="prog %s %s" % (ver, rev))
parser.add_option("-u", "--userName", "--username", dest="userName", help="Mysql username")
parser.add_option("-p", "--password", dest="password", help="Admin mysql password")
(options, args) = parser.parse_args()
@@ -101,7 +101,7 @@
except MySQLdb.OperationalError, e:
if e[0] == 2005:
- print "ERROR :" + str(e[1])
+ print "ERROR: %s" % str(e[1])
exit(1)
else:
print "Connection Error : ", e
@@ -128,7 +128,7 @@
conn.commit()
except MySQLdb.OperationalError, e:
sys.stdout.write("Fail\n")
- msg = "ERROR: " + e[1]
+ msg = "ERROR: %s" % e[1]
sys.stderr.write(msg)
exit()
return cursor
@@ -162,7 +162,8 @@
query = "UPDATE hardwareinfo set hw_blenc = hw_notes"
r = execQuery(conn, query)
for repl in res:
- query="update hardwareinfo set hw_notes = NULL where hw_notes = \"" + repl[0] + "\""
+ query="update hardwareinfo set hw_notes = NULL where hw_notes = '%s'" % repl[0]
+
execQuery(conn, query)
sys.stdout.write(" Sync and Update Success\n\n")
else:
diff --git a/src/zoni/extensions/m_extensions.py b/src/zoni/extensions/m_extensions.py
index 5361ec5..de5c578 100644
--- a/src/zoni/extensions/m_extensions.py
+++ b/src/zoni/extensions/m_extensions.py
@@ -52,7 +52,7 @@
try:
return MySQLdb.connect(host = self.host, port = self.port, user = self.user, passwd = self.passwd, db = self.db)
except MySQLdb.OperationalError, e:
- msg = "Error: " + str(e[1])
+ msg = "Error: %s" % str(e[1])
self.log.error(msg)
return
@@ -70,18 +70,19 @@
return
def getDestFile(self, configs, host):
- return (configs['tftpImageDir'] + "/01-" + ((host['mac_addr']).replace(":","-")).lower())
+ therole = ("%s/01-%s" % (configs['tftpImageDir'], (host['mac_addr']).replace(":", "-").lower())
+ return therole
def addRoletoNode(self, configs, host, thenode, roletemplate):
- therole = configs['tftpImageDir'] + "/01-" + ((host['mac_addr']).replace(":","-")).lower()
+ therole = ("%s/01-%s" % (configs['tftpImageDir'], (host['mac_addr']).replace(":", "-").lower())
self.log.info("Roles: addRole for %s" % thenode)
- srctpl = configs['tftpTemplateDir'] + "/" + roletemplate
+ srctpl = "%s/%s" % (configs['tftpTemplateDir'], roletemplate)
if os.path.isfile(therole):
- mesg = "Roles: Role File Exist! Exiting!"
+ mesg = "Roles: Role file exists! Exiting!"
self.log.error(mesg)
exit()
if not os.path.isfile(srctpl):
- mesg = "Roles: Role Template Missing! Exiting!"
+ mesg = "Roles: Role template missing! Exiting!"
self.log.error(mesg)
exit()
#shutil.copy(srctpl,therole) #this is direct copy approach, template is not customized, retained here just in case we still need it
@@ -105,7 +106,7 @@
return 0
def removeRolefromNode(self, configs, host, thenode):
- therole = configs['tftpImageDir'] + "/01-" + ((host['mac_addr']).replace(":","-")).lower()
+ therole = ("%s/01-%s" % (configs['tftpImageDir'], (host['mac_addr']).replace(":", "-").lower())
self.log.info("Roles: removeRole for %s" % thenode)
if not os.path.isfile(therole):
mesg = "No Role File for %s! Exiting!" % thenode
@@ -119,26 +120,26 @@
# A new temp table rolemap added to support this but should merge back to imagemap
def assignRoletoHost(self, host, image):
cur_image = host['pxe_image_name']
- query = "select image_id from imageinfo where image_name = " + "\"" + image + "\""
+ query = "select image_id from imageinfo where image_name = '%s'" % image
row = self.queryDb(query)
if len(row) < 1:
- mesg = "assignRoletoHost: Image \"" + image + "\" does not exist in db"
+ mesg = "assignRoletoHost: Image \"%s\" does not exist in db" % image
self.log.error(mesg)
return 1
new_image_id = str(row[0][0])
- query = "select * from rolemap where sys_id = \"" + str(host['sys_id']) + "\""
+ query = "select * from rolemap where sys_id = '%s'" % host['sys_id']
result = self.selectDb(query)
if result.rowcount > 0:
mesg = "assignRoletoHost: detected assigned role - removing from db first"
self.log.info(mesg)
- query = "delete from rolemap where sys_id = \"" + str(host['sys_id']) + "\""
+ query = "delete from rolemap where sys_id = '%s'" % host['sys_id']
self.delDb(query)
- query = "insert into rolemap (sys_id, image_id) values (\"" + str(host['sys_id']) + "\", " + new_image_id + ")"
+ query = "insert into rolemap (sys_id, image_id) values ('%s', %s)" % (host['sys_id'], new_image_id)
self.insertDb(connection,query)
return 0
def unassignRolefromHost(self, host):
- query="delete from rolemap where sys_id = \"" + str(host['sys_id']) + "\""
+ query="delete from rolemap where sys_id = '%s'" % str(host['sys_id'])
self.delDb(query)
return 0
@@ -178,7 +179,11 @@
return 0
def getKernelInitrdID(self, info):
- query="select k.kernel_id, i.initrd_id from kernelinfo k, initrdinfo i where k.kernel_name=\"" + info.split(":")[0] + "\" and i.initrd_name=\"" + info.split(":")[1] + "\" and k.kernel_arch=\"" + info.split(":")[2] + "\" and i.initrd_arch=\"" + info.split(":")[2] + "\""
+ kernel_name = info.split(":")[0]
+ initrd_name = info.split(":")[1]
+ kernel_arch = info.split(":")[2]
+
+ query = "select k.kernel_id, i.initrd_id from kernelinfo k, initrdinfo i where k.kernel_name='%s' and i.initrd_name='%s' and k.kernel_arch='%s' and i.initrd_arch='%s'" % (kernel_name, initrd_name, kernel_arch, kernel_arch)
rows=self.queryDb(query)
if len(rows) > 0:
for row in rows:
@@ -187,10 +192,20 @@
print "%s:%s" % (kid, iid)
return 0
- def registerKernelInitrd(self, configs, KernelInitrd):
- query="insert into kernelinfo (kernel_name, kernel_release, kernel_arch) values (\"" + KernelInitrd.split(":")[0] + "\", \"" + KernelInitrd.split(":")[1] + "\", \"" + KernelInitrd.split(":")[2] + "\")"
+ def registerKernelInitrd(self, configs, info):
+ foo = info.split(":")
+ kernel_name = foo[0]
+ kernel_release = foo[1]
+ kernel_arch = foo[2]
+ initrd_name = foo[3]
+ initrd_arch = foo[4]
+ kernel_something = foo[5]
+
+ initrd_options = "boot=live toram nopersistent fetch=http://%s/%s/%s initrd=%s/%s" % (configs['imageServerIP'], configs['fsImagesBaseDir'], kernel_something, configs['initrdRoot'], initrd_name)
+
+ query = "insert into kernelinfo (kernel_name, kernel_release, kernel_arch) values ('%s', '%s', '%s)" % (kernel_name, kernel_release, kernel_arch)
k_id=self.insertDb(query)
- query="insert into initrdinfo (initrd_name, initrd_arch, initrd_options) values (\"" + KernelInitrd.split(":")[3] + "\", \"" + KernelInitrd.split(":")[4] + "\", \"boot=live toram nopersistent fetch=http://" + configs['imageServerIP'] + "/" + configs['fsImagesBaseDir'] + "/" + KernelInitrd.split(":")[5] + " initrd=" + configs['initrdRoot'] + "/" + KernelInitrd.split(":")[3] + "\")"
+ query = "insert into initrdinfo (initrd_name, initrd_arch, initrd_options) values ('%s', '%s', '%s')" % (initrd_name, initrd_arch, initrd_options)
i_id=self.insertDb(query)
print "%s:%s" % (k_id, i_id)
return 0