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 st...@apache.org on 2012/02/08 04:44:11 UTC

svn commit: r1241773 [3/3] - in /incubator/tashi/branches/oldstable: ./ etc/ src/ src/tashi/ src/tashi/agents/ src/tashi/client/ src/tashi/clustermanager/ src/tashi/clustermanager/data/ src/tashi/nodemanager/ src/tashi/nodemanager/vmcontrol/ src/tashi/...

Modified: incubator/tashi/branches/oldstable/src/zoni/hardware/delldrac.py
URL: http://svn.apache.org/viewvc/incubator/tashi/branches/oldstable/src/zoni/hardware/delldrac.py?rev=1241773&r1=1241772&r2=1241773&view=diff
==============================================================================
--- incubator/tashi/branches/oldstable/src/zoni/hardware/delldrac.py (original)
+++ incubator/tashi/branches/oldstable/src/zoni/hardware/delldrac.py Wed Feb  8 04:44:09 2012
@@ -22,46 +22,26 @@ import sys
 import os 
 import pexpect
 import time
+import logging
+import tempfile
 
 from systemmanagementinterface import SystemManagementInterface
-
-
-#class systemmagement():
-	#def __init__(self, proto):
-		#self.proto = proto
-
-def log(f):
-	def myF(*args, **kw):
-		print "calling %s%s" % (f.__name__, str(args))
-		res = f(*args, **kw)
-		print "returning from %s -> %s" % (f.__name__, str(res))
-		return res
-	myF.__name__ = f.__name__
-	return myF
-
-import time
-
-def timeF(f):
-	def myF(*args, **kw):
-		start = time.time()
-		res = f(*args, **kw)
-		end = time.time()
-		print "%s took %f" % (f.__name__, end-start)
-		return res
-	myF.__name__ = f.__name__
-	return myF
+from zoni.extra.util import timeF, log
 
 
 class dellDrac(SystemManagementInterface):
-	def __init__(self, host):
-		self.hostname = host['location']
-		self.host = host['drac_name']
-		self.user = host['drac_userid']
-		self.password = host['drac_password']
-		self.port = host['drac_port']
+	def __init__(self, config, nodeName, hostInfo):
+		self.config = config
+		self.nodeName = nodeName
+		self.hostname = hostInfo['location']
+		self.host = hostInfo['drac_name']
+		self.user = hostInfo['drac_userid']
+		self.password = hostInfo['drac_password']
+		self.port = hostInfo['drac_port']
 		self.powerStatus = None
-		self.verbose = 0
+		self.verbose = False
 		self.server = "Server-" + str(self.port)
+		self.log = logging.getLogger(__name__)
 
 	def setVerbose(self, verbose):
 		self.verbose = verbose
@@ -75,50 +55,42 @@ class dellDrac(SystemManagementInterface
 
 		opt = child.expect(['Login:',  pexpect.EOF, pexpect.TIMEOUT])
 
-
-		#XXX  Doesn't seem to do what I want:(
 		child.setecho(False)
 		if opt == 0:
-			child.sendline(self.user)
 			time.sleep(.5)
+			child.sendline(self.user)
+			i=child.expect(["assword:", pexpect.EOF, pexpect.TIMEOUT])
 			child.sendline(self.password)
-			time.sleep(.5)
 			i=child.expect(['DRAC/MC:', pexpect.EOF, pexpect.TIMEOUT])
+			if i == 2:
+				self.log.error("Login to %s failed" % (switchIp))
+				return -1
 		else:
 			mesg = "Error"
-			sys.stderr.write(mesg)
-			exit(1)
+			self.log.error(mesg)
+			return -1
 
 		return child
 
 	@timeF
-	@log
-	def getPowerStatus(self):
+	def __setPowerStatus(self):
+		fout = tempfile.TemporaryFile()
 		child = self.__login()
+		child.logfile = fout
 		cmd = "getmodinfo -m " + self.server
 		child.sendline(cmd)
-		#i=child.expect(['DRAC/MC:', pexpect.EOF, pexpect.TIMEOUT])
-		#exit()
-		val = child.readline()
-		val = child.readline()
-		while self.server not in val:
-			val = child.readline()
-
-		if "ON" in val:
-			mesg = self.hostname + " Power is on\n\n"
-			self.powerStatus = 1
-		if "OFF" in val:
-			mesg = self.hostname + " Power is off\n\n"
-			self.powerStatus = 0
-
-		sys.stdout.write(mesg)
-
-		#while status not in val:
-			#val = child.readline()
-		#
-		#print "val for", status, "is ", val
-		#i=child.expect(['DRAC/MC:', pexpect.EOF, pexpect.TIMEOUT])
-		#val = child.readlines()
+		i=child.expect(['DRAC/MC:', pexpect.EOF, pexpect.TIMEOUT])
+		fout.seek(0)
+		for i in fout.readlines():
+			if "ON" in i and self.server in i:
+				mesg = self.hostname + " Power is on\n\n"
+				self.powerStatus = 1
+			if "OFF" in i and self.server in i:
+				mesg = self.hostname + " Power is off\n\n"
+				self.powerStatus = 0
+		self.log.info(mesg)
+
+		fout.close()
 		child.close()
 		child.terminate()
 
@@ -126,76 +98,128 @@ class dellDrac(SystemManagementInterface
 	@timeF
 	def isPowered(self):
 		if self.powerStatus == None:
-			self.getPowerStatus()
+			self.__setPowerStatus()
 		if self.powerStatus:
-			return 1;
-		if not self.powerStatus:
 			return 0;
+		return 1;
 	
+	def getPowerStatus(self):
+		return self.isPowered()
 
 	@timeF
 	def powerOn(self):
+		code = 0
+		fout = tempfile.TemporaryFile()
 		if self.powerStatus == 1:
-			mesg = self.hostname + " Power On\n\n"
-			exit(1)
+			self.log.info("Hardware power on : %s", self.hostname)
+			return 1
 			
 		child = self.__login()
+		child.logfile = fout
 		cmd = "racadm serveraction -m " +  self.server + " powerup"
 		child.sendline(cmd)
-		val = child.readline()
-		val = child.readline()
-		if "OK" in val:
-			mesg = self.hostname + " Power On\n\n"
-		else:
-			mesg = self.hostname + " Power On Fail\n\n"
-		sys.stdout.write(mesg)
-		#i=child.expect(['DRAC/MC:', pexpect.EOF, pexpect.TIMEOUT])
+		i=child.expect(['DRAC/MC:', pexpect.EOF, pexpect.TIMEOUT])
+		fout.seek(0)
+		self.log.info("Hardware power on : %s", self.hostname)
+		for val in fout.readlines():
+			if "OK" in val:
+				code = 1 
+			if "ALREADY POWER-ON" in val:
+				code = 1 
+				self.log.info("Hardware already powered on : %s", self.hostname)
+		if code < 1:
+			self.log.info("Hardware power on failed : %s", self.hostname)
+		fout.close()
 		child.terminate()
+		return code
 
 	@timeF
 	def powerOff(self):
+		code = 0
+		fout = tempfile.TemporaryFile()
 		child = self.__login()
+		child.logfile = fout
 		cmd = "racadm serveraction -m " + self.server + " powerdown"
 		child.sendline(cmd)
-		val = child.readline()
-		val = child.readline()
-		if "OK" in val:
-			mesg = self.hostname + " Power Off\n\n"
-		else:
-			mesg = self.hostname + " Power Off Fail\n\n"
-		sys.stdout.write(mesg)
-		#i=child.expect(['DRAC/MC:', pexpect.EOF, pexpect.TIMEOUT])
+		i=child.expect(['DRAC/MC:', pexpect.EOF, pexpect.TIMEOUT])
+		fout.seek(0)
+		self.log.info("Hardware power off : %s", self.hostname)
+		for val in fout.readlines():
+			if "OK" in val:
+				code = 1
+ 			if "CURRENTLY POWER-OFF" in val:
+				self.log.info("Hardware already power off : %s", self.hostname)
+				code = 1
+		if code < 1:
+			self.log.info("Hardware power off failed : %s", self.hostname)
+		child.terminate()
+		fout.close()
+		return code
+
+	@timeF
+	def powerOffSoft(self):
+		code = 0
+		fout = tempfile.TemporaryFile()
+		child = self.__login()
+		child.logfile = fout
+		cmd = "racadm serveraction -m " + self.server + " graceshutdown"
+		child.sendline(cmd)
+		i=child.expect(['DRAC/MC:', pexpect.EOF, pexpect.TIMEOUT])
+		fout.seek(0)
+		self.log.info("Hardware power off (soft): %s", self.hostname)
+
+		for val in fout.readlines():
+			if "OK" in val:
+				code = 1
+ 			if "CURRENTLY POWER-OFF" in val:
+				self.log.info("Hardware already power off : %s", self.hostname)
+				code = 1
+		if code < 1:
+			self.log.info("Hardware power off failed : %s", self.hostname)
 		child.terminate()
+		fout.close()
+		return code
 
 	@timeF
 	def powerCycle(self):
+		code = 0
+		fout = tempfile.TemporaryFile()
 		child = self.__login()
+		child.logfile = fout
 		cmd = "racadm serveraction -m " + self.server + " powercycle"
 		child.sendline(cmd)
-		val = child.readline()
-		val = child.readline()
-		if "OK" in val:
-			mesg = self.hostname + " Power Cycle\n\n"
-		else:
-			mesg = self.hostname + " Power Cycle Fail\n\n"
-		sys.stdout.write(mesg)
-		#i=child.expect(['DRAC/MC:', pexpect.EOF, pexpect.TIMEOUT])
+		i=child.expect(['DRAC/MC:', pexpect.EOF, pexpect.TIMEOUT])
+		fout.seek(0)
+		self.log.info("Hardware power cycle : %s", self.hostname)
+		for val in fout.readlines():
+			if "OK" in val:
+				code = 1
+		if code < 1:
+			self.log.info("Hardware power cycle failed : %s", self.hostname)
 		child.terminate()
+		fout.close()
+		return code
 		
 	@timeF
 	def powerReset(self):
+		code = 0
+		fout = tempfile.TemporaryFile()
 		child = self.__login()
+		child.logfile = fout
 		cmd = "racadm serveraction -m " + self.server + " hardreset"
 		child.sendline(cmd)
-		val = child.readline()
-		val = child.readline()
-		if "OK" in val:
-			mesg = self.hostname + " Power Reset\n\n"
-		else:
-			mesg = self.hostname + " Power Reset Fail\n\n"
-		sys.stdout.write(mesg)
-		#i=child.expect(['DRAC/MC:', pexpect.EOF, pexpect.TIMEOUT])
+		i=child.expect(['DRAC/MC:', pexpect.EOF, pexpect.TIMEOUT])
+		fout.seek(0)
+		for val in fout.readlines():
+			if "OK" in val:
+				self.log.info("Hardware power reset : %s", self.nodeName)
+				code = 1
+		if code < 1:
+			self.log.info("Hardware power reset fail: %s", self.nodeName)
+
 		child.terminate()
+		fout.close()
+		return code
 		
 	def activateConsole(self):
 		child = self.__login()
@@ -203,5 +227,3 @@ class dellDrac(SystemManagementInterface
 		child.sendline(cmd)
 		i=child.expect(['DRAC/MC:', pexpect.EOF, pexpect.TIMEOUT])
 		child.terminate()
-		
-#ipmitool -I lanplus -E -H r2r1c3b0-ipmi -U root chassis power status

Propchange: incubator/tashi/branches/oldstable/src/zoni/hardware/delldrac.py
            ('svn:mergeinfo' removed)

Modified: incubator/tashi/branches/oldstable/src/zoni/hardware/dellswitch.py
URL: http://svn.apache.org/viewvc/incubator/tashi/branches/oldstable/src/zoni/hardware/dellswitch.py?rev=1241773&r1=1241772&r2=1241773&view=diff
==============================================================================
--- incubator/tashi/branches/oldstable/src/zoni/hardware/dellswitch.py (original)
+++ incubator/tashi/branches/oldstable/src/zoni/hardware/dellswitch.py Wed Feb  8 04:44:09 2012
@@ -35,6 +35,7 @@ from zoni.data.resourcequerysql import *
 from zoni.hardware.hwswitchinterface import HwSwitchInterface
 from zoni.data.resourcequerysql import ResourceQuerySql
 from zoni.agents.dhcpdns import DhcpDns
+from zoni.extra.util import *
 
 
 '''  Using pexpect to control switches because couldn't get snmp to work 
@@ -47,20 +48,39 @@ class HwDellSwitch(HwSwitchInterface):
 		self.verbose = False
 		self.log = logging.getLogger(os.path.basename(__file__))
 
+		try:
+			self.switchModel = host['hw_model']
+		except:
+			pass
+
 
  	def setVerbose(self, verbose):
 		self.verbose = verbose
 
 	def __login(self):
-		
-		switchIp = "ssh " +  self.host['hw_userid'] + "@" + self.host['hw_name']
+		# ssh
+		if self.config['hardwareControl']['dellswitch']['accessmode'] == "ssh":
+			switchIp = "ssh " +  self.host['hw_userid'] + "@" + self.host['hw_name']
+		# telnet 
+		else:
+			switchIp = "telnet " +  self.host['hw_name'] 
+
+
+
 		child = pexpect.spawn(switchIp)
 
 		#  Be Verbose and print everything
 		if self.verbose:
 			child.logfile = sys.stdout
 
-		opt = child.expect(['Name:', 'assword:', 'Are you sure.*', pexpect.EOF, pexpect.TIMEOUT])
+		opt = child.expect(['Name:', 'assword:', 'Are you sure.*', 'User:', 'No route to host', pexpect.EOF, pexpect.TIMEOUT])
+
+		#  Unable to connect
+		if opt == 4:
+			mesg = "ERROR:  Login to %s failed\n" % (self.host['hw_name'])
+			self.log.error(mesg)
+			exit(1)
+			
 		#XXX  Doesn't seem to do what I want:(
 		child.setecho(False)
 
@@ -69,11 +89,11 @@ class HwDellSwitch(HwSwitchInterface):
 			child.sendline("yes")
 			opt = child.expect(['Name:', 'assword:', 'Are you sure.*', pexpect.EOF, pexpect.TIMEOUT])
 			
-		if opt == 0:
+		if opt == 0 or opt == 3:
 			child.sendline(self.host['hw_userid'])
 			i = child.expect(['assword:', 'Connection',  pexpect.EOF, pexpect.TIMEOUT])
 			child.sendline(self.host['hw_password'])
-			i=child.expect(['console','#', 'Name:', pexpect.EOF, pexpect.TIMEOUT])
+			i=child.expect(['console','#', 'Name:', '>',pexpect.EOF, pexpect.TIMEOUT])
 			if i == 2:
 				mesg = "ERROR:  Login to %s failed\n" % (self.host['hw_name'])
 				self.log.error(mesg)
@@ -84,36 +104,62 @@ class HwDellSwitch(HwSwitchInterface):
 			child.sendline(self.host['hw_password'])
 			i=child.expect(['console','>', 'Name:', pexpect.EOF, pexpect.TIMEOUT])
 			#  on the 6448 dell, need to send enable, just send to all
+		
+		if opt == 1 or opt == 3:
 			child.sendline('enable')
 			i=child.expect(['#', pexpect.EOF, pexpect.TIMEOUT])
 
-
 		return child
 
 	def __getPrsLabel(self):
 		dadate = datetime.datetime.now().strftime("%Y%m%d-%H%M-%S")
-		return "PRS_" + dadate
+		return "Zoni_" + dadate
+
+	def __genPortName(self, port):
+		if "62" in self.switchModel:
+			return "1/g%s" % str(port)
+		elif "54" in self.switchModel:
+			return "g%s" % str(port)
+		else:
+			return "g%s" % str(port)
 
+	def labelPort(self, desc=None):
+		mydesc = "%s-%s" % (self.host['location'], desc)
+		if desc == None or desc == " ":
+			mydesc = "%s" % (self.host['location'])
+		child = self.__login()
+		child.sendline('config')
+		portname = self.__genPortName(self.host['hw_port'])
+		cmd = "interface ethernet %s" % str(portname)
+		child.sendline(cmd)
+		cmd = "description \"%s\"" % mydesc
+		child.sendline(cmd)
+		child.sendline('exit')
+		child.terminate()
 	
 	def enableHostPort(self):
 		child = self.__login()
 		child.sendline('config')
-		cmd = "interface ethernet g" + str(self.host['hw_port'])
+		portname = self.__genPortName(self.host['hw_port'])
+		cmd = "interface ethernet %s" % str(portname)
 		child.sendline(cmd)
 		cmd = "no shutdown" 
 		child.sendline(cmd)
 		child.sendline('exit')
 		child.terminate()
+		self.log.info("Host port enabled %s:%s" % (self.host['hw_name'], self.host['hw_port']))
 		
 	def disableHostPort(self):
 		child = self.__login()
 		child.sendline('config')
-		cmd = "interface ethernet g" + str(self.host['hw_port'])
+		portname = self.__genPortName(self.host['hw_port'])
+		cmd = "interface ethernet %s" % str(portname)
 		child.sendline(cmd)
 		cmd = "shutdown"
 		child.sendline(cmd)
 		child.sendline('exit')
 		child.terminate()
+		self.log.info("Host port disabled %s:%s" % (self.host['hw_name'], self.host['hw_port']))
 
 	def removeVlan(self, num):
 		#  Check for important vlans
@@ -125,6 +171,7 @@ class HwDellSwitch(HwSwitchInterface):
 		child.sendline(cmd)
 		child.sendline('exit')
 		child.terminate()
+		self.log.info("Vlan %s removed from switch %s" % (num, self.host['hw_name']))
 	
 	def addVlanToTrunk(self, vlan):
 		mesg = "Adding Vlan %s to trunks on switch" % (vlan)
@@ -140,11 +187,8 @@ class HwDellSwitch(HwSwitchInterface):
 
 	def createVlansThread(self, vlan, switch,host):
 		mesg = "Creating vlan %s on switch %s" % (str(vlan),str(switch))
-		print "host is ", host
 		self.log(mesg)
-		print "create"
 		self.createVlan(vlan)
-		print "cend"
 		self.addVlanToTrunk(vlan);
 		thread.exit()
 
@@ -225,27 +269,37 @@ class HwDellSwitch(HwSwitchInterface):
 		#child.interact(escape_character='\x1d', input_filter=None, output_filter=None)
 
 		child.terminate()
-		#print "before", child.before
-		#print "after", child.after
 
-	def addNodeToVlan(self, vlan):
-		mesg = "Adding Node to vlan %s" % (str(vlan))
+	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)
 		
 		child = self.__login()
 		child.sendline('config')
-		cmd = "interface ethernet g" + str(self.host['hw_port'])
+		portname = self.__genPortName(self.host['hw_port'])
+		cmd = "interface ethernet %s" % str(portname)
 		child.sendline(cmd)
 		child.expect(["config-if", pexpect.EOF])
-		cmd = "switchport trunk allowed vlan add " + vlan
+		#cmd = "switchport trunk allowed vlan add " + vlan
+		cmd = "switchport mode general"
+		child.sendline(cmd)
+		cmd = "switchport general allowed vlan add %s %s" % (str(vlan), str(tag))
 		child.sendline(cmd)
-		child.sendline('exit')
 
 		NOVLAN = "VLAN was not created by user."
-		i=child.expect(['config-if',NOVLAN, pexpect.EOF, pexpect.TIMEOUT])
+		#  XXX this has problems with 62xx switches.  Need to catch the error if a vlan doesn't exist. 
+		#  Currently you can leave out the 'config-if' and it will work but will require you to wait for 
+		#  the timeout when you finally create and add the node to the vlan.  Leaving out support for 62xx switches
+		#  for now.
+		NOVLAN62 = "ERROR"
+		i=child.expect(['config-if',NOVLAN, NOVLAN62, pexpect.EOF, pexpect.TIMEOUT])
 		#  Vlan must exist in order to add a host to it.  
 		#  If it doesn't exist, try to create it
-		if i == 1:
+		if i == 1 or i == 2:
 			self.log.warning("WARNING:  Vlan %sdoesn't exist, trying to create" % (vlan))
 			#  Add a tag showing this was created by PRS
 			newvlan = vlan + ":" + self.__getPrsLabel()
@@ -257,13 +311,14 @@ class HwDellSwitch(HwSwitchInterface):
 		child.terminate()
 
 	def removeNodeFromVlan(self, vlan):
-		mesg = "Removing Node from vlan %s" % (str(vlan))
+		mesg = "Removing switchport (%s:%s) from vlan %s" % (str(self.host['hw_name']), str(self.host['hw_port']), str(vlan))
 		self.log.info(mesg)
 		child = self.__login()
 		child.sendline('config')
-		cmd = "interface ethernet g" + str(self.host['hw_port'])
+		portname = self.__genPortName(self.host['hw_port'])
+		cmd = "interface ethernet %s" % str(portname)
 		child.sendline(cmd)
-		cmd = "switchport trunk allowed vlan remove " + vlan
+		cmd = "switchport general allowed vlan remove " + vlan
 		child.sendline(cmd)
 		child.sendline('exit')
 		child.sendline('exit')
@@ -282,19 +337,37 @@ class HwDellSwitch(HwSwitchInterface):
 			##self.createVlan(newvlan)
 			##self.setNativeVlan(vlan)
 			
+	def setPortMode (self, mode):
+		child = self.__login()
+		child.logfile = sys.stdout
+		child.sendline('config')
+		portname = self.__genPortName(self.host['hw_port'])
+		cmd = "interface ethernet %s" % str(portname)
+		child.sendline(cmd)
+		i=child.expect(['config-if', pexpect.EOF, pexpect.TIMEOUT])
+		if i > 0:
+			self.log.error("setPortMode %s failed" % (cmd))
+
+		cmd = "switchport mode %s" % mode
+		child.sendline(cmd)
+		i=child.expect(['config-if', pexpect.EOF, pexpect.TIMEOUT])
+		child.sendline('exit')
+		child.sendline('exit')
+		child.terminate()
 
 	def setNativeVlan(self, vlan):
 		child = self.__login()
 		child.logfile = sys.stdout
 		child.sendline('config')
-		cmd = "interface ethernet g" + str(self.host['hw_port'])
+		portname = self.__genPortName(self.host['hw_port'])
+		cmd = "interface ethernet %s" % str(portname)
 		child.sendline(cmd)
 		i=child.expect(['config-if', pexpect.EOF, pexpect.TIMEOUT])
 		if i > 0:
 			self.log.error("setNativeVlan %s failed" % (cmd))
 
 		NOVLAN = "VLAN was not created by user."
-		cmd = "switchport trunk native vlan " + vlan
+		cmd = "switchport general pvid " + vlan
 		child.sendline(cmd)
 		i=child.expect(['config-if', NOVLAN, pexpect.EOF, pexpect.TIMEOUT])
 		#  Vlan must exist in order to add a host to it.  
@@ -311,19 +384,22 @@ class HwDellSwitch(HwSwitchInterface):
 		child.terminate()
 
 	#  Restore Native Vlan.  In Dell's case, this is vlan 1
-	def restoreNativeVlan(self):
-		child = self.__login()
-		child.sendline('config')
-		cmd = "interface ethernet g" + str(self.host['hw_port'])
-		child.sendline(cmd)
-		cmd = "switchport trunk native vlan 1"
-		child.sendline(cmd)
-		child.sendline('exit')
-		child.sendline('exit')
+	#  Removing this 
+	#def restoreNativeVlan(self):
+		#child = self.__login()
+		#child.sendline('config')
+		#portname = self.__genPortName(self.host['hw_port'])
+		#cmd = "interface ethernet %s" % str(portname)
+		#child.sendline(cmd)
+		##cmd = "switchport trunk native vlan 1"
+		#cmd = "switchport general pvid 1"
+		#child.sendline(cmd)
+		#child.sendline('exit')
+		#child.sendline('exit')
+		##child.terminate()
 		#child.terminate()
-		child.terminate()
 
-	#  Setup the switch for node allocation
+	##  Setup the switch for node allocation
 	def allocateNode(self):
 		pass
 
@@ -332,7 +408,8 @@ class HwDellSwitch(HwSwitchInterface):
 		child = self.__login()
 		child.logfile = sys.stdout
 		child.sendline('config')
-		cmd = "interface ethernet g" + str(self.host['hw_port'])
+		portname = self.__genPortName(self.host['hw_port'])
+		cmd = "interface ethernet %s" % str(portname)
 		child.sendline(cmd)
 		i=child.expect(['config-if', pexpect.EOF, pexpect.TIMEOUT])
 		if i > 0:
@@ -358,9 +435,16 @@ class HwDellSwitch(HwSwitchInterface):
 		print "NODE   - " + self.host['location']
 		print "------------------------------------\n"
 		child.logfile = sys.stdout
-		cmd = "show interface switchport ethernet g" + str(self.host['hw_port'])
+		
+		portname = self.__genPortName(self.host['hw_port'])
+
+		cmd = "show interface switchport ethernet %s" % str(portname)
 		child.sendline(cmd)
-		i = child.expect(['#', pexpect.EOF, pexpect.TIMEOUT])
+		i = child.expect(['#','--More--', pexpect.EOF, pexpect.TIMEOUT])
+		#  send a space for more
+		while i == 1:
+			child.sendline(" ")
+			i = child.expect(['#','--More--', pexpect.EOF, pexpect.TIMEOUT])
 		child.terminate()
 
 	def interactiveSwitchConfig(self):
@@ -373,8 +457,26 @@ class HwDellSwitch(HwSwitchInterface):
 		#child.logfile = sys.stdout
 		child.sendline(self.host['hw_password'])
 		child.interact(escape_character='\x1d', input_filter=None, output_filter=None)
+
+	def saveConfig(self, switch, query):
+		self.host = query.getSwitchInfo(switch)
+		child = self.__login()
+		cmd = "copy running-config startup-config"
+		child.sendline(cmd)
+		i = child.expect(['y/n', pexpect.EOF, pexpect.TIMEOUT])
+		child.sendline("y")
+		child.terminate()
+
+	def __saveConfig(self):
+		cmd = "copy running-config startup-config"
+		child.sendline(cmd)
+		i = child.expect(['y/n', pexpect.EOF, pexpect.TIMEOUT])
+		child.sendline("y")
+		child.terminate()
+
 	
 	def registerToZoni(self, user, password, host):
+		self.setVerbose(True)
 		host = string.strip(str(host))
 		#  Get hostname of the switch
 		if len(host.split(".")) == 4:
@@ -395,33 +497,12 @@ class HwDellSwitch(HwSwitchInterface):
 				self.log.critical(mesg)
 				exit()
 
-		switchIp = "ssh " + user + "@" + ip
-		child = pexpect.spawn(switchIp)
-		opt = child.expect(['Name:', 'assword:', 'Are you sure.*', pexpect.EOF, pexpect.TIMEOUT])
-		#XXX  Doesn't seem to do what I want:(
-		child.setecho(False)
-
-		#  Send a yes to register authenticity of host for ssh
-		if opt == 2:
-			child.sendline("yes")
-			opt = child.expect(['Name:', 'assword:', 'Are you sure.*', pexpect.EOF, pexpect.TIMEOUT])
-			
-		if opt == 0:
-			child.sendline(user)
-			i = child.expect(['assword:', 'Connection',  pexpect.EOF, pexpect.TIMEOUT])
-			child.sendline(password)
-			i=child.expect(['console',host, 'Name:', pexpect.EOF, pexpect.TIMEOUT])
-			if i == 2:
-				mesg = "Login to switch %s failed" % (host)
-				self.log.error(mesg)
-				exit(1)
-
-		if opt == 1:
-			child.sendline(password)
-			i=child.expect(['console',host, 'Name:', pexpect.EOF, pexpect.TIMEOUT])
-			#  on the 6448 dell, need to send enable, just send to all
-			child.sendline('enable')
-			i=child.expect(['#', pexpect.EOF, pexpect.TIMEOUT])
+		#  log into the switch
+		self.host = {}
+		self.host['hw_userid'] = user
+		self.host['hw_name'] = host
+		self.host['hw_password'] = password
+		child = self.__login()
 
 		fout = tempfile.TemporaryFile()
 		child.logfile = fout
@@ -429,10 +510,11 @@ class HwDellSwitch(HwSwitchInterface):
 		cmd = "show system"
 		child.sendline(cmd)
 		val = host + "#"
-		i = child.expect([val, '\n\r\n\r', pexpect.EOF, pexpect.TIMEOUT])
+		tval = host + ">"
+		i = child.expect([val, tval, '\n\r\n\r', "--More--",  pexpect.EOF, pexpect.TIMEOUT])
 		cmd = "show version"
 		child.sendline(cmd)
-		i = child.expect([val, '\n\r\n\r', pexpect.EOF, pexpect.TIMEOUT])
+		i = child.expect([val, tval, '\n\r\n\r', pexpect.EOF, pexpect.TIMEOUT])
 
 		fout.seek(0)
 		a={}
@@ -441,10 +523,11 @@ class HwDellSwitch(HwSwitchInterface):
 				datime = time.strftime("%a, %d %b %Y %H:%M:%S +0000", time.localtime())
 				val = "Registered by Zoni on : " + datime
 				a['hw_notes'] = val + "; " + string.strip(i.split(':', 1)[1])
-			if "System MAC" in i:
-				a['hw_mac'] = string.strip(i.split(':', 1)[1])
-			if "SW version" in i:
-				a['hw_version_sw'] = string.strip(i.split('   ')[1].split()[0])
+			if "MAC" in i:
+				a['hw_mac'] = normalizeMac(string.strip(i.split(":", 1)[1]))
+			#  moving this capture to snmp 
+			#if "SW version" in i:
+				#a['hw_version_sw'] = string.strip(i.split('   ')[1].split()[0])
 			if "HW version" in i:
 				a['hw_version_fw'] = string.strip(i.split('   ')[1].split()[0])
 				
@@ -468,12 +551,19 @@ class HwDellSwitch(HwSwitchInterface):
 		cmdgen.CommunityData('my-agent', user, 0), \
 		cmdgen.UdpTransportTarget((host, 161)), oid)
 		a['hw_model'] = str(varBinds[0][1])
+
 		oid = eval("1,3,6,1,4,1,674,10895,3000,1,2,100,3,0")
 		errorIndication, errorStatus, errorIndex, varBinds = cmdgen.CommandGenerator().getCmd( \
 		cmdgen.CommunityData('my-agent', user, 0), \
 		cmdgen.UdpTransportTarget((host, 161)), oid)
 		a['hw_make'] = str(varBinds[0][1])
 
+		oid = eval("1,3,6,1,4,1,674,10895,3000,1,2,100,4,0")
+		errorIndication, errorStatus, errorIndex, varBinds = cmdgen.CommandGenerator().getCmd( \
+		cmdgen.CommunityData('my-agent', user, 0), \
+		cmdgen.UdpTransportTarget((host, 161)), oid)
+		a['hw_version_sw'] = str(varBinds[0][1])
+
 		#  Register in dns
 		if self.config['dnsEnabled']:
 			try:

Propchange: incubator/tashi/branches/oldstable/src/zoni/hardware/dellswitch.py
            ('svn:mergeinfo' removed)

Propchange: incubator/tashi/branches/oldstable/src/zoni/hardware/hpswitch.py
            ('svn:mergeinfo' removed)

Modified: incubator/tashi/branches/oldstable/src/zoni/hardware/hwswitchinterface.py
URL: http://svn.apache.org/viewvc/incubator/tashi/branches/oldstable/src/zoni/hardware/hwswitchinterface.py?rev=1241773&r1=1241772&r2=1241773&view=diff
==============================================================================
--- incubator/tashi/branches/oldstable/src/zoni/hardware/hwswitchinterface.py (original)
+++ incubator/tashi/branches/oldstable/src/zoni/hardware/hwswitchinterface.py Wed Feb  8 04:44:09 2012
@@ -48,7 +48,7 @@ class HwSwitchInterface(object):
 	def createVlan(self, vlan):
 		raise NotImplementedError
 
-	def addNode2Vlan(self, vlan):
+	def addNode2Vlan(self, vlan, taginfo):
 		raise NotImplementedError
 
 	def removeNodeFromVlan(self, vlan):

Propchange: incubator/tashi/branches/oldstable/src/zoni/hardware/hwswitchinterface.py
            ('svn:mergeinfo' removed)

Modified: incubator/tashi/branches/oldstable/src/zoni/hardware/ipmi.py
URL: http://svn.apache.org/viewvc/incubator/tashi/branches/oldstable/src/zoni/hardware/ipmi.py?rev=1241773&r1=1241772&r2=1241773&view=diff
==============================================================================
--- incubator/tashi/branches/oldstable/src/zoni/hardware/ipmi.py (original)
+++ incubator/tashi/branches/oldstable/src/zoni/hardware/ipmi.py Wed Feb  8 04:44:09 2012
@@ -20,6 +20,9 @@
 
 import sys
 import os 
+import subprocess
+import logging
+import string
 
 from systemmanagementinterface import SystemManagementInterface
 
@@ -29,77 +32,91 @@ from systemmanagementinterface import Sy
 		#self.proto = proto
 
 class Ipmi(SystemManagementInterface):
-	def __init__(self, host, user, password):
-		self.host = host + "-ipmi"
-		self.password = password
-		self.user = user
+	def __init__(self, config, nodeName, hostInfo):
+		#  should send data obj instead of hostInfo
+		self.config = config
+		self.nodeName = nodeName + "-ipmi"
+		self.password = hostInfo['ipmi_password']
+		self.user = hostInfo['ipmi_user']
 		self.powerStatus = None
 		self.verbose = False
-		self.ipmicmd = "ipmitool -I lanplus -U" + self.user + " -H" + self.host + \
-						" -P " + self.password  + " "
+		self.log = logging.getLogger(__name__)
+		self.ipmicmd = "ipmitool -I lanplus -U %s -H %s -P %s " % (self.user, self.nodeName, self.password)
+		print self.ipmicmd
 		
 
 	def setVerbose(self, verbose):
 		self.verbose = verbose
 
-	def getPowerStatus(self):
+	def __executeCmd(self, cmd):
+		a = subprocess.Popen(args=cmd.split(), stderr=subprocess.PIPE, stdout=subprocess.PIPE)
+		out=  a.stdout.readline()
+		err =  a.stderr.readline()
+		if self.verbose:
+			print "out is ", out
+			print "err is ", err
+		if err:
+			self.log.info("%s %s" % (self.nodeName, err))
+			return -1
+			
+		self.log.info("%s %s" % (self.nodeName, out))
+		return 1
+
+
+	def __setPowerStatus(self):
 		if self.verbose:
 			print self.ipmicmd
 		cmd = self.ipmicmd + "chassis power status"
-		a = os.popen(cmd)
-		output = a.read()
-
-		print "%s\n%s" % (self.host, output)
+		a = subprocess.Popen(args=cmd.split(), stderr=subprocess.PIPE, stdout=subprocess.PIPE)
+		output = a.stdout.readline()
+		myerr = a.stderr.readline()
+	
 		if "off" in output:
 			self.powerStatus = 0
 		if "on" in output:
 			self.powerStatus = 1
-		if "Unable" in output:
-			print "unable to get the status"
-			self.powerStatus = 0
-	
+		if "Unable" in myerr:
+			self.powerStatus = -1
+
 		return output
-		#return a.read()
-		#for line in a.readlines():
-			#print line 	
 
 	def isPowered(self):
 		if self.powerStatus == None:
-			self.getPowerStatus()
-		if self.powerStatus:
-			return 1;
-		if not self.powerStatus:
-			return 0;
+			self.__setPowerStatus()
+		self.log.info("Hardware get power status : %s", self.powerStatus)
+		return self.powerStatus
+
+	def getPowerStatus(self):
+		#self.log.info("getPowerStatus :%s" % self.nodeName)
+		return self.isPowered()
 	
 
 	def powerOn(self):
+		self.log.info("Hardware power on : %s", self.nodeName)
 		cmd = self.ipmicmd + "chassis power on"
-		a = os.popen(cmd)
-		output = a.read()
-		print "output is ", output
+		return self.__executeCmd(cmd)
 
 	def powerOff(self):
+		self.log.info("Hardware power off : %s", self.nodeName)
 		cmd = self.ipmicmd + "chassis power off"
-		a = os.popen(cmd)
-		output = a.read()
-		print "output is ", output
+		return self.__executeCmd(cmd)
+
+	def powerOffSoft(self):
+		self.log.info("Hardware power off (soft): %s", self.nodeName)
+		cmd = self.ipmicmd + "chassis power soft"
+		return self.__executeCmd(cmd)
 
 	def powerCycle(self):
+		self.log.info("Hardware power cycle : %s", self.nodeName)
 		cmd = self.ipmicmd + "chassis power cycle"
-		a = os.popen(cmd)
-		output = a.read()
-		print "output is ", output
+		return self.__executeCmd(cmd)
 		
 	def powerReset(self):
+		self.log.info("Hardware power reset : %s", self.nodeName)
 		cmd = self.ipmicmd + "chassis power reset"
-		a = os.popen(cmd)
-		output = a.read()
-		print "output is ", output
+		return self.__executeCmd(cmd)
 		
 	def activateConsole(self):
+		self.log.info("Hardware sol activate : %s", self.nodeName)
 		cmd = self.ipmicmd + "sol activate"
-		a = os.popen(cmd)
-		output = a.read()
-		print "output is ", output
-		
-#ipmitool -I lanplus -E -H r2r1c3b0-ipmi -U root chassis power status
+		return self.__executeCmd(cmd)

Propchange: incubator/tashi/branches/oldstable/src/zoni/hardware/ipmi.py
            ('svn:mergeinfo' removed)

Modified: incubator/tashi/branches/oldstable/src/zoni/hardware/raritanpdu.py
URL: http://svn.apache.org/viewvc/incubator/tashi/branches/oldstable/src/zoni/hardware/raritanpdu.py?rev=1241773&r1=1241772&r2=1241773&view=diff
==============================================================================
--- incubator/tashi/branches/oldstable/src/zoni/hardware/raritanpdu.py (original)
+++ incubator/tashi/branches/oldstable/src/zoni/hardware/raritanpdu.py Wed Feb  8 04:44:09 2012
@@ -37,18 +37,20 @@ from zoni.hardware.systemmanagementinter
 		#self.proto = proto
 
 class raritanDominionPx(SystemManagementInterface):
-	def __init__(self, config, host=None):
+	def __init__(self, config, nodeName, hostInfo):
 		#  Register
 		self.config = config
+		self.nodeName = nodeName
 		self.log = logging.getLogger(__name__)
 		self.verbose = False
+		self.powerStatus = None
 
-		if host != None:
-			self.host = host['location']
-			self.pdu_name = host['pdu_name']
-			self.port = host['pdu_port']
-			self.user = host['pdu_userid']
-			self.password = host['pdu_password']
+		if hostInfo != None:
+			self.host = nodeName
+			self.pdu_name = hostInfo['pdu_name']
+			self.port = hostInfo['pdu_port']
+			self.user = hostInfo['pdu_userid']
+			self.password = hostInfo['pdu_password']
 
 			self.oid = "1,3,6,1,4,1,13742,4,1,2,2,1"
 			self.oid_name = ",2"
@@ -56,7 +58,7 @@ class raritanDominionPx(SystemManagement
 			self.oid_status = ",3"
 
 			if self.getOffset():
-				self.port = host['pdu_port'] - 1
+				self.port = hostInfo['pdu_port'] - 1
 
 
 		#  this works
@@ -98,12 +100,13 @@ class raritanDominionPx(SystemManagement
 			return 1
 
 
-	def getPowerStatus(self):
+	def __setPowerStatus(self):
 		thisoid = eval(str(self.oid) + str(self.oid_status) + "," + str(self.port))
 		errorIndication, errorStatus, errorIndex, varBinds = cmdgen.CommandGenerator().getCmd( \
 		cmdgen.CommunityData('my-agent', self.user, 0), \
 		cmdgen.UdpTransportTarget((self.pdu_name, 161)), thisoid)
 		output = varBinds[0][1]
+		print output, varBinds
 		
 		if output == 1:
 			self.powerStatus = 1
@@ -111,8 +114,8 @@ class raritanDominionPx(SystemManagement
 		if output == 0:
 			self.powerStatus = 0
 			powerstat = "off"
-
-		print "PDU Power for %s is %s" % (self.host, powerstat)
+		print "pwerstat", powerstat 
+		self.log.info("hardware setPowerStatus %s : %s" % (powerstat, self.nodeName))
 
 		if output:
 			return 1
@@ -121,12 +124,13 @@ class raritanDominionPx(SystemManagement
 
 	def isPowered(self):
 		if self.powerStatus == None:
-			self.getPowerStatus()
+			self.__setPowerStatus()
 		if self.powerStatus:
 			return 1;
-		if not self.powerStatus:
-			return 0;
+		return 0;
 	
+	def getPowerStatus(self):
+		return self.isPowered()
 
 	def powerOn(self):
 		thisoid = eval(str(self.oid) + str(self.oid_status) + "," + str(self.port)) 
@@ -134,7 +138,7 @@ class raritanDominionPx(SystemManagement
 		cmdgen.CommunityData('my-agent', self.user, 1), \
 		cmdgen.UdpTransportTarget((self.pdu_name, 161)), \
 		(thisoid, rfc1902.Integer('1')))
-		self.getPowerStatus()
+		return self.getPowerStatus()
 
 	def powerOff(self):
 		thisoid = eval(str(self.oid) + str(self.oid_status) + "," + str(self.port)) 
@@ -142,7 +146,7 @@ class raritanDominionPx(SystemManagement
 		cmdgen.CommunityData('my-agent', self.user, 1), \
 		cmdgen.UdpTransportTarget((self.pdu_name, 161)), \
 		(thisoid, rfc1902.Integer('0')))
-		self.getPowerStatus()
+		return self.getPowerStatus()
 
 	def powerCycle(self):
 		self.powerOff()

Propchange: incubator/tashi/branches/oldstable/src/zoni/hardware/raritanpdu.py
            ('svn:mergeinfo' removed)

Modified: incubator/tashi/branches/oldstable/src/zoni/hardware/systemmanagementinterface.py
URL: http://svn.apache.org/viewvc/incubator/tashi/branches/oldstable/src/zoni/hardware/systemmanagementinterface.py?rev=1241773&r1=1241772&r2=1241773&view=diff
==============================================================================
--- incubator/tashi/branches/oldstable/src/zoni/hardware/systemmanagementinterface.py (original)
+++ incubator/tashi/branches/oldstable/src/zoni/hardware/systemmanagementinterface.py Wed Feb  8 04:44:09 2012
@@ -46,6 +46,10 @@ class SystemManagementInterface(object):
 		'''  Powers off a system '''
 		raise NotImplementedError
 
+	def powerOffSoft(self):
+		'''  Powers off a system via acpi'''
+		raise NotImplementedError
+
 	def powerCycle(self):
 		'''  Powers cycles a system '''
 		raise NotImplementedError

Propchange: incubator/tashi/branches/oldstable/src/zoni/hardware/systemmanagementinterface.py
            ('svn:mergeinfo' removed)

Modified: incubator/tashi/branches/oldstable/src/zoni/install/db/zoniDbSetup.py
URL: http://svn.apache.org/viewvc/incubator/tashi/branches/oldstable/src/zoni/install/db/zoniDbSetup.py?rev=1241773&r1=1241772&r2=1241773&view=diff
==============================================================================
--- incubator/tashi/branches/oldstable/src/zoni/install/db/zoniDbSetup.py (original)
+++ incubator/tashi/branches/oldstable/src/zoni/install/db/zoniDbSetup.py Wed Feb  8 04:44:09 2012
@@ -21,10 +21,15 @@
 import os 
 import sys
 import string
-import MySQLdb
-import traceback
-import optparse
-import getpass
+try:
+	import MySQLdb
+	import traceback
+	import optparse
+	import getpass
+except ImportError, e:
+        print "Module not installed : %s" % e
+        exit()
+
 
 a = os.path.join("../")
 sys.path.append(a)
@@ -78,7 +83,11 @@ def CreateZoniDb(config, adminUser, admi
 
 	port = config['dbPort']
 
-	conn = connectDb(host, port, adminUser, adminPassword)
+	try:
+		conn = connectDb(host, port, adminUser, adminPassword)
+	except e:
+		print "error here ", e
+		exit()
 	createDatabase(conn, adminUser, adminPassword, db)
 	setPriviledges(conn, user, passwd, db)
 	conn.close()
@@ -129,7 +138,7 @@ def createTables(conn):
 	'''  Create Tables  '''
 	#  Create sysinfo 
 	sys.stdout.write("    Creating sysinfo...")
-	execQuery(conn, "CREATE TABLE IF NOT EXISTS `sysinfo` (`sys_id` int(11) unsigned 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, `system_serial_number` char(128) default NULL, `chassis_serial_number` char(128) default NULL, `system_uuid` char(254) 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, `last_update` timestamp, state_id int(11) DEFAULT 1,max_reservation int(10) default -1, PRIMARY KEY  (`sys
 _id`))")
+	execQuery(conn, "CREATE TABLE IF NOT EXISTS `sysinfo` (`sys_id` int(11) unsigned 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, `system_serial_number` char(128) default NULL, `chassis_serial_number` char(128) default NULL, `system_uuid` char(254) 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 0, `last_update` timestamp not null default 0 on update CURRENT_TIMESTAMP, state_id int(11) DEFAULT 1,max_reservation int(10)
  default -1, PRIMARY KEY  (`sys_id`))")
 	sys.stdout.write("Success\n")
 
 	#  Create hardwareinfo
@@ -154,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_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...")
@@ -166,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, 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...")
@@ -221,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'"
@@ -257,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")
@@ -280,7 +291,7 @@ def addInitialConfig(conn, config):
 		#  Get the domainId 
 		vlanId = str(checkVal[1][0][0])
 	else:
-		r = execQuery(conn, "INSERT into `reservationinfo` (user_id, reservation_expiration, notes) values (0, '9999-12-31', 'Zoni Default Registration')")
+		r = execQuery(conn, "INSERT into `reservationinfo` (user_id, reservation_expiration, notes) values (0, '9999-12-31', 'Zoni Default')")
 		vlanId = str(r.lastrowid)
 		sys.stdout.write("Success\n")
 
@@ -304,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/oldstable/src/zoni/install/pxe/base-menu
URL: http://svn.apache.org/viewvc/incubator/tashi/branches/oldstable/src/zoni/install/pxe/base-menu?rev=1241773&r1=1241772&r2=1241773&view=diff
==============================================================================
--- incubator/tashi/branches/oldstable/src/zoni/install/pxe/base-menu (original)
+++ incubator/tashi/branches/oldstable/src/zoni/install/pxe/base-menu Wed Feb  8 04:44:09 2012
@@ -18,18 +18,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 --
+        kernel builds/amd64/zoni-reg/linux
+        append initrd=builds/amd64/zoni-reg/initrd.gz pxeserver=10.10.0.5 imageserver=10.10.0.5 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 --
+        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 --
+        kernel ubuntu-installer/hardy/i386/linux
+        append vga=normal initrd=ubuntu-installer/hardy/i386/initrd.gz  rescue/enable=true --
 
 PROMPT 1
 TIMEOUT 100

Modified: incubator/tashi/branches/oldstable/src/zoni/install/pxe/zoniPxeSetup.py
URL: http://svn.apache.org/viewvc/incubator/tashi/branches/oldstable/src/zoni/install/pxe/zoniPxeSetup.py?rev=1241773&r1=1241772&r2=1241773&view=diff
==============================================================================
--- incubator/tashi/branches/oldstable/src/zoni/install/pxe/zoniPxeSetup.py (original)
+++ incubator/tashi/branches/oldstable/src/zoni/install/pxe/zoniPxeSetup.py Wed Feb  8 04:44:09 2012
@@ -57,17 +57,6 @@ def main():
 	ZoniPxeSetup(configs)
 	ZoniGetSyslinux(configs)
 
-
-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']
@@ -77,6 +66,7 @@ def ZoniPxeSetup(config):
 	tftpBaseFile = config['tftpBaseFile'] 
 	tftpBaseMenuFile = config['tftpBaseMenuFile'] 
 	installBaseDir = config['installBaseDir']
+	registrationBaseDir = config['registrationBaseDir']
 	
 
 	#  Create the directory structure
@@ -88,12 +78,17 @@ def ZoniPxeSetup(config):
 	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-menu")
+	#shutil.copy2(dirName, tftpBaseMenuFile)
+	print "open dir name ", tftpBaseMenuFile
+	open(tftpBaseMenuFile, 'w').write(zoniCreateBaseMenu(config))
+	
 	dirName = os.path.join(pxeDir, "base.zoni")
 	shutil.copy2(dirName, tftpBaseFile)
 	#  Copy over zoni pxe image 
@@ -168,6 +163,29 @@ def ZoniGetSyslinux(config, ver=None):
 	shutil.copy2(tmpfile, tftpRootDir)
 	print "Finished"
 
+def zoniCreateBaseMenu(config):
+
+	a = ""
+	a += "DISPLAY boot-screens/boot.txt\n\n"
+	a += "LABEL zoni-register-64\n"
+	a += "        kernel builds/amd64/zoni-reg/linux\n"
+	a += "        append initrd=builds/initrd/images/zoni-register-64.gz pxeserver=" + config['pxeServerIP'] +  " imageserver=" + config['imageServerIP'] + " defaultimage=amd64-tashi_nm registerfile=register_node mode=register image_root=" + config['registrationBaseDir'] + " console=tty1 rw --\n"
+	a += "\n"
+	a += "LABEL zoni-register-64-interactive\n"
+	a += "        kernel builds/amd64/zoni-reg/linux\n"
+	a += "        append initrd=builds/initrd/images/zoni-register-64.gz pxeserver=" + config['pxeServerIP'] +  " imageserver=" + config['imageServerIP'] + " defaultimage=amd64-tashi_nm registerfile=register_node mode=register verbose=1 image_root=" + config['registrationBaseDir'] + " console=tty1 rw --\n"
+	a += "\n"
+	a += "LABEL localdisk\n"
+	a += "    LOCALBOOT 0\n"
+	a += "LABEL rescue\n"
+	a += "        kernel ubuntu-installer/hardy/i386/linux\n"
+	a += "        append vga=normal initrd=ubuntu-installer/hardy/i386/initrd.gz  rescue/enable=true --\n"
+	a += "\n"
+	a += "PROMPT 1\n"
+	a += "TIMEOUT 100\n"
+	return a
+
+
 		
 
 if __name__ in "__main__":

Modified: incubator/tashi/branches/oldstable/src/zoni/install/www/zoniWebSetup.py
URL: http://svn.apache.org/viewvc/incubator/tashi/branches/oldstable/src/zoni/install/www/zoniWebSetup.py?rev=1241773&r1=1241772&r2=1241773&view=diff
==============================================================================
--- incubator/tashi/branches/oldstable/src/zoni/install/www/zoniWebSetup.py (original)
+++ incubator/tashi/branches/oldstable/src/zoni/install/www/zoniWebSetup.py Wed Feb  8 04:44:09 2012
@@ -124,7 +124,7 @@ def ZoniWebSetup(config):
 	zoniInstallDir = config['installBaseDir']
 
 	zoniWebRoot = os.path.join(docRoot, baseDir )
-	createDir(zoniWebRoot, 1)
+	if not (createDir(zoniWebRoot, 1)):  print "Please use sudo"; exit()
 	zoniIncludeDir = os.path.join(zoniWebRoot, "include")
 	createDir(zoniIncludeDir)
 	zoniRegisterDir = os.path.join(zoniWebRoot, "register")

Copied: incubator/tashi/branches/oldstable/src/zoni/services/rpycservices.py (from r1203835, incubator/tashi/trunk/src/zoni/services/rpycservices.py)
URL: http://svn.apache.org/viewvc/incubator/tashi/branches/oldstable/src/zoni/services/rpycservices.py?p2=incubator/tashi/branches/oldstable/src/zoni/services/rpycservices.py&p1=incubator/tashi/trunk/src/zoni/services/rpycservices.py&r1=1203835&r2=1241773&rev=1241773&view=diff
==============================================================================
--- incubator/tashi/trunk/src/zoni/services/rpycservices.py (original)
+++ incubator/tashi/branches/oldstable/src/zoni/services/rpycservices.py Wed Feb  8 04:44:09 2012
@@ -27,7 +27,7 @@ hardwareRPCs = ['getPowerStatus']
 
 class client:
 	def __init__(self, host, port, username=None, password=None):
-		"""Client for ManagerService. If username and password are provided, rpyc.tls_connect will be used to connect, else rpyc.connect will be used."""
+		"""Client for ManagerService. If username and password are provided, rpyc.tlslite_connect will be used to connect, else rpyc.connect will be used."""
 		self.host = host
 		self.port = int(port)
 		self.username = username
@@ -37,7 +37,7 @@ class client:
 	def createConn(self):
 		"""Creates a rpyc connection."""
 		if self.username != None and self.password != None:
-			return rpyc.tls_connect(host=self.host, port=self.port, username=self.username, password=self.password)
+			return rpyc.tlslite_connect(host=self.host, port=self.port, username=self.username, password=self.password)
 		else:
 			return rpyc.connect(host=self.host, port=self.port)
 

Modified: incubator/tashi/branches/oldstable/src/zoni/system/registration/register/register_automate
URL: http://svn.apache.org/viewvc/incubator/tashi/branches/oldstable/src/zoni/system/registration/register/register_automate?rev=1241773&r1=1241772&r2=1241773&view=diff
==============================================================================
--- incubator/tashi/branches/oldstable/src/zoni/system/registration/register/register_automate (original)
+++ incubator/tashi/branches/oldstable/src/zoni/system/registration/register/register_automate Wed Feb  8 04:44:09 2012
@@ -21,10 +21,44 @@
 # This program takes two args:
 # register_automate <svg_tag|mac_addr> <"location"|"switchinfo"|"pduinfo"">
 #
+
+# 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.
+
 # Based on the the service tag or the mac address of the machine, it returns 
 # the intented location, hostname, or IP address of the machine, respectively.
 # It is intented to short-circuit the question phase of registration.
 #
+# 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.
 
 #  Example Chassis r2r1c1 : note, the line must begin with a "#"
 #  tag|mac|uuid location switchname:portnum pduname:portnum
@@ -45,17 +79,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/oldstable/src/zoni/system/registration/register/register_node
URL: http://svn.apache.org/viewvc/incubator/tashi/branches/oldstable/src/zoni/system/registration/register/register_node?rev=1241773&r1=1241772&r2=1241773&view=diff
==============================================================================
--- incubator/tashi/branches/oldstable/src/zoni/system/registration/register/register_node (original)
+++ incubator/tashi/branches/oldstable/src/zoni/system/registration/register/register_node Wed Feb  8 04:44:09 2012
@@ -23,11 +23,11 @@
 DEBUG () {
 	if [ $VERBOSE ] && [ $VERBOSE -eq 1 ];then 
 		echo DEBUG: $*
+		echo DEBUG: $* >> /tmp/output.log
 	fi
 }
 
 #  Capture vars passed via kernal args
-VERBOSE=0
 for x in $(cat /proc/cmdline); do
     case $x in
     imagename=*)
@@ -39,8 +39,11 @@ for x in $(cat /proc/cmdline); do
     defaultimage=*)
         DEFAULTIMAGE=${x#defaultimage=}
         ;;
-    image_root=*)
-        IMAGE_ROOT=${x#image_root=}
+    zoniroot=*)
+        ZONIROOT=${x#zoniroot=}
+        ;;
+    configipmi=*)
+        CONFIGIPMI=${x#configipmi=}
         ;;
     verbose=*)
         VERBOSE=${x#verbose=}
@@ -48,7 +51,8 @@ for x in $(cat /proc/cmdline); do
 	esac
 done
 
-IMAGE_URL="${PXESERVER}/${IMAGE_ROOT}/"
+
+IMAGE_URL="${PXESERVER}/${ZONIROOT}/"
 
 #  Scrape system for specs
 #/sbin/getSystemId > /tmp/sysinfo
@@ -127,11 +131,11 @@ DEBUG DISK_INFO - ${DISK_INFO}
 
 #  Register sysinfo to DB
 DEBUG "wget -O- http://${IMAGE_URL}/zoni-register.php?action=register_system&mac=$MAC&mod_mac=$MOD_MAC&sys_model=$SYS_MODEL&bios_rev=$BIOS_REV&system_serial_number=$SYSTEM_SERIAL_NUMBER&chassis_serial_number=${CHASSIS_SERIAL_NUMBER}&system_uuid=$SYSTEM_UUID&sys_vendor=$SYS_VENDOR&proc_vendor=$PROC_VENDOR&proc_model=$PROC_MODEL&clock_speed=$CLOCK_SPEED&proc_cache=$PROC_CACHE&num_procs=$NUM_PROCS&num_cores=$NUM_CORES&mem_total=$MEM_TOTAL&cpu_flags=$CPU_FLAGS&num_disks=${NUM_DISKS}&disk_info=${DISK_INFO}"
-wget "http://${IMAGE_URL}/zoni-register.php?action=register_system&mac=$MAC&mod_mac=$MOD_MAC&sys_model=$SYS_MODEL&bios_rev=$BIOS_REV&system_serial_number=$SYSTEM_SERIAL_NUMBER&chassis_serial_number=${CHASSIS_SERIAL_NUMBER}&system_uuid=$SYSTEM_UUID&sys_vendor=$SYS_VENDOR&proc_vendor=$PROC_VENDOR&proc_model=$PROC_MODEL&clock_speed=$CLOCK_SPEED&proc_cache=$PROC_CACHE&num_procs=$NUM_PROCS&num_cores=$NUM_CORES&mem_total=$MEM_TOTAL&cpu_flags=$CPU_FLAGS&num_disks=${NUM_DISKS}&disk_info=${DISK_INFO}"
+wget -O- "http://${IMAGE_URL}/zoni-register.php?action=register_system&mac=$MAC&mod_mac=$MOD_MAC&sys_model=$SYS_MODEL&bios_rev=$BIOS_REV&system_serial_number=$SYSTEM_SERIAL_NUMBER&chassis_serial_number=${CHASSIS_SERIAL_NUMBER}&system_uuid=$SYSTEM_UUID&sys_vendor=$SYS_VENDOR&proc_vendor=$PROC_VENDOR&proc_model=$PROC_MODEL&clock_speed=$CLOCK_SPEED&proc_cache=$PROC_CACHE&num_procs=$NUM_PROCS&num_cores=$NUM_CORES&mem_total=$MEM_TOTAL&cpu_flags=$CPU_FLAGS&num_disks=${NUM_DISKS}&disk_info=${DISK_INFO}"
 
 #  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)
@@ -156,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: "
@@ -197,7 +201,6 @@ fi
 	#DEBUG "Update ip $ip_addr"
 	#wget -O- "http://${IMAGE_URL}/zoni-register.php?action=addip&mac=$MAC&ip_addr=$ip_addr"
 #fi
-VERBOSE=0
 if [ $location ];then 
 	DEBUG "Set location ${location}"
 	echo "wget -O- http://${IMAGE_URL}/zoni-register.php?action=addlocation&verbose=${VERBOSE}&mac=$MAC&location=$location"
@@ -222,59 +225,67 @@ fi
 	#wget -O- "http://${IMAGE_URL}/zoni-register.php?action=addip&mac=$MAC&ip_addr=$ip_addr"
 #fi
 
-#  Add dns and dhcp
-DEBUG "adding to dhcp and dns"
-wget -O- "http://${IMAGE_URL}/zoni-register.php?action=updatednsdhcp&verbose=${VERBOSE}&mac=${MAC}&location=$location&ip_addr=$IPADDR"
+if [ $location ];then
+	#  Add dns and dhcp
+	DEBUG "adding to dhcp and dns"
+	wget -O- "http://${IMAGE_URL}/zoni-register.php?action=updatednsdhcp&verbose=${VERBOSE}&mac=${MAC}&location=$location&ip_addr=$IPADDR"
+fi
 
 #  Setup the management interface, if any
 
-#  Check for ipmi
-#  Check for the existance of the module.  
-cat /proc/modules | grep ipmi_si 
-if [ $? -eq 0 ];then 
-	#  Assigning IP address to IPMI card since they don't seem to every accept an address from DHCP
-	#  Subnet is selected from config file
-	#  Get IPMI card mac address
-	ipmi_mac=$(ipmitool lan print |  grep -i "MAC Address" | awk -F ": " '{print $2}')
-	ipmi_ver=$(ipmitool mc info |  grep -i "IPMI Version" | awk -F ": " '{print $2}')
-	ipmi_rev=$(ipmitool mc info |  grep -i "Firmware Revision" | awk -F ": " '{print $2}')
-
-	vlan_disable=$(ipmitool lan print |  grep -i "Vlan" | awk -F ": " '{print $2}')
-
-	#  Add IPMI info 
-VERBOSE=1
-	wget -O/outfile.txt "http://${IMAGE_URL}/zoni-register.php?action=add_ipmi&verbose=${VERBOSE}&mac=$MAC&location=${location}&ip_addr=${IPADDR}&ipmi_mac=${ipmi_mac}&ipmi_ver=${ipmi_ver}&ipmi_rev=${ipmi_rev}"
-	IPMI_ADDR=$(cat /outfile.txt | grep IPMI_ADDR | awk '{print $2}')
-	IPMI_PASSWORD=$(cat /outfile.txt | grep IPMI_PASSWORD | awk '{print $2}')
-	IPMI_DOMAIN=$(cat /outfile.txt | grep IPMI_DOMAIN| awk '{print $2}')
-	IPMI_NETMASK=$(cat /outfile.txt | grep IPMI_NETMASK| awk '{print $2}')
-	IPMI_GATEWAY=$(cat /outfile.txt | grep IPMI_GATEWAY| awk '{print $2}')
-
-
-	
-	if [ ${IPMI_DOMAIN} -eq 1 ];then 
-		IPMI_DOMAIN="off"
-	fi
-	DEBUG "ip $IPMI_ADDR pass $IPMI_PASSWORD domain $IPMI_DOMAIN netmask $IPMI_NETMASK gateway $IPMI_GATEWAY "
-	ipmitool lan set 1 ipsrc static
-	ipmitool lan set 1 ipaddr ${IPMI_ADDR}
-	ipmitool lan set 1 vlan id ${IPMI_DOMAIN}
-	ipmitool lan set 1 defgw ipaddr ${IPMI_GATEWAY}
-	ipmitool lan set 1 netmask ${IPMI_NETMASK}
-	ipmitool lan set 1 password ${IPMI_PASSWORD}
-	ipmitool lan set 1 access on
-
-	#  Make user 2 be root with random password
-	ipmitool user set name 2 root
-	ipmitool user set password 2 $IPMI_PASSWORD
-	ipmitool channel setaccess 1 2 callin=on ipmi=on link=on privilege=4
-	ipmitool user enable 2
+if [ $configipmi ] && [ $configipmi -eq 1 ];then 
 
-	#DEBUG "adding to dhcp and dns"
-	#wget -O- "http://${IMAGE_URL}/zoni-register.php?action=updatednsdhcp&verbose=${VERBOSE}&mac=${ipmi_mac}&location=${location}$&ip_addr=${IPMI_ADDR}"
+	#  Check for ipmi
+	#  Check for the existance of the module.  
+	cat /proc/modules | grep ipmi_si 
+	if [ $? -eq 0 ];then 
+		#  Assigning IP address to IPMI card since they don't seem to every accept an address from DHCP
+		#  Subnet is selected from config file
+		#  Get IPMI card mac address
+		ipmi_mac=$(ipmitool lan print |  grep -i "MAC Address" | awk -F ": " '{print $2}')
+		ipmi_ver=$(ipmitool mc info |  grep -i "IPMI Version" | awk -F ": " '{print $2}')
+		ipmi_rev=$(ipmitool mc info |  grep -i "Firmware Revision" | awk -F ": " '{print $2}')
+
+		vlan_disable=$(ipmitool lan print |  grep -i "Vlan" | awk -F ": " '{print $2}')
+
+		#  Add IPMI info 
+		echo "wget -O/outfile.txt 'http://${IMAGE_URL}/zoni-register.php?action=add_ipmi&verbose=${VERBOSE}&mac=$MAC&location=${location}&ip_addr=${IPADDR}&ipmi_mac=${ipmi_mac}&ipmi_ver=${ipmi_ver}&ipmi_rev=${ipmi_rev}'"
+		wget -O/outfile.txt "http://${IMAGE_URL}/zoni-register.php?action=add_ipmi&verbose=${VERBOSE}&mac=$MAC&location=${location}&ip_addr=${IPADDR}&ipmi_mac=${ipmi_mac}&ipmi_ver=${ipmi_ver}&ipmi_rev=${ipmi_rev}"
+		IPMI_ADDR=$(cat /outfile.txt | grep IPMI_ADDR | awk '{print $2}')
+		IPMI_PASSWORD=$(cat /outfile.txt | grep IPMI_PASSWORD | awk '{print $2}')
+		IPMI_DOMAIN=$(cat /outfile.txt | grep IPMI_DOMAIN| awk '{print $2}')
+		IPMI_NETMASK=$(cat /outfile.txt | grep IPMI_NETMASK| awk '{print $2}')
+		IPMI_GATEWAY=$(cat /outfile.txt | grep IPMI_GATEWAY| awk '{print $2}')
+
+
+		
+		if [ ${IPMI_DOMAIN} -eq 1 ];then 
+			IPMI_DOMAIN="off"
+		fi
+		DEBUG "ip $IPMI_ADDR pass $IPMI_PASSWORD domain $IPMI_DOMAIN netmask $IPMI_NETMASK gateway $IPMI_GATEWAY "
+		ipmitool lan set 1 ipsrc static
+		ipmitool lan set 1 ipaddr ${IPMI_ADDR}
+		ipmitool lan set 1 vlan id ${IPMI_DOMAIN}
+		ipmitool lan set 1 defgw ipaddr ${IPMI_GATEWAY}
+		ipmitool lan set 1 netmask ${IPMI_NETMASK}
+		ipmitool lan set 1 password ${IPMI_PASSWORD}
+		ipmitool lan set 1 access on
+
+		#  Make user 2 be root with random password
+		ipmitool user set name 2 root
+		ipmitool user set password 2 $IPMI_PASSWORD
+		ipmitool channel setaccess 1 2 callin=on ipmi=on link=on privilege=4
+		ipmitool user enable 2
+
+		#Already done in add_ipmi
+		#DEBUG "adding to dhcp and dns"
+		#DEBUG "wget -O- http://${IMAGE_URL}/zoni-register.php?action=updatednsdhcp&verbose=${VERBOSE}&mac=${ipmi_mac}&location=${location}$&ip_addr=${IPMI_ADDR}"
+		#wget -O- "http://${IMAGE_URL}/zoni-register.php?action=updatednsdhcp&verbose=${VERBOSE}&mac=${ipmi_mac}&location=${location}&ip_addr=${IPMI_ADDR}"
+
+	else
+		DEBUG "IPMI interface not found"
+	fi
 
-else
-	DEBUG "IPMI interface not found"
 fi
 
 

Modified: incubator/tashi/branches/oldstable/src/zoni/system/registration/www/include/zoni_functions.php
URL: http://svn.apache.org/viewvc/incubator/tashi/branches/oldstable/src/zoni/system/registration/www/include/zoni_functions.php?rev=1241773&r1=1241772&r2=1241773&view=diff
==============================================================================
--- incubator/tashi/branches/oldstable/src/zoni/system/registration/www/include/zoni_functions.php (original)
+++ incubator/tashi/branches/oldstable/src/zoni/system/registration/www/include/zoni_functions.php Wed Feb  8 04:44:09 2012
@@ -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/oldstable/src/zoni/system/registration/www/zoni-register.php
URL: http://svn.apache.org/viewvc/incubator/tashi/branches/oldstable/src/zoni/system/registration/www/zoni-register.php?rev=1241773&r1=1241772&r2=1241773&view=diff
==============================================================================
--- incubator/tashi/branches/oldstable/src/zoni/system/registration/www/zoni-register.php (original)
+++ incubator/tashi/branches/oldstable/src/zoni/system/registration/www/zoni-register.php Wed Feb  8 04:44:09 2012
@@ -18,12 +18,15 @@
 #
 #  $Id$
 #
+	#  Need to put base directory here 
     include("include/zoni_www_registration.conf");
 	include("include/zoni_functions.php");
 
     $G = init_globals();
+	$PYTHONPATH=$G['ZONI_BASE_DIR'] . "/src";
     $verbose = (isset($_GET['verbose'])) ? $_GET['verbose']: 0;
 
+	print "verbose is $verbose";
     DEBUG($verbose, "<pre>");
     DEBUG($verbose, $G);
 
@@ -138,7 +141,7 @@
             $query .= "(mac_addr, num_procs, num_cores, mem_total, ";
             $query .= "clock_speed, sys_vendor, sys_model, proc_vendor, ";
             $query .= "proc_model, proc_cache, bios_rev, system_serial_number, ";
-            $query .= "chassis_serial_number, system_uuid, last_update, ";
+            $query .= "chassis_serial_number, system_uuid, init_checkin, ";
             $query .= "cpu_flags)";
             $query .= " values ('$mac_addr', '$num_procs', '$num_cores', ";
             $query .= " '$mem_total', '$clock_speed', '$sys_vendor', ";
@@ -165,11 +168,10 @@
 			$query .= "bios_rev = '$bios_rev', ";
 			$query .= "chassis_serial_number = '$chassis_serial_number', ";
 			$query .= "system_uuid = '$system_uuid', ";
-			$query .= "last_update= NOW(), ";
-            $query .= "cpu_flags = '$cpu_flags' ";
+            $query .= "cpu_flags = '$cpu_flags', ";
+            $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());
 		}
@@ -208,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
@@ -216,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);
 	}
 
@@ -230,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");
 	}
 
@@ -305,6 +307,7 @@
 			$query .= "hw_version_fw = '$ipmi_rev'  ";
 			$query .= "where hw_mac = '$ipmi_mac'";
 			$result = $myconn->run_query($query);
+			DEBUG($verbose, "UPDATING THE HARDWEARE INFO");
 			DEBUG($verbose, $query, $result);
 			
 		}
@@ -319,9 +322,8 @@
 		print "IPMI_GATEWAY $ipmi_gateway\n";
 
 		print "IPMI name is $ipmi_name  address is $ipmi_addr\n";
-
-		print shell_exec("PYTHONPATH=/usr/local/tashi/src  zoni --addDns $ipmi_name $ipmi_addr");
-		print shell_exec("PYTHONPATH=/usr/local/tashi/src zoni --addDhcp $ipmi_name $ipmi_addr $mac_addr");
+		print shell_exec("PYTHONPATH=$PYTHONPATH  zoni --addDns $ipmi_name $ipmi_addr");
+		print shell_exec("PYTHONPATH=$PYTHONPATH zoni --addDhcp $ipmi_name $ipmi_addr $mac_addr");
         #print shell_exec("cd /var/www/cluster-admin/scripts-prs/; sudo ./remove_dns ${location}-ipmi");
         #print shell_exec("cd /var/www/cluster-admin/scripts-prs/; sudo ./remove_rdns ${location}-ipmi $ipmi_addr");
         #print shell_exec("cd /var/www/cluster-admin/scripts-prs/; sudo ./add_dns ${location}-ipmi $ipmi_addr");
@@ -376,10 +378,8 @@
 		}
 		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 shell_exec("PYTHONPATH=/usr/local/tashi/src  zoni --addDns $location $ip_addr");
-		print shell_exec("PYTHONPATH=/usr/local/tashi/src zoni --addDhcp $location $ip_addr $mac_addr");
+		print shell_exec("PYTHONPATH=$PYTHONPATH zoni --addDns $location $ip_addr");
+		print shell_exec("PYTHONPATH=$PYTHONPATH zoni --addDhcp $location $ip_addr $mac_addr");
 	}
 
 	#  set next boot image after allocation setup
@@ -411,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");
         }

Modified: incubator/tashi/branches/oldstable/src/zoni/version.py
URL: http://svn.apache.org/viewvc/incubator/tashi/branches/oldstable/src/zoni/version.py?rev=1241773&r1=1241772&r2=1241773&view=diff
==============================================================================
--- incubator/tashi/branches/oldstable/src/zoni/version.py (original)
+++ incubator/tashi/branches/oldstable/src/zoni/version.py Wed Feb  8 04:44:09 2012
@@ -20,5 +20,5 @@ lastChangeDate = "$LastChangedDate$"
 lastChangeRevision = "$Rev: 964467 $"
 revision = lastChangeRevision
 #version="$LastChangedDate$"
-version = "201104"
+version = "201111"
 

Propchange: incubator/tashi/branches/oldstable/src/zoni/version.py
            ('svn:mergeinfo' removed)