incubator-tashi-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From strou...@apache.org
Subject svn commit: r1187632 - in /incubator/tashi/branches/cmu: ./ etc/ src/tashi/agents/ src/tashi/nodemanager/vmcontrol/ src/zoni/bootstrap/ src/zoni/client/ src/zoni/data/ src/zoni/extra/ src/zoni/hardware/ src/zoni/install/db/ src/zoni/system/registration...
Date Sat, 22 Oct 2011 01:38:52 GMT
Author: stroucki
Date: Sat Oct 22 01:38:52 2011
New Revision: 1187632

URL: http://svn.apache.org/viewvc?rev=1187632&view=rev
Log:
merge CMU branch with trunk

Added:
    incubator/tashi/branches/cmu/src/zoni/data/reservation.py
      - copied unchanged from r1187508, incubator/tashi/trunk/src/zoni/data/reservation.py
    incubator/tashi/branches/cmu/src/zoni/data/reservationmanagementinterface.py
      - copied unchanged from r1187508, incubator/tashi/trunk/src/zoni/data/reservationmanagementinterface.py
Modified:
    incubator/tashi/branches/cmu/   (props changed)
    incubator/tashi/branches/cmu/etc/TashiDefaults.cfg
    incubator/tashi/branches/cmu/etc/ZoniDefaults.cfg
    incubator/tashi/branches/cmu/src/tashi/agents/primitive.py
    incubator/tashi/branches/cmu/src/tashi/nodemanager/vmcontrol/qemu.py
    incubator/tashi/branches/cmu/src/zoni/bootstrap/pxe.py
    incubator/tashi/branches/cmu/src/zoni/client/zoni-cli.py
    incubator/tashi/branches/cmu/src/zoni/data/resourcequerysql.py
    incubator/tashi/branches/cmu/src/zoni/data/usermanagement.py
    incubator/tashi/branches/cmu/src/zoni/extra/util.py
    incubator/tashi/branches/cmu/src/zoni/hardware/dellswitch.py
    incubator/tashi/branches/cmu/src/zoni/install/db/zoniDbSetup.py
    incubator/tashi/branches/cmu/src/zoni/system/registration/register/register_automate
    incubator/tashi/branches/cmu/src/zoni/system/registration/register/register_node
    incubator/tashi/branches/cmu/src/zoni/system/registration/www/include/zoni_functions.php
    incubator/tashi/branches/cmu/src/zoni/system/registration/www/zoni-register.php

Propchange: incubator/tashi/branches/cmu/
------------------------------------------------------------------------------
--- svn:mergeinfo (original)
+++ svn:mergeinfo Sat Oct 22 01:38:52 2011
@@ -1 +1,2 @@
 /incubator/tashi/branches/zoni-dev/trunk:1034098-1177646
+/incubator/tashi/trunk:1178106-1187508

Modified: incubator/tashi/branches/cmu/etc/TashiDefaults.cfg
URL: http://svn.apache.org/viewvc/incubator/tashi/branches/cmu/etc/TashiDefaults.cfg?rev=1187632&r1=1187631&r2=1187632&view=diff
==============================================================================
--- incubator/tashi/branches/cmu/etc/TashiDefaults.cfg (original)
+++ incubator/tashi/branches/cmu/etc/TashiDefaults.cfg Sat Oct 22 01:38:52 2011
@@ -117,7 +117,8 @@ migrateTimeout = 300.0
 maxParallelMigrations = 10
 useMigrateArgument = False
 statsInterval = 0.0
-#scratchVg = vgscratch
+scratchDir = /tmp
+scratchVg = vgscratch
 
 [XenPV]
 vmNamePrefix = tashi

Modified: incubator/tashi/branches/cmu/etc/ZoniDefaults.cfg
URL: http://svn.apache.org/viewvc/incubator/tashi/branches/cmu/etc/ZoniDefaults.cfg?rev=1187632&r1=1187631&r2=1187632&view=diff
==============================================================================
--- incubator/tashi/branches/cmu/etc/ZoniDefaults.cfg (original)
+++ incubator/tashi/branches/cmu/etc/ZoniDefaults.cfg Sat Oct 22 01:38:52 2011
@@ -78,7 +78,7 @@ VLAN_MAX = 4095
 
 [hardware]
 #  Hardware control available for the cluster 
-HARDWARE_CONTROL = {"ipmi": {"class":"zoni.hardware.ipmi.Ipmi"}, "drac": {"class":"zoni.hardware.delldrac.dellDrac"},
"pdu":{"class": "zoni.hardware.raritanpdu.raritanDominionPx"}, "dellswitch" : {"class", "zoni.hardware.dellswitch.HwDellSwitch",
"accessmode" : "ssh"}}
+HARDWARE_CONTROL = {"ipmi": {"class":"zoni.hardware.ipmi.Ipmi"}, "drac": {"class":"zoni.hardware.delldrac.dellDrac"},
"pdu":{"class": "zoni.hardware.raritanpdu.raritanDominionPx"}, "dellswitch" : {"class":"zoni.hardware.dellswitch.HwDellSwitch",
"accessmode" : "ssh"}}
 HARDWARE_PDU = "raritan"
 HARDWARE_DRAC = "DELL DRAC"
 

Modified: incubator/tashi/branches/cmu/src/tashi/agents/primitive.py
URL: http://svn.apache.org/viewvc/incubator/tashi/branches/cmu/src/tashi/agents/primitive.py?rev=1187632&r1=1187631&r2=1187632&view=diff
==============================================================================
--- incubator/tashi/branches/cmu/src/tashi/agents/primitive.py (original)
+++ incubator/tashi/branches/cmu/src/tashi/agents/primitive.py Sat Oct 22 01:38:52 2011
@@ -119,7 +119,7 @@ class Primitive(object):
 				allowElsewhere = False
 			# has a host preference been expressed?
 			if (targetHost != None):
-				for h in hosts.values():
+				for h in self.hosts.values():
 					# if this is not the host we are looking for, continue
 					if ((str(h.id) != targetHost and h.name != targetHost)):
 						continue

Modified: incubator/tashi/branches/cmu/src/tashi/nodemanager/vmcontrol/qemu.py
URL: http://svn.apache.org/viewvc/incubator/tashi/branches/cmu/src/tashi/nodemanager/vmcontrol/qemu.py?rev=1187632&r1=1187631&r2=1187632&view=diff
==============================================================================
--- incubator/tashi/branches/cmu/src/tashi/nodemanager/vmcontrol/qemu.py (original)
+++ incubator/tashi/branches/cmu/src/tashi/nodemanager/vmcontrol/qemu.py Sat Oct 22 01:38:52
2011
@@ -105,6 +105,7 @@ class Qemu(VmControlInterface):
 		self.consolePortLock = threading.Lock()
 		self.migrationSemaphore = threading.Semaphore(int(self.config.get("Qemu", "maxParallelMigrations")))
 		self.stats = {}
+		self.scratchVg = self.config.get("Qemu", "scratchVg")
 		# XXXstroucki revise
 		self.scratchDir = self.config.get("Qemu", "scratchDir")
 		if len(self.scratchDir) == 0:
@@ -178,11 +179,15 @@ class Qemu(VmControlInterface):
 						f.write(i)
 					f.close()
 				#XXXstroucki remove scratch storage
-				scratch_name = child.instance.name
-				log.info("Removing scratch for " + scratch_name)
-				#cmd = "/sbin/lvremove -f vgscratch/lv" + scratch_name
-				cmd = "/sbin/lvremove -f vgscratch"
-    				result = subprocess.Popen(cmd.split(), executable=cmd.split()[0], stdout=subprocess.PIPE).wait()
+				try:
+					if self.scratchVg is not None:
+						scratch_name = child.instance.name
+						log.info("Removing scratch for " + scratch_name)
+						cmd = "/sbin/lvremove -f %s" % self.scratchVg
+    						result = subprocess.Popen(cmd.split(), executable=cmd.split()[0], stdout=subprocess.PIPE).wait()
+				except:
+					pass
+
 				try:
 					if (not child.migratingOut):
 						self.nm.vmStateChange(vmId, None, InstanceState.Exited)
@@ -396,17 +401,19 @@ class Qemu(VmControlInterface):
 
 		try:
 			if scratchSize > 0:
+				if self.scratchVg is None:
+					raise Exception, "No scratch volume group defined"
 				# create scratch disk
 				# XXXstroucki: needs to be cleaned somewhere
 				# XXXstroucki: clean user provided instance name
 				scratch_name = "lv" + instance.name
 				# XXXstroucki hold lock
 				# XXXstroucki check for capacity
-				cmd = "/sbin/lvcreate -n" + scratch_name + " -L" + str(scratchSize) + "G vgscratch"
+				cmd = "/sbin/lvcreate -n" + scratch_name + " -L" + str(scratchSize) + "G " + self.scratchVg
 				result = subprocess.Popen(cmd.split(), executable=cmd.split()[0], stdout=subprocess.PIPE).wait()
 				index += 1
 
-				thisDiskList = [ "file=/dev/vgscratch/%s" % scratch_name ]
+				thisDiskList = [ "file=/dev/%s/%s" % (self.scratchVg, scratch_name) ]
 				thisDiskList.append("if=%s" % diskInterface)
 				thisDiskList.append("index=%d" % index)
 				thisDiskList.append("cache=off")

Modified: incubator/tashi/branches/cmu/src/zoni/bootstrap/pxe.py
URL: http://svn.apache.org/viewvc/incubator/tashi/branches/cmu/src/zoni/bootstrap/pxe.py?rev=1187632&r1=1187631&r2=1187632&view=diff
==============================================================================
--- incubator/tashi/branches/cmu/src/zoni/bootstrap/pxe.py (original)
+++ incubator/tashi/branches/cmu/src/zoni/bootstrap/pxe.py Sat Oct 22 01:38:52 2011
@@ -115,8 +115,9 @@ class Pxe(BootStrapInterface):
 		#  Write out boot image file
 		val = "DISPLAY boot-screens/boot.txt\n"
 		val += "DEFAULT vesamenu.c32\n"
-		val += "MENU BACKGROUND boot-screens/zoni_pxe.jpg\n"
+		val += "TIMEOUT 2\n"
 		val += "PROMPT 0\n"
+		val += "MENU BACKGROUND boot-screens/zoni_pxe.jpg\n"
 		
 		val += "MENU COLOR border 49;37 #00FFFFFF #00FFFFFF none\n"
 		val += "MENU INCLUDE %s-menu\n" % imagedir

Modified: incubator/tashi/branches/cmu/src/zoni/client/zoni-cli.py
URL: http://svn.apache.org/viewvc/incubator/tashi/branches/cmu/src/zoni/client/zoni-cli.py?rev=1187632&r1=1187631&r2=1187632&view=diff
==============================================================================
--- incubator/tashi/branches/cmu/src/zoni/client/zoni-cli.py (original)
+++ incubator/tashi/branches/cmu/src/zoni/client/zoni-cli.py Sat Oct 22 01:38:52 2011
@@ -27,6 +27,7 @@ import socket
 import logging.config
 import getpass
 import re
+import subprocess
 
 
 
@@ -443,7 +444,7 @@ def main():
 			host = data.getHostInfo(options.nodeName)
 			#  optparse does not pass multiple args that are quoted anymore?  
 			#  Used to work with python 2.5.2.  Doesn't work with python 2.6.5.  
-			data.allocateNode(options.reservationId, options.domain, host['sys_id'], options.vlanInfo,
options.imageName, options.myNotes + " " + str(string.join(args[0:len(args)])))
+			data.allocateNode(options.reservationId, options.domain, host['sys_id'], options.vlanInfo,
options.imageName, options.hostName, options.myNotes + " " + str(string.join(args[0:len(args)])))
 		else:
 			mesg = "USAGE: %s --allocateNode --nodeName nodeName --domain domainname --reservationId
ID --vlanInfo vlanNums:info, --imageName imagename [--notes]\n" % (sys.argv[0])
 			mesg += "Options\n"
@@ -456,7 +457,6 @@ def main():
 			sys.stdout.write(mesg)
 			exit()
 		
-		exit()  #remove this
 		if not (options.reservationId) or not options.nodeName: 
 			mesg = "ERROR:  AllocateNode requires the following arguments...\n"
 			if not (options.nodeName):
@@ -471,8 +471,23 @@ def main():
 			sys.stderr.write(mesg)		
 			exit()
 
-		print host['sys_id']
-		data.allocateNode(options.reservationId, host['sys_id'], options.hostName,  vlanNum, options.ipAddr,
options.Notes)
+		#  Reconfigure switchports
+		memberMap = data.getDomainMembership(host['sys_id'])
+		HwSwitch = HwDellSwitch
+		hwswitch = HwSwitch(configs, host)
+		for vlan, tag in memberMap.iteritems():
+			hwswitch.addNodeToVlan(vlan, tag)
+		#  Register node in DNS
+		if options.hostName:
+			#  Add cname
+			cmd = "zoni --addCname %s %s" % (options.hostName, host['location'])
+			subprocess.Popen(string.split(cmd))
+			
+		
+
+	
+		#data.allocateNode(options.reservationId, options.domain, host['sys_id'], options.vlanInfo,
options.imageName, options.hostName, options.myNotes + " " + str(string.join(args[0:len(args)])))
+		#data.allocateNode(options.reservationId, host['sys_id'], options.hostName,  vlanNum, options.ipAddr,
options.myNotes)
 		exit()
 
 	#  Update allocation
@@ -490,14 +505,13 @@ def main():
 			exit()
 
 		userId = None
-		if options.uid and options.userName:
+		if options.uid or options.userName:
 			#  Get the username from uid 
 			userId = options.uid
 			if not options.uid:
 				userId = usermgt.getUserId(options.userName)
 
-		print options.reservationId, userId, options.reservationDuration, options.vlanIsolate,
options.Notes
-		data.updateReservation(options.reservationId, userId, options.reservationDuration, options.vlanIsolate,
options.Notes)
+		data.updateReservation(options.reservationId, userId, options.reservationDuration, options.vlanIsolate,
options.myNotes)
 
 	#  Release node allocation
 	if (options.releaseNode):
@@ -539,10 +553,11 @@ def main():
 	if (options.showDomains):
 		data.showDomains()
 	if (options.addDomain):
-		if len(args) > 2 and options.reservationId:
-			data.addDomain(args[0], string.join(args[1:len(args)]), options.reservationId)
+		if len(args) > 2 and options.vlanInfo:
+			data.addDomain(args[0], string.join(args[1:len(args)]), options.vlanInfo)
 		else:
-			mesg = "USAGE: %s --addDomain domainname domaindesc --reservationId ID\n" % (sys.argv[0])
+			mesg = "USAGE: %s --addDomain domainname \"domain desc\" --vlanInfo vlan:type,vlan:type\n"
% (sys.argv[0])
+			mesg += "Options\n\n  --vlanInfo 999:native,1000:untagged,1001:tagged\n"
 			sys.stdout.write(mesg)
 			exit()
 	if (options.removeDomain):
@@ -633,7 +648,7 @@ def main():
 			data.removeVlan(options.destroyVlanId)
 
 		if options.add2Vlan and (options.nodeName or options.switchPort):
-			tag=None
+			tag="untagged"
 			vlan = options.add2Vlan
 			if ":" in options.add2Vlan:
 				print options.add2Vlan
@@ -641,11 +656,15 @@ def main():
 				tag = options.add2Vlan.split(":")[1]
 
 			hwswitch.addNodeToVlan(vlan, tag)
+			data.addNodeToVlan(host['location'], vlan, tag)
+			exit()
 
 		if options.removeFromVlan and (options.nodeName or options.switchPort): 
 			hwswitch.removeNodeFromVlan(options.removeFromVlan)
+			data.removeNodeFromVlan(options.nodeName, options.removeFromVlan)
 		if options.setNative and (options.nodeName or options.switchPort):
 			hwswitch.setNativeVlan(options.setNative)
+			data.addNodeToVlan(host['location'], options.setNative, "native")
 		if options.restoreNative and options.nodeName:
 			hwswitch.restoreNativeVlan()
 		if options.removeAllVlans and (options.nodeName or options.switchPort):

Modified: incubator/tashi/branches/cmu/src/zoni/data/resourcequerysql.py
URL: http://svn.apache.org/viewvc/incubator/tashi/branches/cmu/src/zoni/data/resourcequerysql.py?rev=1187632&r1=1187631&r2=1187632&view=diff
==============================================================================
--- incubator/tashi/branches/cmu/src/zoni/data/resourcequerysql.py (original)
+++ incubator/tashi/branches/cmu/src/zoni/data/resourcequerysql.py Sat Oct 22 01:38:52 2011
@@ -75,14 +75,16 @@ class ResourceQuerySql(InfoStore):
 	def getNote(self):
 		return "Created by Zoni"
 
-	def addDomain(self, name, desc, reservationId):
-		#  Check if there is a reservation
-		query = "select * from reservationinfo where reservation_id = %s" % (reservationId)
-		result = self.selectDb(query)
-		if result.rowcount < 1:
-			mesg = "Reservation does not exist : %s" % (reservationId)
-			self.log.error(mesg)
-			return -1
+	def addDomain(self, name, desc, vlanInfo):
+		#  Check if vlans exist
+		vlans = []
+		for val in vlanInfo.split(","):
+			try:
+				ret = self.getVlanId(val.split(":")[0])
+				vlans.append(val)
+			except Exception, e:
+				print e
+				exit()
 
 		if desc == None:
 			desc = self.getNote()
@@ -92,7 +94,7 @@ class ResourceQuerySql(InfoStore):
 			return -1
 		#  Create a key for the reservation
 		domainKey = createKey(name)
-		query = "insert into domaininfo (domain_name, domain_desc, domain_key, reservation_id)
values ('%s','%s', '%s', '%s')" % (name, desc, domainKey, reservationId)
+		query = "insert into domaininfo (domain_name, domain_desc, domain_key) values ('%s','%s',
'%s')" % (name, desc, domainKey)
 		try:
 			result = self.insertDb(query)
 			mesg = "Adding domain %s(%s)" % (name, desc)
@@ -100,14 +102,41 @@ class ResourceQuerySql(InfoStore):
 		except Exception, e:
 			mesg = "Adding domain %s(%s) failed : %s" % (name, desc, e)
 			self.log.error(mesg)
+
+		#  Get the domain_id
+		domainId = int(self.getDomainIdFromKey(domainKey))
+
+		#  Map domain to vlan
+		for i in vlans:
+			vlanId = int(i.split(":")[0])
+			vlanType = i.split(":")[1]
+			query = "insert into domainmembermap values (%d, %d, '%s')" % (domainId, vlanId, vlanType)
+			try:
+				result = self.insertDb(query)
+			except Exception, e:
+				print e
 		
 
+	def getDomainMembership(self, sys_id):
+		query = "select v.vlan_num, q.vlan_type from allocationinfo a, vlanmembermap q, vlaninfo
v where q.vlan_id = v.vlan_id and a.allocation_id = q.allocation_id and sys_id = '%s'" % (sys_id)
+		result = self.selectDb(query)
+		data = {}
+		if result.rowcount:
+			for i in result.fetchall():
+				data[int(i[0])] = i[1]
+			return data
+		else:
+			return -1
+
 	def removeDomain(self, name):
+		domainId = self.__getSomething("domain_id", "domaininfo", "domain_name", name)
 		mesg = "Removing domain %s" % (name)
 		self.log.info(mesg)
 		query = "delete from domaininfo where domain_name = '%s'" % (name)
 		result = self.__deleteDb(query)
 		#  Need to remove any vlans attached to this domain
+		query = "delete from domainmembermap where domain_id = '%s'" % (domainId)
+		result = self.__deleteDb(query)
 
 	def showDomains(self):
 		usermgt = eval("usermanagement.%s" % (self.config['userManagement']) + "()")
@@ -278,14 +307,23 @@ class ResourceQuerySql(InfoStore):
 		for i in defaultFields.split(","):
 			#line += string.strip(str(i)) + "\t"
 			line += str(i.center(20))
+		#  header
 		print line
 
+		sum = {}
 		for row in result.fetchall():
 			line = ""
+			sum['totProc'] = sum.get('totProc', 0)
+			sum['totProc'] += int(row[2])
+			sum['totCores'] = sum.get('totCores', 0)
+			sum['totCores'] += int(row[3])
+			sum['totMemory'] = sum.get('totMemory', 0)
+			sum['totMemory'] += int(row[5])
 			for val in row:
 				line += str(val).center(20)
+			
 			print line
-		print str(result.rowcount) + " systems returned"
+		print "\n%s systems registered -  %d procs | %d cores | %d bytes RAM" % (str(result.rowcount),
sum['totProc'], sum['totCores'], sum['totMemory'],)
 
 	def getAvailableResources(self):
 		#  Maybe should add a status flag?
@@ -313,7 +351,6 @@ class ResourceQuerySql(InfoStore):
 				res[location][desc[4][0]] = int(i[4])
 				res[location][desc[5][0]] = int(i[5])
 				res[location][desc[6][0]] = i[6]
-			
 		return res
 
 	def getMyResources(self, key):
@@ -399,11 +436,11 @@ class ResourceQuerySql(InfoStore):
 		result = self.selectDb(query)
 		#print result.rowcount 
 		if result.rowcount > 0:
-			return result.fetchall()[0][0]
+			return int(result.fetchall()[0][0])
 		else:
 			mesg = "VLAN does not exist: " + str(vlan)
 			self.log.error(mesg)
-			return -1 
+			raise Exception, mesg
 
 	def isIpAvailable(self, ip_addr, vlan_id):
 		query = "select * from allocationinfo where ip_addr = \"" + str(ip_addr) + "\" and vlan_id
= \"" + str(vlan_id) + "\""
@@ -453,14 +490,11 @@ class ResourceQuerySql(InfoStore):
 		#  specify usermanagement - ldap or files
 		usermgt = eval("usermanagement.%s" % (self.config['userManagement']) + "()")
 
-		query = "select r.user_id, d.domain_name, s.location, s.num_cores, \
-				s.mem_total, r.reservation_expiration, r.notes, r.reservation_id, a.hostname, \
-				a.notes, i.image_name from \
-				sysinfo s, imageinfo i, \
-				allocationinfo a, domaininfo d, reservationinfo r, imagemap j where \
-				i.image_id = j.image_id \
-				and r.reservation_id = a.reservation_id \
-				and d.domain_id = a.domain_id and s.sys_id = a.sys_id "
+		#select a.reservation_id, a.sys_id, r.user_id, s.location, s.num_cores, s.mem_total, a.hostname,
ii.image_name 
+		#from allocationinfo a, reservationinfo r, sysinfo s, imageinfo ii, imagemap im 
+		#where r.reservation_id = a.reservation_id and a.sys_id = s.sys_id and im.image_id = ii.image_id
and im.allocation_id = a.allocation_id;
+
+		query = "select r.user_id, d.domain_name, s.location, s.num_cores, s.mem_total, r.reservation_expiration,
r.notes, r.reservation_id,  a.hostname, a.notes, ii.image_name, a.allocation_id from sysinfo
s, imageinfo ii, allocationinfo a, domaininfo d, reservationinfo r, imagemap im where  im.image_id
= ii.image_id and r.reservation_id = a.reservation_id and  d.domain_id = a.domain_id and s.sys_id
= a.sys_id and im.allocation_id = a.allocation_id"
 		if userId:
 			myid = userId
 			if type(userId) == str:
@@ -469,15 +503,16 @@ class ResourceQuerySql(InfoStore):
 				
 			query += " and user_id = '%s' " % (myid)
 
-		query += "order by r.reservation_id asc, s.location"
+		query += " order by r.reservation_id asc, s.location"
 
 		result = self.selectDb(query)
 		
 		print "NODE ALLOCATION\n"
+		sum = {}
 		if self.verbose:
-			print "%-5s%-10s%-10s%-13s%-12s%-15s%-18s%-24s%-20s%s" % ("Res", "User", "Host", "Cores/Mem","Expiration",
"Hostname", "IP Addr", "Boot Image Name", "Vlan Member", "Notes")
+			print "%-5s%-10s%-10s%-10s%-13s%-12s%-10s%-34s%-20s%s" % ("Res", "User", "Host", "Domain",
"Cores/Mem","Expiration", "Hostname", "Boot Image Name", "Vlan Member", "Notes")
 		else:
-			print "%-10s%-10s%-13s%-12s%s" % ("User", "Node", "Cores/Mem","Expiration", "Notes")
+			print "%-10s%-10s%-10s%-13s%-12s%s" % ("User", "Node", "Domain", "Cores/Mem","Expiration",
"Notes")
 
 		for i in result.fetchall():
 			uid = i[0]
@@ -495,21 +530,27 @@ class ResourceQuerySql(InfoStore):
 				hostname = host
 			anotes = i[9]
 			image_name = i[10]
+			allocation_id = i[11]
 			userName = usermgt.getUserName(uid)
 			combined_notes = str(rnotes) + "|" + str(anotes)
+			sum['totCores'] = sum.get('totCores', 0)
+			sum['totCores'] += cores
+			sum['totMemory'] = sum.get('totMemory', 0)
+			sum['totMemory'] += memory
 			if self.verbose:
-				query = "select vlan_num from vlaninfo v, domainmembermap m, domaininfo d where v.vlan_id
= m.vlan_id and d.domain_id = m.domain_id and d.domain_name = '%s'" % (domain);
+				query = "select v.vlan_num, m.vlan_type from vlaninfo v, vlanmembermap m where v.vlan_id
= m.vlan_id and allocation_id = '%d' order by vlan_num asc" % allocation_id
 				vlanRes = self.selectDb(query)
 				vlanList = []
 				for i in vlanRes.fetchall():
-					vlanList.append(str(i[0]))
+					tag = string.upper(str(i[1][0]))
+					mytag = "%s(%s)" %(str(i[0]), tag )
+					vlanList.append(mytag)
 				
 				vlanMember = string.join(vlanList, ",")
-				ip_addr = "10.0.0.10"
-				print "%-5s%-10s%-10s%-2s/%-10s%-12s%-15s%-18s%-24s%-20s%s" % (resId, userName, host,
cores, memory,expire, hostname, ip_addr, image_name, vlanMember,combined_notes)
+				print "%-5s%-10s%-10s%-10s%-2s/%-10s%-12s%-10s%-34s%-20s%s" % (resId, userName, host,
domain, cores, memory,expire, hostname, image_name, vlanMember,combined_notes)
 			else:
-				print "%-10s%-10s%-2s/%-10s%-12s%s" % (userName, host, cores, memory,expire, combined_notes)
-		print "\n%s systems returned" % (str(result.rowcount))
+				print "%-10s%-10s%-10s%-2s/%-10s%-12s%s" % (userName, host, domain, cores, memory,expire,
combined_notes)
+		print "\n%s systems allocated - %d cores| %d bytes RAM" % (str(result.rowcount), sum['totCores'],
sum['totMemory'])
 
 	def showReservation(self, userId=None):
 		#from IPython.Shell import IPShellEmbed
@@ -858,7 +899,6 @@ class ResourceQuerySql(InfoStore):
 			mesg = "UPDATING Vlan: " 
 			self.log.info(mesg)
 			query = "update reservationinfo set vlan_num = " + vlanIsolate + " where reservation_id
= \"" + str(reservationId) + "\""
-			print "query is ", query
 			self.__updateDb(query)
 		if userId:
 			mesg = "UPDATING USER:"
@@ -914,7 +954,8 @@ class ResourceQuerySql(InfoStore):
 #
 		#self.insertDb(query)
 
-	def allocateNode(self, reservationId, domain, sysId, vlanInfo, imageName, notes=None):
+
+	def allocateNode(self, reservationId, domain, sysId, vlanInfo, imageName, newHostName=None,
notes=None):
 		print "reservationId", reservationId, domain, sysId, vlanInfo, imageName, notes
 
 		#  Check if node is already allocated
@@ -949,27 +990,24 @@ class ResourceQuerySql(InfoStore):
 		#  Check that all the vlans exist
 		for i in vlanInfo.split(","):
 			v = i.split(":")[0]
-			if self.getVlanId(v) < 0:
-				return -1
+			try:
+				self.getVlanId(v)
+			except Exception, e:
+				print e
 
 		#  Insert to allocationinfo
 		nodeName = self.getLocationFromSysId(sysId)
 		mesg = "allocateNode %s : domain %s : reservation %s(%s)" % (nodeName, domain, reservationId,
resinfo[4])
 		self.log.info(mesg)
-		query = "insert into allocationinfo (sys_id, reservation_id, domain_id, notes) values ('%s',
'%s', '%s', '%s')" % (sysId, reservationId, domainId, notes)
+		query = "insert into allocationinfo (sys_id, reservation_id, domain_id, hostname, notes)
values ('%s', '%s', '%s', '%s', '%s')" % (sysId, reservationId, domainId, newHostName, notes)
 		result = self.insertDb(query)
 		allocationId = result.lastrowid
 
 		#  Parse vlan info and add to vlanmembermap
 		for i in vlanInfo.split(","):
-			print i
 			v = i.split(":")[0]
-			vId = self.getVlanId(v)
 			t = i.split(":")[1]
-			query = "insert into vlanmembermap (allocation_id, vlan_id, vlan_type) values ('%s', '%s',
'%s')" % (allocationId, vId, t)
-			result = self.insertDb(query)
-			mesg = "Adding vlan %s to node %s" % (v, nodeName)
-			self.log.info(mesg)
+			self.addNodeToVlan(nodeName, v, t)
 
 		#  Insert into imagemap
 		query = "insert into imagemap (allocation_id, image_id) values ('%s', '%s')" % (allocationId,
imageId)
@@ -977,17 +1015,43 @@ class ResourceQuerySql(InfoStore):
 	
 		self.__updateSysState(sysId, 1)
 
+	def addNodeToVlan(self, nodeName, v, t):
+		sysId = self.getSysIdFromLocation(nodeName)	
+		allocationId = self.__getSomething("allocation_id", "allocationinfo", "sys_id", sysId)
+		vId = self.getVlanId(v)
+		if t == "native":
+			query = "select vlan_id from vlanmembermap where allocation_id = %d and vlan_type = 'native'"
% (allocationId)
+			result = self.selectDb(query)
+			if result.rowcount > 0:
+				query = "update vlanmembermap set vlan_type = 'untagged' where allocation_id = %d and
vlan_id = %d" % (allocationId, result.fetchall()[0][0])
+			else:
+				query = "delete from vlanmembermap where allocation_id = %d and vlan_id = %d" % (allocationId,
vId)
+			result = self.selectDb(query)
+
+		if self.__checkDup("vlanmembermap", "vlan_id", vId, "allocation_id", allocationId):
+			self.log.error("Vlan %s already exists" % (v))
+			return -1
+		query = "insert into vlanmembermap (allocation_id, vlan_id, vlan_type) values ('%s', '%s',
'%s')" % (allocationId, vId, t)
+
+		result = self.insertDb(query)
+		mesg = "Adding vlan %s to node %s" % (v, nodeName)
+		self.log.info(mesg)
+
+	def removeNodeFromVlan(self, nodeName, v):
+		sysId = self.getSysIdFromLocation(nodeName)	
+		allocationId = self.__getSomething("allocation_id", "allocationinfo", "sys_id", sysId)
+		vId = self.getVlanId(v)
+		query = "delete from vlanmembermap where allocation_id = '%s' and vlan_id = '%s'" % (allocationId,
vId)
+
+		result = self.insertDb(query)
+		mesg = "Removing vlan %s from node %s" % (v, nodeName)
+		self.log.info(mesg)
+
+
 		
 	def __updateSysState(self, sysId, stateId):
 		query = "update sysinfo set state_id = '%s' where sys_id = '%s'" % (stateId, sysId)
 		return self.__updateDb(query)
-
-	def rgasstest(self, vlan_num):
-		query = "select * from vlaninfo where vlan_num = " + vlan_num
-		res = self.selectDb(query).fetchall()
-		print res
-		
-		
 			
 	def removeReservation(self, res):
 		mesg = "Removing reservation (%s)" % str(res)

Modified: incubator/tashi/branches/cmu/src/zoni/data/usermanagement.py
URL: http://svn.apache.org/viewvc/incubator/tashi/branches/cmu/src/zoni/data/usermanagement.py?rev=1187632&r1=1187631&r2=1187632&view=diff
==============================================================================
--- incubator/tashi/branches/cmu/src/zoni/data/usermanagement.py (original)
+++ incubator/tashi/branches/cmu/src/zoni/data/usermanagement.py Sat Oct 22 01:38:52 2011
@@ -131,7 +131,7 @@ class files(UserManagementInterface):
 		cmd = "cat /etc/passwd "
 		a = os.popen(cmd)
 		for line in a.readlines():
-			if userName in line :
+			if str(userId) in line :
 				return line.split(":")[0]
 
 		return 0

Modified: incubator/tashi/branches/cmu/src/zoni/extra/util.py
URL: http://svn.apache.org/viewvc/incubator/tashi/branches/cmu/src/zoni/extra/util.py?rev=1187632&r1=1187631&r2=1187632&view=diff
==============================================================================
--- incubator/tashi/branches/cmu/src/zoni/extra/util.py (original)
+++ incubator/tashi/branches/cmu/src/zoni/extra/util.py Sat Oct 22 01:38:52 2011
@@ -39,7 +39,7 @@ def loadConfigFile(parser):
 	config['logFile'] = parser.get("logging", "LOG_FILE").split()[0]
 	
 	#  Management
-	#config['userManagement'] = parser.get("management", "USER_MANAGEMENT").split()[0]
+	config['userManagement'] = parser.get("management", "USER_MANAGEMENT").split()[0]
 	#config['infoStore'] = parser.get("management", "INFO_STORE").split()[0]
 	config['pickleFile'] = parser.get("management", "PICKLE_FILE").split()[0]
 	

Modified: incubator/tashi/branches/cmu/src/zoni/hardware/dellswitch.py
URL: http://svn.apache.org/viewvc/incubator/tashi/branches/cmu/src/zoni/hardware/dellswitch.py?rev=1187632&r1=1187631&r2=1187632&view=diff
==============================================================================
--- incubator/tashi/branches/cmu/src/zoni/hardware/dellswitch.py (original)
+++ incubator/tashi/branches/cmu/src/zoni/hardware/dellswitch.py Sat Oct 22 01:38:52 2011
@@ -271,6 +271,10 @@ class HwDellSwitch(HwSwitchInterface):
 		child.terminate()
 
 	def addNodeToVlan(self, vlan, tag="untagged"):
+		if tag == "native":
+			self.setNativeVlan(vlan)
+			tag = "untagged"
+		
 		mesg = "Adding switchport (%s:%s) to vlan %s:%s" % (str(self.host['hw_name']), str(self.host['hw_port']),
str(vlan), str(tag))
 		self.log.info(mesg)
 		

Modified: incubator/tashi/branches/cmu/src/zoni/install/db/zoniDbSetup.py
URL: http://svn.apache.org/viewvc/incubator/tashi/branches/cmu/src/zoni/install/db/zoniDbSetup.py?rev=1187632&r1=1187631&r2=1187632&view=diff
==============================================================================
--- incubator/tashi/branches/cmu/src/zoni/install/db/zoniDbSetup.py (original)
+++ incubator/tashi/branches/cmu/src/zoni/install/db/zoniDbSetup.py Sat Oct 22 01:38:52 2011
@@ -163,11 +163,12 @@ def createTables(conn):
 	sys.stdout.write("Success\n")
 	#  Create domaininfo
 	sys.stdout.write("    Creating domaininfo...")
-	execQuery(conn, "CREATE TABLE IF NOT EXISTS `domaininfo` ( `domain_id` int(11) unsigned
NOT NULL auto_increment, `domain_name` varchar(64) NOT NULL, `domain_key` varchar(1024) NULL,
`domain_desc` varchar(256) NOT NULL, `reservation_id` int(11) unsigned NOT NULL,  PRIMARY
KEY  (`domain_id`), INDEX (reservation_id), FOREIGN KEY (reservation_id) REFERENCES reservationinfo(reservation_id)
on DELETE CASCADE) ENGINE=INNODB")
+	#execQuery(conn, "CREATE TABLE IF NOT EXISTS `domaininfo` ( `domain_id` int(11) unsigned
NOT NULL auto_increment, `domain_name` varchar(64) NOT NULL, `domain_key` varchar(1024) NULL,
`domain_desc` varchar(256) NOT NULL, `reservation_id` int(11) unsigned NOT NULL,  PRIMARY
KEY  (`domain_id`), INDEX (reservation_id), FOREIGN KEY (reservation_id) REFERENCES reservationinfo(reservation_id)
on DELETE CASCADE) ENGINE=INNODB")
+	execQuery(conn, "CREATE TABLE IF NOT EXISTS `domaininfo` ( `domain_id` int(11) unsigned
NOT NULL auto_increment, `domain_name` varchar(64) NOT NULL, `domain_key` varchar(1024) NULL,
`domain_desc` varchar(256) NOT NULL, PRIMARY KEY (`domain_id`)) ENGINE=INNODB")
 	sys.stdout.write("Success\n")
 	#  Create domainmap
 	sys.stdout.write("    Creating domainmembermap...")
-	execQuery(conn, "CREATE TABLE IF NOT EXISTS `domainmembermap` (`domain_id` int(11) unsigned
NOT NULL, `vlan_id` int(11) unsigned NOT NULL, INDEX (domain_id), FOREIGN KEY (domain_id)
REFERENCES domaininfo(domain_id) on DELETE CASCADE) ENGINE=INNODB")
+	execQuery(conn, "CREATE TABLE IF NOT EXISTS `domainmembermap` (`domain_id` int(11) unsigned
NOT NULL, `vlan_id` int(11) unsigned NOT NULL, `vlan_type` varchar(20) NULL, INDEX (domain_id),
FOREIGN KEY (domain_id) REFERENCES domaininfo(domain_id) on DELETE CASCADE) ENGINE=INNODB")
 	sys.stdout.write("Success\n")
 	#  Create system, domain member map
 	sys.stdout.write("    Creating sysdomainmembermap...")
@@ -175,7 +176,7 @@ def createTables(conn):
 	sys.stdout.write("Success\n")
  	#  Create allocationinfo
 	sys.stdout.write("    Creating allocationinfo...")
-	execQuery(conn, "CREATE TABLE IF NOT EXISTS `allocationinfo` ( `allocation_id` int(11) unsigned
NOT NULL auto_increment, `sys_id` int(11) unsigned NOT NULL, `reservation_id` int(11) unsigned
NOT NULL, `pool_id` int(11) unsigned NULL, `hostname` varchar(64) default NULL, `domain_id`
int(11) unsigned NOT NULL, `notes` tinytext, `expire_time` timestamp default 0 NOT NULL, PRIMARY
KEY  (`allocation_id`), INDEX (domain_id), FOREIGN KEY (domain_id) REFERENCES domaininfo (domain_id)
on DELETE CASCADE) ENGINE=INNODB")
+	execQuery(conn, "CREATE TABLE IF NOT EXISTS `allocationinfo` ( `allocation_id` int(11) unsigned
NOT NULL auto_increment, `sys_id` int(11) unsigned NOT NULL, `reservation_id` int(11) unsigned
NOT NULL, `pool_id` int(11) unsigned NULL, `hostname` varchar(64) default NULL, `domain_id`
int(11) unsigned NOT NULL, `notes` tinytext, `expire_time` timestamp default 0 NOT NULL, PRIMARY
KEY  (`allocation_id`)) ENGINE=INNODB")
 	sys.stdout.write("Success\n")
 	#  Create imagemap
 	sys.stdout.write("    Creating imagemap...")
@@ -230,33 +231,34 @@ def createRegistration(conn, config):
 		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])
+	#checkVal =  entryExists(conn, "initrdinfo", "initrd_name", "zoni-register-64")
+	#sys.stdout.write("    Checking existence of initrd...")
+	#if not checkVal:
+		#sys.stdout.write("No\n") 
+#1,'initrd.img-2.6.38-10-server','x86_64','pxeserver=10.10.0.10 imageserver=10.10.0.10 defaultimage=x86_64-natty-hadoop-tashi_nm
registerfile=register_node mode=register zoniroot=zoni configipmi=1 verbose=0'
+		#optionList = "pxeserver=" + config['pxeServerIP'] + " imageserver=" + config['imageServerIP']
+ " defaultimage=amd64-tashi_nm registerfile=register_node mode=register zoniroot="  + config['registrationBaseDir']
+ "configipmi=1 verbose=0
+		#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])
-
+	#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])
+#
 	#  Insert disk option
 	sys.stdout.write("    Adding Disk to imageinfo...")
 	query = "select * from imageinfo where image_name = 'disk'"
@@ -266,18 +268,18 @@ def createRegistration(conn, config):
 		sys.stdout.write("Success\n")
 
 	#  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")
-
+	#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 addInitialConfig(conn, config):
 	sys.stdout.write("    Adding initial configuration info into DB...\n")
@@ -313,7 +315,7 @@ def addInitialConfig(conn, config):
 		#  Get the domainId 
 		domainId = str(checkVal[1][0][0])
 	else:
-		r = execQuery(conn, "INSERT into `domaininfo` (domain_name, domain_desc, reservation_id)
values ('Zoni', 'Zoni Home Domain',1)")
+		r = execQuery(conn, "INSERT into `domaininfo` (domain_name, domain_desc) values ('Zoni',
'Zoni Home Domain')")
 		domainId = str(r.lastrowid)
 		sys.stdout.write("Success\n")
 

Modified: incubator/tashi/branches/cmu/src/zoni/system/registration/register/register_automate
URL: http://svn.apache.org/viewvc/incubator/tashi/branches/cmu/src/zoni/system/registration/register/register_automate?rev=1187632&r1=1187631&r2=1187632&view=diff
==============================================================================
--- incubator/tashi/branches/cmu/src/zoni/system/registration/register/register_automate (original)
+++ incubator/tashi/branches/cmu/src/zoni/system/registration/register/register_automate Sat
Oct 22 01:38:52 2011
@@ -63,17 +63,17 @@ SVC_TAG=$1
 REQUEST=$2
 
 res=""
-if [[ "$REQUEST" == "location" ]]; then
+if [ "$REQUEST" = "location" ]; then
     res=`cat /register_automate | grep -i "^#$SVC_TAG" | awk '{print $2}'`
-elif [[ "$REQUEST" == "switchinfo" ]]; then
+elif [ "$REQUEST" = "switchinfo" ]; then
     res=`cat /register_automate | grep -i "^#$SVC_TAG" | awk '{print $3}'`
-elif [[ "$REQUEST" == "pduinfo" ]]; then
+elif [ "$REQUEST" = "pduinfo" ]; then
     res=`cat /register_automate | grep -i "^#$SVC_TAG" | awk '{print $4}'`
-elif [[ "$REQUEST" == "image" ]]; then
+elif [ "$REQUEST" = "image" ]; then
     res=`cat /register_automate | grep -i "^#$SVC_TAG" | awk '{print $5}'`
 fi
 
-if [[ `echo -n $res | wc -c` -gt 1 ]]; then
+if [ `echo -n $res | wc -c` -gt 1 ]; then
     echo $res
     exit 0
 else

Modified: incubator/tashi/branches/cmu/src/zoni/system/registration/register/register_node
URL: http://svn.apache.org/viewvc/incubator/tashi/branches/cmu/src/zoni/system/registration/register/register_node?rev=1187632&r1=1187631&r2=1187632&view=diff
==============================================================================
--- incubator/tashi/branches/cmu/src/zoni/system/registration/register/register_node (original)
+++ incubator/tashi/branches/cmu/src/zoni/system/registration/register/register_node Sat Oct
22 01:38:52 2011
@@ -23,6 +23,7 @@
 DEBUG () {
 	if [ $VERBOSE ] && [ $VERBOSE -eq 1 ];then 
 		echo DEBUG: $*
+		echo DEBUG: $* >> /tmp/output.log
 	fi
 }
 
@@ -134,7 +135,7 @@ wget -O- "http://${IMAGE_URL}/zoni-regis
 
 #  Get more info either from cheat file or from user entered info
 ec=1
-if [[ -e /register_automate ]]; then
+if [ -e /register_automate ]; then
 	switchinfo=`/register_automate $SYSTEM_SERIAL_NUMBER switchinfo`
 	switchport=$(echo $switchinfo | cut -d ":" -f 2)
 	switch=$(echo $switchinfo | cut -d ":" -f 1)
@@ -159,9 +160,9 @@ fi
 #if [ $val -gt 0 ];then
 
 #  No automate entry found, prompt user for info
-if [[ $ec -ne 0 ]]; then
+if [ $ec -ne 0 ]; then
 	ans=n;
-	while [ $ans == "n" ] || [ $ans == "N" ]; do
+	while [ $ans = "n" ] || [ $ans = "N" ]; do
 		echo -n "Please enter the location/hostname for this node: "
 		read location
 		#echo -n "Please enter the IP address for this node: "

Modified: incubator/tashi/branches/cmu/src/zoni/system/registration/www/include/zoni_functions.php
URL: http://svn.apache.org/viewvc/incubator/tashi/branches/cmu/src/zoni/system/registration/www/include/zoni_functions.php?rev=1187632&r1=1187631&r2=1187632&view=diff
==============================================================================
--- incubator/tashi/branches/cmu/src/zoni/system/registration/www/include/zoni_functions.php
(original)
+++ incubator/tashi/branches/cmu/src/zoni/system/registration/www/include/zoni_functions.php
Sat Oct 22 01:38:52 2011
@@ -21,11 +21,12 @@
 function DEBUG($verbose, $val) {
 	if ($verbose == 1) {
 		if (is_array($val)) {
-			print "DEBUG:";
-			print_r($val);
+			$mesg = "DEBUG: " . print_r($val,true) . "<br>\n";
 		} else {
-			print "DEBUG: $val<br>\n";
+			$mesg = "DEBUG: " . $val . "<br>\n";
+			
 		}
+		file_put_contents("/tmp/zoni_register.log", $mesg, FILE_APPEND);
 
 	}
 }

Modified: incubator/tashi/branches/cmu/src/zoni/system/registration/www/zoni-register.php
URL: http://svn.apache.org/viewvc/incubator/tashi/branches/cmu/src/zoni/system/registration/www/zoni-register.php?rev=1187632&r1=1187631&r2=1187632&view=diff
==============================================================================
--- incubator/tashi/branches/cmu/src/zoni/system/registration/www/zoni-register.php (original)
+++ incubator/tashi/branches/cmu/src/zoni/system/registration/www/zoni-register.php Sat Oct
22 01:38:52 2011
@@ -26,6 +26,7 @@
 	$PYTHONPATH=$G['ZONI_BASE_DIR'] . "/src";
     $verbose = (isset($_GET['verbose'])) ? $_GET['verbose']: 0;
 
+	print "verbose is $verbose";
     DEBUG($verbose, "<pre>");
     DEBUG($verbose, $G);
 
@@ -168,10 +169,9 @@
 			$query .= "chassis_serial_number = '$chassis_serial_number', ";
 			$query .= "system_uuid = '$system_uuid', ";
             $query .= "cpu_flags = '$cpu_flags', ";
-			$query .= "last_update = now() ";
+            $query .= "last_update = now() ";
             $query .= " where system_serial_number = '$system_serial_number'";
             DEBUG($verbose, "<br>query is $query <br>\n");
-			file_put_contents("/tmp/updatequery.txt", $query);
             $result = mysql_query($query)
                 or die('Update system query failed: ' . mysql_error());
 		}
@@ -210,7 +210,6 @@
 	if ($action == "addip") {
 		$query = "update sysinfo set ip_addr = '$ip_addr' where mac_addr = '$mac_addr'";
 		DEBUG($verbose, "addip query is $query <br>\n");
-		#file_put_contents("/tmp/updatequery.txt", $query);
 		$result = $myconn->run_query($query);
 	}
 	#  add the location
@@ -218,7 +217,6 @@
 		$query = "update sysinfo set location = '$location' where mac_addr = '$mac_addr'";
 		#DEBUG($verbose, "addip query is $query <br>\n");
 		print "query is $query";
-		#file_put_contents("/tmp/updatequery.txt", $query);
 		$result = $myconn->run_query($query);
 	}
 
@@ -232,28 +230,30 @@
         DEBUG($verbose, $results);
         $num_rows = $myconn->get_num_rows();
 		DEBUG($verbose, "num rows is $num_rows<br>\n");
+		$sys_id = $myconn->get_sys_id($mac_addr);
+		$allocation_id = $myconn->get_something("allocation_id", "allocationinfo", "sys_id",
$sys_id);
 
         if ($num_rows == 1) {
 			$image_id = $results[0][0];
+			DEBUG($verbose, "imageid is $image_id,m allocation is $allocation_id");
 
-            if ($myconn->check_dup("imagemap", "mac_addr", $mac_addr)) {
+            if ($myconn->check_dup("imagemap", "allocation_id", $allocation_id)) {
                 $query = "delete from imagemap ";
-                $query .= "where mac_addr = '$mac_addr' ";
+                $query .= "where allocation_id = '$allocation_id' ";
+				DEBUG($verbose, "check_dup query is $query");
                 $result = $myconn->run_query($query);
             }
-		}else {
-			$query = "insert into imagemap ";
-			$query .= "(mac_addr, image_id) ";
-			$query .= "values ('$mac_addr', '$image_id')";
-			DEBUG($verbose, "inserting $query<br>\n");
-			$result = $myconn->run_query($query);
 		}
+		$query = "insert into imagemap ";
+		$query .= "(allocation_id, image_id) ";
+		$query .= "values ('$allocation_id', '$image_id')";
+		$result = $myconn->run_query($query);
 
 		$sys_id = $myconn->get_sys_id($mac_addr);
 		$location = $myconn->get_location($sys_id);
 
 		DEBUG($verbose, "creating link in pxe");
-		print shell_exec("cd {$G['ZONI_BASE_DIR']}; sudo ./bin/zoni-cli.py --assignimage $image_name
--nodeName $location");
+		print shell_exec("cd {$G['ZONI_BASE_DIR']}; sudo zoni --assignimage $image_name --nodeName
$location");
 		DEBUG($verbose, "finished linking in pxe");
 	}
 
@@ -378,9 +378,6 @@
 		}
 		DEBUG($verbose, "location is $location");
 		DEBUG($verbose, "doing the dns and dhcp updates");
-		#print shell_exec("cd {$G['ZONI_BASE_DIR']}; sudo ./bin/zoni-cli.py --addDns $location
$ip_addr");
-		#print shell_exec("cd {$G['ZONI_BASE_DIR']}; sudo ./bin/zoni-cli.py --addDhcp $location
$ip_addr $mac_addr");
-		#print "location is " + $location + " and ip is " + $ip_addr;
 		print shell_exec("PYTHONPATH=$PYTHONPATH zoni --addDns $location $ip_addr");
 		print shell_exec("PYTHONPATH=$PYTHONPATH zoni --addDhcp $location $ip_addr $mac_addr");
 	}
@@ -414,7 +411,8 @@
 
 			echo "creating link in pxe";
 			#  Try to use prs to do this...
-			print shell_exec("cd /home/rgass/projects/prs/; sudo ./zoni-client.py --assignimage $next_image
--nodeName $location");
+			#  Old version, need to fix later
+			#print shell_exec("cd /home/rgass/projects/prs/; sudo ./zoni-client.py --assignimage $next_image
--nodeName $location");
 			#print shell_exec("cd /var/www/cluster/scripts/; sudo ./add_pxe_from_db $location");
 			DEBUG($verbose, "finished linking in pxe");
         }



Mime
View raw message