incubator-tashi-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From strou...@apache.org
Subject svn commit: r1351920 - in /incubator/tashi/trunk: ./ etc/ZoniDefaults.cfg src/zoni/client/zoni-cli.py src/zoni/data/resourcequerysql.py src/zoni/extensions/ src/zoni/extra/util.py src/zoni/hardware/hpilo.py src/zoni/hardware/systemmanagementinterface.py
Date Wed, 20 Jun 2012 02:32:20 GMT
Author: stroucki
Date: Wed Jun 20 02:32:19 2012
New Revision: 1351920

URL: http://svn.apache.org/viewvc?rev=1351920&view=rev
Log:
Merge branch luke-zoni into trunk.

Added:
    incubator/tashi/trunk/src/zoni/extensions/
      - copied from r1351919, incubator/tashi/branches/trunk-staging/src/zoni/extensions/
Modified:
    incubator/tashi/trunk/   (props changed)
    incubator/tashi/trunk/etc/ZoniDefaults.cfg
    incubator/tashi/trunk/src/zoni/client/zoni-cli.py
    incubator/tashi/trunk/src/zoni/data/resourcequerysql.py
    incubator/tashi/trunk/src/zoni/extra/util.py
    incubator/tashi/trunk/src/zoni/hardware/hpilo.py
    incubator/tashi/trunk/src/zoni/hardware/systemmanagementinterface.py

Propchange: incubator/tashi/trunk/
------------------------------------------------------------------------------
  Merged /incubator/tashi/branches/luke-zoni:r1292129-1351835,1351890-1351918
  Merged /incubator/tashi/branches/luke-zoni-staging:r1351875-1351888
  Merged /incubator/tashi/branches/trunk-staging:r1351915-1351919

Modified: incubator/tashi/trunk/etc/ZoniDefaults.cfg
URL: http://svn.apache.org/viewvc/incubator/tashi/trunk/etc/ZoniDefaults.cfg?rev=1351920&r1=1351919&r2=1351920&view=diff
==============================================================================
--- incubator/tashi/trunk/etc/ZoniDefaults.cfg (original)
+++ incubator/tashi/trunk/etc/ZoniDefaults.cfg Wed Jun 20 02:32:19 2012
@@ -30,6 +30,7 @@ LOG_FILE = /var/tmp/zoni_logfile.txt
 #  Specify data store
 INFO_STORE = sql
 USER_MANAGEMENT = ldap
+PICKLE_FILE = pickled
 
 #  DB host
 [dbConnection]
@@ -58,6 +59,10 @@ PXE_SERVER_IP = IP_OF_PXE_SERVER_IN_DOMA
 #  Must be relative to TFTP_ROOT_DIR
 INITRD_ROOT = builds/initrd
 KERNEL_ROOT = builds/kernel
+# Extensions from MIMOS
+# put the IP address of your NTP server here
+NTPSVR = 127.0.0.1
+CUSTOM_TEMPLATES_DIR = /var/lib/tftpboot/templates
 
 [www]
 WWW_DOCUMENT_ROOT = /var/www
@@ -96,13 +101,6 @@ dhcpServer = xx_dhcpserver_host_or_ip_xx
 dhcpKeyName = xx_dhcpservername_xx
 dhcpSecretKey = xx_secretkey_xx
 
-#  Domain Config
-[domain]
-domainDescription = "/usr/local/tashi/etc/ZoniDomains.xml"
-ZONI_HOME_DOMAIN = 1  #  Default domain for most switches
-ZONI_HOME_NETWORK = 10.10.0.0/20
-ZONI_IPMI_NETWORK = 10.10.16.0/20
-
 #  Logging
 [loggers]
 keys=root

Modified: incubator/tashi/trunk/src/zoni/client/zoni-cli.py
URL: http://svn.apache.org/viewvc/incubator/tashi/trunk/src/zoni/client/zoni-cli.py?rev=1351920&r1=1351919&r2=1351920&view=diff
==============================================================================
--- incubator/tashi/trunk/src/zoni/client/zoni-cli.py (original)
+++ incubator/tashi/trunk/src/zoni/client/zoni-cli.py Wed Jun 20 02:32:19 2012
@@ -53,6 +53,9 @@ from tashi.util import instantiateImplem
 #import zoni.data.usermanagement 
 #from usermanagement import UserManagement
 
+# Extensions from MIMOS
+from zoni.extensions.m_extensions import *
+
 def parseTable():
 	pass
 
@@ -92,6 +95,8 @@ def main():
 	group.add_option("--powerOn", "--poweron", dest="POWERON", help="Power on node", action="store_true",
default=False)
 	group.add_option("--powerReset", "--powerreset", dest="POWERRESET", help="Power reset node",
action="store_true", default=False)
 	group.add_option("--console", dest="CONSOLE", help="Console mode", action="store_true",
default=False)
+	# Extensions from MIMOS - specific only for HP Blades and HP c7000 Blade Enclosures
+	group.add_option("--powerOnNet", "--poweronnet", dest="POWERONENET", help="Power on Node
into PXE (Currently support on HP Blades through HP c7000 Blade Enclosure)", action="store_true",
default=False)
 	parser.add_option_group(group)
 
 	#  Query Interface
@@ -188,6 +193,18 @@ def main():
 	group.add_option("--removeDhcp", dest="removeDhcp", help="Remove a DHCP entry", action="store_true",
default=False)
 	parser.add_option_group(group)
 
+	# Extensions from MIMOS
+	group = optparse.OptionGroup(parser, "Zoni MIMOS Extensions", "Special Functions created
by MIMOS Lab:")
+	group.add_option("--addRole", "--addrole", dest="addRole", help="Create a disk based installation
default file for a node based on its role or function, e.g. one|oned|cc|clc|walrus|sc|nc|preseed|kickstart",
default=None, action="store")
+	group.add_option("--removeRole", "--removerole", dest="removeRole", help="Remove the default
file of a node", action="store_true", default=False)
+	group.add_option("--showRoleMap", dest="showRoleMap", help="Show Role to Host Mapping",
action="store_true", default=False)
+	group.add_option("--showKernel", dest="showKernelInfo", help="Show Kernel Info", action="store_true",
default=False)
+	group.add_option("--showInitrd", dest="showInitrdInfo", help="Show Initrd Info", action="store_true",
default=False)
+	group.add_option("--registerKernelInitrd", dest="registerKernelInitrd", help="Register Kernel
and Initrd - vmlinuz:vmlinuz-ver:vmlinuz-arch:initrd:initrd-arch:imagename")
+	group.add_option("--getKernelInitrdID", dest="getKernelInitrdID", help="Get corresponding
Kernel and Initrd Info - vmlinuz:initrd:arch")
+	group.add_option("--getConfig", dest="getConfig", help="Get a value from ZoniDefault.cfg
- e.g. tftpRootDir, initrdRoot, kernelRoot, fsImagesBaseDir, etc.", default=None, action="store")
+	parser.add_option_group(group)
+
 	(options, args) = parser.parse_args()
 
 	
@@ -201,6 +218,8 @@ def main():
 	data = instantiateImplementation("zoni.data.resourcequerysql.ResourceQuerySql", configs,
options.verbosity)
 	reservation = instantiateImplementation("zoni.data.reservation.reservationMysql", configs,
data, options.verbosity)
 	#query = zoni.data.resourcequerysql.ResourceQuerySql(configs, options.verbosity)
+	# Extensions from MIMOS
+	mimos = instantiateImplementation("zoni.extensions.m_extensions.mimos",configs)
 
 	#  Get host info
 	host=None
@@ -224,12 +243,21 @@ def main():
 			if "drac_name" in host:
 				hw= dellDrac(configs, options.nodeName, host)
 			else:
-				mesg = "Host (" + options.nodeName + ") does not have a DRAC card!!\n"
+				mesg = "Host (%s) does not have a DRAC card!!\n" % options.nodeName
 				sys.stdout.write(mesg)
 				exit(1)
+
+		## Extensions from MIMOS - For Dell Blades - calling Dell Blades via the Blade Enclosure,
some DRAC commands are slightly different from the ones in blade enclosure when compared to
those in the actual blade, this allow a bit more flexiblity and standard calls to the blades
+		if options.hardwareType == "dracblade":
+			hw = dellBlade(configs, options.nodeName, host)
+
+		## Extensions from MIMOS - For HP Blades - calling HP Blades via the HP c7000 Blade Enclosure
instead of direct to the blade server itself, this allow a bit more flexiblity and standard
calls to the blades
+		if options.hardwareType == "hpilo":
+			hw = hpILO(configs, options.nodeName, host)
+
 		if (options.REBOOTNODE or options.POWERCYCLE  or options.POWEROFF or options.POWEROFFSOFT
or \
 			options.POWERON or options.POWERSTATUS or options.CONSOLE or \
-			options.POWERRESET) and options.nodeName:
+			options.POWERONNET or options.POWERRESET) and options.nodeName: # Extensions from MIMOS
- added POWERONNET
 
 			if options.verbosity:
 				hw.setVerbose(True)
@@ -258,6 +286,10 @@ def main():
 			if options.CONSOLE:
 				hw.activateConsole()
 				exit()
+			## Extensions from MIMOS - For HP Blade via c7000 Blade Enclosure
+			if options.POWERONNET:
+				hw.powerOnNet()
+				exit()
 			hw.getPowerStatus()
 			exit()
 	else:
@@ -817,5 +849,29 @@ def main():
 				mesg = "[SUCCESS]\n"
 				sys.stdout.write(mesg) 
 
+	## Extensions from MIMOS - functions are defined in m_extensions.py
+	if ( options.addRole and options.nodeName ) or ( options.removeRole and options.nodeName
):
+		if options.addRole:
+			mimos.assignRoletoHost(host,options.addRole)
+			mimos.addRoletoNode(configs,host,options.nodeName,options.addRole)
+		if options.removeRole:
+			mimos.unassignRolefromHost(host)
+			mimos.removeRolefromNode(configs,host,options.nodeName)
+	if ( options.addRole and not options.nodeName ) or ( options.removeRole and not options.nodeName
):
+		mesg = "Roles: Missing Parameter(s)!"
+		log.error(mesg)
+	if options.showRoleMap:
+		mimos.showRoletoHost(configs)
+	if options.showKernelInfo:
+		mimos.showKernelInfo()
+	if options.showInitrdInfo:
+		mimos.showInitrdInfo()
+	if options.registerKernelInitrd:
+		mimos.registerKernelInitrd(configs,options.registerKernelInitrd)
+	if options.getKernelInitrdID:
+		mimos.getKernelInitrdID(options.getKernelInitrdID)
+	if options.getConfig:
+		mimos.getConfig(configs,options.getConfig)
+
 if __name__ == "__main__":
 	main()

Modified: incubator/tashi/trunk/src/zoni/data/resourcequerysql.py
URL: http://svn.apache.org/viewvc/incubator/tashi/trunk/src/zoni/data/resourcequerysql.py?rev=1351920&r1=1351919&r2=1351920&view=diff
==============================================================================
--- incubator/tashi/trunk/src/zoni/data/resourcequerysql.py (original)
+++ incubator/tashi/trunk/src/zoni/data/resourcequerysql.py Wed Jun 20 02:32:19 2012
@@ -298,6 +298,11 @@ class ResourceQuerySql(InfoStore):
 		query = "select " + defaultFields + "from sysinfo " + queryopt
 		result = self.selectDb(query)	
 
+		# Extensions from MIMOS - allow showResources to fail gracefully if the Zoni DB is not
populated yet
+		if result.rowcount < 1:
+			print "Zoni Hardware/System Database is empty."
+			exit(1)
+
 		line = ""
 		for i in defaultFields.split(","):
 			#line += string.strip(str(i)) + "\t"
@@ -732,7 +737,7 @@ class ResourceQuerySql(InfoStore):
 			host['hw_port'] = int(i[6])
 
 		#  Get drac info
-		query = "select h.hw_id, h.hw_name, h.hw_model, h.hw_ipaddr, h.hw_userid, h.hw_password,
p.port_num from hardwareinfo h, portmap p where p.hw_id = h.hw_id and hw_type = 'drac' and
sys_id = " +  str(host['sys_id'])
+		query = "select h.hw_id, h.hw_name, h.hw_model, h.hw_ipaddr, h.hw_userid, h.hw_password,
0, p.port_num from hardwareinfo h, portmap p where p.hw_id = h.hw_id and hw_type = 'drac'
and sys_id = " +  str(host['sys_id'])
 		result = self.selectDb(query)
 		if result.rowcount > 0:
 			for i in result.fetchall():
@@ -742,7 +747,10 @@ class ResourceQuerySql(InfoStore):
 				host['drac_ipaddr'] = i[3]
 				host['drac_userid'] = i[4]
 				host['drac_password'] = i[5]
-				host['drac_port'] = int(i[6])
+				# Extensions from MIMOS - for Dell Blade
+				# XXXstroucki removed hw_blenc from query
+				# host['drac_enclosure'] = i[6]
+				host['drac_port'] = int(i[7])
 
 		#  Get PDU info
 		query = "select h.hw_id, h.hw_name, h.hw_model, h.hw_ipaddr, h.hw_userid, h.hw_password,
p.port_num from hardwareinfo h, portmap p where p.hw_id = h.hw_id and h.hw_type = 'pdu' and
p.sys_id = " +  str(host['sys_id'])
@@ -756,6 +764,19 @@ class ResourceQuerySql(InfoStore):
 			host['pdu_password'] = i[5]
 			host['pdu_port'] = int(i[6])
 
+		# Extensions from MIMOS - for HP Blade iLO
+		query = "select h.hw_id, h.hw_name, h.hw_model, h.hw_ipaddr, h.hw_userid, h.hw_password,
0, p.port_num from hardwareinfo h, portmap p where p.hw_id = h.hw_id and hw_type = 'hpilo'
and sys_id = " +  str(host['sys_id'])
+		result = self.selectDb(query)
+		for i in result.fetchall():
+			host['ilo_id'] = int(i[0])
+			host['ilo_name'] = i[1]
+			host['ilo_model'] = i[2]
+			host['ilo_ipaddr'] = i[3]
+			host['ilo_userid'] = i[4]
+			host['ilo_password'] = i[5]
+			# XXXstroucki removed hw_blenc from query
+			#host['ilo_enclosure'] = i[6]
+			host['ilo_port'] = int(i[7])
 
 		#print "host is ", host
 		return host
@@ -1088,8 +1109,14 @@ class ResourceQuerySql(InfoStore):
 			name = imageName.split(":")[0]
 		if len(imageName.split(":")) > 2:
 			dist = imageName.split(":")[1]
-		if len(imageName.split(":")) >= 3:
+		# Extensions from MIMOS - allow adding 2 more pieces of info - kernel_id and initrd_id
+		#if len(imageName.split(":")) >= 3:
+		if len(imageName.split(":")) > 3:
 			dist_ver = imageName.split(":")[2]
+		if len(imageName.split(":")) > 4:
+			kernel_id = imageName.split(":")[3]
+		if len(imageName.split(":")) >= 5:
+			initrd_id = imageName.split(":")[4]
 
 		query = "select * from imageinfo where image_name = \"" + name + "\""
 		result = self.selectDb(query)
@@ -1106,7 +1133,9 @@ class ResourceQuerySql(InfoStore):
 			sys.stderr.write(mesg)
 			return 
 
-		query = "insert into imageinfo (image_name, dist, dist_ver) values(\"" + name + "\", \""
+ dist + "\", \"" + dist_ver + "\")"
+		# Extensions from MIMOS - to take care of the addition of kernel_id and initrd_id
+		#query = "insert into imageinfo (image_name, dist, dist_ver) values(\"" + name + "\", \""
+ dist + "\", \"" + dist_ver + "\")"
+		query = "insert into imageinfo (image_name, dist, dist_ver, kernel_id, initrd_id) values
('%s', '%s', '%s', '%s', '%s')" % (name, dist, dist_ver, kernel_id, initrd_id)
 		self.insertDb(query)
 
 

Modified: incubator/tashi/trunk/src/zoni/extra/util.py
URL: http://svn.apache.org/viewvc/incubator/tashi/trunk/src/zoni/extra/util.py?rev=1351920&r1=1351919&r2=1351920&view=diff
==============================================================================
--- incubator/tashi/trunk/src/zoni/extra/util.py (original)
+++ incubator/tashi/trunk/src/zoni/extra/util.py Wed Jun 20 02:32:19 2012
@@ -63,6 +63,10 @@ def loadConfigFile(parser):
 	config['initrdRoot'] = parser.get("pxe", "INITRD_ROOT").split()[0]
 	config['kernelRoot'] = parser.get("pxe", "KERNEL_ROOT").split()[0]
 
+	# Extensions from MIMOS
+	config['ntpsvrIP'] = parser.get("pxe", "NTPSVR").split()[0] # NTP Server IP Address Support
+	config['tftpTemplateDir'] = parser.get("pxe", "CUSTOM_TEMPLATES_DIR") # Custom Templates
for Disk Image
+
 	#  Image store
 	config['imageServerIP'] = parser.get("imageStore", "IMAGE_SERVER_IP").split()[0]
 	config['fsImagesBaseDir'] = parser.get("imageStore", "FS_IMAGES_BASE_DIR").split()[0]
@@ -107,7 +111,8 @@ def getConfig(additionalNames=[], additi
 	"""Creates many permutations of a list of locations to look for config 
 	   files and then loads them"""
 	config = ConfigParser.ConfigParser()
-	baseLocations = ['./etc/', '/usr/share/zoni/', '/etc/zoni/', os.path.expanduser('~/.zoni/')]
+	# added /usr/local/tashi/etc - MIMOS
+	baseLocations = ['./etc/', '/usr/share/zoni/', '/usr/local/tashi/etc/', '/etc/zoni/', os.path.expanduser('~/.zoni/')]
 	names = ['Zoni'] + additionalNames
 	names = reduce(lambda x, y: x + [y+"Defaults", y], names, [])
 	allLocations = reduce(lambda x, y: x + reduce(lambda z, a: z + [y + a + ".cfg"], names,
[]), baseLocations, []) + additionalFiles

Modified: incubator/tashi/trunk/src/zoni/hardware/hpilo.py
URL: http://svn.apache.org/viewvc/incubator/tashi/trunk/src/zoni/hardware/hpilo.py?rev=1351920&r1=1351919&r2=1351920&view=diff
==============================================================================
--- incubator/tashi/trunk/src/zoni/hardware/hpilo.py (original)
+++ incubator/tashi/trunk/src/zoni/hardware/hpilo.py Wed Jun 20 02:32:19 2012
@@ -23,13 +23,10 @@ import pexpect
 import time
 
 from systemmanagementinterface import SystemManagementInterface
-
-
-#class systemmagement():
-	#def __init__(self, proto):
-		#self.proto = proto
+from zoni.extra.util import timeF, log
 
 #XXX  Need to add more error checking!
+#XXX  Need to consider difference in responses between a rackmount server and a blade server
- MIMOS
 
 def log(f):
 	def myF(*args, **kw):
@@ -52,15 +49,19 @@ def timeF(f):
 
 
 class hpILo(SystemManagementInterface):
-	def __init__(self, host):
-		self.hostname = host['location']
-		self.host = host['ilo_name']
+	def __init__(self, config, nodeName, hostInfo):
+		self.config = config
+		self.nodename = nodeName
+		self.hostname = hostInfo['location']
+		## Need to add in checking to differentiate between rackmount and blade server
+		#self.host = host['ilo_name']
+		self.host = hostInfo['ilo_enclosure']
 		self.user = host['ilo_userid']
 		self.password = host['ilo_password']
 		self.port = host['ilo_port']
 		self.powerStatus = None
 		self.verbose = 0
-		#self.server = "Server-" + str(self.port)
+		self.log = logging.getLogger(__name__)
 
 	def setVerbose(self, verbose):
 		self.verbose = verbose
@@ -83,7 +84,7 @@ class hpILo(SystemManagementInterface):
 			i=child.expect(['>', 'please try again.', pexpect.EOF, pexpect.TIMEOUT])
 		else:
 			mesg = "Error"
-			sys.stderr.write(mesg)
+			self.log.error(mesg)
 			exit(1)
 
 		if i == 1:
@@ -99,7 +100,6 @@ class hpILo(SystemManagementInterface):
 
 
 	@timeF
-	@log
 	def getPowerStatus(self):
 		child = self.__login()
 		cmd = "show server status " + str(self.port)
@@ -115,7 +115,7 @@ class hpILo(SystemManagementInterface):
 			mesg = self.hostname + " Power is off\n\n"
 			self.powerStatus = 0
 
-		sys.stdout.write(mesg)
+		self.log.info(mesg)
 
 		child.close()
 		child.terminate()
@@ -128,7 +128,6 @@ class hpILo(SystemManagementInterface):
 			return 1;
 		if not self.powerStatus:
 			return 0;
-	
 
 	@timeF
 	def powerOn(self):
@@ -148,7 +147,28 @@ class hpILo(SystemManagementInterface):
 			mesg = self.hostname + " Power On\n\n"
 		else:
 			mesg = self.hostname + " Power On Fail\n\n"
-		sys.stdout.write(mesg)
+		self.log.info(mesg)
+		child.sendline("quit")
+		child.terminate()
+
+	@timeF
+	def powerOnNet(self):
+		if self.powerStatus == 1:
+			mesg = self.hostname + " Power On\n\n"
+			exit(1)
+
+		child = self.__login()
+		cmd = "poweron server " + str(self.port) + " PXE"
+		child.sendline(cmd)
+		val = child.readline()
+		while "Powering" not in val and "powered" not in val:
+			val = child.readline()
+
+		if "Powering" in val or "already" in val:
+			mesg = self.hostname + " Power On\n\n"
+		else:
+			mesg = self.hostname + " Power On Fail\n\n"
+		self.log.info(mesg)
 		child.sendline("quit")
 		child.terminate()
 
@@ -166,7 +186,7 @@ class hpILo(SystemManagementInterface):
 		else:
 			mesg = self.hostname + " Power Off Fail\n\n"
 
-		sys.stdout.write(mesg)
+		self.log.info(mesg)
 		child.sendline("quit")
 		child.terminate()
 
@@ -186,7 +206,7 @@ class hpILo(SystemManagementInterface):
 		mesg = self.hostname + " Power Reset\n\n"
 		#else:
 			#mesg = self.hostname + " Power Reset Fail\n\n"
-		sys.stdout.write(mesg)
+		self.log.info(mesg)
 		child.sendline("quit")
 		child.terminate()
 		

Modified: incubator/tashi/trunk/src/zoni/hardware/systemmanagementinterface.py
URL: http://svn.apache.org/viewvc/incubator/tashi/trunk/src/zoni/hardware/systemmanagementinterface.py?rev=1351920&r1=1351919&r2=1351920&view=diff
==============================================================================
--- incubator/tashi/trunk/src/zoni/hardware/systemmanagementinterface.py (original)
+++ incubator/tashi/trunk/src/zoni/hardware/systemmanagementinterface.py Wed Jun 20 02:32:19
2012
@@ -63,7 +63,8 @@ class SystemManagementInterface(object):
 		'''  register hardware to zoni'''
 		raise NotImplementedError
 
-
-
-
+	# Extensions from MIMOS - specific to HP Blade via c7000 Blade Enclosure
+	def powerOnNet(self):
+		''' Power HP Blade Server directly from PXE '''
+		raise NotImplementedError
 



Mime
View raw message