incubator-tashi-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From rg...@apache.org
Subject svn commit: r1177661 [2/2] - in /incubator/tashi/trunk: ./ etc/ src/ src/tashi/agents/ src/tashi/client/ src/tashi/clustermanager/ src/tashi/nodemanager/ src/zoni/ src/zoni/agents/ src/zoni/bootstrap/ src/zoni/client/ src/zoni/data/ src/zoni/extra/ src...
Date Fri, 30 Sep 2011 13:47:23 GMT
Modified: incubator/tashi/trunk/src/zoni/extra/util.py
URL: http://svn.apache.org/viewvc/incubator/tashi/trunk/src/zoni/extra/util.py?rev=1177661&r1=1177660&r2=1177661&view=diff
==============================================================================
--- incubator/tashi/trunk/src/zoni/extra/util.py (original)
+++ incubator/tashi/trunk/src/zoni/extra/util.py Fri Sep 30 13:47:21 2011
@@ -19,10 +19,14 @@
 #
 
 import os
+import string
 import ConfigParser
 import time
 import shutil
 import re
+import threading
+import subprocess
+import logging
 
 def loadConfigFile(parser):
 	#parser = ConfigParser.ConfigParser()
@@ -35,8 +39,9 @@ def loadConfigFile(parser):
 	config['logFile'] = parser.get("logging", "LOG_FILE").split()[0]
 	
 	#  Management
-	config['userManagement'] = parser.get("management", "USER_MANAGEMENT").split()[0]
-	config['infoStore'] = parser.get("management", "INFO_STORE").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]
 	
 	#  DB connection
 	config['dbUser'] = parser.get("dbConnection", "DB_USER").split()[0]
@@ -56,6 +61,7 @@ def loadConfigFile(parser):
 	config['tftpBaseMenuFile'] = parser.get("pxe", "TFTP_BASE_MENU_FILE").split()[0]
 	config['pxeServerIP'] = parser.get("pxe", "PXE_SERVER_IP").split()[0]
 	config['initrdRoot'] = parser.get("pxe", "INITRD_ROOT").split()[0]
+	config['kernelRoot'] = parser.get("pxe", "KERNEL_ROOT").split()[0]
 
 	#  Image store
 	config['imageServerIP'] = parser.get("imageStore", "IMAGE_SERVER_IP").split()[0]
@@ -70,7 +76,7 @@ def loadConfigFile(parser):
 
 	#  VLAN
 	#config['vlan_reserved'] = parser.get("vlan", "VLAN_RESERVED")
-	config['vlan_max'] = int(parser.get("vlan", "VLAN_MAX"))
+	config['vlanMax'] = int(parser.get("vlan", "VLAN_MAX"))
 
 	#  Domain
 	config['zoniHomeDomain'] = parser.get("domain", "ZONI_HOME_DOMAIN").split()[0]
@@ -79,7 +85,7 @@ def loadConfigFile(parser):
 	#config['vlan_max'] = parser.get("vlan", "VLAN_MAX")
 
 	#  HARDWARE CONTROL
-	config['hardware_control'] = parser.get("hardware", "HARDWARE_CONTROL")
+	config['hardwareControl'] = eval(parser.get("hardware", "HARDWARE_CONTROL"))
 
 	#  DHCP/DNS
 	config['dnsEnabled'] = parser.get("DhcpDns", "dnsEnabled")
@@ -131,6 +137,7 @@ def checkSuper(f):
 			exit()
 		return res
 	myF.__name__ = f.__name__
+	
 	return myF
 
 
@@ -144,6 +151,14 @@ def timeF(f):
 	myF.__name__ = f.__name__
 	return myF
 
+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
 
 def createDir(dirName, checkexists=None):
 	if checkexists and os.path.exists(dirName):
@@ -154,10 +169,11 @@ def createDir(dirName, checkexists=None)
 		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
+		print "	" + e.args[1] + ": " + dirName
+		return 0
+
+	return 1
+
 
 
 def validIp(ip):
@@ -172,6 +188,10 @@ def validIp(ip):
 			return 0
 	return 1
 
+def normalizeMac(mac):
+	rawmac = re.sub('[.:-]', '', mac)
+	return  string.lower(":".join(["%s%s" % (rawmac[i], rawmac[i+1]) for i in range(0,12,2)]))
+
 def validMac(mac):
 	reg = '([a-fA-F0-9]{2}[:|\\-]?){6}'
 	val = re.compile(reg).search(mac)
@@ -179,5 +199,50 @@ def validMac(mac):
 		return 1
 	return 0
 
+def createKey(name):
+	tmpdir = "/tmp"
+	def cleanIt(tmpdir, name):
+		check = "K%s" % name
+		for i in os.listdir(tmpdir):
+			if check in i:
+				keyName = os.path.join(tmpdir, i)
+				os.unlink(keyName)
+
+	cleanIt(tmpdir, name)
+	cmd = "dnssec-keygen -a HMAC-MD5 -r /dev/urandom -b 128 -K %s -n USER %s" % (tmpdir, name)
+	c = subprocess.Popen(args=cmd.split(), stdout=subprocess.PIPE)
+	keyName = os.path.join(tmpdir, string.strip(c.stdout.readline()) + ".key")
+	f = open(keyName, "r")
+	val = string.strip(string.split(f.readline(), " " , 6)[6])
+	f.close()
+	return val
+	
+
+
 
+def debugConsole(globalDict):
+	"""A debugging console that optionally uses pysh"""
+	def realDebugConsole(globalDict):
+		try :
+			import atexit
+			from IPython.Shell import IPShellEmbed
+			def resetConsole():
+# XXXpipe: make input window sane
+				(stdin, stdout) = os.popen2("reset")
+				stdout.read()
+			dbgshell = IPShellEmbed()
+			atexit.register(resetConsole)
+			dbgshell(local_ns=globalDict, global_ns=globalDict)
+		except Exception:
+			CONSOLE_TEXT=">>> "
+			input = " "
+			while (input != ""):
+				sys.stdout.write(CONSOLE_TEXT)
+				input = sys.stdin.readline()
+				try:
+					exec(input) in globalDict
+				except Exception, e:
+					sys.stdout.write(str(e) + "\n")
+	if (os.getenv("DEBUG", "0") == "1"):
+		threading.Thread(target=lambda: realDebugConsole(globalDict)).start()
 

Propchange: incubator/tashi/trunk/src/zoni/extra/util.py
            ('svn:mergeinfo' removed)

Modified: incubator/tashi/trunk/src/zoni/hardware/delldrac.py
URL: http://svn.apache.org/viewvc/incubator/tashi/trunk/src/zoni/hardware/delldrac.py?rev=1177661&r1=1177660&r2=1177661&view=diff
==============================================================================
--- incubator/tashi/trunk/src/zoni/hardware/delldrac.py (original)
+++ incubator/tashi/trunk/src/zoni/hardware/delldrac.py Fri Sep 30 13:47:21 2011
@@ -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/trunk/src/zoni/hardware/delldrac.py
            ('svn:mergeinfo' removed)

Modified: incubator/tashi/trunk/src/zoni/hardware/dellswitch.py
URL: http://svn.apache.org/viewvc/incubator/tashi/trunk/src/zoni/hardware/dellswitch.py?rev=1177661&r1=1177660&r2=1177661&view=diff
==============================================================================
--- incubator/tashi/trunk/src/zoni/hardware/dellswitch.py (original)
+++ incubator/tashi/trunk/src/zoni/hardware/dellswitch.py Fri Sep 30 13:47:21 2011
@@ -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,33 @@ 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"):
+		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 +307,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 +333,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 +380,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 +404,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 +431,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 +453,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 +493,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 +506,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 +519,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 +547,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/trunk/src/zoni/hardware/dellswitch.py
            ('svn:mergeinfo' removed)

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

Modified: incubator/tashi/trunk/src/zoni/hardware/hwswitchinterface.py
URL: http://svn.apache.org/viewvc/incubator/tashi/trunk/src/zoni/hardware/hwswitchinterface.py?rev=1177661&r1=1177660&r2=1177661&view=diff
==============================================================================
--- incubator/tashi/trunk/src/zoni/hardware/hwswitchinterface.py (original)
+++ incubator/tashi/trunk/src/zoni/hardware/hwswitchinterface.py Fri Sep 30 13:47:21 2011
@@ -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/trunk/src/zoni/hardware/hwswitchinterface.py
            ('svn:mergeinfo' removed)

Modified: incubator/tashi/trunk/src/zoni/hardware/ipmi.py
URL: http://svn.apache.org/viewvc/incubator/tashi/trunk/src/zoni/hardware/ipmi.py?rev=1177661&r1=1177660&r2=1177661&view=diff
==============================================================================
--- incubator/tashi/trunk/src/zoni/hardware/ipmi.py (original)
+++ incubator/tashi/trunk/src/zoni/hardware/ipmi.py Fri Sep 30 13:47:21 2011
@@ -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/trunk/src/zoni/hardware/ipmi.py
            ('svn:mergeinfo' removed)

Modified: incubator/tashi/trunk/src/zoni/hardware/raritanpdu.py
URL: http://svn.apache.org/viewvc/incubator/tashi/trunk/src/zoni/hardware/raritanpdu.py?rev=1177661&r1=1177660&r2=1177661&view=diff
==============================================================================
--- incubator/tashi/trunk/src/zoni/hardware/raritanpdu.py (original)
+++ incubator/tashi/trunk/src/zoni/hardware/raritanpdu.py Fri Sep 30 13:47:21 2011
@@ -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/trunk/src/zoni/hardware/raritanpdu.py
            ('svn:mergeinfo' removed)

Modified: incubator/tashi/trunk/src/zoni/hardware/systemmanagementinterface.py
URL: http://svn.apache.org/viewvc/incubator/tashi/trunk/src/zoni/hardware/systemmanagementinterface.py?rev=1177661&r1=1177660&r2=1177661&view=diff
==============================================================================
--- incubator/tashi/trunk/src/zoni/hardware/systemmanagementinterface.py (original)
+++ incubator/tashi/trunk/src/zoni/hardware/systemmanagementinterface.py Fri Sep 30 13:47:21 2011
@@ -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/trunk/src/zoni/hardware/systemmanagementinterface.py
            ('svn:mergeinfo' removed)

Modified: incubator/tashi/trunk/src/zoni/install/db/zoniDbSetup.py
URL: http://svn.apache.org/viewvc/incubator/tashi/trunk/src/zoni/install/db/zoniDbSetup.py?rev=1177661&r1=1177660&r2=1177661&view=diff
==============================================================================
--- incubator/tashi/trunk/src/zoni/install/db/zoniDbSetup.py (original)
+++ incubator/tashi/trunk/src/zoni/install/db/zoniDbSetup.py Fri Sep 30 13:47:21 2011
@@ -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,7 +163,7 @@ 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")
 	sys.stdout.write("Success\n")
 	#  Create domainmap
 	sys.stdout.write("    Creating domainmembermap...")
@@ -166,7 +175,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`), INDEX (domain_id), FOREIGN KEY (domain_id) REFERENCES domaininfo (domain_id) on DELETE CASCADE) ENGINE=INNODB")
 	sys.stdout.write("Success\n")
 	#  Create imagemap
 	sys.stdout.write("    Creating imagemap...")
@@ -280,7 +289,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")
 

Modified: incubator/tashi/trunk/src/zoni/install/pxe/base-menu
URL: http://svn.apache.org/viewvc/incubator/tashi/trunk/src/zoni/install/pxe/base-menu?rev=1177661&r1=1177660&r2=1177661&view=diff
==============================================================================
--- incubator/tashi/trunk/src/zoni/install/pxe/base-menu (original)
+++ incubator/tashi/trunk/src/zoni/install/pxe/base-menu Fri Sep 30 13:47:21 2011
@@ -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/trunk/src/zoni/install/pxe/zoniPxeSetup.py
URL: http://svn.apache.org/viewvc/incubator/tashi/trunk/src/zoni/install/pxe/zoniPxeSetup.py?rev=1177661&r1=1177660&r2=1177661&view=diff
==============================================================================
--- incubator/tashi/trunk/src/zoni/install/pxe/zoniPxeSetup.py (original)
+++ incubator/tashi/trunk/src/zoni/install/pxe/zoniPxeSetup.py Fri Sep 30 13:47:21 2011
@@ -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/trunk/src/zoni/install/www/zoniWebSetup.py
URL: http://svn.apache.org/viewvc/incubator/tashi/trunk/src/zoni/install/www/zoniWebSetup.py?rev=1177661&r1=1177660&r2=1177661&view=diff
==============================================================================
--- incubator/tashi/trunk/src/zoni/install/www/zoniWebSetup.py (original)
+++ incubator/tashi/trunk/src/zoni/install/www/zoniWebSetup.py Fri Sep 30 13:47:21 2011
@@ -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")

Modified: incubator/tashi/trunk/src/zoni/system/registration/register/register_automate
URL: http://svn.apache.org/viewvc/incubator/tashi/trunk/src/zoni/system/registration/register/register_automate?rev=1177661&r1=1177660&r2=1177661&view=diff
==============================================================================
--- incubator/tashi/trunk/src/zoni/system/registration/register/register_automate (original)
+++ incubator/tashi/trunk/src/zoni/system/registration/register/register_automate Fri Sep 30 13:47:21 2011
@@ -27,6 +27,22 @@
 # 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

Modified: incubator/tashi/trunk/src/zoni/system/registration/register/register_node
URL: http://svn.apache.org/viewvc/incubator/tashi/trunk/src/zoni/system/registration/register/register_node?rev=1177661&r1=1177660&r2=1177661&view=diff
==============================================================================
--- incubator/tashi/trunk/src/zoni/system/registration/register/register_node (original)
+++ incubator/tashi/trunk/src/zoni/system/registration/register/register_node Fri Sep 30 13:47:21 2011
@@ -27,7 +27,6 @@ DEBUG () {
 }
 
 #  Capture vars passed via kernal args
-VERBOSE=0
 for x in $(cat /proc/cmdline); do
     case $x in
     imagename=*)
@@ -39,8 +38,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 +50,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,7 +130,7 @@ 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
@@ -197,7 +200,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 +224,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/trunk/src/zoni/system/registration/www/zoni-register.php
URL: http://svn.apache.org/viewvc/incubator/tashi/trunk/src/zoni/system/registration/www/zoni-register.php?rev=1177661&r1=1177660&r2=1177661&view=diff
==============================================================================
--- incubator/tashi/trunk/src/zoni/system/registration/www/zoni-register.php (original)
+++ incubator/tashi/trunk/src/zoni/system/registration/www/zoni-register.php Fri Sep 30 13:47:21 2011
@@ -18,10 +18,12 @@
 #
 #  $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;
 
     DEBUG($verbose, "<pre>");
@@ -138,7 +140,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,8 +167,8 @@
 			$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);
@@ -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");
@@ -378,8 +380,9 @@
 		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 "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");
 	}
 
 	#  set next boot image after allocation setup

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



Mime
View raw message