You are viewing a plain text version of this content. The canonical link for it is here.
Posted to tashi-commits@incubator.apache.org by rg...@apache.org on 2010/08/06 18:46:50 UTC

svn commit: r983093 - in /incubator/tashi/trunk: etc/ src/zoni/bootstrap/ src/zoni/client/ src/zoni/extra/ src/zoni/hardware/ src/zoni/install/ src/zoni/install/db/ src/zoni/install/pxe/

Author: rgass
Date: Fri Aug  6 18:46:49 2010
New Revision: 983093

URL: http://svn.apache.org/viewvc?rev=983093&view=rev
Log:
adding initial files needed to install and setup Zoni.  
Adding files necessary for PXE setup

A few items are missing but will be added shortly.

Added a line to ignore pysnmp deprication warnings
Added a few more config options



Added:
    incubator/tashi/trunk/src/zoni/install/
    incubator/tashi/trunk/src/zoni/install/db/
    incubator/tashi/trunk/src/zoni/install/db/zoniDbSetup.py   (with props)
    incubator/tashi/trunk/src/zoni/install/pxe/
    incubator/tashi/trunk/src/zoni/install/pxe/base-menu
    incubator/tashi/trunk/src/zoni/install/pxe/base.zoni
    incubator/tashi/trunk/src/zoni/install/pxe/zoniPxeSetup.py   (with props)
    incubator/tashi/trunk/src/zoni/install/pxe/zoni_pxe.jpg   (with props)
Removed:
    incubator/tashi/trunk/src/zoni/extra/zoniDbSetup.py
Modified:
    incubator/tashi/trunk/etc/ZoniDefaults.cfg
    incubator/tashi/trunk/src/zoni/bootstrap/pxe.py
    incubator/tashi/trunk/src/zoni/client/zoni-cli.py
    incubator/tashi/trunk/src/zoni/extra/util.py
    incubator/tashi/trunk/src/zoni/hardware/raritanpdu.py

Modified: incubator/tashi/trunk/etc/ZoniDefaults.cfg
URL: http://svn.apache.org/viewvc/incubator/tashi/trunk/etc/ZoniDefaults.cfg?rev=983093&r1=983092&r2=983093&view=diff
==============================================================================
--- incubator/tashi/trunk/etc/ZoniDefaults.cfg (original)
+++ incubator/tashi/trunk/etc/ZoniDefaults.cfg Fri Aug  6 18:46:49 2010
@@ -18,6 +18,10 @@
 #  $Id$
 #
 
+#   Installation Directory
+[home]
+INSTALL_BASE_DIR = /usr/local/tashi
+
 #  Logfile
 [logging]
 LOG_FILE = /var/tmp/zoni_logfile.txt
@@ -30,14 +34,23 @@ DB_USER = xx_db_username_xx
 DB_INST = xx_db_inst_xx
 DB_PASSWORD = "xx_db_password_xx"
 
-#  TFTP
-[tftp]
+#  Image store
+#  IP address of the server hosting the physical disk images
+[imageStore]
+IMAGE_SERVER_IP = IP_OF_IMAGE_STORE
+
+
+#  PXE
+[pxe]
 TFTP_ROOT_DIR = /var/lib/tftpboot
 TFTP_IMAGE_DIR = /var/lib/tftpboot/pxelinux.cfg
 TFTP_BOOT_OPTIONS_DIR = /var/lib/tftpboot/pxelinux.cfg/boot_options_zoni
 TFTP_UPDATE_FILE = /var/lib/tftpboot/pxelinux.cfg/update.zoni
 TFTP_BASE_FILE = /var/lib/tftpboot/pxelinux.cfg/base.zoni
 TFTP_BASE_MENU_FILE = /var/lib/tftpboot/pxelinux.cfg/base-menu
+PXE_SERVER_IP = IP_OF_PXE_SERVER_IN_DOMAIN_0
+#  Relative to TFTP_ROOT_DIR
+INITRD_ROOT = initrd
 
 [snmp]
 SNMP_COMMUNITY = xx_snmp_community_name_xx

Modified: incubator/tashi/trunk/src/zoni/bootstrap/pxe.py
URL: http://svn.apache.org/viewvc/incubator/tashi/trunk/src/zoni/bootstrap/pxe.py?rev=983093&r1=983092&r2=983093&view=diff
==============================================================================
--- incubator/tashi/trunk/src/zoni/bootstrap/pxe.py (original)
+++ incubator/tashi/trunk/src/zoni/bootstrap/pxe.py Fri Aug  6 18:46:49 2010
@@ -73,13 +73,13 @@ class Pxe(BootStrapInterface):
 			traceback.print_exc(sys.exc_info())
 
 		dadate = datetime.datetime.now().strftime("%Y%m%d.%H%M.%S")
-		val = "#  Generated by PRS : " + dadate
+		val = "#  Generated by ZONI  " + dadate
 		f.write(val)
 		for image in images:
 			val = "\n#  IMAGE " + image + "\n"
 			f.write(val)
 			base = "cat " + self.tftpBaseFile + " | sed 's/MAGIC1/" + image + "/' > " + self.tftpBootOptionsDir + "/" + image + "\n"
-			basemenu= "cat " + self.tftpBaseMenuFile + " | sed 's/LABEL " + image + "/LABEL " + image + "\\n\\tMENU DEFAULT/' > " + self.tftpBootOptionsDir + "/" + image + "-menu\n" 
+			basemenu= "cat " + self.tftpBaseMenuFile + " | sed 's/LABEL " + image + "$/LABEL " + image + "\\n\\tMENU DEFAULT/' > " + self.tftpBootOptionsDir + "/" + image + "-menu\n" 
 			f.write(base)
 			f.write(basemenu)
 		f.close()

Modified: incubator/tashi/trunk/src/zoni/client/zoni-cli.py
URL: http://svn.apache.org/viewvc/incubator/tashi/trunk/src/zoni/client/zoni-cli.py?rev=983093&r1=983092&r2=983093&view=diff
==============================================================================
--- incubator/tashi/trunk/src/zoni/client/zoni-cli.py (original)
+++ incubator/tashi/trunk/src/zoni/client/zoni-cli.py Fri Aug  6 18:46:49 2010
@@ -1,4 +1,4 @@
-#! /usr/bin/env python
+#! /usr/bin/env python 
 #
 # Licensed to the Apache Software Foundation (ASF) under one
 # or more contributor license agreements.  See the NOTICE file
@@ -25,6 +25,7 @@ import sys
 import optparse
 
 
+
 #from zoni import *
 #from zoni.data.resourcequerysql import ResourceQuerySql
 import zoni

Modified: incubator/tashi/trunk/src/zoni/extra/util.py
URL: http://svn.apache.org/viewvc/incubator/tashi/trunk/src/zoni/extra/util.py?rev=983093&r1=983092&r2=983093&view=diff
==============================================================================
--- incubator/tashi/trunk/src/zoni/extra/util.py (original)
+++ incubator/tashi/trunk/src/zoni/extra/util.py Fri Aug  6 18:46:49 2010
@@ -26,6 +26,9 @@ def loadConfigFile(parser):
 	#parser = ConfigParser.ConfigParser()
 	#parser.read(filename)
 	config = {}
+	#  Install dir
+	config['installBaseDir'] = parser.get("home", "INSTALL_BASE_DIR").split()[0]
+
 	#  Logging
 	config['logFile'] = parser.get("logging", "LOG_FILE").split()[0]
 	
@@ -38,13 +41,18 @@ def loadConfigFile(parser):
 	config['dbPort'] = int(parser.get("dbConnection", "DB_PORT").split()[0])
 	config['dbInst'] = parser.get("dbConnection", "DB_INST").split()[0]
 
-	#  TFTP info
-	config['tftpRootDir'] = parser.get("tftp", "TFTP_ROOT_DIR").split()[0]
-	config['tftpImageDir'] = parser.get("tftp", "TFTP_IMAGE_DIR").split()[0]
-	config['tftpBootOptionsDir'] = parser.get("tftp", "TFTP_BOOT_OPTIONS_DIR").split()[0]
-	config['tftpUpdateFile'] = parser.get("tftp", "TFTP_UPDATE_FILE").split()[0]
-	config['tftpBaseFile'] = parser.get("tftp", "TFTP_BASE_FILE").split()[0]
-	config['tftpBaseMenuFile'] = parser.get("tftp", "TFTP_BASE_MENU_FILE").split()[0]
+	#  PXE info
+	config['tftpRootDir'] = parser.get("pxe", "TFTP_ROOT_DIR").split()[0]
+	config['tftpImageDir'] = parser.get("pxe", "TFTP_IMAGE_DIR").split()[0]
+	config['tftpBootOptionsDir'] = parser.get("pxe", "TFTP_BOOT_OPTIONS_DIR").split()[0]
+	config['tftpUpdateFile'] = parser.get("pxe", "TFTP_UPDATE_FILE").split()[0]
+	config['tftpBaseFile'] = parser.get("pxe", "TFTP_BASE_FILE").split()[0]
+	config['tftpBaseMenuFile'] = parser.get("pxe", "TFTP_BASE_MENU_FILE").split()[0]
+	config['pxeServerIP'] = parser.get("pxe", "PXE_SERVER_IP").split()[0]
+	config['initrdRoot'] = parser.get("pxe", "INITRD_ROOT").split()[0]
+
+	#  Image store
+	config['imageServerIP'] = parser.get("imageStore", "IMAGE_SERVER_IP").split()[0]
 	
 	#  SNMP
 	config['snmpCommunity'] = parser.get("snmp", "SNMP_COMMUNITY").split()[0]

Modified: incubator/tashi/trunk/src/zoni/hardware/raritanpdu.py
URL: http://svn.apache.org/viewvc/incubator/tashi/trunk/src/zoni/hardware/raritanpdu.py?rev=983093&r1=983092&r2=983093&view=diff
==============================================================================
--- incubator/tashi/trunk/src/zoni/hardware/raritanpdu.py (original)
+++ incubator/tashi/trunk/src/zoni/hardware/raritanpdu.py Fri Aug  6 18:46:49 2010
@@ -20,9 +20,13 @@
 
 import sys
 import os 
+import warnings
+warnings.filterwarnings("ignore")
+
 from pysnmp.entity.rfc3413.oneliner import cmdgen
 from pysnmp.proto import rfc1902
 
+
 #import netsnmp
 
 from systemmanagementinterface import SystemManagementInterface

Added: incubator/tashi/trunk/src/zoni/install/db/zoniDbSetup.py
URL: http://svn.apache.org/viewvc/incubator/tashi/trunk/src/zoni/install/db/zoniDbSetup.py?rev=983093&view=auto
==============================================================================
--- incubator/tashi/trunk/src/zoni/install/db/zoniDbSetup.py (added)
+++ incubator/tashi/trunk/src/zoni/install/db/zoniDbSetup.py Fri Aug  6 18:46:49 2010
@@ -0,0 +1,245 @@
+# Licensed to the Apache Software Foundation (ASF) under one
+# or more contributor license agreements.  See the NOTICE file
+# distributed with this work for additional information
+# regarding copyright ownership.  The ASF licenses this file
+# to you under the Apache License, Version 2.0 (the
+# "License"); you may not use this file except in compliance
+# with the License.  You may obtain a copy of the License at
+# 
+#   http://www.apache.org/licenses/LICENSE-2.0
+# 
+# Unless required by applicable law or agreed to in writing,
+# software distributed under the License is distributed on an
+# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+# KIND, either express or implied.  See the License for the
+# specific language governing permissions and limitations
+# under the License.    
+#
+#  $Id$
+#
+
+import os 
+import sys
+import string
+import MySQLdb
+import traceback
+import optparse
+
+from zoni.extra.util import *
+from zoni.version import *
+
+def main():
+	''' This file sets up the database for Zoni '''
+
+	ver = version.split(" ")[0]
+	rev = revision
+
+
+	parser = optparse.OptionParser(usage="%prog -u username -p password  ", version="%prog " + ver + " " + rev)
+	parser.add_option("-u", "--userName", "--username", dest="userName", help="Mysql username")
+	parser.add_option("-p", "--password", dest="password", help="Admin mysql password")
+	#parser.add_option("-v", "--verbose", dest="verbosity", help="Be verbose", action="store_true", default=False)
+	(options, args) = parser.parse_args()
+
+	if not options.userName or not options.password:
+		parser.print_help()
+		exit(1)
+
+
+	configFile = getConfig()
+
+	CreateZoniDb(configFile, options.userName, options.password)
+
+
+def CreateZoniDb(config, adminUser, adminPassword):
+	config = config
+	host = config['dbHost']
+	user = config['dbUser']
+	adminUser = adminUser
+	adminPassword = adminPassword
+	passwd = config['dbPassword']
+	#db = "`" + config['dbInst'] + "`"
+	db = config['dbInst']
+
+	if config['dbPort'] == "":
+		config['dbPort'] = 3306
+
+	port = config['dbPort']
+
+	conn = connectDb(host, port, adminUser, adminPassword)
+	createDatabase(conn, adminUser, adminPassword, db)
+	setPriviledges(conn, user, passwd, db)
+	conn.close()
+	conn = connectDb(host, port, adminUser, adminPassword, db)
+	createTables(conn)
+	createRegistration(conn, config)
+	sys.stdout.write("Finished\n")
+
+def connectDb (host, port, user, passwd, db=None):
+	#  Connect to DB
+	try:
+		if db:
+			conn = MySQLdb.connect(host = host, port = port, user = user , passwd = passwd, db = db)
+		else:
+			conn = MySQLdb.connect(host = host, port = port, user = user , passwd = passwd)
+
+	except MySQLdb.OperationalError, e:
+		if e[0] == 2005:
+			print "ERROR :" + str(e[1])
+			exit(1)
+		else:
+			print "Connection Error : ", e
+			exit(1)
+	return conn
+
+
+def createDatabase (conn, user, passwd, db):
+	sys.stdout.write("Creating database...")
+	cmd = "create database if not exists " + db + ";"
+	execQuery(conn, cmd)
+	sys.stdout.write("Success\n")
+
+
+def setPriviledges(conn, user, passwd, db):
+	sys.stdout.write("Setting user priviledges...")
+	cmd = "grant select, insert, update, delete on " + db + ".* to " + user + "@\'%\' identified by \'" + passwd + "\';"
+	execQuery(conn, cmd)
+	sys.stdout.write("Success\n")
+
+
+
+def createTables(conn):
+	sys.stdout.write("Create Zoni Database Schema...\n")
+	'''  Create Tables  '''
+	#  Create sysinfo 
+	sys.stdout.write("    Creating sysinfo...")
+	execQuery(conn, "CREATE TABLE IF NOT EXISTS `sysinfo` (`sys_id` int(8) NOT NULL auto_increment, `mac_addr` char(64) NOT NULL, `num_procs` int(10) unsigned default NULL, `num_cores` int(10) unsigned default NULL, `mem_sticks` int(10) unsigned default NULL, `mem_slots` int(10) unsigned default NULL, `mem_total` int(10) unsigned default NULL, `mem_limit` int(10) unsigned default NULL, `clock_speed` int(10) unsigned default NULL, `sys_vendor` text, `sys_model` text, `proc_vendor` char(64) default NULL, `proc_model` char(128) default NULL, `proc_cache` char(32) default NULL, `service_tag` char(64) default NULL, `express_service_code` char(64) default NULL, `cpu_flags` text, `location` text, `bios_rev` char(32) default NULL, `ip_addr` varchar(64) NOT NULL, `init_checkin` timestamp NOT NULL default CURRENT_TIMESTAMP, PRIMARY KEY  (`sys_id`))")
+	sys.stdout.write("Success\n")
+
+	#  Create hardwareinfo
+	sys.stdout.write("    Creating hardwareinfo...")
+	execQuery(conn, "CREATE TABLE IF NOT EXISTS `hardwareinfo` ( `hw_id` int(8) NOT NULL auto_increment, `hw_type` varchar(64) NOT NULL, `hw_mac` varchar(64) default NULL, `hw_name` varchar(256) NOT NULL, `hw_make` varchar(64) NOT NULL, `hw_model` varchar(64) NOT NULL, `hw_ipaddr` varchar(64) NOT NULL, `hw_userid` varchar(64) default NULL, `hw_password` varchar(64) default NULL, `hw_notes` longtext NOT NULL, PRIMARY KEY  (`hw_id`))") 
+	sys.stdout.write("Success\n")
+ 	#  Create allocationinfo
+	sys.stdout.write("    Creating allocationinfo...")
+	execQuery(conn, "CREATE TABLE IF NOT EXISTS `allocationinfo` ( `allocation_id` int(8) NOT NULL auto_increment, `node_id` int(8) NOT NULL, `reservation_id` int(8) NOT NULL, `ip_addr` varchar(64) NOT NULL, `hostname` varchar(64) default NULL, `vlan_id` int(11) NOT NULL, `notes` tinytext, PRIMARY KEY  (`allocation_id`))")
+	sys.stdout.write("Success\n")
+	#  Create imageinfo
+	sys.stdout.write("    Creating imageinfo...")
+	execQuery(conn, "CREATE TABLE IF NOT EXISTS `imageinfo` ( `image_id` int(11) unsigned NOT NULL auto_increment, `image_name` varchar(256) NOT NULL, `dist` varchar(128) NOT NULL, `dist_ver` varchar(128) NOT NULL, `kernel_id` int(11), `initrd_id` int(11), PRIMARY KEY  (`image_id`))")
+	sys.stdout.write("Success\n")
+	#  Create imagemap
+	sys.stdout.write("    Creating imagemap...")
+	execQuery(conn, "CREATE TABLE IF NOT EXISTS `imagemap` ( `mac_addr` char(64) NOT NULL, `image_id` int(11) NOT NULL, PRIMARY KEY  (`mac_addr`))")
+	sys.stdout.write("Success\n")
+	#  Create reservationinfo
+	sys.stdout.write("    Creating reservationinfo...")
+	execQuery(conn, "CREATE TABLE IF NOT EXISTS `reservationinfo` ( `reservation_id` int(8) NOT NULL auto_increment, `user_id` int(8) NOT NULL, `reservation_date` timestamp NOT NULL default CURRENT_TIMESTAMP, `reservation_expiration` datetime NOT NULL, `notes` tinytext, PRIMARY KEY  (`reservation_id`))")
+	sys.stdout.write("Success\n")
+	#  Create portmap 
+	sys.stdout.write("    Creating portmap...")
+	execQuery(conn, "CREATE TABLE IF NOT EXISTS `portmap` ( `port_id` int(8) NOT NULL auto_increment, `hw_id` int(8) NOT NULL, `node_id` int(8) NOT NULL, `port_num` int(8) NOT NULL, PRIMARY KEY  (`port_id`))")
+	sys.stdout.write("Success\n")
+	#  Create vlaninfo
+	sys.stdout.write("    Creating vlaninfo...")
+	execQuery(conn, "CREATE TABLE IF NOT EXISTS `vlaninfo` ( `vlan_id` int(11) NOT NULL auto_increment, `vlan_num` int(11) NOT NULL, `ip_network` varchar(64) NOT NULL, `domain` varchar(64) NOT NULL, PRIMARY KEY  (`vlan_id`))")
+	sys.stdout.write("Success\n")
+	#  Create allocationarchive
+	sys.stdout.write("    Creating allocationarchive...")
+	execQuery(conn, "CREATE TABLE IF NOT EXISTS `allocationarchive` ( `ar_id` smallint(8) NOT NULL auto_increment, `node_id` int(8) NOT NULL, `ip_addr` varchar(64) NOT NULL, `hostname` varchar(64) NOT NULL, `vlan_id` int(11) NOT NULL, `user_id` int(8) NOT NULL, `cur_time` timestamp NOT NULL default CURRENT_TIMESTAMP on update CURRENT_TIMESTAMP, `reservation_type` varchar(64) NOT NULL, `notes` tinytext, PRIMARY KEY  (`ar_id`))")
+	sys.stdout.write("Success\n")
+	#  Create kernelinfo 
+	sys.stdout.write("    Creating kernelinfo...")
+	execQuery(conn, "CREATE TABLE IF NOT EXISTS `kernelinfo` ( `kernel_id` int(11) unsigned NOT NULL auto_increment, `kernel_name` varchar(256) NOT NULL, `kernel_release` varchar(128) NOT NULL, `kernel_arch` varchar(128) NOT NULL, PRIMARY KEY  (`kernel_id`))")
+	sys.stdout.write("Success\n")
+	#  Create initrdinfo
+	sys.stdout.write("    Creating initrdinfo...")
+	execQuery(conn, "CREATE TABLE IF NOT EXISTS `initrdinfo` ( `initrd_id` int(11) unsigned NOT NULL auto_increment, `initrd_name` varchar(256) NOT NULL, `initrd_arch` varchar(128) NOT NULL, `initrd_options` varchar(1024) NOT NULL, PRIMARY KEY  (`initrd_id`))")
+	sys.stdout.write("Success\n")
+
+def createRegistration(conn, config):
+
+	sys.stdout.write("Inserting initial Registration info into DB...\n")
+
+	#  Check if already there...
+	checkVal =  entryExists(conn, "kernelinfo", "kernel_name", "linux-2.6.24-19-server")
+	if checkVal:
+		sys.stdout.write("    Kernel already exists in DB...\n")
+		#  Get the kernel_id
+		kernelId = str(checkVal[1][0][0])
+	else:
+		r = execQuery(conn, "INSERT into `kernelinfo` (kernel_name, kernel_release, kernel_arch) values ('linux-2.6.24-19-server', '2.6.24-19-server', 'x86_64' )")
+		kernelId = str(r.lastrowid)
+		sys.stdout.write("Success\n")
+
+	#  Initrd
+	checkVal =  entryExists(conn, "initrdinfo", "initrd_name", "zoni-register-64")
+	sys.stdout.write("    Checking existence of initrd...")
+	if not checkVal:
+		sys.stdout.write("No\n") 
+		optionList = "initrd=" + config['initrdRoot'] + "/x86_64/zoni-register-64.gz pxeserver=" + config['pxeServerIP'] + " imageserver=" + config['imageServerIP'] + " defaultimage=amd64-tashi_nm registerfile=register_node mode=register" 
+		sys.stdout.write("    Inserting default register image into DB...")
+		r = execQuery(conn, "INSERT into `initrdinfo` (initrd_name, initrd_arch, initrd_options) values ('zoni-register-64','x86_64', '" + optionList + "')")
+		initrdId = str(r.lastrowid)
+		sys.stdout.write("Success\n")
+	else:
+		sys.stdout.write("Yes\n")    
+		initrdId = str(checkVal[1][0][0])
+		
+	#  Interactive Registration
+	checkVal =  entryExists(conn, "initrdinfo", "initrd_name", "zoni-register-64-interactive")
+	sys.stdout.write("    Checking existence of interactive initrd...")
+	if not checkVal:
+		sys.stdout.write("No\n") 
+		sys.stdout.write("    Inserting default register-interactive image into DB...")
+		optionList = "initrd=" + config['initrdRoot'] + "/x86_64/zoni-register-64-interactive.gz pxeserver=" + config['pxeServerIP'] + " imageserver=" + config['imageServerIP'] + " defaultimage=amd64-tashi_nm registerfile=register_node mode=register verbose=1" 
+		r = execQuery(conn, "INSERT into `initrdinfo` (initrd_name, initrd_arch, initrd_options) values ('zoni-register-64-interactive','x86_64', '" + optionList + "')")
+		initrdIdInteractive = str(r.lastrowid)
+		sys.stdout.write("Success\n")
+	else:
+		sys.stdout.write("Yes\n")    
+		initrdIdInteractive = str(checkVal[1][0][0])
+
+	#  Link initrd and kernel to image
+	sys.stdout.write("    Registering initrd and kernel to registration image...")
+	query = "select * from imageinfo where image_name = 'zoni-register-64' and kernel_id = " + kernelId + " and initrd_id = " + initrdId
+	r = execQuery(conn, query)
+	if len(r.fetchall()) < 1:
+		execQuery(conn, "INSERT into `imageinfo` (image_name, dist, dist_ver, kernel_id, initrd_id) values ('zoni-register-64', 'Ubuntu', 'Hardy', " + kernelId + ", " + initrdId + ")")
+
+	query = "select * from imageinfo where image_name = 'zoni-register-64-interactive' and kernel_id = " + kernelId + " and initrd_id = " + initrdId
+	r = execQuery(conn, query)
+	if len(r.fetchall()) < 1:
+		execQuery(conn, "INSERT into `imageinfo` (image_name, dist, dist_ver, kernel_id, initrd_id) values ('zoni-register-64-interactive', 'Ubuntu', 'Hardy', " + kernelId + ", " + initrdIdInteractive + ")")
+	sys.stdout.write("Success\n")
+
+
+
+def execQuery(conn, query):
+	cursor = conn.cursor()
+	try:
+		cursor.execute (query)
+	#except Exception:
+		#traceback.print_exc(sys.exc_info())
+	except MySQLdb.OperationalError, e:
+		sys.stdout.write("Fail\n")
+		msg = "ERROR: " + e[1]
+		sys.stderr.write(msg)
+		#logit(logFile, msg)
+		#traceback.print_exc(sys.exc_info())
+		exit()
+	return cursor
+
+def entryExists(conn, table, col, checkVal):
+	query = "select * from " + table + " where " + col + " = '" + checkVal + "'"
+ 	r = execQuery(conn, query)
+	res = r.fetchall()
+	if len(res) > 0:
+		return (1, res)
+
+	return 0
+
+
+if __name__ == "__main__":
+    main()
+

Propchange: incubator/tashi/trunk/src/zoni/install/db/zoniDbSetup.py
------------------------------------------------------------------------------
    svn:keywords = Id

Added: incubator/tashi/trunk/src/zoni/install/pxe/base-menu
URL: http://svn.apache.org/viewvc/incubator/tashi/trunk/src/zoni/install/pxe/base-menu?rev=983093&view=auto
==============================================================================
--- incubator/tashi/trunk/src/zoni/install/pxe/base-menu (added)
+++ incubator/tashi/trunk/src/zoni/install/pxe/base-menu Fri Aug  6 18:46:49 2010
@@ -0,0 +1,18 @@
+DISPLAY boot-screens/boot.txt
+
+LABEL zoni-register-64
+	kernel builds/amd64/zoni-reg/linux
+	append initrd=builds/amd64/zoni-reg/initrd.gz pxeserver=192.168.0.5 imageserver=192.168.0.254 defaultimage=amd64-tashi_nm registerfile=register_node mode=register console=tty1 rw --
+
+LABEL zoni-register-64-interactive
+	kernel builds/amd64/zoni-reg/linux
+	append initrd=builds/amd64/zoni-reg/initrd_zoni_interactive.gz pxeserver=192.168.0.5 imageserver=192.168.0.254 defaultimage=amd64-tashi_nm registerfile=register_node mode=register verbose=1 console=tty1 rw --
+
+LABEL localdisk
+    LOCALBOOT 0
+LABEL rescue
+	kernel ubuntu-installer/hardy/i386/linux
+	append vga=normal initrd=ubuntu-installer/hardy/i386/initrd.gz  rescue/enable=true --
+
+PROMPT 1
+TIMEOUT 100

Added: incubator/tashi/trunk/src/zoni/install/pxe/base.zoni
URL: http://svn.apache.org/viewvc/incubator/tashi/trunk/src/zoni/install/pxe/base.zoni?rev=983093&view=auto
==============================================================================
--- incubator/tashi/trunk/src/zoni/install/pxe/base.zoni (added)
+++ incubator/tashi/trunk/src/zoni/install/pxe/base.zoni Fri Aug  6 18:46:49 2010
@@ -0,0 +1,9 @@
+DISPLAY boot-screens/boot.txt
+
+DEFAULT vesamenu.c32
+PROMPT 0
+MENU BACKGROUND boot-screens/zoni_pxe.jpg
+#MENU BACKGROUND boot-screens/intel-logo2.jpg
+MENU COLOR border 49;37 #00FFFFFF #00FFFFFF none
+MENU INCLUDE pxelinux.cfg/boot_options_zoni/MAGIC1-menu
+

Added: incubator/tashi/trunk/src/zoni/install/pxe/zoniPxeSetup.py
URL: http://svn.apache.org/viewvc/incubator/tashi/trunk/src/zoni/install/pxe/zoniPxeSetup.py?rev=983093&view=auto
==============================================================================
--- incubator/tashi/trunk/src/zoni/install/pxe/zoniPxeSetup.py (added)
+++ incubator/tashi/trunk/src/zoni/install/pxe/zoniPxeSetup.py Fri Aug  6 18:46:49 2010
@@ -0,0 +1,174 @@
+#!/usr/bin/env python
+# Licensed to the Apache Software Foundation (ASF) under one
+# or more contributor license agreements.  See the NOTICE file
+# distributed with this work for additional information
+# regarding copyright ownership.  The ASF licenses this file
+# to you under the Apache License, Version 2.0 (the
+# "License"); you may not use this file except in compliance
+# with the License.  You may obtain a copy of the License at
+# 
+#   http://www.apache.org/licenses/LICENSE-2.0
+# 
+# Unless required by applicable law or agreed to in writing,
+# software distributed under the License is distributed on an
+# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+# KIND, either express or implied.  See the License for the
+# specific language governing permissions and limitations
+# under the License.    
+#
+#  $Id$
+#
+
+import os 
+import sys
+import string
+import traceback
+import optparse
+import shutil
+import urllib
+import tarfile
+
+#a = os.path.join("zoni", "install", "pxe")
+#a = os.path.join("zoni", "install")
+#sys.path.append(os.getcwd().split(a)[0])
+a = os.path.join("../")
+sys.path.append(a)
+a = os.path.join("../../")
+sys.path.append(a)
+a = os.path.join("../../..")
+sys.path.append(a)
+
+from zoni.extra.util import *
+from zoni.version import *
+from zoni.bootstrap.pxe import Pxe
+
+
+def main():
+	''' This file sets up PXE for Zoni '''
+
+	ver = version.split(" ")[0]
+	rev = revision
+
+	parser = optparse.OptionParser(usage="%prog ", version="%prog " + ver + " " + rev)
+	(options, args) = parser.parse_args()
+
+	configFile = getConfig()
+
+	ZoniPxeSetup(configFile)
+	ZoniGetSyslinux(configFile)
+
+
+def createDir(dirName):
+	try:
+		os.mkdir(dirName, 0755)
+		print "    Creating directory " + dirName 
+	except (OSError, Exception), e:
+		if e.errno == 17:
+			print "    " + e.args[1] + ": " + dirName
+		else:
+			print "    " + e.args[1] + ": " + dirName
+
+@checkSuper
+def ZoniPxeSetup(config):
+	tftpRootDir = config['tftpRootDir']
+	tftpImageDir = config['tftpImageDir']
+	tftpBootOptionsDir = config['tftpBootOptionsDir']
+	tftpUpdateFile =  config['tftpUpdateFile'] 
+	tftpBaseFile = config['tftpBaseFile'] 
+	tftpBaseMenuFile = config['tftpBaseMenuFile'] 
+	installBaseDir = config['installBaseDir']
+	
+
+	#  Create the directory structure
+	print "Creating PXE Directory Structure..."
+	createDir(tftpRootDir)
+	bootScreenDir = os.path.join(tftpRootDir, "boot-screens")
+	createDir(bootScreenDir)
+	dirName = os.path.join(tftpRootDir, "builds")
+	createDir(dirName)
+	createDir(tftpImageDir)
+	createDir(tftpBootOptionsDir)
+
+	#  Find the base files to copy
+	
+	pxeDir = os.path.join(installBaseDir, "src", "zoni", "install", "pxe")
+	dirName = os.path.join(pxeDir, "base-menu")
+	shutil.copy2(dirName, tftpBaseMenuFile)
+	dirName = os.path.join(pxeDir, "base.zoni")
+	shutil.copy2(dirName, tftpBaseFile)
+	#  Copy over zoni pxe image 
+	dirName = os.path.join(pxeDir, "zoni_pxe.jpg")
+	shutil.copy2(dirName, os.path.join(bootScreenDir, "zoni_pxe.jpg"))
+
+	#  Create the PXE config files, seeding the register images
+	pxe = Pxe(config)
+	pxe.createPxeUpdateFile(["zoni-register-64", "zoni-register-64-interactive"])
+	pxe.updatePxe()
+
+	try:
+		#  Create the default image to be the registration image
+		os.chdir(tftpImageDir)
+		dirName = os.path.join(os.path.basename(tftpBootOptionsDir), "zoni-register-64")
+		os.symlink(dirName, "default")
+		print "   Symlinking default in " + dirName 
+	except (OSError, Exception), e:
+		if e.errno == 17:
+			print "    " + e.args[1] + ": " + dirName
+		else:
+			print "    " + e.args[1] + ": " + dirName
+
+	print "Finished"
+
+@checkSuper
+def ZoniGetSyslinux(config, ver=None):
+	tftpRootDir = config['tftpRootDir']
+	tmpdir = os.path.join("/tmp")
+
+	print "Installing necessary files for PXE"
+	
+
+	#  Download syslinux and get latest version
+	syslinuxVersion = 0
+	if not ver:
+		#  Get latest
+		print "    Determining latest version of syslinux...",
+		data = urllib.urlopen("http://www.kernel.org/pub/linux/utils/boot/syslinux/")
+		for line in data.readlines():
+			if "syslinux" in line and "tar.bz2" in line and not "sign" in line:
+				a = float(line.split("syslinux-")[1].split(".tar.bz2")[0])
+				if a > syslinuxVersion:
+					syslinuxVersion = a
+		ver = str(syslinuxVersion)
+		print ver
+
+	syslinuxFile = "syslinux-" + ver
+	#  Check if the file already exists
+	tmpfile = os.path.join(tmpdir, "syslinux-" + ver + ".tar.bz2")
+	if not os.path.exists(tmpfile):
+		print "Downloading syslinux from kernel.org"
+		url = "http://www.kernel.org/pub/linux/utils/boot/syslinux/syslinux-" + ver + ".tar.bz2" 
+		print "    Downloading: " + url
+		tmpfile = os.path.join(tmpdir, "syslinux-" + ver + ".tar.bz2")
+		urllib.urlretrieve(url, tmpfile)
+	else:
+		print "    Found syslinux: " + tmpfile
+
+	print "    Opening syslinux tar.bz2"
+	myTar = tarfile.TarFile.open(tmpfile)
+	tmpfile = os.path.join(tmpdir, syslinuxFile)
+	print "    Extracting pxelinux.0 from tarball"
+	memberName = os.path.join(syslinuxFile, "core", "pxelinux.0")
+	myTar.extract(memberName, tmpdir)
+	tmpfile = os.path.join(tmpdir, syslinuxFile, "core", "pxelinux.0")
+	shutil.copy2(tmpfile, tftpRootDir)
+	print "    Extracting vesamenu.c32 from tarball"
+	memberName = os.path.join(syslinuxFile, "com32", "menu", "vesamenu.c32")
+	myTar.extract(memberName, tmpdir)
+	tmpfile = os.path.join(tmpdir, syslinuxFile, "com32", "menu", "vesamenu.c32")
+	shutil.copy2(tmpfile, tftpRootDir)
+	print "Finished"
+
+		
+
+if __name__ in "__main__":
+	main()

Propchange: incubator/tashi/trunk/src/zoni/install/pxe/zoniPxeSetup.py
------------------------------------------------------------------------------
    svn:keywords = Id

Added: incubator/tashi/trunk/src/zoni/install/pxe/zoni_pxe.jpg
URL: http://svn.apache.org/viewvc/incubator/tashi/trunk/src/zoni/install/pxe/zoni_pxe.jpg?rev=983093&view=auto
==============================================================================
Binary file - no diff available.

Propchange: incubator/tashi/trunk/src/zoni/install/pxe/zoni_pxe.jpg
------------------------------------------------------------------------------
    svn:mime-type = application/octet-stream